BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
McContext Class Reference
+ Inheritance diagram for McContext:

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)
 

Detailed Description

Definition at line 44 of file McEventSelector.cxx.

Constructor & Destructor Documentation

◆ McContext() [1/2]

McContext::McContext ( const McEventSelector pSelector)

Standard constructor.

Definition at line 123 of file McEventSelector.cxx.

123 :
124 m_pSelector(pSelector), m_firstEvent(true), m_lumiBlockNo(0), m_initEventNo(0) {
125 // Obtain the IProperty of the ApplicationMgr
126 //SmartIF<IProperty> prpMgr(IProperty::interfaceID(), Gaudi::svcLocator());
127 SmartIF<IProperty> prpMgr(Gaudi::svcLocator());
128 if ( ! prpMgr.isValid() ) {
129 std::cout << "IProperty interface not found in ApplicationMgr." << std::endl;
130 }
131 else {
132 m_appMgrProperty = prpMgr;
133 }
134 //get IRealizationSvc
135 ISvcLocator* svcLocator = Gaudi::svcLocator();
136 IRealizationSvc *tmpReal;
137 StatusCode status = svcLocator->service("RealizationSvc", tmpReal);
138 if (!status.isSuccess())
139 {
140 std::cout << " Could not initialize Realization Service" << std::endl;
141 } else {
142 m_RealizationSvc=dynamic_cast<RealizationSvc*>(tmpReal);
143 }
144 //get jobSvc
145 IDataInfoSvc* tmpInfoSvc;
146 DataInfoSvc* jobInfoSvc;
147 status = svcLocator->service("DataInfoSvc",tmpInfoSvc);
148 if (status.isSuccess()) {
149 std::cout << "get the DataInfoSvc" << std::endl;
150 jobInfoSvc=dynamic_cast<DataInfoSvc *>(tmpInfoSvc);
151 }else {
152 std::cout << "could not get the DataInfoSvc." << std::endl;
153 }
154
155 //set initial event ID
156 m_initEventNo = m_RealizationSvc->getInitEvtID();
157
158 std::string sMax;
159 status = m_appMgrProperty->getProperty("EvtMax", sMax);
160 int EvtMax = std::atoi(sMax.c_str());
161 //for realization
162 if(m_RealizationSvc->UseDBFlag() == true) {
163 std::vector<int> totEvtNo;
164 totEvtNo.clear();
165 std::vector<float> lumi;
166 std::vector<int> tmp_runList = m_RealizationSvc->getRunList();
167 float totLumi = 0;
168 for(unsigned int i = 0; i < tmp_runList.size(); i++)
169 {
170 float lumi_value = m_RealizationSvc->getLuminosity(tmp_runList[i]);
171 lumi.push_back(lumi_value);
172 totLumi += lumi_value;
173 }
174
175 m_runList.clear();
176
177 int totSimEvt = 0;
178 int evtSubNo = 0;
179 if(totLumi != 0) {
180 for(unsigned int i = 0; i < lumi.size(); i++) {
181 //if(i == 0) m_evtNoList.push_back(0);
182 double ratio = lumi[i]/totLumi*EvtMax;
183 evtSubNo = int (ratio);
184 if((ratio-evtSubNo) >= 0.5) evtSubNo = evtSubNo + 1;
185 totSimEvt += evtSubNo;
186 if(evtSubNo == 0) {
187 std::cout << "The run " <<tmp_runList[i]<<" is not simulated, due to the luminosity is too small!" << std::endl;
188 }
189 else {
190 //m_evtNoList.push_back(totSimEvt);
191 m_evtNoList.push_back(evtSubNo);
192 m_runList.push_back(tmp_runList[i]);
193 totEvtNo.push_back(tmp_runList[i]);
194 totEvtNo.push_back(evtSubNo);
195 }
196 std::cout <<"Total "<< evtSubNo <<" events need to be simulated in run " <<tmp_runList[i]<< std::endl;
197 }
198
199 if((EvtMax - totSimEvt) != 0) {
200 unsigned int effRunSize = m_evtNoList.size();
201 if(effRunSize > 0) {
202 m_evtNoList[effRunSize - 1] = m_evtNoList[effRunSize - 1] + (EvtMax - totSimEvt);
203 effRunSize = totEvtNo.size();
204 totEvtNo[effRunSize - 1] = totEvtNo[effRunSize - 1] + (EvtMax - totSimEvt);
205 std::cout <<"Additional "<< EvtMax - totSimEvt <<" events need to be simulated in run " << m_runList[m_runList.size() - 1]<< std::endl;
206 }
207 else {
208 bool found = false;
209 for(unsigned int i = 0; i < lumi.size(); i++) {
210 if(lumi[i] > 0) {
211 m_evtNoList.push_back(EvtMax - totSimEvt);
212 m_runList.push_back(tmp_runList[i]);
213 totEvtNo.push_back(tmp_runList[i]);
214 totEvtNo.push_back(EvtMax - totSimEvt);
215 found = true;
216 std::cout <<"The max event number maybe too small, all "<< evtSubNo <<" events need to be simulated in run " <<tmp_runList[i]<< std::endl;
217 break;
218 }
219 }
220 if(!found) {
221 std::cerr << "ERORR: " << "Total luminosity is ZERO, please check your run list. " << std::endl;
222 std::exit(0);
223 }
224 }
225 }
226 }
227 else {
228 std::cerr << "ERORR: " << "Total luminosity is ZERO!!! Please check your run list. " << std::endl;
229 std::exit(0);
230 }
231 m_RealizationSvc->setRunId(-std::abs(m_runList[0]));
232 m_RealizationSvc->setRunEvtNum(m_evtNoList[0]);
233 m_initRunNo = -std::abs(m_runList[0]);
234 jobInfoSvc->setTotEvtNo(totEvtNo);
235 }
236 else {
237 m_initRunNo = -std::abs((m_RealizationSvc->getRunList())[0]);
238 }
239}

