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
DrellYanValidation Class Reference

#include <DrellYanValidation.h>

Inheritance diagram for DrellYanValidation:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
 
 DrellYanValidation (const edm::ParameterSet &)
 
virtual void endJob ()
 
virtual void endRun (const edm::Run &, const edm::EventSetup &)
 
virtual ~DrellYanValidation ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

int _flavor
 decay flavor More...
 
std::string _name
 decay flavor name More...
 
MonitorElementcos_theta_gamma_lepton
 
DQMStoredbe
 ME's "container". More...
 
MonitorElementdilep_mass
 
MonitorElementdilep_massPeak
 
MonitorElementdilep_pt
 
MonitorElementdilep_ptLog
 
MonitorElementdilep_rap
 
edm::ESHandle
< HepPDT::ParticleDataTable
fPDGTable
 PDT table. More...
 
MonitorElementgamma_energy
 
edm::InputTag hepmcCollection_
 
edm::EDGetTokenT
< edm::HepMCProduct
hepmcCollectionToken_
 
MonitorElementleadeta
 
MonitorElementleadpt
 
MonitorElementnEvt
 
MonitorElementseceta
 
MonitorElementsecpt
 
WeightManager wmanager_
 
MonitorElementZdaughters
 
MonitorElementZmass
 
MonitorElementZmassPeak
 
MonitorElementZpt
 
MonitorElementZptLog
 
MonitorElementZrap
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 33 of file DrellYanValidation.h.

Constructor & Destructor Documentation

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

Definition at line 19 of file DrellYanValidation.cc.

References dbe, hepmcCollection_, hepmcCollectionToken_, and cppFunctionSkipper::operator.

19  :
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 
28  hepmcCollectionToken_=consumes<HepMCProduct>(hepmcCollection_);
29 }
T getParameter(std::string const &) const
edm::InputTag hepmcCollection_
int _flavor
decay flavor
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
DQMStore * dbe
ME&#39;s &quot;container&quot;.
WeightManager wmanager_
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
std::string _name
decay flavor name
DrellYanValidation::~DrellYanValidation ( )
virtual

Definition at line 31 of file DrellYanValidation.cc.

31 {}

Member Function Documentation

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

Gathering the HepMCProduct information

Implements edm::EDAnalyzer.

Definition at line 78 of file DrellYanValidation.cc.

References _flavor, funct::abs(), funct::cos(), cos_theta_gamma_lepton, dilep_mass, dilep_massPeak, dilep_pt, dilep_ptLog, dilep_rap, MonitorElement::Fill(), HepMCValidationHelper::findFSRPhotons(), fPDGTable, gamma_energy, edm::Event::getByToken(), hepmcCollectionToken_, i, leadeta, leadpt, nEvt, RecoTau_DiTaus_pt_20-420_cfg::ParticleID, perp(), edm::es::products(), seceta, secpt, python.multivaluedict::sort(), HepMCValidationHelper::sortByPt(), lumiQTWidget::t, WeightManager::weight(), histoStyle::weight, wmanager_, x, detailsBasic3DVector::y, detailsBasic3DVector::z, Zdaughters, Zmass, ZmassPeak, Zpt, ZptLog, and Zrap.

