BOSS 8.0.0
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 39 of file McEventSelector.cxx.

Constructor & Destructor Documentation

◆ McContext() [1/2]

McContext::McContext ( const McEventSelector * pSelector)

Standard constructor.

Definition at line 111 of file McEventSelector.cxx.

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

◆ McContext() [2/2]

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

Definition at line 235 of file McEventSelector.cxx.

237 : m_pSelector( pSelector )
238 , m_initRunNo( initRunNo )
239 , m_initEventNo( initEventNo )
240 , m_eventsP( evPR )
241 , m_firstEvent( true )
242 , m_lumiBlockNo( 0 ) {}

◆ ~McContext()

McContext::~McContext ( )
virtual

Standard destructor.

Definition at line 244 of file McEventSelector.cxx.

244{}

Member Function Documentation

◆ eventNumber()

unsigned int McContext::eventNumber ( ) const
inline

Definition at line 105 of file McEventSelector.cxx.

105{ return m_eventNo; }

Referenced by McEventSelector::createAddress().

◆ identifier()

virtual void * McContext::identifier ( ) const
inlinevirtual

Definition at line 67 of file McEventSelector.cxx.

67{ return (void*)m_pSelector; }

◆ next()

void McContext::next ( )
inline

Definition at line 80 of file McEventSelector.cxx.

80 {
81 if ( m_firstEvent )
82 {
83 m_firstEvent = false;
84
85 m_eventNo = m_initEventNo;
86 m_runNo = m_initRunNo;
87
88 return;
89 }
90 m_eventNo++;
91 if ( m_RealizationSvc->UseDBFlag() == false ) return;
92 if ( m_eventNo >= ( m_initEventNo + m_evtNoList[m_lumiBlockNo] ) )
93 {
94 m_lumiBlockNo++;
95 m_runNo = -std::abs( m_runList[m_lumiBlockNo] );
96 m_RealizationSvc->setRunId( m_runNo );
97 m_RealizationSvc->setRunEvtNum( m_evtNoList[m_lumiBlockNo] );
98 m_eventNo = m_initEventNo;
99 }
100 }

Referenced by McEventSelector::next().

◆ previous()

void McContext::previous ( )
inline

Definition at line 102 of file McEventSelector.cxx.

102{ m_eventNo--; }

Referenced by McEventSelector::previous().

◆ rewind()

void McContext::rewind ( )
inline

Definition at line 70 of file McEventSelector.cxx.

70 {
71
72 // Question: should this rewind to before the first event, or to
73 // it? ie, will next() be called right after rewind()?
74 // if so, then should set m_firstEvent to true;
75
76 m_eventNo = m_initEventNo;
77 m_runNo = m_initRunNo;
78 }

Referenced by McEventSelector::rewind().

◆ runNumber()

int McContext::runNumber ( ) const
inline

Definition at line 104 of file McEventSelector.cxx.

104{ return m_runNo; }

Referenced by McEventSelector::createAddress().

◆ setCriteria()

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

Definition at line 68 of file McEventSelector.cxx.

68{ m_criteria = crit; }

◆ setEventNumber()

void McContext::setEventNumber ( unsigned int eventNo)
inline

Definition at line 108 of file McEventSelector.cxx.

108{ m_eventNo = eventNo; }
int eventNo

◆ setRunNumber()

void McContext::setRunNumber ( int runNo)
inline

Definition at line 107 of file McEventSelector.cxx.

107{ m_runNo = runNo; }
int runNo
Definition DQA_TO_DB.cxx:13

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