Public Member Functions | |
McContext (const McEventSelector *pSelector) | |
Standard constructor. | |
McContext (const McEventSelector *pSelector, const int &initRunNo, const unsigned int &initEventNo, const unsigned int &evPR) | |
virtual | ~McContext () |
Standard destructor. | |
virtual void * | identifier () const |
void | setCriteria (const std::string &crit) |
void | rewind () |
void | next () |
void | previous () |
int | runNumber () const |
unsigned int | eventNumber () const |
void | setRunNumber (int runNo) |
void | setEventNumber (unsigned int eventNo) |
Private Attributes | |
const McEventSelector * | m_pSelector |
std::string | m_criteria |
std::vector< int > | m_runList |
std::vector< int > | m_evtNoList |
RealizationSvc * | m_RealizationSvc |
IProperty * | m_appMgrProperty |
int | m_initRunNo |
unsigned int | m_initEventNo |
unsigned int | m_eventsP |
int | m_runNo |
unsigned int | m_eventNo |
bool | m_firstEvent |
int | m_lumiBlockNo |
Definition at line 44 of file McEventSelector.cxx.
McContext::McContext | ( | const McEventSelector * | pSelector | ) |
Standard constructor.
Definition at line 123 of file McEventSelector.cxx.
References abs, RealizationSvc::getInitEvtID(), RealizationSvc::getLuminosity(), RealizationSvc::getRunList(), genRecEmupikp::i, m_appMgrProperty, m_evtNoList, m_initEventNo, m_initRunNo, m_RealizationSvc, m_runList, RealizationSvc::setRunEvtNum(), RealizationSvc::setRunId(), DataInfoSvc::setTotEvtNo(), deljobs::string, and RealizationSvc::UseDBFlag().
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(IProperty::interfaceID(), Gaudi::svcLocator()); 00127 SmartIF<IProperty> prpMgr(Gaudi::svcLocator()); 00128 if ( ! prpMgr.isValid() ) { 00129 std::cout << "IProperty interface not found in ApplicationMgr." << std::endl; 00130 } 00131 else { 00132 m_appMgrProperty = prpMgr; 00133 } 00134 //get IRealizationSvc 00135 ISvcLocator* svcLocator = Gaudi::svcLocator(); 00136 IRealizationSvc *tmpReal; 00137 StatusCode status = svcLocator->service("RealizationSvc", tmpReal); 00138 if (!status.isSuccess()) 00139 { 00140 std::cout << " Could not initialize Realization Service" << std::endl; 00141 } else { 00142 m_RealizationSvc=dynamic_cast<RealizationSvc*>(tmpReal); 00143 } 00144 //get jobSvc 00145 IDataInfoSvc* tmpInfoSvc; 00146 DataInfoSvc* jobInfoSvc; 00147 status = svcLocator->service("DataInfoSvc",tmpInfoSvc); 00148 if (status.isSuccess()) { 00149 std::cout << "get the DataInfoSvc" << std::endl; 00150 jobInfoSvc=dynamic_cast<DataInfoSvc *>(tmpInfoSvc); 00151 }else { 00152 std::cout << "could not get the DataInfoSvc." << std::endl; 00153 } 00154 00155 //set initial event ID 00156 m_initEventNo = m_RealizationSvc->getInitEvtID(); 00157 00158 std::string sMax; 00159 status = m_appMgrProperty->getProperty("EvtMax", sMax); 00160 int EvtMax = std::atoi(sMax.c_str()); 00161 //for realization 00162 if(m_RealizationSvc->UseDBFlag() == true) { 00163 std::vector<int> totEvtNo; 00164 totEvtNo.clear(); 00165 std::vector<float> lumi; 00166 std::vector<int> tmp_runList = m_RealizationSvc->getRunList(); 00167 float totLumi = 0; 00168 for(unsigned int i = 0; i < tmp_runList.size(); i++) 00169 { 00170 float lumi_value = m_RealizationSvc->getLuminosity(tmp_runList[i]); 00171 lumi.push_back(lumi_value); 00172 totLumi += lumi_value; 00173 } 00174 00175 m_runList.clear(); 00176 00177 int totSimEvt = 0; 00178 int evtSubNo = 0; 00179 if(totLumi != 0) { 00180 for(unsigned int i = 0; i < lumi.size(); i++) { 00181 //if(i == 0) m_evtNoList.push_back(0); 00182 double ratio = lumi[i]/totLumi*EvtMax; 00183 evtSubNo = int (ratio); 00184 if((ratio-evtSubNo) >= 0.5) evtSubNo = evtSubNo + 1; 00185 totSimEvt += evtSubNo; 00186 if(evtSubNo == 0) { 00187 std::cout << "The run " <<tmp_runList[i]<<" is not simulated, due to the luminosity is too small!" << std::endl; 00188 } 00189 else { 00190 //m_evtNoList.push_back(totSimEvt); 00191 m_evtNoList.push_back(evtSubNo); 00192 m_runList.push_back(tmp_runList[i]); 00193 totEvtNo.push_back(tmp_runList[i]); 00194 totEvtNo.push_back(evtSubNo); 00195 } 00196 std::cout <<"Total "<< evtSubNo <<" events need to be simulated in run " <<tmp_runList[i]<< std::endl; 00197 } 00198 00199 if((EvtMax - totSimEvt) != 0) { 00200 unsigned int effRunSize = m_evtNoList.size(); 00201 if(effRunSize > 0) { 00202 m_evtNoList[effRunSize - 1] = m_evtNoList[effRunSize - 1] + (EvtMax - totSimEvt); 00203 effRunSize = totEvtNo.size(); 00204 totEvtNo[effRunSize - 1] = totEvtNo[effRunSize - 1] + (EvtMax - totSimEvt); 00205 std::cout <<"Additional "<< EvtMax - totSimEvt <<" events need to be simulated in run " << m_runList[m_runList.size() - 1]<< std::endl; 00206 } 00207 else { 00208 bool found = false; 00209 for(unsigned int i = 0; i < lumi.size(); i++) { 00210 if(lumi[i] > 0) { 00211 m_evtNoList.push_back(EvtMax - totSimEvt); 00212 m_runList.push_back(tmp_runList[i]); 00213 totEvtNo.push_back(tmp_runList[i]); 00214 totEvtNo.push_back(EvtMax - totSimEvt); 00215 found = true; 00216 std::cout <<"The max event number maybe too small, all "<< evtSubNo <<" events need to be simulated in run " <<tmp_runList[i]<< std::endl; 00217 break; 00218 } 00219 } 00220 if(!found) { 00221 std::cerr << "ERORR: " << "Total luminosity is ZERO, please check your run list. " << std::endl; 00222 std::exit(0); 00223 } 00224 } 00225 } 00226 } 00227 else { 00228 std::cerr << "ERORR: " << "Total luminosity is ZERO!!! Please check your run list. " << std::endl; 00229 std::exit(0); 00230 } 00231 m_RealizationSvc->setRunId(-std::abs(m_runList[0])); 00232 m_RealizationSvc->setRunEvtNum(m_evtNoList[0]); 00233 m_initRunNo = -std::abs(m_runList[0]); 00234 jobInfoSvc->setTotEvtNo(totEvtNo); 00235 } 00236 else { 00237 m_initRunNo = -std::abs((m_RealizationSvc->getRunList())[0]); 00238 } 00239 }
McContext::McContext | ( | const McEventSelector * | pSelector, | |
const int & | initRunNo, | |||
const unsigned int & | initEventNo, | |||
const unsigned int & | evPR | |||
) |
Definition at line 241 of file McEventSelector.cxx.
00244 : 00245 m_pSelector(pSelector), 00246 m_initRunNo(initRunNo), m_initEventNo(initEventNo), m_eventsP(evPR), 00247 m_firstEvent(true), m_lumiBlockNo(0) { 00248 }
McContext::~McContext | ( | ) | [virtual] |
unsigned int McContext::eventNumber | ( | ) | const [inline] |
Definition at line 116 of file McEventSelector.cxx.
References m_eventNo.
Referenced by McEventSelector::createAddress().
00116 { return m_eventNo; }
virtual void* McContext::identifier | ( | ) | const [inline, virtual] |
Definition at line 74 of file McEventSelector.cxx.
References m_pSelector.
00074 { 00075 return (void*)m_pSelector; 00076 }
void McContext::next | ( | void | ) | [inline] |
Definition at line 91 of file McEventSelector.cxx.
References abs, m_eventNo, m_evtNoList, m_firstEvent, m_initEventNo, m_initRunNo, m_lumiBlockNo, m_RealizationSvc, m_runList, m_runNo, RealizationSvc::setRunEvtNum(), RealizationSvc::setRunId(), and RealizationSvc::UseDBFlag().
Referenced by McEventSelector::next().
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] |
Definition at line 111 of file McEventSelector.cxx.
References m_eventNo.
Referenced by McEventSelector::previous().
00111 { 00112 m_eventNo--; 00113 }
void McContext::rewind | ( | ) | [inline] |
Definition at line 81 of file McEventSelector.cxx.
References m_eventNo, m_initEventNo, m_initRunNo, and m_runNo.
Referenced by McEventSelector::rewind().
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] |
Definition at line 115 of file McEventSelector.cxx.
References m_runNo.
Referenced by McEventSelector::createAddress().
00115 { return m_runNo; }
void McContext::setCriteria | ( | const std::string & | crit | ) | [inline] |
Definition at line 77 of file McEventSelector.cxx.
References m_criteria.
00077 { 00078 m_criteria = crit; 00079 }
void McContext::setEventNumber | ( | unsigned int | eventNo | ) | [inline] |
void McContext::setRunNumber | ( | int | runNo | ) | [inline] |
IProperty* McContext::m_appMgrProperty [private] |
std::string McContext::m_criteria [private] |
unsigned int McContext::m_eventNo [private] |
Definition at line 59 of file McEventSelector.cxx.
Referenced by eventNumber(), next(), previous(), rewind(), and setEventNumber().
unsigned int McContext::m_eventsP [private] |
Definition at line 56 of file McEventSelector.cxx.
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] |
Definition at line 58 of file McEventSelector.cxx.
Referenced by next(), rewind(), runNumber(), and setRunNumber().