Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

McContext Class Reference

List of all members.

Public Member Functions

unsigned int eventNumber () const
virtual void * identifier () const
 McContext (const McEventSelector *pSelector, const int &initRunNo, const unsigned int &initEventNo, const unsigned int &evPR)
 McContext (const McEventSelector *pSelector)
 Standard constructor.
void next ()
void previous ()
void rewind ()
int runNumber () const
void setCriteria (const std::string &crit)
void setEventNumber (unsigned int eventNo)
void setRunNumber (int runNo)
virtual ~McContext ()
 Standard destructor.

Private Attributes

IProperty * m_appMgrProperty
std::string m_criteria
unsigned int m_eventNo
unsigned int m_eventsP
std::vector< int > m_evtNoList
bool m_firstEvent
unsigned int m_initEventNo
int m_initRunNo
int m_lumiBlockNo
const McEventSelectorm_pSelector
RealizationSvcm_RealizationSvc
std::vector< int > m_runList
int m_runNo

Constructor & Destructor Documentation

McContext::McContext const McEventSelector pSelector  ) 
 

Standard constructor.

00123                                                     :
00124   m_pSelector(pSelector), m_firstEvent(true), m_lumiBlockNo(0), m_initEventNo(0) {
00125   // Obtain the IProperty of the ApplicationMgr
00126   SmartIF<IProperty> prpMgr(IID_IProperty, Gaudi::svcLocator());
00127   if ( ! prpMgr.isValid() )   {
00128     std::cout << "IProperty interface not found in ApplicationMgr." << std::endl;
00129   }
00130   else {
00131     m_appMgrProperty = prpMgr;
00132   }
00133   //get IRealizationSvc
00134   ISvcLocator* svcLocator = Gaudi::svcLocator();
00135   IRealizationSvc *tmpReal;
00136   StatusCode status = svcLocator->service("RealizationSvc", tmpReal);
00137   if (!status.isSuccess())
00138   {
00139      std::cout << " Could not initialize Realization Service" << std::endl;
00140   } else {
00141     m_RealizationSvc=dynamic_cast<RealizationSvc*>(tmpReal);
00142   }
00143   //get jobSvc
00144   IDataInfoSvc* tmpInfoSvc;
00145   DataInfoSvc* jobInfoSvc;
00146   status = svcLocator->service("DataInfoSvc",tmpInfoSvc);
00147   if (status.isSuccess()) {
00148     std::cout << "get the DataInfoSvc" << std::endl;
00149     jobInfoSvc=dynamic_cast<DataInfoSvc *>(tmpInfoSvc);
00150   }else {
00151     std::cout << "could not get the DataInfoSvc." << std::endl;
00152   }
00153 
00154   //set initial event ID
00155   m_initEventNo = m_RealizationSvc->getInitEvtID();
00156 
00157   std::string sMax;
00158   status = m_appMgrProperty->getProperty("EvtMax", sMax);
00159   int EvtMax = std::atoi(sMax.c_str());
00160   //for realization
00161   if(m_RealizationSvc->UseDBFlag() == true) {
00162     std::vector<int> totEvtNo;
00163     totEvtNo.clear();
00164     std::vector<float> lumi;
00165     std::vector<int> tmp_runList = m_RealizationSvc->getRunList();
00166     float totLumi = 0;
00167     for(unsigned int i = 0; i < tmp_runList.size(); i++)
00168     {
00169       float lumi_value = m_RealizationSvc->getLuminosity(tmp_runList[i]);
00170       lumi.push_back(lumi_value); 
00171       totLumi += lumi_value;      
00172     }                             
00173                                   
00174     m_runList.clear();
00175 
00176     int totSimEvt = 0;
00177     int evtSubNo = 0;
00178     if(totLumi != 0) {
00179       for(unsigned int i = 0; i < (lumi.size() - 1); i++) {
00180         //if(i == 0) m_evtNoList.push_back(0);
00181         double ratio = lumi[i]/totLumi*EvtMax;
00182         evtSubNo = int (ratio);
00183         if((ratio-evtSubNo) >= 0.5) evtSubNo = evtSubNo + 1;
00184         totSimEvt += evtSubNo;
00185         if(evtSubNo == 0) {
00186           std::cout << "The run " <<tmp_runList[i]<<" is not simulated, due to the luminosity is too small!" << std::endl;
00187         }
00188         else {
00189           //m_evtNoList.push_back(totSimEvt);
00190           m_evtNoList.push_back(evtSubNo);
00191           m_runList.push_back(tmp_runList[i]);
00192           totEvtNo.push_back(tmp_runList[i]);
00193           totEvtNo.push_back(evtSubNo);
00194         }
00195         std::cout <<"Total "<< evtSubNo <<" events need to be simulated in run " <<tmp_runList[i]<< std::endl;
00196       }
00197       if((EvtMax - totSimEvt) != 0) {
00198         m_evtNoList.push_back(EvtMax - totSimEvt);
00199         m_runList.push_back(tmp_runList[lumi.size() - 1]); //set the last run id
00200         totEvtNo.push_back(tmp_runList[lumi.size() - 1]);
00201         totEvtNo.push_back(EvtMax - totSimEvt);
00202         std::cout <<"Total "<< EvtMax - totSimEvt <<" events need to be simulated in run " <<tmp_runList[lumi.size() - 1]<< std::endl;
00203       }
00204     }
00205     else {
00206       std::cerr << "ERORR: " << "Total luminosity is ZERO!!! Please check your run list. " << std::endl;
00207       std::abort();
00208     }
00209     m_RealizationSvc->setRunId(-std::abs(m_runList[0]));
00210     m_RealizationSvc->setRunEvtNum(m_evtNoList[0]);
00211     m_initRunNo = -std::abs(m_runList[0]);
00212     jobInfoSvc->setTotEvtNo(totEvtNo);
00213   }
00214   else {
00215     m_initRunNo = -std::abs((m_RealizationSvc->getRunList())[0]);
00216   }
00217 }

