Standard constructor.
00123 :
00124 m_pSelector(pSelector), m_firstEvent(true), m_lumiBlockNo(0), m_initEventNo(0) {
00125
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
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
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
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
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
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
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]);
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 }