79 {
80 
81  // we *DO NOT* rely on a Z entry in the particle listings!
82 
85  iEvent.getByToken(hepmcCollectionToken_, evt);
86 
87  //Get EVENT
88  const HepMC::GenEvent *myGenEvent = evt->GetEvent();
89 
90  double weight = wmanager_.weight(iEvent);
91 
92  //std::cout << "weight: " << weight << std::endl;
93 
94  nEvt->Fill(0.5,weight);
95 
96  std::vector<const HepMC::GenParticle*> allproducts;
97 
98  //requires status 1 for leptons and neutrinos (except tau)
99  int requiredstatus = (abs(_flavor) == 11 || abs(_flavor) == 12 || abs(_flavor) ==13 || abs(_flavor) ==14 || abs(_flavor) ==16) ? 1 : 3;
100 
101  bool vetotau = true; //(abs(_flavor) == 11 || abs(_flavor) == 12 || abs(_flavor) ==13 || abs(_flavor) ==14 || abs(_flavor) ==16) ? true : false;
102 
103  for(HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin(); iter != myGenEvent->particles_end(); ++iter) {
104  if (vetotau) {
105  if ((*iter)->status()==3 && abs((*iter)->pdg_id() == 15) ) return;
106  }
107  if((*iter)->status()==requiredstatus) {
108  if(abs((*iter)->pdg_id())==_flavor)
109  allproducts.push_back(*iter);
110  }
111  }
112 
113  //nothing to do if we don't have 2 particles
114  if (allproducts.size() < 2) return;
115 
116  //sort them in pt
117  std::sort(allproducts.begin(), allproducts.end(), HepMCValidationHelper::sortByPt);
118 
119  //get the first element and the first following element with opposite charge
120  std::vector<const HepMC::GenParticle*> products;
121  products.push_back(allproducts.front());
122  const HepPDT::ParticleData* PData1 = fPDGTable->particle(HepPDT::ParticleID(allproducts.front()->pdg_id()));
123  double charge1 = PData1->charge();
124  for (unsigned int i = 1; i < allproducts.size(); ++i ){
125  const HepPDT::ParticleData* PData2 = fPDGTable->particle(HepPDT::ParticleID(allproducts[i]->pdg_id()));
126  double charge2 = PData2->charge();
127  if (charge1*charge2 < 0) products.push_back(allproducts[i]);
128  }
129 
130  //if we did not find any opposite charge pair there is nothing to do
131  if (products.size() < 2) return;
132 
133  assert(products[0]->momentum().perp() >= products[1]->momentum().perp());
134 
135  //leading lepton with pt > 20.
136  if (products[0]->momentum().perp() < 20.) return;
137 
138  //assemble FourMomenta
139  TLorentzVector lep1(products[0]->momentum().x(), products[0]->momentum().y(), products[0]->momentum().z(), products[0]->momentum().t());
140  TLorentzVector lep2(products[1]->momentum().x(), products[1]->momentum().y(), products[1]->momentum().z(), products[1]->momentum().t());
141  TLorentzVector dilepton_mom = lep1 + lep2;
142  TLorentzVector dilepton_andphoton_mom = dilepton_mom;
143 
144  //mass > 60.
145  if (dilepton_mom.M() < 60.) return;
146 
147  //find possible qed fsr photons
148  std::vector<const HepMC::GenParticle*> fsrphotons;
149  HepMCValidationHelper::findFSRPhotons(products, myGenEvent, 0.1, fsrphotons);
150 
151  Zdaughters->Fill(products[0]->pdg_id(),weight);
152  Zdaughters->Fill(products[1]->pdg_id(),weight);
153 
154  std::vector<TLorentzVector> gammasMomenta;
155  for (unsigned int ipho = 0; ipho < fsrphotons.size(); ++ipho){
156  TLorentzVector phomom(fsrphotons[ipho]->momentum().x(), fsrphotons[ipho]->momentum().y(), fsrphotons[ipho]->momentum().z(), fsrphotons[ipho]->momentum().t());
157  dilepton_andphoton_mom += phomom;
158  Zdaughters->Fill(fsrphotons[ipho]->pdg_id(),weight);
159  gammasMomenta.push_back(phomom);
160  }
161  //Fill Z histograms
162  Zmass->Fill(dilepton_andphoton_mom.M(),weight);
163  ZmassPeak->Fill(dilepton_andphoton_mom.M(),weight);
164  Zpt->Fill(dilepton_andphoton_mom.Pt(),weight);
165  ZptLog->Fill(log10(dilepton_andphoton_mom.Pt()),weight);
166  Zrap->Fill(dilepton_andphoton_mom.Rapidity(),weight);
167 
168  //Fill dilepton histograms
169  dilep_mass->Fill(dilepton_mom.M(),weight);
170  dilep_massPeak->Fill(dilepton_mom.M(),weight);
171  dilep_pt->Fill(dilepton_mom.Pt(),weight);
172  dilep_ptLog->Fill(log10(dilepton_mom.Pt()),weight);
173  dilep_rap->Fill(dilepton_mom.Rapidity(),weight);
174 
175  //Fill lepton histograms
176  leadpt->Fill(lep1.Pt(),weight);
177  secpt->Fill(lep2.Pt(),weight);
178  leadeta->Fill(lep1.Eta(),weight);
179  seceta->Fill(lep2.Eta(),weight);
180 
181  //boost everything in the Z frame
182  TVector3 boost = dilepton_andphoton_mom.BoostVector();
183  boost*=-1.;
184  lep1.Boost(boost);
185  lep2.Boost(boost);
186  for (unsigned int ipho = 0; ipho < gammasMomenta.size(); ++ipho){
187  gammasMomenta[ipho].Boost(boost);
188  }
189  std::sort(gammasMomenta.begin(), gammasMomenta.end(), HepMCValidationHelper::GreaterByE<TLorentzVector>);
190 
191  //fill gamma histograms
192  if (gammasMomenta.size() != 0 && dilepton_andphoton_mom.M() > 50.) {
193  gamma_energy->Fill(gammasMomenta.front().E(),weight);
194  double dphi = lep1.DeltaR(gammasMomenta.front()) < lep2.DeltaR(gammasMomenta.front()) ?
195  lep1.DeltaPhi(gammasMomenta.front()) : lep2.DeltaPhi(gammasMomenta.front());
196  cos_theta_gamma_lepton->Fill(cos(dphi),weight);
197  }
198 
199 }//analyze
MonitorElement * secpt
MonitorElement * gamma_energy
int i
Definition: DBlmapReader.cc:9
MonitorElement * dilep_rap
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 * Zmass
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
MonitorElement * cos_theta_gamma_lepton
MonitorElement * nEvt
MonitorElement * leadeta
bool sortByPt(const HepMC::GenParticle *a, const HepMC::GenParticle *b)
MonitorElement * Zrap
MonitorElement * leadpt
float float float z
void Fill(long long x)
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
PDT table.
int _flavor
decay flavor
MonitorElement * dilep_massPeak
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
WeightManager wmanager_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MonitorElement * Zdaughters
MonitorElement * dilep_pt
HepPDT::ParticleData ParticleData
MonitorElement * ZptLog
edm::EDGetTokenT< edm::HepMCProduct > hepmcCollectionToken_
MonitorElement * seceta
T perp() const
Magnitude of transverse component.
MonitorElement * dilep_mass
MonitorElement * ZmassPeak
MonitorElement * dilep_ptLog
Definition: DDAxes.h:10
int weight
Definition: histoStyle.py:50
double weight(const edm::Event &)
MonitorElement * Zpt
void DrellYanValidation::beginJob ( void  )
virtual

