CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
WValidation Class Reference

#include <WValidation.h>

Inheritance diagram for WValidation:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
 
virtual void endJob ()
 
virtual void endRun (const edm::Run &, const edm::EventSetup &)
 
 WValidation (const edm::ParameterSet &)
 
virtual ~WValidation ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

int _flavor
 decay flavor More...
 
std::string _name
 decay flavor name More...
 
MonitorElementcos_theta_gamma_lepton
 
DQMStoredbe
 ME's "container". More...
 
edm::ESHandle
< HepPDT::ParticleDataTable
fPDGTable
 PDT table. More...
 
MonitorElementgamma_energy
 
edm::InputTag hepmcCollection_
 
MonitorElementlepeta
 
MonitorElementlepmet_mT
 
MonitorElementlepmet_mTPeak
 
MonitorElementlepmet_pt
 
MonitorElementlepmet_ptLog
 
MonitorElementlepmet_rap
 
MonitorElementleppt
 
MonitorElementmet
 
MonitorElementnEvt
 
MonitorElementWdaughters
 
MonitorElementWmass
 
MonitorElementWmassPeak
 
MonitorElementWpt
 
MonitorElementWptLog
 
MonitorElementWrap
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 34 of file WValidation.h.

Constructor & Destructor Documentation

WValidation::WValidation ( const edm::ParameterSet iPSet)
explicit

Definition at line 20 of file WValidation.cc.

References dbe, and cmsCodeRules.cppFunctionSkipper::operator.

20  :
21  hepmcCollection_(iPSet.getParameter<edm::InputTag>("hepmcCollection")),
22  _flavor(iPSet.getParameter<int>("decaysTo")),
23  _name(iPSet.getParameter<std::string>("name"))
24 {
25  dbe = 0;
27 }
edm::InputTag hepmcCollection_
Definition: WValidation.h:47
T getParameter(std::string const &) const
std::string _name
decay flavor name
Definition: WValidation.h:64
DQMStore * dbe
ME&#39;s &quot;container&quot;.
Definition: WValidation.h:53
int _flavor
decay flavor
Definition: WValidation.h:62
WValidation::~WValidation ( )
virtual

Definition at line 29 of file WValidation.cc.

29 {}

Member Function Documentation

void WValidation::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Gathering the HepMCProduct information

Implements edm::EDAnalyzer.

Definition at line 74 of file WValidation.cc.

References _flavor, abs, funct::cos(), cos_theta_gamma_lepton, MonitorElement::Fill(), HepMCValidationHelper::findFSRPhotons(), gamma_energy, HepMCValidationHelper::genMet(), edm::Event::getByLabel(), hepmcCollection_, lepeta, lepmet_mT, lepmet_mTPeak, lepmet_pt, lepmet_ptLog, leppt, met, nEvt, edm::es::products(), python.multivaluedict::sort(), HepMCValidationHelper::sortByPt(), matplotRender::t, Wdaughters, Wmass, WmassPeak, Wpt, WptLog, Wrap, x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