◆ McContext() [2/2]

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

Definition at line 241 of file McEventSelector.cxx.

244 :
245 m_pSelector(pSelector),
246 m_initRunNo(initRunNo), m_initEventNo(initEventNo), m_eventsP(evPR),
247 m_firstEvent(true), m_lumiBlockNo(0) {
248}

◆ ~McContext()

McContext::~McContext ( )
virtual

Standard destructor.

Definition at line 251 of file McEventSelector.cxx.

251 {
252}

Member Function Documentation

◆ eventNumber()

unsigned int McContext::eventNumber ( ) const
inline

Definition at line 116 of file McEventSelector.cxx.

116{ return m_eventNo; }

Referenced by McEventSelector::createAddress().

◆ identifier()

virtual void * McContext::identifier ( ) const
inlinevirtual

Definition at line 74 of file McEventSelector.cxx.

74 {
75 return (void*)m_pSelector;
76 }

◆ next()

void McContext::next ( )
inline

Definition at line 91 of file McEventSelector.cxx.

91 {
92 if (m_firstEvent) {
93 m_firstEvent = false;
94
95 m_eventNo = m_initEventNo;
96 m_runNo = m_initRunNo;
97
98 return;
99 }
100 m_eventNo++;
101 if(m_RealizationSvc->UseDBFlag() == false) return;
102 if(m_eventNo>=(m_initEventNo + m_evtNoList[m_lumiBlockNo])){
103 m_lumiBlockNo++;
104 m_runNo = -std::abs(m_runList[m_lumiBlockNo]);
105 m_RealizationSvc->setRunId(m_runNo);
106 m_RealizationSvc->setRunEvtNum(m_evtNoList[m_lumiBlockNo]);
107 m_eventNo= m_initEventNo;
108 }
109 }

Referenced by McEventSelector::next().

◆ previous()

void McContext::previous ( )
inline

Definition at line 111 of file McEventSelector.cxx.

111 {
112 m_eventNo--;
113 }

Referenced by McEventSelector::previous().

◆ rewind()

void McContext::rewind ( )
inline

Definition at line 81 of file McEventSelector.cxx.

81 {
82
83 // Question: should this rewind to before the first event, or to
84 // it? ie, will next() be called right after rewind()?
85 // if so, then should set m_firstEvent to true;
86
87 m_eventNo = m_initEventNo;
88 m_runNo = m_initRunNo;
89 }

Referenced by McEventSelector::rewind().

◆ runNumber()

int McContext::runNumber ( ) const
inline

Definition at line 115 of file McEventSelector.cxx.

115{ return m_runNo; }

Referenced by McEventSelector::createAddress().

◆ setCriteria()

void McContext::setCriteria ( const std::string &  crit)
inline

Definition at line 77 of file McEventSelector.cxx.

77 {
78 m_criteria = crit;
79 }

◆ setEventNumber()

void McContext::setEventNumber ( unsigned int  eventNo)
inline

Definition at line 119 of file McEventSelector.cxx.

119{ m_eventNo = eventNo ; }
int eventNo

◆ setRunNumber()

void McContext::setRunNumber ( int  runNo)
inline

Definition at line 118 of file McEventSelector.cxx.

118{ m_runNo = runNo; }
int runNo
Definition: DQA_TO_DB.cxx:12

The documentation for this class was generated from the following file: