CMS 3D CMS Logo

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