McContext::McContext const McEventSelector pSelector,
const int &  initRunNo,
const unsigned int &  initEventNo,
const unsigned int &  evPR
 

00222                                               :
00223   m_pSelector(pSelector),
00224   m_initRunNo(initRunNo), m_initEventNo(initEventNo), m_eventsP(evPR),
00225   m_firstEvent(true), m_lumiBlockNo(0) {
00226 }
  

McContext::~McContext  )  [virtual]
 

Standard destructor.

00229                       {
00230 }


Member Function Documentation

unsigned int McContext::eventNumber  )  const [inline]
 

00116 { return m_eventNo; }

virtual void* McContext::identifier  )  const [inline, virtual]
 

00074                                    {
00075     return (void*)m_pSelector;
00076   }

void McContext::next void   )  [inline]
 

00091               {
00092     if (m_firstEvent) {
00093       m_firstEvent = false;
00094 
00095       m_eventNo = m_initEventNo;
00096       m_runNo = m_initRunNo;
00097 
00098       return;
00099     }
00100     m_eventNo++;
00101     if(m_RealizationSvc->UseDBFlag() == false) return;
00102     if(m_eventNo>=(m_initEventNo + m_evtNoList[m_lumiBlockNo])){
00103       m_lumiBlockNo++;
00104       m_runNo = -std::abs(m_runList[m_lumiBlockNo]);
00105       m_RealizationSvc->setRunId(m_runNo);
00106       m_RealizationSvc->setRunEvtNum(m_evtNoList[m_lumiBlockNo]);
00107       m_eventNo= m_initEventNo;
00108     }
00109   }

void McContext::previous  )  [inline]
 

00111                   {
00112     m_eventNo--;
00113   }

void McContext::rewind  )  [inline]
 

00081                 {
00082 
00083     // Question: should this rewind to before the first event, or to
00084     // it? ie, will next() be called right after rewind()?
00085     // if so, then should set m_firstEvent to true;
00086 
00087       m_eventNo = m_initEventNo;
00088       m_runNo = m_initRunNo;
00089   }    

int McContext::runNumber  )  const [inline]
 

00115 { return m_runNo; }

void McContext::setCriteria const std::string &  crit  )  [inline]
 

00077                                           {
00078     m_criteria = crit;
00079   }

void McContext::setEventNumber unsigned int  eventNo  )  [inline]
 

00119 { m_eventNo = eventNo ; }

void McContext::setRunNumber int  runNo  )  [inline]
 

00118 { m_runNo = runNo; }


Member Data Documentation

IProperty* McContext::m_appMgrProperty [private]
 

std::string McContext::m_criteria [private]
 

unsigned int McContext::m_eventNo [private]
 

unsigned int McContext::m_eventsP [private]
 

std::vector<int> McContext::m_evtNoList [private]
 

bool McContext::m_firstEvent [private]
 

unsigned int McContext::m_initEventNo [private]
 

int McContext::m_initRunNo [private]
 

int McContext::m_lumiBlockNo [private]
 

const McEventSelector* McContext::m_pSelector [private]
 

RealizationSvc* McContext::m_RealizationSvc [private]
 

std::vector<int> McContext::m_runList [private]
 

int McContext::m_runNo [private]
 


The documentation for this class was generated from the following file:
Generated on Wed Feb 2 16:22:16 2011 for BOSS6.5.5 by  doxygen 1.3.9.1