75 {
76 
77  // we *DO NOT* rely on a Z entry in the particle listings!
78 
81  iEvent.getByLabel(hepmcCollection_, evt);
82 
83  //Get EVENT
84  const HepMC::GenEvent *myGenEvent = evt->GetEvent();
85 
86  nEvt->Fill(0.5);
87 
88  std::vector<const HepMC::GenParticle*> allleptons;
89  std::vector<const HepMC::GenParticle*> allneutrinos;
90 
91  //requires status 1 for leptons and neutrinos (except tau)
92  int requiredstatus = (abs(_flavor) == 11 || abs(_flavor) ==13 ) ? 1 : 3;
93 
94  bool vetotau = true; //(abs(_flavor) == 11 || abs(_flavor) == 12 || abs(_flavor) ==13 || abs(_flavor) ==14 || abs(_flavor) ==16) ? true : false;
95 
96  for(HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin(); iter != myGenEvent->particles_end(); ++iter) {
97  if (vetotau) {
98  if ((*iter)->status()==3 && abs((*iter)->pdg_id() == 15) ) return;
99  }
100  if((*iter)->status()==requiredstatus) {
101  //@todo: improve this selection
102  if((*iter)->pdg_id()==_flavor)
103  allleptons.push_back(*iter);
104  else if (abs((*iter)->pdg_id()) == abs(_flavor)+1)
105  allneutrinos.push_back(*iter);
106  }
107  }
108 
109  //nothing to do if we don't have 2 particles
110  if (allleptons.empty() || allneutrinos.empty()) return;
111 
112  //sort them in pt
113  std::sort(allleptons.begin(), allleptons.end(), HepMCValidationHelper::sortByPt);
114  std::sort(allneutrinos.begin(), allneutrinos.end(), HepMCValidationHelper::sortByPt);
115 
116  //get the first lepton and the first neutrino, and check that one is particle one is antiparticle (product of pdgids < 0)
117  std::vector<const HepMC::GenParticle*> products;
118  if (allleptons.front()->pdg_id() * allneutrinos.front()->pdg_id() > 0) return;
119 
120  //require at least 20 GeV on the lepton
121  if (allleptons.front()->momentum().perp() < 20. || allneutrinos.front()->momentum().perp() < 20. ) return;
122 
123  //find possible qed fsr photons
124  std::vector<const HepMC::GenParticle*> selectedLepton;
125  selectedLepton.push_back(allleptons.front());
126  std::vector<const HepMC::GenParticle*> fsrphotons;
127  HepMCValidationHelper::findFSRPhotons(selectedLepton, myGenEvent, 0.1, fsrphotons);
128 
129  Wdaughters->Fill(allleptons.front()->pdg_id());
130  Wdaughters->Fill(allneutrinos.front()->pdg_id());
131 
132  //assemble FourMomenta
133  TLorentzVector lep1(allleptons[0]->momentum().x(), allleptons[0]->momentum().y(), allleptons[0]->momentum().z(), allleptons[0]->momentum().t());
134  TLorentzVector lep2(allneutrinos[0]->momentum().x(), allneutrinos[0]->momentum().y(), allneutrinos[0]->momentum().z(), allneutrinos[0]->momentum().t());
135  TLorentzVector dilepton_mom = lep1 + lep2;
136  TLorentzVector dilepton_andphoton_mom = dilepton_mom;
137  std::vector<TLorentzVector> gammasMomenta;
138  for (unsigned int ipho = 0; ipho < fsrphotons.size(); ++ipho){
139  TLorentzVector phomom(fsrphotons[ipho]->momentum().x(), fsrphotons[ipho]->momentum().y(), fsrphotons[ipho]->momentum().z(), fsrphotons[ipho]->momentum().t());
140  dilepton_andphoton_mom += phomom;
141  Wdaughters->Fill(fsrphotons[ipho]->pdg_id());
142  gammasMomenta.push_back(phomom);
143  }
144  //Fill "true" W histograms
145  Wmass->Fill(dilepton_andphoton_mom.M());
146  WmassPeak->Fill(dilepton_andphoton_mom.M());
147  Wpt->Fill(dilepton_andphoton_mom.Pt());
148  WptLog->Fill(log10(dilepton_andphoton_mom.Pt()));
149  Wrap->Fill(dilepton_andphoton_mom.Rapidity());
150 
151  TLorentzVector met_mom = HepMCValidationHelper::genMet(myGenEvent, -3., 3.);
152  TLorentzVector lep1T(lep1.Px(), lep1.Py(), 0., lep1.Et());
153  TLorentzVector lepmet_mom = lep1T + met_mom;
154  //Fill lepmet histograms
155  lepmet_mT->Fill(lepmet_mom.M());
156  lepmet_mTPeak->Fill(lepmet_mom.M());
157  lepmet_pt->Fill(lepmet_mom.Pt());
158  lepmet_ptLog->Fill(log10(lepmet_mom.Pt()));
159 
160  //Fill lepton histograms
161  leppt->Fill(lep1.Pt());
162  lepeta->Fill(lep1.Eta());
163  met->Fill(met_mom.Pt());
164 
165  //boost everything in the W frame
166  TVector3 boost = dilepton_andphoton_mom.BoostVector();
167  boost*=-1.;
168  lep1.Boost(boost);
169  lep2.Boost(boost);
170  for (unsigned int ipho = 0; ipho < gammasMomenta.size(); ++ipho){
171  gammasMomenta[ipho].Boost(boost);
172  }
173  std::sort(gammasMomenta.begin(), gammasMomenta.end(), HepMCValidationHelper::GreaterByE<TLorentzVector>);
174 
175  //fill gamma histograms
176  if (gammasMomenta.size() != 0 && dilepton_andphoton_mom.M() > 50.) {
177  gamma_energy->Fill(gammasMomenta.front().E());
178  double dphi = lep1.DeltaR(gammasMomenta.front());
180  }
181 
182 
183 }//analyze
edm::InputTag hepmcCollection_
Definition: WValidation.h:47
MonitorElement * leppt
Definition: WValidation.h:58
void findFSRPhotons(const std::vector< const HepMC::GenParticle * > &leptons, const std::vector< const HepMC::GenParticle * > &all, double deltaR, std::vector< const HepMC::GenParticle * > &photons)
MonitorElement * Wrap
Definition: WValidation.h:56
MonitorElement * nEvt
Definition: WValidation.h:55
bool sortByPt(const HepMC::GenParticle *a, const HepMC::GenParticle *b)
#define abs(x)
Definition: mlp_lapack.h:159
MonitorElement * lepeta
Definition: WValidation.h:58
double double double z
MonitorElement * lepmet_mT
Definition: WValidation.h:57
void Fill(long long x)
MonitorElement * lepmet_pt
Definition: WValidation.h:57
ESProducts< T, S > products(const T &i1, const S &i2)
Definition: ESProducts.h:189
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
MonitorElement * gamma_energy
Definition: WValidation.h:59
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
MonitorElement * WptLog
Definition: WValidation.h:56
TLorentzVector genMet(const HepMC::GenEvent *all, double etamin=-9999., double etamax=9999.)
MonitorElement * lepmet_mTPeak
Definition: WValidation.h:57
MonitorElement * WmassPeak
Definition: WValidation.h:56
MonitorElement * met
Definition: WValidation.h:58
MonitorElement * Wpt
Definition: WValidation.h:56
MonitorElement * lepmet_ptLog
Definition: WValidation.h:57
Definition: DDAxes.h:10
MonitorElement * Wdaughters
Definition: WValidation.h:56
MonitorElement * Wmass
Definition: WValidation.h:56
MonitorElement * cos_theta_gamma_lepton
Definition: WValidation.h:59
int _flavor
decay flavor
Definition: WValidation.h:62
void WValidation::beginJob ( void  )
virtual