Setting the DQM top directories

Reimplemented from edm::EDAnalyzer.

Definition at line 33 of file DrellYanValidation.cc.

References _name, DQMStore::book1D(), cos_theta_gamma_lepton, dbe, dilep_mass, dilep_massPeak, dilep_pt, dilep_ptLog, dilep_rap, gamma_energy, leadeta, leadpt, nEvt, seceta, secpt, DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, Zdaughters, Zmass, ZmassPeak, Zpt, ZptLog, and Zrap.

34 {
35  if(dbe){
37  std::string folderName = "Generator/DrellYan";
38  folderName+=_name;
39  dbe->setCurrentFolder(folderName.c_str());
40 
41  // Number of analyzed events
42  nEvt = dbe->book1D("nEvt", "n analyzed Events", 1, 0., 1.);
43 
44  //Kinematics
45  Zmass = dbe->book1D("Zmass","inv. Mass Z", 70 ,0,140);
46  ZmassPeak = dbe->book1D("ZmassPeak","inv. Mass Z", 80 ,80 ,100);
47  Zpt = dbe->book1D("Zpt","Z pt",100,0,200);
48  ZptLog = dbe->book1D("ZptLog","log(Z pt)",100,0.,5.);
49  Zrap = dbe->book1D("Zrap", "Z y", 100, -5, 5);
50  Zdaughters = dbe->book1D("Zdaughters", "Z daughters", 60, -30, 30);
51 
52  dilep_mass = dbe->book1D("dilep_mass","inv. Mass dilepton", 70 ,0,140);
53  dilep_massPeak = dbe->book1D("dilep_massPeak","inv. Mass dilepton", 80 ,80 ,100);
54  dilep_pt = dbe->book1D("dilep_pt","dilepton pt",100,0,200);
55  dilep_ptLog = dbe->book1D("dilep_ptLog","log(dilepton pt)",100,0.,5.);
56  dilep_rap = dbe->book1D("dilep_rap", "dilepton y", 100, -5, 5);
57 
58  gamma_energy = dbe->book1D("gamma_energy", "photon energy in Z rest frame", 200, 0., 100.);
59  cos_theta_gamma_lepton = dbe->book1D("cos_theta_gamma_lepton", "cos_theta_gamma_lepton in Z rest frame", 200, -1, 1);
60 
61  leadpt = dbe->book1D("leadpt","leading lepton pt", 200, 0., 200.);
62  secpt = dbe->book1D("secpt","second lepton pt", 200, 0., 200.);
63  leadeta = dbe->book1D("leadeta","leading lepton eta", 100, -5., 5.);
64  seceta = dbe->book1D("seceta","second lepton eta", 100, -5., 5.);
65 
66  }
67  return;
68 }
MonitorElement * secpt
MonitorElement * gamma_energy
MonitorElement * dilep_rap
MonitorElement * Zmass
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
MonitorElement * cos_theta_gamma_lepton
MonitorElement * nEvt
MonitorElement * leadeta
MonitorElement * Zrap
MonitorElement * leadpt
MonitorElement * dilep_massPeak
DQMStore * dbe
ME&#39;s &quot;container&quot;.
MonitorElement * Zdaughters
MonitorElement * dilep_pt
MonitorElement * ZptLog
std::string _name
decay flavor name
MonitorElement * seceta
MonitorElement * dilep_mass
MonitorElement * ZmassPeak
MonitorElement * dilep_ptLog
MonitorElement * Zpt
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
void DrellYanValidation::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
virtual

