BOSS 7.1.1
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 45 of file McEventSelector.cxx.

Constructor & Destructor Documentation

◆ McContext() [1/2]

McContext::McContext ( const McEventSelector * pSelector)

Standard constructor.

Definition at line 124 of file McEventSelector.cxx.

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

◆ McContext() [2/2]

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

Definition at line 242 of file McEventSelector.cxx.

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

◆ ~McContext()

McContext::~McContext ( )
virtual

Standard destructor.

Definition at line 252 of file McEventSelector.cxx.

252 {
253}

Member Function Documentation

◆ eventNumber()

unsigned int McContext::eventNumber ( ) const
inline

Definition at line 117 of file McEventSelector.cxx.

117{ return m_eventNo; }

Referenced by McEventSelector::createAddress().

◆ identifier()

virtual void * McContext::identifier ( ) const
inlinevirtual

Definition at line 75 of file McEventSelector.cxx.

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

◆ next()

void McContext::next ( )
inline

Definition at line 92 of file McEventSelector.cxx.

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

Referenced by McEventSelector::next().

◆ previous()

void McContext::previous ( )
inline

Definition at line 112 of file McEventSelector.cxx.

112 {
113 m_eventNo--;
114 }

Referenced by McEventSelector::previous().

◆ rewind()

void McContext::rewind ( )
inline

Definition at line 82 of file McEventSelector.cxx.

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

Referenced by McEventSelector::rewind().

◆ runNumber()

int McContext::runNumber ( ) const
inline

Definition at line 116 of file McEventSelector.cxx.

116{ return m_runNo; }

Referenced by McEventSelector::createAddress().

◆ setCriteria()

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

Definition at line 78 of file McEventSelector.cxx.

78 {
79 m_criteria = crit;
80 }

◆ setEventNumber()

void McContext::setEventNumber ( unsigned int eventNo)
inline

Definition at line 120 of file McEventSelector.cxx.

120{ m_eventNo = eventNo ; }
int eventNo

◆ setRunNumber()

void McContext::setRunNumber ( int runNo)
inline

Definition at line 119 of file McEventSelector.cxx.

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

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