112 : m_pSelector( pSelector ), m_firstEvent( true ), m_lumiBlockNo( 0 ), m_initEventNo( 0 ) {
115 SmartIF<IProperty> prpMgr( Gaudi::svcLocator() );
116 if ( !prpMgr.isValid() )
117 { std::cout <<
"IProperty interface not found in ApplicationMgr." << std::endl; }
118 else { m_appMgrProperty = prpMgr; }
120 ISvcLocator* svcLocator = Gaudi::svcLocator();
121 StatusCode status = svcLocator->service(
"RealizationSvc", m_RealizationSvc );
122 if ( !status.isSuccess() )
123 { std::cout <<
" Could not initialize Realization Service" << std::endl; }
127 status = svcLocator->service(
"DataInfoSvc", jobInfoSvc );
128 if ( status.isSuccess() ) { std::cout <<
"get the DataInfoSvc" << std::endl; }
129 else { std::cout <<
"could not get the DataInfoSvc." << std::endl; }
132 m_initEventNo = m_RealizationSvc->getInitEvtID();
135 status = m_appMgrProperty->getProperty(
"EvtMax", sMax );
136 int EvtMax = std::atoi( sMax.c_str() );
138 if ( m_RealizationSvc->UseDBFlag() ==
true )
140 std::vector<int> totEvtNo;
142 std::vector<float> lumi;
143 std::vector<int> tmp_runList = m_RealizationSvc->getRunList();
145 for (
unsigned int i = 0; i < tmp_runList.size(); i++ )
147 float lumi_value = m_RealizationSvc->getLuminosity( tmp_runList[i] );
148 lumi.push_back( lumi_value );
149 totLumi += lumi_value;
158 for (
unsigned int i = 0; i < lumi.size(); i++ )
161 double ratio = lumi[i] / totLumi * EvtMax;
162 evtSubNo = int( ratio );
163 if ( ( ratio - evtSubNo ) >= 0.5 ) evtSubNo = evtSubNo + 1;
164 totSimEvt += evtSubNo;
167 std::cout <<
"The run " << tmp_runList[i]
168 <<
" is not simulated, due to the luminosity is too small!" << std::endl;
173 m_evtNoList.push_back( evtSubNo );
174 m_runList.push_back( tmp_runList[i] );
175 totEvtNo.push_back( tmp_runList[i] );
176 totEvtNo.push_back( evtSubNo );
178 std::cout <<
"Total " << evtSubNo <<
" events need to be simulated in run "
179 << tmp_runList[i] << std::endl;
182 if ( ( EvtMax - totSimEvt ) != 0 )
184 unsigned int effRunSize = m_evtNoList.size();
185 if ( effRunSize > 0 )
187 m_evtNoList[effRunSize - 1] = m_evtNoList[effRunSize - 1] + ( EvtMax - totSimEvt );
188 effRunSize = totEvtNo.size();
189 totEvtNo[effRunSize - 1] = totEvtNo[effRunSize - 1] + ( EvtMax - totSimEvt );
190 std::cout <<
"Additional " << EvtMax - totSimEvt
191 <<
" events need to be simulated in run "
192 << m_runList[m_runList.size() - 1] << std::endl;
197 for (
unsigned int i = 0; i < lumi.size(); i++ )
201 m_evtNoList.push_back( EvtMax - totSimEvt );
202 m_runList.push_back( tmp_runList[i] );
203 totEvtNo.push_back( tmp_runList[i] );
204 totEvtNo.push_back( EvtMax - totSimEvt );
206 std::cout <<
"The max event number maybe too small, all " << evtSubNo
207 <<
" events need to be simulated in run " << tmp_runList[i]
214 std::cerr <<
"ERORR: "
215 <<
"Total luminosity is ZERO, please check your run list. " << std::endl;
223 std::cerr <<
"ERORR: "
224 <<
"Total luminosity is ZERO!!! Please check your run list. " << std::endl;
227 m_RealizationSvc->setRunId( -std::abs( m_runList[0] ) );
228 m_RealizationSvc->setRunEvtNum( m_evtNoList[0] );
229 m_initRunNo = -std::abs( m_runList[0] );
232 else { m_initRunNo = -std::abs( ( m_RealizationSvc->getRunList() )[0] ); }
void setCriteria(const std::string &crit)
virtual void * identifier() const
unsigned int eventNumber() const
void setRunNumber(int runNo)
void setEventNumber(unsigned int eventNo)
McContext(const McEventSelector *pSelector)
Standard constructor.