Setting the DQM top directories

Reimplemented from edm::EDAnalyzer.

Definition at line 31 of file WValidation.cc.

References _name, DQMStore::book1D(), cos_theta_gamma_lepton, dbe, gamma_energy, lepeta, lepmet_mT, lepmet_mTPeak, lepmet_pt, lepmet_ptLog, leppt, met, nEvt, DQMStore::setCurrentFolder(), Wdaughters, Wmass, WmassPeak, Wpt, WptLog, and Wrap.

32 {
33  if(dbe){
35  std::string folderName = "Generator/W";
36  folderName+=_name;
37  dbe->setCurrentFolder(folderName.c_str());
38 
39  // Number of analyzed events
40  nEvt = dbe->book1D("nEvt", "n analyzed Events", 1, 0., 1.);
41 
42  //Kinematics
43  Wmass = dbe->book1D("Wmass","inv. Mass W", 70 ,0,140);
44  WmassPeak = dbe->book1D("WmassPeak","inv. Mass W", 80 ,80 ,100);
45  Wpt = dbe->book1D("Wpt","W pt",100,0,200);
46  WptLog = dbe->book1D("WptLog","log(W pt)",100,0.,5.);
47  Wrap = dbe->book1D("Wrap", "W y", 100, -5, 5);
48  Wdaughters = dbe->book1D("Wdaughters", "W daughters", 60, -30, 30);
49 
50  lepmet_mT = dbe->book1D("lepmet_mT","lepton-met transverse mass", 70 ,0,140);
51  lepmet_mTPeak = dbe->book1D("lepmet_mTPeak","lepton-met transverse mass", 80 ,80 ,100);
52  lepmet_pt = dbe->book1D("lepmet_pt","lepton-met",100,0,200);
53  lepmet_ptLog = dbe->book1D("lepmet_ptLog","log(lepton-met pt)",100,0.,5.);
54 
55  gamma_energy = dbe->book1D("gamma_energy", "photon energy in W rest frame", 200, 0., 100.);
56  cos_theta_gamma_lepton = dbe->book1D("cos_theta_gamma_lepton", "cos_theta_gamma_lepton in W rest frame", 200, -1, 1);
57 
58  leppt = dbe->book1D("leadpt","lepton pt", 200, 0., 200.);
59  met = dbe->book1D("met","met", 200, 0., 200.);
60  lepeta = dbe->book1D("leadeta","leading lepton eta", 100, -5., 5.);
61 
62  }
63  return;
64 }
MonitorElement * leppt
Definition: WValidation.h:58
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:514
MonitorElement * Wrap
Definition: WValidation.h:56
MonitorElement * nEvt
Definition: WValidation.h:55
std::string _name
decay flavor name
Definition: WValidation.h:64
DQMStore * dbe
ME&#39;s &quot;container&quot;.
Definition: WValidation.h:53
MonitorElement * lepeta
Definition: WValidation.h:58
MonitorElement * lepmet_mT
Definition: WValidation.h:57
MonitorElement * lepmet_pt
Definition: WValidation.h:57
MonitorElement * gamma_energy
Definition: WValidation.h:59
MonitorElement * WptLog
Definition: WValidation.h:56
MonitorElement * lepmet_mTPeak
Definition: WValidation.h:57
MonitorElement * WmassPeak
Definition: WValidation.h:56
MonitorElement * met
Definition: WValidation.h:58
MonitorElement * Wpt
Definition: WValidation.h:56
MonitorElement * lepmet_ptLog
Definition: WValidation.h:57
MonitorElement * Wdaughters
Definition: WValidation.h:56
MonitorElement * Wmass
Definition: WValidation.h:56
MonitorElement * cos_theta_gamma_lepton
Definition: WValidation.h:59
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
void WValidation::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
virtual

