test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MCDijetResonance.cc
Go to the documentation of this file.
2 
4 #include <iostream>
5 
7 
8 using namespace edm;
9 using namespace std;
10 
11 
13  token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared")))
14 {
15  //here do whatever other initialization is needed
16 
17  //Get dijet process type we will select
18  dijetProcess = iConfig.getUntrackedParameter<string>( "dijetProcess" );
19  cout << "Dijet Resonance Filter Selecting Process = " << dijetProcess << endl;
20 
21  maxQuarkID = 4; //Maximum |ID| of Light Quark = charm quark gives u, d, s, and c decays of Zprime.
22  bosonID = 21; //Gluon
23 
24  //Number of events and Number Accepted
25  nEvents = 0;
26  nAccepted = 0;
27 }
28 
29 
31 {
32 
33  // do anything here that needs to be done at desctruction time
34  // (e.g. close files, deallocate resources etc.)
35 
36 }
37 
39 {
40  edm::LogVerbatim("MCDijetResonanceInfo") << "================MCDijetResonance report========================================\n"
41  << "Events read " << nEvents << " Events accepted " << nAccepted << "\nEfficiency " << ((double)nAccepted)/((double)nEvents)
42  << "\n====================================================================" << std::endl;
43 }
44 
45 // ------------ method called to skim the data ------------
47 {
48  nEvents++;
49  cout << endl << "Event=" << nEvents << endl;
50  using namespace edm;
52  iEvent.getByToken(token_, evt);
53  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
54 
55  //If process is not the desired primary process, cleanup and reject the event.
56  if (dijetProcess == "ZprimeLightQuarks" && myGenEvent->signal_process_id() != 141){
57  // Wanted a Z' but didn't find it, so reject event.
58  delete myGenEvent;
59  return false;
60  }
61  if (dijetProcess == "QstarQuarkGluon" && myGenEvent->signal_process_id() != 147 && myGenEvent->signal_process_id() != 148){
62  // Wanted a q* but didn't find it, so reject event.
63  delete myGenEvent;
64  return false;
65  }
66 
67  //found a dijet resonance
68 
69  //debug
70  // int count = 0;
71  //for ( HepMC::GenEvent::particle_iterator p = myGenEvent->particles_begin();
72  // p != myGenEvent->particles_end() & count<13; ++p )
73  // {
74  //std::cout << count << ": ID=" << (*p)->pdg_id() << ", status=" << (*p)->status() << ", mass=" << (*p)->momentum().invariantMass() << ", pt=" <<(*p)->momentum().perp() << std::endl;
75  //count++;
76  //}
77 
78  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
79  p != myGenEvent->particles_end(); ++p )
80  {
81  //Find resonance particle and check that it is part of hard collision
82  if ( (*p)->status() == 3 && ( (dijetProcess == "ZprimeLightQuarks" && (*p)->pdg_id() == 32) ||
83  (dijetProcess == "QstarQuarkGluon" && abs((*p)->pdg_id()) == 4000001) ||
84  (dijetProcess == "QstarQuarkGluon" && abs((*p)->pdg_id()) == 4000002) ) )
85  {
86  // The next two particles are the outgoing particles from the resonance decay
87  p++;
88  int ID1 = (*p)->pdg_id();
89  p++;
90  int ID2 = (*p)->pdg_id();
91 
92  //Check for the process we want
93  if( (dijetProcess == "ZprimeLightQuarks" && abs(ID1) <= maxQuarkID && abs(ID2) <= maxQuarkID ) ||
94  (dijetProcess == "QstarQuarkGluon" && ( ID1 == bosonID || ID2 == bosonID ) ) )
95  {
96  //cout << "dijet resonance " << dijetProcess << " found " << endl;
97  nAccepted++;
98  delete myGenEvent;
99  return true;
100  }
101  else
102  {
103  delete myGenEvent;
104  return false;
105  }
106  }
107 
108  }
109 
110  delete myGenEvent;
111  return false;
112 }
T getUntrackedParameter(std::string const &, T const &) const
virtual bool filter(edm::Event &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< edm::HepMCProduct > token_
unsigned int nAccepted
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MCDijetResonance(const edm::ParameterSet &)
std::string dijetProcess
unsigned int nEvents
virtual void endJob()
tuple cout
Definition: gather_cfg.py:145