Get PDT Table

Reimplemented from edm::EDAnalyzer.

Definition at line 71 of file DrellYanValidation.cc.

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

72 {
74  iSetup.getData( fPDGTable );
75  return;
76 }
void getData(T &iHolder) const
Definition: EventSetup.h:67
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
PDT table.
void DrellYanValidation::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 70 of file DrellYanValidation.cc.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 77 of file DrellYanValidation.cc.

77 {return;}

Member Data Documentation

int DrellYanValidation::_flavor
private

decay flavor

Definition at line 61 of file DrellYanValidation.h.

Referenced by analyze().

std::string DrellYanValidation::_name
private

decay flavor name

Definition at line 63 of file DrellYanValidation.h.

Referenced by beginJob().

MonitorElement * DrellYanValidation::cos_theta_gamma_lepton
private

Definition at line 58 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

DQMStore* DrellYanValidation::dbe
private

ME's "container".

Definition at line 52 of file DrellYanValidation.h.

Referenced by beginJob(), and DrellYanValidation().

MonitorElement* DrellYanValidation::dilep_mass
private

Definition at line 56 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * DrellYanValidation::dilep_massPeak
private

Definition at line 56 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * DrellYanValidation::dilep_pt
private

Definition at line 56 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * DrellYanValidation::dilep_ptLog
private

Definition at line 56 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * DrellYanValidation::dilep_rap
private

Definition at line 56 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

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

PDT table.

Definition at line 49 of file DrellYanValidation.h.

Referenced by analyze(), and beginRun().

MonitorElement* DrellYanValidation::gamma_energy
private

Definition at line 58 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

edm::InputTag DrellYanValidation::hepmcCollection_
private

Definition at line 46 of file DrellYanValidation.h.

Referenced by DrellYanValidation().

edm::EDGetTokenT<edm::HepMCProduct> DrellYanValidation::hepmcCollectionToken_
private

Definition at line 65 of file DrellYanValidation.h.

Referenced by analyze(), and DrellYanValidation().

MonitorElement * DrellYanValidation::leadeta
private

Definition at line 57 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement* DrellYanValidation::leadpt
private

Definition at line 57 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement* DrellYanValidation::nEvt
private

Definition at line 54 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * DrellYanValidation::seceta
private

Definition at line 57 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * DrellYanValidation::secpt
private

Definition at line 57 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

WeightManager DrellYanValidation::wmanager_
private

Definition at line 45 of file DrellYanValidation.h.

Referenced by analyze().

MonitorElement * DrellYanValidation::Zdaughters
private

Definition at line 55 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement* DrellYanValidation::Zmass
private

Definition at line 55 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * DrellYanValidation::ZmassPeak
private

Definition at line 55 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * DrellYanValidation::Zpt
private

Definition at line 55 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * DrellYanValidation::ZptLog
private

Definition at line 55 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().

MonitorElement * DrellYanValidation::Zrap
private

Definition at line 55 of file DrellYanValidation.h.

Referenced by analyze(), and beginJob().