Get PDT Table

Reimplemented from edm::EDAnalyzer.

Definition at line 67 of file WValidation.cc.

References fPDGTable, and edm::EventSetup::getData().

68 {
70  iSetup.getData( fPDGTable );
71  return;
72 }
void getData(T &iHolder) const
Definition: EventSetup.h:67
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
PDT table.
Definition: WValidation.h:50
void WValidation::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 66 of file WValidation.cc.

66 {return;}
void WValidation::endRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 73 of file WValidation.cc.

73 {return;}

Member Data Documentation

int WValidation::_flavor
private

decay flavor

Definition at line 62 of file WValidation.h.

Referenced by analyze().

std::string WValidation::_name
private

decay flavor name

Definition at line 64 of file WValidation.h.

Referenced by beginJob().

MonitorElement * WValidation::cos_theta_gamma_lepton
private

Definition at line 59 of file WValidation.h.

Referenced by analyze(), and beginJob().

DQMStore* WValidation::dbe
private

ME's "container".

Definition at line 53 of file WValidation.h.

Referenced by beginJob(), and WValidation().

edm::ESHandle<HepPDT::ParticleDataTable> WValidation::fPDGTable
private

PDT table.

Definition at line 50 of file WValidation.h.

Referenced by beginRun().

MonitorElement* WValidation::gamma_energy
private

Definition at line 59 of file WValidation.h.

Referenced by analyze(), and beginJob().

edm::InputTag WValidation::hepmcCollection_
private

Definition at line 47 of file WValidation.h.

Referenced by analyze().

MonitorElement * WValidation::lepeta
private

Definition at line 58 of file WValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement* WValidation::lepmet_mT
private

Definition at line 57 of file WValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * WValidation::lepmet_mTPeak
private

Definition at line 57 of file WValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * WValidation::lepmet_pt
private

Definition at line 57 of file WValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * WValidation::lepmet_ptLog
private

Definition at line 57 of file WValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * WValidation::lepmet_rap
private

Definition at line 57 of file WValidation.h.

MonitorElement* WValidation::leppt
private

Definition at line 58 of file WValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * WValidation::met
private

Definition at line 58 of file WValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement* WValidation::nEvt
private

Definition at line 55 of file WValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * WValidation::Wdaughters
private

Definition at line 56 of file WValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement* WValidation::Wmass
private

Definition at line 56 of file WValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * WValidation::WmassPeak
private

Definition at line 56 of file WValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * WValidation::Wpt
private

Definition at line 56 of file WValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * WValidation::WptLog
private

Definition at line 56 of file WValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * WValidation::Wrap
private

Definition at line 56 of file WValidation.h.

Referenced by analyze(), and beginJob().