13 #include "HepMC/GenEvent.h"
14 #include "HepMC/GenParticle.h"
15 #include "HepMC/IO_GenEvent.h"
17 #include "CLHEP/Units/GlobalPhysicalConstants.h"
49 edm::LogError(
"HepMCFileReader") <<
"Constructing a new instance";
57 edm::LogInfo(
"HepMCFileReader") <<
"Destructing HepMCFileReader";
68 edm::LogError(
"HepMCFileReader") <<
"Was already initialized... reinitializing";
72 edm::LogInfo(
"HepMCFileReader") <<
"Opening file" << filename <<
"using HepMC::IO_GenEvent";
75 if (
rdstate() == std::ios::failbit) {
76 throw cms::Exception(
"FileNotFound",
"HepMCFileReader::initialize()")
77 <<
"File " << filename <<
" was not found.\n";
87 HepMC::IO_GenEvent *
p =
dynamic_cast<HepMC::IO_GenEvent*
>(
input_);
88 if (p)
return p->rdstate();
90 return std::ios::failbit;
99 edm::LogInfo(
"HepMCFileReader") <<
"| --- Event Nr. " <<
evt_->event_number()
100 <<
" with " <<
evt_->particles_size() <<
" particles --- !";
105 edm::LogInfo(
"HepMCFileReader") <<
"Got no event" <<endl;
138 int mo1=0,mo2=0,da1=0,da2=0,
status=0,
pid=0;
140 cout <<
"---#-------pid--st---Mo1---Mo2---Da1---Da2------px------py------pz-------E-";
141 cout <<
"------m---------x---------y---------z---------t-";
143 cout.setf(ios::right, ios::adjustfield);
144 for(
int n=1;
n<=
evt_->particles_size();
n++) {
154 cout.setf(ios::fixed, ios::floatfield);
155 cout.setf(ios::right, ios::adjustfield);
156 cout << setw(10) << setprecision(2) << g->momentum().x();
157 cout << setw(8) << setprecision(2) << g->momentum().y();
158 cout << setw(10) << setprecision(2) << g->momentum().z();
159 cout << setw(8) << setprecision(2) << g->momentum().t();
160 cout << setw(8) << setprecision(2) << g->generatedMass();
162 if (g->production_vertex() != 0 && g->end_vertex() != 0 &&
status == 2) {
163 cout << setw(10) << setprecision(2) <<g->production_vertex()->position().x();
164 cout << setw(10) << setprecision(2) <<g->production_vertex()->position().y();
165 cout << setw(10) << setprecision(2) <<g->production_vertex()->position().z();
167 double xm = g->production_vertex()->position().x();
168 double ym = g->production_vertex()->position().y();
169 double zm = g->production_vertex()->position().z();
170 double xd = g->end_vertex()->position().x();
171 double yd = g->end_vertex()->position().y();
172 double zd = g->end_vertex()->position().z();
173 double decl =
sqrt((xd-xm)*(xd-xm)+(yd-ym)*(yd-ym)+(zd-zm)*(zd-zm));
174 double labTime = decl/c_light;
176 double properTime = labTime/g->momentum().rho()*(g->generatedMass() );
178 cout << setw(8) << setprecision(2) <<properTime;
181 cout << setw(10) << setprecision(2) << 0.0;
182 cout << setw(10) << setprecision(2) << 0.0;
183 cout << setw(10) << setprecision(2) << 0.0;
184 cout << setw(8) << setprecision(2) << 0.0;
189 cout <<
" HepMCFileReader: No event available !" << endl;
197 unsigned int particle_counter=0;
200 for (HepMC::GenEvent::vertex_const_iterator
v =
evt_->vertices_begin();
201 v !=
evt_->vertices_end(); ++
v ) {
204 for (HepMC::GenVertex::particles_in_const_iterator
p1 = (*v)->particles_in_const_begin();
205 p1 != (*v)->particles_in_const_end(); ++
p1 ) {
217 for (HepMC::GenVertex::particles_out_const_iterator
p2 = (*v)->particles_out_const_begin();
218 p2 != (*v)->particles_out_const_end(); ++
p2) {
219 if (!(*p2)->end_vertex()) {
239 cout <<
"HepMCFileReader: Got no event :-( Game over already ?" <<endl;
252 production_vertex()->
253 particles_in_const_begin()));
254 int last_mother = first_mother + num_mothers - 1;
255 if ( first_mother == 0 ) last_mother = 0;
267 HepMC::GenVertex::particle_iterator ic;
274 if (first_daughter== 0) last_daughter = 0;
289 std::map<HepMC::GenParticle*,int>::const_iterator iter = m.find(p);
290 return (iter == m.end()) ? 0 : iter->second;
static HepMCFileReader * instance_
std::map< HepMC::GenParticle *, int > particle_to_index
virtual void initialize(const std::string &filename)
virtual bool setEvent(int event)
std::vector< HepMC::GenParticle * > index_to_particle
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
virtual ~HepMCFileReader()
static HepMCFileReader * instance()
virtual void getStatsFromTuple(int &mo1, int &mo2, int &da1, int &da2, int &status, int &pid, int j) const
int find_in_map(const std::map< HepMC::GenParticle *, int > &m, HepMC::GenParticle *p) const
HepMC::IO_BaseClass * input_
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isInitialized() const
virtual bool printHepMcEvent() const
virtual bool readCurrentEvent()
HepMC::GenEvent * fillCurrentEventData()