diff --git a/GeneratorInterface/LHEInterface/python/lhe2HepMCConverter_cff.py b/GeneratorInterface/LHEInterface/python/lhe2HepMCConverter_cff.py new file mode 100644 index 0000000000000..6d05f9a1f7a61 --- /dev/null +++ b/GeneratorInterface/LHEInterface/python/lhe2HepMCConverter_cff.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +generator = cms.EDProducer("LHE2HepMCConverter", + LHEEventProduct = cms.InputTag("source"), + LHERunInfoProduct = cms.InputTag("source") + ) diff --git a/GeneratorInterface/LHEInterface/python/lheCOMWeightProducer.py b/GeneratorInterface/LHEInterface/python/lheCOMWeightProducer.py new file mode 100644 index 0000000000000..bf7471718bdb7 --- /dev/null +++ b/GeneratorInterface/LHEInterface/python/lheCOMWeightProducer.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +lheCOMWeightProducer = cms.EDProducer("LHECOMWeightProducer", + lheSrc = cms.InputTag("source"), + NewECMS = cms.double(7000) + ) diff --git a/Validation/EventGenerator/BuildFile.xml b/Validation/EventGenerator/BuildFile.xml index 07be7b94331d7..2e2ced026f0be 100644 --- a/Validation/EventGenerator/BuildFile.xml +++ b/Validation/EventGenerator/BuildFile.xml @@ -1,5 +1,8 @@ + + + diff --git a/Validation/EventGenerator/interface/BasicGenParticleValidation.h b/Validation/EventGenerator/interface/BasicGenParticleValidation.h index 9c17e41a1d4fa..e58e9f0a661f4 100644 --- a/Validation/EventGenerator/interface/BasicGenParticleValidation.h +++ b/Validation/EventGenerator/interface/BasicGenParticleValidation.h @@ -34,6 +34,7 @@ #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" +#include "Validation/EventGenerator/interface/WeightManager.h" class BasicGenParticleValidation : public edm::EDAnalyzer { @@ -50,6 +51,8 @@ class BasicGenParticleValidation : public edm::EDAnalyzer private: + WeightManager _wmanager; + edm::InputTag hepmcCollection_; edm::InputTag genparticleCollection_; edm::InputTag genjetCollection_; diff --git a/Validation/EventGenerator/interface/BasicHepMCHeavyIonValidation.h b/Validation/EventGenerator/interface/BasicHepMCHeavyIonValidation.h new file mode 100644 index 0000000000000..7b4d82914e8c5 --- /dev/null +++ b/Validation/EventGenerator/interface/BasicHepMCHeavyIonValidation.h @@ -0,0 +1,80 @@ +#ifndef BASICHEPMCHEAVYIONVALIDATION_H +#define BASICHEPMCHEAVYIONVALIDATION_H + +/*class BasicHepMCHeavyIonValidation + * + * Class to fill Event Generator dqm monitor elements; works on HepMCProduct HepMC::HeavyIon + * Quan Wang - 04/2013 + * + */ + +// framework & common header files +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Run.h" + +#include "DataFormats/Common/interface/Handle.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" + +//DQM services +#include "DQMServices/Core/interface/DQMStore.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "DQMServices/Core/interface/MonitorElement.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" + +#include "Validation/EventGenerator/interface/WeightManager.h" + +class BasicHepMCHeavyIonValidation : public edm::EDAnalyzer +{ + public: + explicit BasicHepMCHeavyIonValidation(const edm::ParameterSet&); + virtual ~BasicHepMCHeavyIonValidation(); + virtual void beginJob(); + virtual void endJob(); + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void beginRun(const edm::Run&, const edm::EventSetup&); + virtual void endRun(const edm::Run&, const edm::EventSetup&); + + private: + + WeightManager _wmanager; + + edm::InputTag hepmcCollection_; + bool QWdebug_; + + /// PDT table + //edm::ESHandle fPDGTable ; + + ///ME's "container" + DQMStore *dbe; + + MonitorElement* nEvt; + + // Additional information stored in HeavyIon structure + MonitorElement* Ncoll_hard; // Number of hard scatterings + MonitorElement* Npart_proj; // Number of projectile participants + MonitorElement* Npart_targ; // Number of target participants + MonitorElement* Ncoll; // Number of NN (nucleon-nucleon) collisions + MonitorElement* N_Nwounded_collisions; // Number of N-Nwounded collisions + MonitorElement* Nwounded_N_collisions; // Number of Nwounded-N collisons + MonitorElement* Nwounded_Nwounded_collisions; // Number of Nwounded-Nwounded collisions + MonitorElement* spectator_neutrons; // Number of spectator neutrons + MonitorElement* spectator_protons; // Number of spectator protons + MonitorElement* impact_parameter; // Impact Parameter(fm) of collision + MonitorElement* event_plane_angle; // Azimuthal angle of event plane + MonitorElement* eccentricity; // eccentricity of participating nucleons + // in the transverse plane + // (as in phobos nucl-ex/0510031) + MonitorElement* sigma_inel_NN; // nucleon-nucleon inelastic + // (including diffractive) cross-section + + +}; + +#endif diff --git a/Validation/EventGenerator/interface/BasicHepMCValidation.h b/Validation/EventGenerator/interface/BasicHepMCValidation.h index 9f534f9c0aeea..9a67d84da2c45 100644 --- a/Validation/EventGenerator/interface/BasicHepMCValidation.h +++ b/Validation/EventGenerator/interface/BasicHepMCValidation.h @@ -30,6 +30,7 @@ #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" +#include "Validation/EventGenerator/interface/WeightManager.h" class BasicHepMCValidation : public edm::EDAnalyzer { @@ -44,6 +45,8 @@ class BasicHepMCValidation : public edm::EDAnalyzer private: + WeightManager _wmanager; + edm::InputTag hepmcCollection_; /// PDT table @@ -101,6 +104,8 @@ class BasicHepMCValidation : public edm::EDAnalyzer MonitorElement *stablePtclCharge; MonitorElement *stablePtclp; MonitorElement *stablePtclpT; + MonitorElement *partonNumber; + MonitorElement *partonpT; MonitorElement *outVrtxStablePtclNumber; // MonitorElement *vrtxZ; @@ -108,6 +113,13 @@ class BasicHepMCValidation : public edm::EDAnalyzer // MonitorElement *Bjorken_x; + MonitorElement *status1ShortLived; + + MonitorElement *DeltaEcms; + MonitorElement *DeltaPx; + MonitorElement *DeltaPy; + MonitorElement *DeltaPz; + }; #endif diff --git a/Validation/EventGenerator/interface/DrellYanValidation.h b/Validation/EventGenerator/interface/DrellYanValidation.h index 4775fcb02fa41..4be25f25f61fd 100644 --- a/Validation/EventGenerator/interface/DrellYanValidation.h +++ b/Validation/EventGenerator/interface/DrellYanValidation.h @@ -30,6 +30,7 @@ #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" +#include "Validation/EventGenerator/interface/WeightManager.h" class DrellYanValidation : public edm::EDAnalyzer { @@ -44,6 +45,8 @@ class DrellYanValidation : public edm::EDAnalyzer private: + WeightManager _wmanager; + edm::InputTag hepmcCollection_; /// PDT table diff --git a/Validation/EventGenerator/interface/DuplicationChecker.h b/Validation/EventGenerator/interface/DuplicationChecker.h index 953d6c9c2cfa3..019bd5cdde6d5 100644 --- a/Validation/EventGenerator/interface/DuplicationChecker.h +++ b/Validation/EventGenerator/interface/DuplicationChecker.h @@ -35,6 +35,8 @@ #include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h" #include "DataFormats/Provenance/interface/EventID.h" +#include "Validation/EventGenerator/interface/WeightManager.h" + class DuplicationChecker : public edm::EDAnalyzer { @@ -53,8 +55,10 @@ class DuplicationChecker : public edm::EDAnalyzer void findValuesAssociatedWithKey(associationMap &mMap, double &key, itemList &theObjects); private: + WeightManager _wmanager; edm::InputTag generatedCollection_; + edm::InputTag lheEventProduct_; bool searchForLHE_; diff --git a/Validation/EventGenerator/interface/HiggsValidation.h b/Validation/EventGenerator/interface/HiggsValidation.h new file mode 100644 index 0000000000000..5cb1862d47331 --- /dev/null +++ b/Validation/EventGenerator/interface/HiggsValidation.h @@ -0,0 +1,187 @@ +#ifndef HiggsValidation_H +#define HiggsValidation_H + +/*class HiggsValidation + * + * Class to fill Event Generator dqm monitor elements; works on HepMCProduct + * + * $Date: 2012/08/12 16:13:28 $ + * $Revision: 1.1 $ + * + */ +#include + +// framework & common header files +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Run.h" + +#include "DataFormats/Common/interface/Handle.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" + +//DQM services +#include "DQMServices/Core/interface/DQMStore.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "DQMServices/Core/interface/MonitorElement.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" +//#include "DataFormats/HepMCCandidate/interface/GenParticle.h" + +#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" +#include "TLorentzVector.h" + +#include "Validation/EventGenerator/interface/WeightManager.h" + +class HiggsValidation : public edm::EDAnalyzer { + public: + explicit HiggsValidation(const edm::ParameterSet&); + virtual ~HiggsValidation(); + virtual void beginJob(); + virtual void endJob(); + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void beginRun(const edm::Run&, const edm::EventSetup&); + virtual void endRun(const edm::Run&, const edm::EventSetup&); + + private: + + + class MonitoredDecays { + public: + + MonitoredDecays(const edm::ParameterSet& iConfig){ + fillMap(); + std::vector input = iConfig.getParameter >("monitorDecays"); + for(std::vector::const_iterator i = input.begin(); i!= input.end(); ++i){ + fill(*i); + } + } + + ~MonitoredDecays(){}; + + size_t position(int pid1,int pid2){ + if(abs(pid1) == 14 || abs(pid1) == 16) pid1 = 12; + if(abs(pid2) == 14 || abs(pid2) == 16) pid2 = 12; + for(size_t i = 0; i < channels.size(); ++i){ + if((channels[i].first == abs(pid1) && channels[i].second == abs(pid2)) || + (channels[i].first == abs(pid2) && channels[i].second == abs(pid1))) return i+1; + } + return channels.size()+1; + } + + size_t size(){return channels.size() + 2;} + size_t undetermined(){return 0;} + size_t stable(){return size();} + std::string channel(size_t i){ + if(i == 0) return "?"; + if(i == channels.size()+1) return "Stable"; + return convert(channels[i-1].first)+convert(channels[i-1].second); + } + + int convert(std::string s){ + if( namePidMap.count(s)){ + return namePidMap[s]; + } + return 0; + } + + std::string convert(int pid){ + pid = abs(pid); + if(pid == 14 || pid == 16) pid = 12; + for(std::map::const_iterator i = namePidMap.begin(); i!= namePidMap.end(); ++i) { + if(i->second == pid) return i->first; + } + return "not found"; + } + + unsigned int NDecayParticles(){return nparticles_;} + + int isDecayParticle(int pid){ + int idx=0; + for(std::map::const_iterator i = namePidMap.begin(); i!= namePidMap.end(); ++i) { + if(i->second == pid) return idx; + idx++; + } + return -1; + } + + std::string ConvertIndex(int index){ + int idx=0; + for(std::map::const_iterator i = namePidMap.begin(); i!= namePidMap.end(); ++i) { + if(idx==index) return i->first; + idx++; + } + return "unknown"; + } + + private: + void fill(std::string s){ + size_t pos = s.find("+"); + std::string particle1 = s.substr(0,pos); + std::string particle2 = s.substr(pos+1,s.length()-pos); + std::pair decay; + decay.first = convert(particle1); + decay.second = convert(particle2); + channels.push_back(decay); + } + + void fillMap(){ + namePidMap["d"] = 1; + namePidMap["u"] = 2; + namePidMap["s"] = 3; + namePidMap["c"] = 4; + namePidMap["b"] = 5; + namePidMap["t"] = 6; + namePidMap["e"] = 11; + namePidMap["nu"] = 12; + namePidMap["mu"] = 13; + namePidMap["tau"] = 15; + namePidMap["gamma"] = 22; + namePidMap["Z"] = 23; + namePidMap["W"] = 24; + nparticles_=0; + for(std::map::const_iterator i = namePidMap.begin(); i!= namePidMap.end(); ++i){ + nparticles_++; + } + } + + std::map namePidMap; + + std::vector > channels; + unsigned int nparticles_; + + }; + + int findHiggsDecayChannel(const HepMC::GenParticle*,std::vector &decayprod); + std::string convert(int); + + WeightManager _wmanager; + + edm::InputTag hepmcCollection_; + + int particle_id; + std::string particle_name; + + MonitoredDecays* monitoredDecays; + + /// PDT table + edm::ESHandle fPDGTable ; + + ///ME's "container" + DQMStore *dbe; + + MonitorElement *nEvt; + MonitorElement *HiggsDecayChannels; + + MonitorElement *Higgs_pt; + MonitorElement *Higgs_eta; + MonitorElement *Higgs_mass; + + std::vector HiggsDecayProd_pt; + std::vector HiggsDecayProd_eta; + +}; + +#endif diff --git a/Validation/EventGenerator/interface/MBUEandQCDValidation.h b/Validation/EventGenerator/interface/MBUEandQCDValidation.h index 23da5b6764700..7aa849cba3ad0 100644 --- a/Validation/EventGenerator/interface/MBUEandQCDValidation.h +++ b/Validation/EventGenerator/interface/MBUEandQCDValidation.h @@ -33,6 +33,7 @@ #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" #include "Validation/EventGenerator/interface/CaloCellManager.h" +#include "Validation/EventGenerator/interface/WeightManager.h" #include @@ -49,6 +50,8 @@ class MBUEandQCDValidation : public edm::EDAnalyzer private: + WeightManager _wmanager; + edm::InputTag hepmcCollection_; edm::InputTag genchjetCollection_; edm::InputTag genjetCollection_; diff --git a/Validation/EventGenerator/interface/PdtPdgMini.h b/Validation/EventGenerator/interface/PdtPdgMini.h new file mode 100755 index 0000000000000..70d54624fb0f5 --- /dev/null +++ b/Validation/EventGenerator/interface/PdtPdgMini.h @@ -0,0 +1,127 @@ +#ifndef PdtPDGMini_h +#define PdtPDGMini_h + +class PdtPdgMini{ + public: + enum PdgPDTMini + { + d = 1 , + anti_d = -1 , + u = 2 , + anti_u = -2 , + s = 3 , + anti_s = -3 , + c = 4 , + anti_c = -4 , + b = 5 , + anti_b = -5 , + t = 6 , + anti_t = -6 , + l = 7 , + anti_l = -7 , + h = 8 , + anti_h = -8 , + g = 21 , + e_minus = 11 , + e_plus = -11 , + nu_e = 12 , + anti_nu_e = -12 , + mu_minus = 13 , + mu_plus = -13 , + nu_mu = 14 , + anti_nu_mu = -14 , + tau_minus = 15 , + tau_plus = -15 , + nu_tau = 16 , + anti_nu_tau = -16 , + L_minus = 17 , + L_plus = -17 , + nu_L = 18 , + anti_nu_L = -18 , + gamma = 22 , + Z0 = 23 , + W_plus = 24 , + W_minus = -24 , + Higgs0 = 25 , + reggeon = 28 , + pomeron = 29 , + Z_prime0 = 32 , + Z_prime_prime0 = 33 , + W_prime_plus = 34 , + W_prime_minus = -34 , + Higgs_prime0 = 35 , + A0 = 36 , + Higgs_plus = 37 , + Higgs_minus = -37 , + pi0 = 111 , + pi_plus = 211 , + pi_minus = -211 , + pi_diffr_plus = 210 , + pi_diffr_minus = -210 , + pi_2S0 = 20111 , + pi_2S_plus = 20211 , + pi_2S_minus = -20211 , + eta = 221 , + eta_2S = 20221 , + eta_prime = 331 , + rho0 = 113 , + rho_plus = 213 , + rho_minus = -213 , + rho_2S0 = 30113 , + rho_2S_plus = 30213 , + rho_2S_minus = -30213 , + rho_3S0 = 40113 , + rho_3S_plus = 40213 , + rho_3S_minus = -40213 , + omega = 223 , + omega_2S = 30223 , + phi = 333 , + a_00 = 10111 , + a_0_plus = 10211 , + a_0_minus = -10211 , + f_0 = 10221 , + f_prime_0 = 10331 , + b_10 = 10113 , + b_1_plus = 10213 , + b_1_minus = -10213 , + h_1 = 10223 , + h_prime_1 = 10333 , + a_10 = 20113 , + a_1_plus = 20213 , + a_1_minus = -20213 , + f_1 = 20223 , + f_prime_1 = 20333 , + a_20 = 115 , + a_2_plus = 215 , + a_2_minus = -215 , + f_2 = 225 , + f_prime_2 = 335 , + K0 = 311 , + anti_K0 = -311 , + K_S0 = 310 , + K_L0 = 130 , + K_plus = 321 , + K_minus = -321 , + K_star0 = 313 , + anti_K_star0 = -313 , + K_star_plus = 323 , + K_star_minus = -323 , + K_0_star0 = 10311 , + anti_K_0_star0 = -10311 , + K_0_star_plus = 10321 , + K_0_star_minus = -10321 , + K_10 = 10313 , + anti_K_10 = -10313 , + K_1_plus = 10323 , + K_1_minus = -10323 , + K_2_star0 = 315 , + anti_K_2_star0 = -315 , + K_2_star_plus = 325 , + K_2_star_minus = -325 , + K_prime_10 = 20313 , + anti_K_prime_10 = -20313 , + K_prime_1_plus = 20323 , + K_prime_1_minus = -20323 + }; +}; +#endif diff --git a/Validation/EventGenerator/interface/TTbarSpinCorrHepMCAnalyzer.h b/Validation/EventGenerator/interface/TTbarSpinCorrHepMCAnalyzer.h new file mode 100644 index 0000000000000..78b50821f96c4 --- /dev/null +++ b/Validation/EventGenerator/interface/TTbarSpinCorrHepMCAnalyzer.h @@ -0,0 +1,83 @@ +// -*- C++ -*- +// +// Package: TTbarSpinCorrHepMCAnalyzer +// Class: TTbarSpinCorrHepMCAnalyzer +// +/**\class TTbarSpinCorrHepMCAnalyzer TTbarAnalyzer.cc MCstuff/TTbarAnalyzer/src/TTbarAnalyzer.cc + + Description: [one line class summary] + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Martijn Gosselink,,, +// Created: Thu Jan 19 18:40:35 CET 2012 +// $Id: TTbarSpinCorrHepMCAnalyzer.h,v 1.3 2012/10/16 15:08:10 inugent Exp $ +// +// +// Added to: Validation/EventGenerator by Ian M. Nugent Oct 9, 2012 + + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "DQMServices/Core/interface/DQMStore.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "DQMServices/Core/interface/MonitorElement.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h" +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include "AnalysisDataFormats/TopObjects/interface/TtGenEvent.h" + +#include "CLHEP/Units/GlobalPhysicalConstants.h" + +#include "TFile.h" +#include "TH1D.h" +#include "TLorentzVector.h" + +// +// class declaration +// + +class TTbarSpinCorrHepMCAnalyzer : public edm::EDAnalyzer { +public: + explicit TTbarSpinCorrHepMCAnalyzer(const edm::ParameterSet&); + ~TTbarSpinCorrHepMCAnalyzer(); + +private: + virtual void beginJob() ; + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void endJob() ; + + virtual void beginRun(edm::Run const&, edm::EventSetup const&); + virtual void endRun(edm::Run const&, edm::EventSetup const&); + virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&); + virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&); + + // ----------member data --------------------------- + DQMStore *dbe; + double weight ; + + MonitorElement* nEvt; + MonitorElement* _h_asym ; + MonitorElement* _h_deltaPhi ; + + MonitorElement* _h_llpairPt ; + MonitorElement* _h_llpairM ; + + edm::InputTag genEventInfoProductTag_,genParticlesTag_; +}; diff --git a/Validation/EventGenerator/interface/TTbar_GenJetAnalyzer.h b/Validation/EventGenerator/interface/TTbar_GenJetAnalyzer.h new file mode 100644 index 0000000000000..47512ed9d77b8 --- /dev/null +++ b/Validation/EventGenerator/interface/TTbar_GenJetAnalyzer.h @@ -0,0 +1,85 @@ +// -*- C++ -*- +// +// Package: ObjectAnalyzer +// Class: TTbar_GenJetAnalyzer +// +/**\class TTbar_GenJetAnalyzer + + Description: [one line class summary] + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Martijn Gosselink,,, +// Created: Thu May 10 17:15:16 CEST 2012 +// $Id: TTbar_GenJetAnalyzer.h,v 1.2 2012/08/24 21:47:01 wdd Exp $ +// +// +// Added to: Validation/EventGenerator by Ian M. Nugent June 28, 2012 + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "DQMServices/Core/interface/DQMStore.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "DQMServices/Core/interface/MonitorElement.h" + + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Utilities/interface/InputTag.h" + +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h" + +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/JetReco/interface/Jet.h" +#include "DataFormats/PatCandidates/interface/Jet.h" + + +#include +#include + + +// +// class declaration +// + +class TTbar_GenJetAnalyzer : public edm::EDAnalyzer { + public: + explicit TTbar_GenJetAnalyzer(const edm::ParameterSet&); + ~TTbar_GenJetAnalyzer(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + + private: + virtual void beginJob() ; + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void endJob() ; + + virtual void beginRun(edm::Run const&, edm::EventSetup const&); + virtual void endRun(edm::Run const&, edm::EventSetup const&); + virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&); + virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&); + + // ----------member data --------------------------- + ///ME's "container" + DQMStore *dbe; + + edm::InputTag jets_; + edm::InputTag genEventInfoProductTag_; + std::map hists_; + + double weight ; +}; + diff --git a/Validation/EventGenerator/interface/TTbar_GenLepAnalyzer.h b/Validation/EventGenerator/interface/TTbar_GenLepAnalyzer.h new file mode 100644 index 0000000000000..fcf822d22bd51 --- /dev/null +++ b/Validation/EventGenerator/interface/TTbar_GenLepAnalyzer.h @@ -0,0 +1,85 @@ +// -*- C++ -*- +// +// Package: TTbar_GenLepAnalyzer +// Class: TTbar_GenLepAnalyzer +// +/**\class TTbar_GenLepAnalyzer + + Description: [one line class summary] + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Martijn Gosselink,,, +// Created: Thu May 10 17:15:16 CEST 2012 +// $Id: TTbar_GenLepAnalyzer.h,v 1.1 2012/07/04 18:24:21 inugent Exp $ +// +// +// Added to: Validation/EventGenerator by Ian M. Nugent June 28, 2012 + +#ifndef TTbar_GenLepAnalyzer_H +#define TTbar_GenLepAnalyzer_H + + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "DQMServices/Core/interface/DQMStore.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "DQMServices/Core/interface/MonitorElement.h" + + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/Candidate/interface/Candidate.h" +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" + +#include +#include + +// +// class declaration +// + +class TTbar_GenLepAnalyzer : public edm::EDAnalyzer { + public: + explicit TTbar_GenLepAnalyzer(const edm::ParameterSet&); + ~TTbar_GenLepAnalyzer(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + + private: + virtual void beginJob() ; + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void endJob() ; + + virtual void beginRun(edm::Run const&, edm::EventSetup const&); + virtual void endRun(edm::Run const&, edm::EventSetup const&); + virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&); + virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&); + + // ----------member data --------------------------- + ///ME's "container" + DQMStore *dbe; + + edm::InputTag leps_; + std::map hists_; + + bool do_e_, do_mu_, do_tau_, do_nu_e_, do_nu_mu_, do_nu_tau_; + double pt_cut_, eta_cut_; + int pdgid; +}; + +#endif diff --git a/Validation/EventGenerator/interface/TTbar_Kinematics.h b/Validation/EventGenerator/interface/TTbar_Kinematics.h new file mode 100644 index 0000000000000..175b967639afb --- /dev/null +++ b/Validation/EventGenerator/interface/TTbar_Kinematics.h @@ -0,0 +1,126 @@ +// -*- C++ -*- +// +// Package: TTbar_Kinematics +// Class: TTbar_Kinematics +// +/**\class TTbar_Kinematics + + Description: [one line class summary] + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Martijn Gosselink,,, +// Created: Thu Jan 19 18:40:35 CET 2012 +// $Id: TTbar_Kinematics.h,v 1.3 2012/08/24 21:47:01 wdd Exp $ +// +// +// Added to: Validation/EventGenerator by Ian M. Nugent June 28, 2012 + + +#ifndef TTbar_Kinematics_H +#define TTbar_Kinematics_H + +// system include files +#include +#include "DQMServices/Core/interface/DQMStore.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "DQMServices/Core/interface/MonitorElement.h" + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "FWCore/Utilities/interface/InputTag.h" + +#include "CommonTools/UtilAlgos/interface/TFileService.h" + +#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h" + +#include "AnalysisDataFormats/TopObjects/interface/TtGenEvent.h" +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" +//#include "Validation/EventGenerator/interface/WeightManager.h" + + + +#include "TTree.h" +#include "TLorentzVector.h" + +// +// class declaration +// + +class TTbar_Kinematics : public edm::EDAnalyzer { + public: + explicit TTbar_Kinematics(const edm::ParameterSet&); + ~TTbar_Kinematics(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + + private: + virtual void beginJob() ; + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void endJob() ; + + virtual void beginRun(edm::Run const&, edm::EventSetup const&); + virtual void endRun(edm::Run const&, edm::EventSetup const&); + virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&); + virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&); + + // ----------member data --------------------------- + ///ME's "container" + DQMStore *dbe; + + edm::InputTag hepmcCollection_; + edm::InputTag genEventInfoProductTag_; + + + double weight ; + + TLorentzVector tlv_Top ; + TLorentzVector tlv_TopBar ; + TLorentzVector tlv_Bottom ; + TLorentzVector tlv_BottomBar ; + TLorentzVector tlv_Wplus ; + TLorentzVector tlv_Wmin ; + + TLorentzVector tlv_TTbar ; + + MonitorElement *nEvt; + MonitorElement* hTopPt ; + MonitorElement* hTopY ; + MonitorElement* hTopMass ; + + MonitorElement* hTTbarPt ; + MonitorElement* hTTbarY ; + MonitorElement* hTTbarMass ; + + MonitorElement* hBottomPt ; + MonitorElement* hBottomEta ; + MonitorElement* hBottomY ; + MonitorElement* hBottomPz ; + MonitorElement* hBottomE ; + MonitorElement* hBottomMass ; + + MonitorElement* hWplusPz ; + MonitorElement* hWminPz ; + + MonitorElement* hBottomPtPz ; + MonitorElement* hBottomEtaPz ; + MonitorElement* hBottomEtaPt ; + MonitorElement* hBottomYPz ; + MonitorElement* hBottomMassPz ; + MonitorElement* hBottomMassEta ; + MonitorElement* hBottomMassY ; + MonitorElement* hBottomMassDeltaY ; + +}; + +#endif diff --git a/Validation/EventGenerator/interface/TTbar_P4Violation.h b/Validation/EventGenerator/interface/TTbar_P4Violation.h new file mode 100644 index 0000000000000..e4cf533689e25 --- /dev/null +++ b/Validation/EventGenerator/interface/TTbar_P4Violation.h @@ -0,0 +1,58 @@ +// -*- C++ -*- +// +// Package: TTbar_P4Violation +// Class: TTbar_P4Violation +// +/**\class TTbar_P4Violation + + Description: [one line class summary] + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Martijn Gosselink,,, +// Created: Fri Jan 20 12:52:00 CET 2012 +// $Id: TTbar_P4Violation.h,v 1.3 2013/03/06 16:40:19 inugent Exp $ +// +// +// Added to: Validation/EventGenerator by Ian M. Nugent June 28, 2012 + +#ifndef TTbar_P4Violation_H +#define TTbar_P4Violation_H + + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDFilter.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "AnalysisDataFormats/TopObjects/interface/TtGenEvent.h" + +// +// class declaration +// + +class TTbar_P4Violation : public edm::EDFilter { + public: + explicit TTbar_P4Violation(const edm::ParameterSet&); + ~TTbar_P4Violation(); + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + private: + virtual void beginJob() ; + virtual bool filter(edm::Event&, const edm::EventSetup&); + virtual void endJob() ; + + // ----------member data --------------------------- +}; + +#endif diff --git a/Validation/EventGenerator/interface/TauDecay.h b/Validation/EventGenerator/interface/TauDecay.h new file mode 100755 index 0000000000000..d9296420b96fc --- /dev/null +++ b/Validation/EventGenerator/interface/TauDecay.h @@ -0,0 +1,127 @@ +// -*- C++ -*- +// +// Package: TauNtuple +// Class: TauDecay +// +/**\class TauDecay TauDecay.cc TauDataFormat/TauNtuple/src/TauDecay.cc + + Description: This class reconstructs the JAK modes of the Tauola decays and provides a bit mask of the decay structure for the tau + +*/ +// +// Original Author: Ian Nugent +// Created: Fri Nov 18 13:49:02 CET 2011 +// $Id: TauDecay.h,v 1.2 2012/12/10 14:59:52 inugent Exp $ +// +// +#ifndef TauDecay_h +#define TauDecay_h + +// +// class declaration +// +class TauDecay { + public: + // TAUOLA list of decay modes avalible presently available in Tauola are (JAK): + // + // * DEC BRTAU NORMAL ROUTINE CHANNEL * + // * 1 0.17810 0.17810 DADMEL ELECTRON * + // * 2 0.17370 0.17370 DADMMU MUON * + // * 3 0.11080 0.11080 DADMPI PION * + // * 4 0.25320 0.25320 DADMRO RHO (->2PI) * + // * 5 0.18250 0.18250 DADMAA A1 (->3PI) * + // * 6 0.00710 0.00710 DADMKK KAON * + // * 7 0.01280 0.01280 DADMKS K* * + // * 8 0.04500 0.04500 DAD4PI 2PI- PI+ PI0 * + // * 9 0.01230 0.01230 DAD4PI PI- 3PI0 * + // * 10 0.00500 0.00500 DADNPI 2PI- PI+ 2PI0 * + // * 11 0.00080 0.00080 DADNPI 3PI- 2PI+ * + // * 12 0.00020 0.00020 DADNPI 3PI- 2PI+ PI0 * + // * 13 0.00030 0.00030 DADNPI 2PI- PI+ 3PI0 * + // * 14 0.00190 0.00190 DADMPK K+ K- PI+ * + // * 15 0.00120 0.00120 DADMPK K0B K0 PI+ * + // * 16 0.00300 0.00300 DADMPK K+ K0B PI0 * + // * 17 0.00100 0.00100 DADMPK K+ PI0 PI0 * + // * 18 0.00230 0.00230 DADMPK K+ PI- PI+ * + // * 19 0.00390 0.00390 DADMPK K0 PI0 PI+ * + // * 20 0.00170 0.00170 DADMPK ET PI- PI0 * + // * 21 0.00160 0.00160 DADMPK PI-PI0 GAM * + // * 22 0.00160 0.00160 DADMPK K- K0B GAM * + + enum JAK{JAK_UNKNOWN=0, + JAK_ELECTRON=1, + JAK_MUON=2, + JAK_PION=3, + JAK_RHO_PIPI0=4, + JAK_A1_3PI=5, + JAK_KAON=6, + JAK_KSTAR=7, + JAK_3PIPI0=8, + JAK_PI3PI0=9, + JAK_3PI2PI0=10, + JAK_5PI=11, + JAK_5PIPI0=12, + JAK_3PI3PI0=13, + JAK_KPIK=14, + JAK_K0BK0PI=15, + JAK_KK0BPI0=16, + JAK_K2PI0=17, + JAK_KPIPI=18, + JAK_PIK0PI0=19, + JAK_ETAPIPI0=20, + JAK_PIPI0GAM=21, + JAK_KK0B=22, + NJAKID=23 + }; + + + enum TauDecayStructure{other=0, + OneProng=1, + ThreeProng=2, + FiveProng=4, + OnePi0=8, + TwoPi0=32, + ThreePi0=64, + Res_a1_pm=128, + Res_a1_0=256, + Res_rho_pm=512, + Res_rho_0=1024, + Res_eta=2048, + Res_omega=4096, + Res_Kstar_pm=8192, + Res_Kstar_0=16384, + KS0_to_pipi=32768 + }; + + TauDecay(); + ~TauDecay(); + + void Reset(); + bool isTauFinalStateParticle(int pdgid); + bool isTauParticleCounter(int pdgid); + bool isTauResonanceCounter(int pdgid); + void ClassifyDecayMode(unsigned int &JAK_ID,unsigned int &TauBitMask); + unsigned int nProng(unsigned int &TauBitMask){ + if(OneProng&TauBitMask) return 1; + if(ThreeProng&TauBitMask) return 3; + if(FiveProng&TauBitMask) return 5; + return 7; + } + unsigned int nPi0(unsigned int &TauBitMask){ + if(OnePi0&TauBitMask) return 1; + if(TwoPi0&TauBitMask) return 2; + if(ThreePi0&TauBitMask) return 3; + return 0; + } + + + private: + // Functions + void ClassifyDecayResonance(unsigned int &TauBitMask); + + //counting varibles + unsigned int n_pi,n_pi0,n_K,n_K0L,n_K0S,n_gamma,n_nu,n_e,n_mu; // particle counters + unsigned int n_a1,n_a10,n_rho,n_rho0,n_eta,n_omega,n_Kstar0,n_Kstar,unknown; // resonance counters + +}; +#endif diff --git a/Validation/EventGenerator/interface/TauDecay_CMSSW.h b/Validation/EventGenerator/interface/TauDecay_CMSSW.h new file mode 100755 index 0000000000000..b9dc8333787b0 --- /dev/null +++ b/Validation/EventGenerator/interface/TauDecay_CMSSW.h @@ -0,0 +1,52 @@ +// -*- C++ -*- +// +// Package: TauNtuple +// Class: TauDecay_CMSSW +// +/**\class TauDecay TauDecay_CMSSW.cc TauDataFormat/TauNtuple/src/TauDecay_CMSSW.cc + + Description: [one line class summary] + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Ian Nugent +// Created: Fri Nov 18 13:49:02 CET 2011 +// $Id: TauDecay_CMSSW.h,v 1.1 2012/02/10 10:08:22 inugent Exp $ +// +// +#ifndef TauDecay_CMSSW_h +#define TauDecay_CMSSW_h + +#include "Validation/EventGenerator/interface/TauDecay.h" + +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" +#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h" +#include + +// +// class declaration +// +class TauDecay_CMSSW : public TauDecay { +public: + TauDecay_CMSSW(); + ~TauDecay_CMSSW(); + + //Function to analyze the tau + bool AnalyzeTau(HepMC::GenParticle *Tau,unsigned int &JAK_ID,unsigned int &TauBitMask,bool dores=true, bool dopi0=true); + // Functions to get results + std::vector Get_TauDecayProducts(){return TauDecayProducts;} + std::vector Get_MotherIdx(){return MotherIdx;} + +private: + // recursive function to loop through tau decay products + void Analyze(HepMC::GenParticle *Particle,unsigned int midx,bool dores, bool dopi0); + void AddPi0Info(HepMC::GenParticle *Particle,unsigned int midx); + //varibles + std::vector TauDecayProducts; + std::vector MotherIdx; + unsigned int JAK_ID, TauBitMask; + +}; +#endif diff --git a/Validation/EventGenerator/interface/TauValidation.h b/Validation/EventGenerator/interface/TauValidation.h index bd4a1ce9f3aad..5543aaabc86dc 100644 --- a/Validation/EventGenerator/interface/TauValidation.h +++ b/Validation/EventGenerator/interface/TauValidation.h @@ -31,6 +31,8 @@ #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" #include "TLorentzVector.h" +#include "Validation/EventGenerator/interface/WeightManager.h" + class TauValidation : public edm::EDAnalyzer { public: @@ -39,7 +41,10 @@ class TauValidation : public edm::EDAnalyzer electron, muon, pi, + rho, + a1, K, + Kstar, pi1pi0, pinpi0, tripi, @@ -47,6 +52,8 @@ class TauValidation : public edm::EDAnalyzer stable}; // tau mother particles enum {other, + B, + D, gamma, Z, W, @@ -65,35 +72,55 @@ class TauValidation : public edm::EDAnalyzer virtual void endRun(const edm::Run&, const edm::EventSetup&); private: - int tauMother(const HepMC::GenParticle*); - int tauProngs(const HepMC::GenParticle*); - int tauDecayChannel(const HepMC::GenParticle*); - void rtau(const HepMC::GenParticle*,int,int); - void spinEffects(const HepMC::GenParticle*,int,int); - double leadingPionMomentum(const HepMC::GenParticle*); + int tauMother(const HepMC::GenParticle*, double weight); + int tauProngs(const HepMC::GenParticle*, double weight); + int tauDecayChannel(const HepMC::GenParticle*, double weight=0.0); + int findMother(const HepMC::GenParticle*); + bool isLastTauinChain(const HepMC::GenParticle* tau); + void rtau(const HepMC::GenParticle*,int,int, double weight); + void spinEffects(const HepMC::GenParticle*,int,int,std::vector &part,double weight); + void spinEffectsZ(const HepMC::GenParticle* boson, double weight); + double leadingPionMomentum(const HepMC::GenParticle*, double weight); double visibleTauEnergy(const HepMC::GenParticle*); TLorentzVector leadingPionP4(const HepMC::GenParticle*); TLorentzVector motherP4(const HepMC::GenParticle*); - void photons(const HepMC::GenParticle*); + void photons(const HepMC::GenParticle*, double weight); + void findTauList(const HepMC::GenParticle* tau,std::vector &TauList); + void findFSRandBrem(const HepMC::GenParticle* p, bool doBrem, std::vector &ListofFSR, + std::vector &ListofBrem); + void FindPhotosFSR(const HepMC::GenParticle* p,std::vector &ListofFSR,double &BosonScale); + const HepMC::GenParticle* GetMother(const HepMC::GenParticle* tau); + const std::vector GetMothers(const HepMC::GenParticle* boson); + double Zstoa(double zs); + + WeightManager _wmanager; edm::InputTag hepmcCollection_; double tauEtCut; - double tauPtSum,photonFromTauPtSum; - int nTaus,nTausWithPhotons; - /// PDT table edm::ESHandle fPDGTable ; ///ME's "container" DQMStore *dbe; - MonitorElement *nEvt; - MonitorElement *TauPt, *TauEta, *TauProngs, *TauDecayChannels, *TauMothers, - *TauRtauW, *TauRtauHpm, - *TauSpinEffectsW, *TauSpinEffectsHpm, - *TauPhotons; + MonitorElement *nTaus, *nPrimeTaus; + MonitorElement *TauPt, *TauEta, *TauPhi, *TauProngs, *TauDecayChannels, *TauMothers, + *TauRtauW, *TauRtauHpm, + *TauSpinEffectsW_X, *TauSpinEffectsW_UpsilonRho, *TauSpinEffectsW_UpsilonA1,*TauSpinEffectsW_eX,*TauSpinEffectsW_muX, + *TauSpinEffectsHpm_X, *TauSpinEffectsHpm_UpsilonRho, *TauSpinEffectsHpm_UpsilonA1,*TauSpinEffectsHpm_eX,*TauSpinEffectsHpm_muX, + *TauSpinEffectsZ_MVis, *TauSpinEffectsZ_Zs, *TauSpinEffectsZ_Xf, *TauSpinEffectsZ_Xb, + *TauSpinEffectsZ_eX, *TauSpinEffectsZ_muX, + *TauSpinEffectsH_MVis, *TauSpinEffectsH_Zs, *TauSpinEffectsH_Xf, *TauSpinEffectsH_Xb, + *TauSpinEffectsH_eX, *TauSpinEffectsH_muX, + *TauBremPhotonsN,*TauBremPhotonsPt,*TauBremPhotonsPtSum,*TauFSRPhotonsN,*TauFSRPhotonsPt,*TauFSRPhotonsPtSum; + unsigned int NJAKID; + MonitorElement *JAKID; + std::vector > JAKInvMass; + + int zsbins; + double zsmin,zsmax; }; #endif diff --git a/Validation/EventGenerator/interface/VVVValidation.h b/Validation/EventGenerator/interface/VVVValidation.h new file mode 100644 index 0000000000000..611ffe9e54284 --- /dev/null +++ b/Validation/EventGenerator/interface/VVVValidation.h @@ -0,0 +1,173 @@ +#ifndef VVVVALIDATION_H +#define VVVVALIDATION_H + + +// framework & common header files +#include "TLorentzVector.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Run.h" +#include "DataFormats/Math/interface/deltaR.h" +#include "DataFormats/Common/interface/Handle.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +//DQM services +#include "DQMServices/Core/interface/DQMStore.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "DQMServices/Core/interface/MonitorElement.h" + +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" +#include "HepMC/GenParticle.h" +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" +#include "DataFormats/JetReco/interface/GenJetCollection.h" + +#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" + +#include "Validation/EventGenerator/interface/WeightManager.h" +class VVVValidation : public edm::EDAnalyzer +{ + public: + explicit VVVValidation(const edm::ParameterSet&); + virtual ~VVVValidation(); + virtual void beginJob(); + virtual void endJob(); + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void beginRun(const edm::Run&, const edm::EventSetup&); + virtual void endRun(const edm::Run&, const edm::EventSetup&); + + bool matchParticles(const HepMC::GenParticle*&, const reco::GenParticle*&); + int getParentBarcode(HepMC::GenParticle* it); + + private: + + WeightManager _wmanager; + + edm::InputTag hepmcCollection_; + edm::InputTag genparticleCollection_; + edm::InputTag genjetCollection_; + double matchPr_; + double _lepStatus; + double _motherStatus; + + unsigned int verbosity_; + + /// PDT table + edm::ESHandle fPDGTable ; + + ///ME's "container" + DQMStore *dbe; + + MonitorElement *nEvt; + + // Basic reco::GenParticle test + + // Basci GenJets analysis + MonitorElement * mll; + MonitorElement * ptll; + MonitorElement * mlll; + MonitorElement * ptlll; + MonitorElement * mlllnununu; + MonitorElement * mtlllnununu; + MonitorElement * ptlllnununu; + MonitorElement * leading_l_pt ; + MonitorElement * subleading_l_pt ; + MonitorElement * subsubleading_l_pt; + MonitorElement * leading_l_eta ; + MonitorElement * subleading_l_eta ; + MonitorElement * subsubleading_l_eta; + MonitorElement *genJetMult; + MonitorElement *genJetEnergy; + MonitorElement *genJetPt; + MonitorElement *genJetEta; + MonitorElement *genJetPhi; + MonitorElement *genJetDeltaEtaMin; + MonitorElement *h_dr; + MonitorElement *genJetPto1; + MonitorElement *genJetPto30; + MonitorElement *genJetPto50; + MonitorElement *genJetPto100; + MonitorElement *genJetCentral; + + MonitorElement *genJetTotPt; + MonitorElement *WW_TwoJEt_JetsM; + + MonitorElement *h_l_jet_eta; + MonitorElement *h_l_jet_pt; + MonitorElement *h_sl_jet_eta; + MonitorElement *h_sl_jet_pt; + MonitorElement *h_ssl_jet_eta; + MonitorElement *h_ssl_jet_pt; + + MonitorElement *h_mWplus ; + MonitorElement *h_phiWplus; + MonitorElement *h_ptWplus ; + MonitorElement *h_yWplus; + + MonitorElement *h_mWminus; + MonitorElement *h_phiWminus; + MonitorElement *h_ptWminus; + MonitorElement *h_yWminus; + + MonitorElement *h_mZ; + MonitorElement *h_phiZ; + MonitorElement *h_ptZ; + MonitorElement *h_yZ; + MonitorElement *h_mWplus_3b ; + MonitorElement *h_phiWplus_3b; + MonitorElement *h_ptWplus_3b ; + MonitorElement *h_yWplus_3b; + + MonitorElement *h_mWminus_3b; + MonitorElement *h_phiWminus_3b; + MonitorElement *h_ptWminus_3b; + MonitorElement *h_yWminus_3b; + + MonitorElement *h_mZ_3b; + MonitorElement *h_phiZ_3b; + MonitorElement *h_ptZ_3b; + MonitorElement *h_yZ_3b; + + MonitorElement *h_mWW; + MonitorElement *h_phiWW; + MonitorElement *h_ptWW; + MonitorElement *h_yWW; + + MonitorElement *h_mWZ; + MonitorElement *h_phiWZ; + MonitorElement *h_ptWZ; + MonitorElement *h_yWZ; + + MonitorElement *h_mZZ; + MonitorElement *h_phiZZ; + MonitorElement *h_ptZZ; + MonitorElement *h_yZZ; + + MonitorElement *h_mWWW; + MonitorElement *h_phiWWW; + MonitorElement *h_ptWWW; + MonitorElement *h_yWWW; + + MonitorElement *h_mWWZ; + MonitorElement *h_phiWWZ; + MonitorElement *h_ptWWZ; + MonitorElement *h_yWWZ; + + MonitorElement *h_mWZZ; + MonitorElement *h_phiWZZ; + MonitorElement *h_ptWZZ; + MonitorElement *h_yWZZ; + + MonitorElement *h_mZZZ; + MonitorElement *h_phiZZZ; + MonitorElement *h_ptZZZ; + MonitorElement *h_yZZZ; + + +}; + +#endif diff --git a/Validation/EventGenerator/interface/WValidation.h b/Validation/EventGenerator/interface/WValidation.h index b38d995e88fd0..9e4008c4409a2 100644 --- a/Validation/EventGenerator/interface/WValidation.h +++ b/Validation/EventGenerator/interface/WValidation.h @@ -30,6 +30,8 @@ #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" +#include "Validation/EventGenerator/interface/WeightManager.h" + class WValidation : public edm::EDAnalyzer { @@ -44,6 +46,8 @@ class WValidation : public edm::EDAnalyzer private: + WeightManager _wmanager; + edm::InputTag hepmcCollection_; /// PDT table diff --git a/Validation/EventGenerator/interface/WeightManager.h b/Validation/EventGenerator/interface/WeightManager.h new file mode 100644 index 0000000000000..ff309379e3a44 --- /dev/null +++ b/Validation/EventGenerator/interface/WeightManager.h @@ -0,0 +1,34 @@ +#ifndef Validation_EventGenerator_WeightManager +#define Validation_EventGenerator_WeightManager + +// Utility class, that computes the event weight, +// either returning the weight as stored in the HepMCCollection +// or returning the product of the weights stored in +// a vector of GenEventInfoProducts + +#include "FWCore/Utilities/interface/InputTag.h" +#include + +namespace edm{ + class ParameterSet; + class Event; +} + +class WeightManager{ + + public: + + WeightManager( const edm::ParameterSet& ); + ~WeightManager(){}; + + double weight(const edm::Event&); + + private: + bool _useHepMC; + std::vector _genEventInfos; + edm::InputTag _hepmcCollection; + +}; + +#endif + diff --git a/Validation/EventGenerator/plugins/BasicGenParticleValidation.cc b/Validation/EventGenerator/plugins/BasicGenParticleValidation.cc index 609e888ccc831..bd8e412e8c38a 100644 --- a/Validation/EventGenerator/plugins/BasicGenParticleValidation.cc +++ b/Validation/EventGenerator/plugins/BasicGenParticleValidation.cc @@ -13,7 +13,8 @@ using namespace edm; -BasicGenParticleValidation::BasicGenParticleValidation(const edm::ParameterSet& iPSet): +BasicGenParticleValidation::BasicGenParticleValidation(const edm::ParameterSet& iPSet): + _wmanager(iPSet), hepmcCollection_(iPSet.getParameter("hepmcCollection")), genparticleCollection_(iPSet.getParameter("genparticleCollection")), genjetCollection_(iPSet.getParameter("genjetsCollection")), @@ -85,7 +86,9 @@ void BasicGenParticleValidation::analyze(const edm::Event& iEvent,const edm::Eve //Get HepMC EVENT HepMC::GenEvent *myGenEvent = new HepMC::GenEvent(*(evt->GetEvent())); - nEvt->Fill(0.5); + double weight = _wmanager.weight(iEvent); + + nEvt->Fill(0.5, weight); std::vector hepmcGPCollection; std::vector barcodeList; @@ -124,7 +127,7 @@ void BasicGenParticleValidation::analyze(const edm::Event& iEvent,const edm::Eve unsigned int nReco = particles.size(); unsigned int nHepMC = hepmcGPCollection.size(); - genPMultiplicity->Fill(std::log10(nReco)); + genPMultiplicity->Fill(std::log10(nReco), weight); // Define vector containing index of hepmc corresponding to the reco::GenParticle std::vector hepmcMatchIndex; @@ -150,7 +153,7 @@ void BasicGenParticleValidation::analyze(const edm::Event& iEvent,const edm::Eve std::cout << "Matching momentum: reco = " << particles[i]->p() << " HepMC = " << hepmcGPCollection[j]->momentum().rho() << " resoultion = " << reso << std::endl; } - matchedResolution->Fill(std::log10(std::fabs(reso))); } + matchedResolution->Fill(std::log10(std::fabs(reso)),weight); } continue; } } @@ -163,7 +166,7 @@ void BasicGenParticleValidation::analyze(const edm::Event& iEvent,const edm::Eve if ( nMatched != nReco ) { edm::LogWarning("IncorrectMatching") << "Incorrect number of matched indexes: GenParticle = " << nReco << " matched indexes = " << nMatched; } - genMatched->Fill(int(nReco-nMatched)); + genMatched->Fill(int(nReco-nMatched),weight); unsigned int nWrMatch = 0; @@ -176,7 +179,7 @@ void BasicGenParticleValidation::analyze(const edm::Event& iEvent,const edm::Eve } } } - multipleMatching->Fill(int(nWrMatch)); + multipleMatching->Fill(int(nWrMatch),weight); // Gather information in the GenJet collection edm::Handle genJets; @@ -203,19 +206,19 @@ void BasicGenParticleValidation::analyze(const edm::Event& iEvent,const edm::Eve if ( std::fabs(eta) < 2.5 ) nJetsCentral++; jetEta.push_back(eta); - genJetEnergy->Fill(std::log10((*iter).energy())); - genJetPt->Fill(std::log10(pt)); - genJetEta->Fill(eta); - genJetPhi->Fill((*iter).phi()/CLHEP::degree); + genJetEnergy->Fill(std::log10((*iter).energy()),weight); + genJetPt->Fill(std::log10(pt),weight); + genJetEta->Fill(eta,weight); + genJetPhi->Fill((*iter).phi()/CLHEP::degree,weight); } - genJetMult->Fill(nJets); - genJetPto1->Fill(nJetso1); - genJetPto10->Fill(nJetso10); - genJetPto100->Fill(nJetso100); - genJetCentral->Fill(nJetsCentral); + genJetMult->Fill(nJets,weight); + genJetPto1->Fill(nJetso1,weight); + genJetPto10->Fill(nJetso10,weight); + genJetPto100->Fill(nJetso100,weight); + genJetCentral->Fill(nJetsCentral,weight); - genJetTotPt->Fill(std::log10(totPt)); + genJetTotPt->Fill(std::log10(totPt),weight); double deltaEta = 999.; if ( jetEta.size() > 1 ) { @@ -226,7 +229,7 @@ void BasicGenParticleValidation::analyze(const edm::Event& iEvent,const edm::Eve } } - genJetDeltaEtaMin->Fill(deltaEta); + genJetDeltaEtaMin->Fill(deltaEta,weight); delete myGenEvent; }//analyze diff --git a/Validation/EventGenerator/plugins/BasicHepMCHeavyIonValidation.cc b/Validation/EventGenerator/plugins/BasicHepMCHeavyIonValidation.cc new file mode 100644 index 0000000000000..f587b24ab9ed9 --- /dev/null +++ b/Validation/EventGenerator/plugins/BasicHepMCHeavyIonValidation.cc @@ -0,0 +1,100 @@ +/*class BasicHepMCHeavyIonValidation + * + * Class to fill dqm monitor elements from existing EDM file + * Quan Wang - 04/2013 + */ + +#include "Validation/EventGenerator/interface/BasicHepMCHeavyIonValidation.h" + +#include "CLHEP/Units/defs.h" +#include "CLHEP/Units/PhysicalConstants.h" + +using namespace edm; + +BasicHepMCHeavyIonValidation::BasicHepMCHeavyIonValidation(const edm::ParameterSet& iPSet): + _wmanager(iPSet), + hepmcCollection_(iPSet.getParameter("hepmcCollection")) +{ + dbe = 0; + dbe = edm::Service().operator->(); + QWdebug_ = iPSet.getUntrackedParameter("QWdebug",false); +} + +BasicHepMCHeavyIonValidation::~BasicHepMCHeavyIonValidation() {} + +void BasicHepMCHeavyIonValidation::beginJob() +{ + if(dbe){ + ///Setting the DQM top directories + dbe->setCurrentFolder("Generator/HeavyIon"); + + // Number of analyzed events + nEvt = dbe->book1D("nEvt", "n analyzed Events", 1, 0., 1.); + + ///Booking the ME's + Ncoll_hard = dbe->book1D("Ncoll_hard", "Ncoll_hard", 700, 0, 700); + Npart_proj = dbe->book1D("Npart_proj", "Npart_proj", 250, 0, 250); + Npart_targ = dbe->book1D("Npart_targ", "Npart_targ", 250, 0, 250); + Ncoll = dbe->book1D("Ncoll", "Ncoll", 700, 0, 700); + N_Nwounded_collisions = dbe->book1D("N_Nwounded_collisions", "N_Nwounded_collisions", 250, 0, 250); + Nwounded_N_collisions = dbe->book1D("Nwounded_N_collisions", "Nwounded_N_collisions", 250, 0, 250); + Nwounded_Nwounded_collisions = dbe->book1D("Nwounded_Nwounded_collisions", "Nwounded_Nwounded_collisions", 250, 0, 250); + spectator_neutrons = dbe->book1D("spectator_neutrons", "spectator_neutrons", 250, 0, 250); + spectator_protons = dbe->book1D("spectator_protons", "spectator_protons", 250, 0, 250); + impact_parameter = dbe->book1D("impact_parameter", "impact_parameter", 50, 0, 50); + event_plane_angle = dbe->book1D("event_plane_angle", "event_plane_angle", 200, -CLHEP::pi, CLHEP::pi); + eccentricity = dbe->book1D("eccentricity", "eccentricity", 200, 0, 1.0); + sigma_inel_NN = dbe->book1D("sigma_inel_NN", "sigma_inel_NN", 200, 0, 10.0); + + } + return; +} + +void BasicHepMCHeavyIonValidation::endJob(){return;} +void BasicHepMCHeavyIonValidation::beginRun(const edm::Run& iRun,const edm::EventSetup& iSetup) +{ + ///Get PDT Table + //iSetup.getData( fPDGTable ); + return; +} +void BasicHepMCHeavyIonValidation::endRun(const edm::Run& iRun,const edm::EventSetup& iSetup){return;} +void BasicHepMCHeavyIonValidation::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup) +{ + ///counters to zero for every event + + ///Gathering the HepMCProduct information + edm::Handle evt; + iEvent.getByLabel(hepmcCollection_, evt); + + //Get EVENT + //HepMC::GenEvent *myGenEvent = new HepMC::GenEvent(*(evt->GetEvent())); + + + + const HepMC::HeavyIon* ion = evt->GetEvent()->heavy_ion(); + + if (!ion) { + if ( QWdebug_ ) std::cout << "!!QW!! HeavyIon == null" << std::endl; + return; + } + + double weight = _wmanager.weight(iEvent); + nEvt->Fill(0.5,weight); + + Ncoll_hard->Fill(ion->Ncoll_hard(), weight); + Npart_proj->Fill(ion->Npart_proj(), weight); + Npart_targ->Fill(ion->Npart_targ(), weight); + Ncoll->Fill(ion->Ncoll(), weight); + N_Nwounded_collisions->Fill(ion->N_Nwounded_collisions(), weight); + Nwounded_N_collisions->Fill(ion->Nwounded_N_collisions(), weight); + Nwounded_Nwounded_collisions->Fill(ion->Nwounded_Nwounded_collisions(), weight); + spectator_neutrons->Fill(ion->spectator_neutrons(), weight); + spectator_protons->Fill(ion->spectator_protons(), weight); + impact_parameter->Fill(ion->impact_parameter(), weight); + event_plane_angle->Fill(ion->event_plane_angle(), weight); + eccentricity->Fill(ion->eccentricity(), weight); + sigma_inel_NN->Fill(ion->sigma_inel_NN(), weight); + + + //delete myGenEvent; +}//analyze diff --git a/Validation/EventGenerator/plugins/BasicHepMCValidation.cc b/Validation/EventGenerator/plugins/BasicHepMCValidation.cc index 229c5bf4e4b92..50fd31350191b 100644 --- a/Validation/EventGenerator/plugins/BasicHepMCValidation.cc +++ b/Validation/EventGenerator/plugins/BasicHepMCValidation.cc @@ -13,7 +13,8 @@ using namespace edm; -BasicHepMCValidation::BasicHepMCValidation(const edm::ParameterSet& iPSet): +BasicHepMCValidation::BasicHepMCValidation(const edm::ParameterSet& iPSet): + _wmanager(iPSet), hepmcCollection_(iPSet.getParameter("hepmcCollection")) { dbe = 0; @@ -165,6 +166,8 @@ void BasicHepMCValidation::beginJob() stableChaNumber= dbe->book1D("stableChaNumber", "Log10(No. stable charged particles)", 50, 0, 5); //Log stablePtclp = dbe->book1D("stablePtclp", "Log10(p) stable ptcl p", 80, -4, 4); //Log stablePtclpT = dbe->book1D("stablePtclpT", "Log10(pT) stable ptcl pT", 80, -4, 4); //Log + partonNumber = dbe->book1D("partonNumber", "number of partons", 100, 0, 100); + partonpT = dbe->book1D("partonpT", "Log10(pT) parton pT", 80, -4, 4); //Log outVrtxStablePtclNumber = dbe->book1D("outVrtxStablePtclNumber", "No. outgoing stable ptcls from vrtx", 10, 0, 10); // outVrtxPtclNumber = dbe->book1D("outVrtxPtclNumber", "No. outgoing ptcls from vrtx", 30, 0, 30); @@ -175,6 +178,25 @@ void BasicHepMCValidation::beginJob() genPtclStatus = dbe->book1D("genPtclStatus", "Status of genParticle", 200,0,200.); // Bjorken_x = dbe->book1D("Bjorken_x", "Bjorken_x", 1000, 0.0, 1.0); + // + status1ShortLived = dbe->book1D("status1ShortLived","Status 1 short lived", 11, 0, 11); + status1ShortLived->setBinLabel(1,"d/dbar"); + status1ShortLived->setBinLabel(2,"u/ubar"); + status1ShortLived->setBinLabel(3,"s/sbar"); + status1ShortLived->setBinLabel(4,"c/cbar"); + status1ShortLived->setBinLabel(5,"b/bbar"); + status1ShortLived->setBinLabel(6,"t/tbar"); + status1ShortLived->setBinLabel(7,"g"); + status1ShortLived->setBinLabel(8,"tau-/tau+"); + status1ShortLived->setBinLabel(9,"Z0"); + status1ShortLived->setBinLabel(10,"W-/W+"); + status1ShortLived->setBinLabel(11,"PDG = 7,8,17,25-99"); + + DeltaEcms = dbe->book1D("DeltaEcms1","deviation from nominal Ecms", 200,-1., 1.); + DeltaPx = dbe->book1D("DeltaPx1","deviation from nominal Px", 200,-1., 1.); + DeltaPy = dbe->book1D("DeltaPy1","deviation from nominal Py", 200,-1., 1.); + DeltaPz = dbe->book1D("DeltaPz1","deviation from nominal Pz", 200,-1., 1.); + } return; } @@ -192,6 +214,7 @@ void BasicHepMCValidation::analyze(const edm::Event& iEvent,const edm::EventSetu ///counters to zero for every event int uNum = 0; int dNum = 0; int sNum = 0; int cNum = 0; int bNum = 0; int tNum = 0; int ubarNum = 0; int dbarNum = 0; int sbarNum = 0; int cbarNum = 0; int bbarNum = 0; int tbarNum = 0; + int partonNum = 0; // int eminusNum = 0; int nueNum = 0; int muminusNum = 0; int numuNum = 0; int tauminusNum = 0; int nutauNum = 0; int eplusNum = 0; int nuebarNum = 0; int muplusNum = 0; int numubarNum = 0; int tauplusNum = 0; int nutaubarNum = 0; @@ -207,6 +230,8 @@ void BasicHepMCValidation::analyze(const edm::Event& iEvent,const edm::EventSetu int outVrtxStablePtclNum = 0; int stablePtclNum = 0; int otherPtclNum = 0; int unknownPDTNum = 0; int stableChaNum = 0; // double bjorken = 0.; + // + double etotal = 0. ; double pxtotal = 0.; double pytotal = 0.; double pztotal = 0.; ///Gathering the HepMCProduct information edm::Handle evt; @@ -215,17 +240,19 @@ void BasicHepMCValidation::analyze(const edm::Event& iEvent,const edm::EventSetu //Get EVENT HepMC::GenEvent *myGenEvent = new HepMC::GenEvent(*(evt->GetEvent())); - nEvt->Fill(0.5); + double weight = _wmanager.weight(iEvent); - genPtclNumber->Fill(log10(myGenEvent->particles_size())); - genVrtxNumber->Fill(log10(myGenEvent->vertices_size())); + nEvt->Fill(0.5,weight); + + genPtclNumber->Fill(log10(myGenEvent->particles_size()),weight); + genVrtxNumber->Fill(log10(myGenEvent->vertices_size()),weight); ///Bjorken variable from PDF HepMC::PdfInfo *pdf = myGenEvent->pdf_info(); if(pdf){ bjorken = ((pdf->x1())/((pdf->x1())+(pdf->x2()))); } - Bjorken_x->Fill(bjorken); + Bjorken_x->Fill(bjorken,weight); //Looping through the VERTICES in the event HepMC::GenEvent::vertex_const_iterator vrtxBegin = myGenEvent->vertices_begin(); @@ -234,9 +261,9 @@ void BasicHepMCValidation::analyze(const edm::Event& iEvent,const edm::EventSetu { ///Vertices HepMC::GenVertex *vrtx = *vrtxIt; - outVrtxPtclNumber->Fill(vrtx->particles_out_size()); //std::cout << "all " << vrtx->particles_out_size() << '\n'; - vrtxZ->Fill(vrtx->point3d().z()); - vrtxRadius->Fill(vrtx->point3d().perp()); + outVrtxPtclNumber->Fill(vrtx->particles_out_size(),weight); //std::cout << "all " << vrtx->particles_out_size() << '\n'; + vrtxZ->Fill(vrtx->point3d().z(),weight); + vrtxRadius->Fill(vrtx->point3d().perp(),weight); ///loop on vertex particles HepMC::GenVertex::particles_out_const_iterator vrtxPtclBegin = vrtx->particles_out_const_begin(); @@ -249,7 +276,7 @@ void BasicHepMCValidation::analyze(const edm::Event& iEvent,const edm::EventSetu ++outVrtxStablePtclNum; //std::cout << "stable " << outVrtxStablePtclNum << '\n'; } } - outVrtxStablePtclNumber->Fill(outVrtxStablePtclNum); + outVrtxStablePtclNumber->Fill(outVrtxStablePtclNum,weight); }//vertices @@ -274,263 +301,294 @@ void BasicHepMCValidation::analyze(const edm::Event& iEvent,const edm::EventSetu charge = PData->charge(); ///Status statistics - genPtclStatus->Fill((float)status); + genPtclStatus->Fill((float)status,weight); ///Stable particles if(ptcl->status() == 1){ ++stablePtclNum; - stablePtclPhi->Fill(ptcl->momentum().phi()/CLHEP::degree); //std::cout << ptcl->polarization().phi() << '\n'; - stablePtclEta->Fill(ptcl->momentum().pseudoRapidity()); - stablePtclCharge->Fill(charge); // std::cout << ptclData.charge() << '\n'; - stablePtclp->Fill(Log_p); - stablePtclpT->Fill(log10(ptcl->momentum().perp())); + stablePtclPhi->Fill(ptcl->momentum().phi()/CLHEP::degree,weight); //std::cout << ptcl->polarization().phi() << '\n'; + stablePtclEta->Fill(ptcl->momentum().pseudoRapidity(),weight); + stablePtclCharge->Fill(charge,weight); // std::cout << ptclData.charge() << '\n'; + stablePtclp->Fill(Log_p,weight); + stablePtclpT->Fill(log10(ptcl->momentum().perp()),weight); if (charge != 0. && charge != 999.) ++stableChaNum; + if ( std::abs(Id) == 1 ) status1ShortLived->Fill(1,weight); + if ( std::abs(Id) == 2 ) status1ShortLived->Fill(2,weight); + if ( std::abs(Id) == 3 ) status1ShortLived->Fill(3,weight); + if ( std::abs(Id) == 4 ) status1ShortLived->Fill(4,weight); + if ( std::abs(Id) == 5 ) status1ShortLived->Fill(5,weight); + if ( std::abs(Id) == 6 ) status1ShortLived->Fill(6,weight); + if ( Id == 21 ) status1ShortLived->Fill(7,weight); + if ( std::abs(Id) == 15 ) status1ShortLived->Fill(8,weight); + if ( Id == 23 ) status1ShortLived->Fill(9,weight); + if ( std::abs(Id) == 24 ) status1ShortLived->Fill(10,weight); + if ( std::abs(Id) == 7 || std::abs(Id) == 8 || std::abs(Id) == 17 || (std::abs(Id) >= 25 && std::abs(Id) <= 99) ) status1ShortLived->Fill(11,weight); + etotal += ptcl->momentum().e(); + pxtotal += ptcl->momentum().px(); + pytotal += ptcl->momentum().py(); + pztotal += ptcl->momentum().pz(); } - + + if (abs(Id) < 6 || abs(Id) == 22){ + ++partonNum; partonpT->Fill(Log_p,weight); + } + ///counting multiplicities and filling momentum distributions switch(abs(Id)){ case 1 : { if(Id > 0) { - ++dNum; dMomentum->Fill(Log_p);} + ++dNum; dMomentum->Fill(Log_p,weight);} else{ - ++dbarNum; dbarMomentum->Fill(Log_p);} + ++dbarNum; dbarMomentum->Fill(Log_p,weight);} } break; // case 2 : { if(Id > 0) { - ++uNum; uMomentum->Fill(Log_p);} + ++uNum; uMomentum->Fill(Log_p,weight);} else{ - ++ubarNum; ubarMomentum->Fill(Log_p);} + ++ubarNum; ubarMomentum->Fill(Log_p,weight);} } break; // case 3 : { if(Id > 0) { - ++sNum; sMomentum->Fill(Log_p);} + ++sNum; sMomentum->Fill(Log_p,weight);} else{ - ++sbarNum; sbarMomentum->Fill(Log_p);} + ++sbarNum; sbarMomentum->Fill(Log_p,weight);} } break; // case 4 : { if(Id > 0) { - ++cNum; cMomentum->Fill(Log_p);} + ++cNum; cMomentum->Fill(Log_p,weight);} else{ - ++cbarNum; cbarMomentum->Fill(Log_p);} + ++cbarNum; cbarMomentum->Fill(Log_p,weight);} } break; // case 5 : { if(Id > 0) { - ++bNum; bMomentum->Fill(Log_p);} + ++bNum; bMomentum->Fill(Log_p,weight);} else{ - ++bbarNum; bbarMomentum->Fill(Log_p);} + ++bbarNum; bbarMomentum->Fill(Log_p,weight);} } break; // case 6 : { if(Id > 0) { - ++tNum; tMomentum->Fill(Log_p);} + ++tNum; tMomentum->Fill(Log_p,weight);} else{ - ++tbarNum; tbarMomentum->Fill(Log_p);} + ++tbarNum; tbarMomentum->Fill(Log_p,weight);} } break; // case 11 : { if(Id > 0) { - ++eminusNum; eminusMomentum->Fill(Log_p);} + ++eminusNum; eminusMomentum->Fill(Log_p,weight);} else{ - ++eplusNum; eplusMomentum->Fill(Log_p);} + ++eplusNum; eplusMomentum->Fill(Log_p,weight);} } break; // case 12 : { if(Id > 0) { - ++nueNum; nueMomentum->Fill(Log_p);} + ++nueNum; nueMomentum->Fill(Log_p, weight);} else{ - ++nuebarNum; nuebarMomentum->Fill(Log_p);} + ++nuebarNum; nuebarMomentum->Fill(Log_p,weight);} } break; // case 13 : { if(Id > 0) { - ++muminusNum; muminusMomentum->Fill(Log_p);} + ++muminusNum; muminusMomentum->Fill(Log_p,weight);} else{ - ++muplusNum; muplusMomentum->Fill(Log_p);} + ++muplusNum; muplusMomentum->Fill(Log_p,weight);} } break; // case 14 : { if(Id > 0) { - ++numuNum; numuMomentum->Fill(Log_p);} + ++numuNum; numuMomentum->Fill(Log_p,weight);} else{ - ++numubarNum; numubarMomentum->Fill(Log_p);} + ++numubarNum; numubarMomentum->Fill(Log_p,weight);} } break; // case 15 : { if(Id > 0) { - ++tauminusNum; tauminusMomentum->Fill(Log_p);} + ++tauminusNum; tauminusMomentum->Fill(Log_p,weight);} else{ - ++tauplusNum; tauplusMomentum->Fill(Log_p);} + ++tauplusNum; tauplusMomentum->Fill(Log_p,weight);} } break; // case 16 : { if(Id > 0) { - ++nutauNum; nutauMomentum->Fill(Log_p);} + ++nutauNum; nutauMomentum->Fill(Log_p,weight);} else{ - ++nutaubarNum; nutaubarMomentum->Fill(Log_p);} + ++nutaubarNum; nutaubarMomentum->Fill(Log_p,weight);} } break; // // case 21 : { - ++gluNum; gluMomentum->Fill(Log_p); + ++gluNum; gluMomentum->Fill(Log_p,weight); } break; // case 22 : { - ++gammaNum; gammaMomentum->Fill(Log_p); + ++gammaNum; gammaMomentum->Fill(Log_p,weight); } break; // case 23 : { - ++ZNum; ZMomentum->Fill(Log_p); + ++ZNum; ZMomentum->Fill(Log_p,weight); } break; case 24 : { if(Id > 0) { - ++WplusNum; WplusMomentum->Fill(Log_p);} + ++WplusNum; WplusMomentum->Fill(Log_p,weight);} else{ - ++WminusNum; WminusMomentum->Fill(Log_p);} + ++WminusNum; WminusMomentum->Fill(Log_p,weight);} } break; // // case 211 : { if(Id > 0) { - ++piplusNum; piplusMomentum->Fill(Log_p);} + ++piplusNum; piplusMomentum->Fill(Log_p,weight);} else{ - ++piminusNum; piminusMomentum->Fill(Log_p);} + ++piminusNum; piminusMomentum->Fill(Log_p,weight);} } break; // case 111 : { - ++pizeroNum; pizeroMomentum->Fill(Log_p); + ++pizeroNum; pizeroMomentum->Fill(Log_p,weight); } break; // case 321 : { if(Id > 0) { - ++KplusNum; KplusMomentum->Fill(Log_p);} + ++KplusNum; KplusMomentum->Fill(Log_p,weight);} else{ - ++KminusNum; KminusMomentum->Fill(Log_p);} + ++KminusNum; KminusMomentum->Fill(Log_p,weight);} } break; // case 130 : { - ++KlzeroNum; KlzeroMomentum->Fill(Log_p); + ++KlzeroNum; KlzeroMomentum->Fill(Log_p,weight); } break; // case 310 : { - ++KszeroNum; KszeroMomentum->Fill(Log_p); + ++KszeroNum; KszeroMomentum->Fill(Log_p,weight); } break; // // case 2212 : { if(Id > 0) { - ++pNum; pMomentum->Fill(Log_p);} + ++pNum; pMomentum->Fill(Log_p,weight);} else{ - ++pbarNum; pbarMomentum->Fill(Log_p);} + ++pbarNum; pbarMomentum->Fill(Log_p,weight);} } break; // case 2112 : { if(Id > 0) { - ++nNum; nMomentum->Fill(Log_p);} + ++nNum; nMomentum->Fill(Log_p,weight);} else{ - ++nbarNum; nbarMomentum->Fill(Log_p);} + ++nbarNum; nbarMomentum->Fill(Log_p,weight);} } break; // // case 3122 : { if(Id > 0) { - ++l0Num; l0Momentum->Fill(Log_p);} + ++l0Num; l0Momentum->Fill(Log_p,weight);} else{ - ++l0barNum; l0barMomentum->Fill(Log_p);} + ++l0barNum; l0barMomentum->Fill(Log_p,weight);} } break; // // case 411 : { if(Id > 0) { - ++DplusNum; DplusMomentum->Fill(Log_p);} + ++DplusNum; DplusMomentum->Fill(Log_p,weight);} else{ - ++DminusNum; DminusMomentum->Fill(Log_p);} + ++DminusNum; DminusMomentum->Fill(Log_p,weight);} } break; // case 421 : { - ++DzeroNum; DzeroMomentum->Fill(Log_p); + ++DzeroNum; DzeroMomentum->Fill(Log_p,weight); } break; // case 521 : { if(Id > 0) { - ++BplusNum; BplusMomentum->Fill(Log_p);} + ++BplusNum; BplusMomentum->Fill(Log_p,weight);} else{ - ++BminusNum; BminusMomentum->Fill(Log_p);} + ++BminusNum; BminusMomentum->Fill(Log_p,weight);} } break; // case 511 : { - ++BzeroNum; BzeroMomentum->Fill(Log_p); + ++BzeroNum; BzeroMomentum->Fill(Log_p,weight); } break; // case 531 : { - ++BszeroNum; BszeroMomentum->Fill(Log_p); + ++BszeroNum; BszeroMomentum->Fill(Log_p,weight); } break; // default : { - ++otherPtclNum; otherPtclMomentum->Fill(Log_p); + ++otherPtclNum; otherPtclMomentum->Fill(Log_p,weight); } }//switch // if( 0 < Id && 100 > Id) ++part_counter[Id]; }//event particles + // set a default sqrt(s) and then check in the event + double ecms = 7000.; + if ( myGenEvent->valid_beam_particles() ) { + ecms = myGenEvent->beam_particles().first->momentum().e()+myGenEvent->beam_particles().second->momentum().e(); + } + DeltaEcms->Fill(etotal-ecms,weight); + DeltaPx->Fill(pxtotal,weight); + DeltaPy->Fill(pytotal,weight); + DeltaPz->Fill(pztotal,weight); + + ///filling multiplicity ME's - stablePtclNumber->Fill(log10(stablePtclNum+0.1)); - stableChaNumber->Fill(log10(stableChaNum+0.1)); - otherPtclNumber->Fill(log10(otherPtclNum+0.1)); - unknownPDTNumber->Fill(log10(unknownPDTNum+0.1)); + stablePtclNumber->Fill(log10(stablePtclNum+0.1),weight); + stableChaNumber->Fill(log10(stableChaNum+0.1),weight); + otherPtclNumber->Fill(log10(otherPtclNum+0.1),weight); + unknownPDTNumber->Fill(log10(unknownPDTNum+0.1),weight); // - dNumber->Fill(dNum); uNumber->Fill(uNum); sNumber->Fill(sNum); cNumber->Fill(cNum); bNumber->Fill(bNum); tNumber->Fill(tNum); - dbarNumber->Fill(dbarNum); ubarNumber->Fill(ubarNum); sbarNumber->Fill(sbarNum); cbarNumber->Fill(cbarNum); bbarNumber->Fill(bbarNum); tbarNumber->Fill(tbarNum); + dNumber->Fill(dNum,weight); uNumber->Fill(uNum,weight); sNumber->Fill(sNum,weight); cNumber->Fill(cNum,weight); bNumber->Fill(bNum,weight); tNumber->Fill(tNum,weight); + dbarNumber->Fill(dbarNum,weight); ubarNumber->Fill(ubarNum,weight); sbarNumber->Fill(sbarNum,weight); cbarNumber->Fill(cbarNum,weight); bbarNumber->Fill(bbarNum,weight); tbarNumber->Fill(tbarNum,weight); + partonNumber->Fill(partonNum,weight); // - eminusNumber->Fill(eminusNum); nueNumber->Fill(nueNum); muminusNumber->Fill(muminusNum); numuNumber->Fill(numuNum); tauminusNumber->Fill(tauminusNum); nutauNumber->Fill(nutauNum); - eplusNumber->Fill(eplusNum); nuebarNumber->Fill(nuebarNum); muplusNumber->Fill(muplusNum); numubarNumber->Fill(numubarNum); tauplusNumber->Fill(tauplusNum); nutaubarNumber->Fill(nutaubarNum); + eminusNumber->Fill(eminusNum,weight); nueNumber->Fill(nueNum,weight); muminusNumber->Fill(muminusNum,weight); numuNumber->Fill(numuNum,weight); tauminusNumber->Fill(tauminusNum,weight); nutauNumber->Fill(nutauNum,weight); + eplusNumber->Fill(eplusNum,weight); nuebarNumber->Fill(nuebarNum,weight); muplusNumber->Fill(muplusNum,weight); numubarNumber->Fill(numubarNum,weight); tauplusNumber->Fill(tauplusNum,weight); nutaubarNumber->Fill(nutaubarNum,weight); // - ZNumber->Fill(ZNum); WminusNumber->Fill(WminusNum); WplusNumber->Fill(WplusNum); - gammaNumber->Fill(log10(gammaNum+0.1)); - gluNumber->Fill(log10(gluNum+0.1)); + ZNumber->Fill(ZNum,weight); WminusNumber->Fill(WminusNum,weight); WplusNumber->Fill(WplusNum,weight); + gammaNumber->Fill(log10(gammaNum+0.1),weight); + gluNumber->Fill(log10(gluNum+0.1),weight); // - piplusNumber->Fill(log10(piplusNum+0.1)); - piminusNumber->Fill(log10(piminusNum+0.1)); - pizeroNumber->Fill(log10(pizeroNum+0.1)); - KplusNumber->Fill(KplusNum); KminusNumber->Fill(KminusNum); KlzeroNumber->Fill(KlzeroNum); KszeroNumber->Fill(KszeroNum); + piplusNumber->Fill(log10(piplusNum+0.1),weight); + piminusNumber->Fill(log10(piminusNum+0.1),weight); + pizeroNumber->Fill(log10(pizeroNum+0.1),weight); + KplusNumber->Fill(KplusNum,weight); KminusNumber->Fill(KminusNum,weight); KlzeroNumber->Fill(KlzeroNum,weight); KszeroNumber->Fill(KszeroNum,weight); // - pNumber->Fill(pNum); pbarNumber->Fill(pbarNum); nNumber->Fill(nNum); nbarNumber->Fill(nbarNum); l0Number->Fill(l0Num); l0barNumber->Fill(l0barNum); + pNumber->Fill(pNum,weight); pbarNumber->Fill(pbarNum,weight); nNumber->Fill(nNum,weight); nbarNumber->Fill(nbarNum,weight); l0Number->Fill(l0Num); l0barNumber->Fill(l0barNum,weight); // - DplusNumber->Fill(DplusNum); DminusNumber->Fill(DminusNum); DzeroNumber->Fill(DzeroNum); BplusNumber->Fill(BplusNum); BminusNumber->Fill(BminusNum); BzeroNumber->Fill(BzeroNum); BszeroNumber->Fill(BszeroNum); + DplusNumber->Fill(DplusNum,weight); DminusNumber->Fill(DminusNum,weight); DzeroNumber->Fill(DzeroNum,weight); BplusNumber->Fill(BplusNum,weight); BminusNumber->Fill(BminusNum,weight); BzeroNumber->Fill(BzeroNum,weight); BszeroNumber->Fill(BszeroNum,weight); delete myGenEvent; }//analyze diff --git a/Validation/EventGenerator/plugins/BuildFile.xml b/Validation/EventGenerator/plugins/BuildFile.xml index 0b072eee95676..95e25050e716c 100644 --- a/Validation/EventGenerator/plugins/BuildFile.xml +++ b/Validation/EventGenerator/plugins/BuildFile.xml @@ -1,9 +1,11 @@ + + diff --git a/Validation/EventGenerator/plugins/DrellYanValidation.cc b/Validation/EventGenerator/plugins/DrellYanValidation.cc index 8f333747e5b95..3924e2ff5b5e2 100644 --- a/Validation/EventGenerator/plugins/DrellYanValidation.cc +++ b/Validation/EventGenerator/plugins/DrellYanValidation.cc @@ -17,7 +17,8 @@ using namespace edm; -DrellYanValidation::DrellYanValidation(const edm::ParameterSet& iPSet): +DrellYanValidation::DrellYanValidation(const edm::ParameterSet& iPSet): + _wmanager(iPSet), hepmcCollection_(iPSet.getParameter("hepmcCollection")), _flavor(iPSet.getParameter("decaysTo")), _name(iPSet.getParameter("name")) @@ -85,7 +86,11 @@ void DrellYanValidation::analyze(const edm::Event& iEvent,const edm::EventSetup& //Get EVENT const HepMC::GenEvent *myGenEvent = evt->GetEvent(); - nEvt->Fill(0.5); + double weight = _wmanager.weight(iEvent); + + //std::cout << "weight: " << weight << std::endl; + + nEvt->Fill(0.5,weight); std::vector allproducts; @@ -124,7 +129,7 @@ void DrellYanValidation::analyze(const edm::Event& iEvent,const edm::EventSetup& //if we did not find any opposite charge pair there is nothing to do if (products.size() < 2) return; - assert(products[0]->momentum().perp() > products[1]->momentum().perp()); + assert(products[0]->momentum().perp() >= products[1]->momentum().perp()); //leading lepton with pt > 20. if (products[0]->momentum().perp() < 20.) return; @@ -142,35 +147,35 @@ void DrellYanValidation::analyze(const edm::Event& iEvent,const edm::EventSetup& std::vector fsrphotons; HepMCValidationHelper::findFSRPhotons(products, myGenEvent, 0.1, fsrphotons); - Zdaughters->Fill(products[0]->pdg_id()); - Zdaughters->Fill(products[1]->pdg_id()); + Zdaughters->Fill(products[0]->pdg_id(),weight); + Zdaughters->Fill(products[1]->pdg_id(),weight); std::vector gammasMomenta; for (unsigned int ipho = 0; ipho < fsrphotons.size(); ++ipho){ TLorentzVector phomom(fsrphotons[ipho]->momentum().x(), fsrphotons[ipho]->momentum().y(), fsrphotons[ipho]->momentum().z(), fsrphotons[ipho]->momentum().t()); dilepton_andphoton_mom += phomom; - Zdaughters->Fill(fsrphotons[ipho]->pdg_id()); + Zdaughters->Fill(fsrphotons[ipho]->pdg_id(),weight); gammasMomenta.push_back(phomom); } //Fill Z histograms - Zmass->Fill(dilepton_andphoton_mom.M()); - ZmassPeak->Fill(dilepton_andphoton_mom.M()); - Zpt->Fill(dilepton_andphoton_mom.Pt()); - ZptLog->Fill(log10(dilepton_andphoton_mom.Pt())); - Zrap->Fill(dilepton_andphoton_mom.Rapidity()); + Zmass->Fill(dilepton_andphoton_mom.M(),weight); + ZmassPeak->Fill(dilepton_andphoton_mom.M(),weight); + Zpt->Fill(dilepton_andphoton_mom.Pt(),weight); + ZptLog->Fill(log10(dilepton_andphoton_mom.Pt()),weight); + Zrap->Fill(dilepton_andphoton_mom.Rapidity(),weight); //Fill dilepton histograms - dilep_mass->Fill(dilepton_mom.M()); - dilep_massPeak->Fill(dilepton_mom.M()); - dilep_pt->Fill(dilepton_mom.Pt()); - dilep_ptLog->Fill(log10(dilepton_mom.Pt())); - dilep_rap->Fill(dilepton_mom.Rapidity()); + dilep_mass->Fill(dilepton_mom.M(),weight); + dilep_massPeak->Fill(dilepton_mom.M(),weight); + dilep_pt->Fill(dilepton_mom.Pt(),weight); + dilep_ptLog->Fill(log10(dilepton_mom.Pt()),weight); + dilep_rap->Fill(dilepton_mom.Rapidity(),weight); //Fill lepton histograms - leadpt->Fill(lep1.Pt()); - secpt->Fill(lep2.Pt()); - leadeta->Fill(lep1.Eta()); - seceta->Fill(lep2.Eta()); + leadpt->Fill(lep1.Pt(),weight); + secpt->Fill(lep2.Pt(),weight); + leadeta->Fill(lep1.Eta(),weight); + seceta->Fill(lep2.Eta(),weight); //boost everything in the Z frame TVector3 boost = dilepton_andphoton_mom.BoostVector(); @@ -184,10 +189,10 @@ void DrellYanValidation::analyze(const edm::Event& iEvent,const edm::EventSetup& //fill gamma histograms if (gammasMomenta.size() != 0 && dilepton_andphoton_mom.M() > 50.) { - gamma_energy->Fill(gammasMomenta.front().E()); + gamma_energy->Fill(gammasMomenta.front().E(),weight); double dphi = lep1.DeltaR(gammasMomenta.front()) < lep2.DeltaR(gammasMomenta.front()) ? lep1.DeltaPhi(gammasMomenta.front()) : lep2.DeltaPhi(gammasMomenta.front()); - cos_theta_gamma_lepton->Fill(cos(dphi)); + cos_theta_gamma_lepton->Fill(cos(dphi),weight); } }//analyze diff --git a/Validation/EventGenerator/plugins/DuplicationChecker.cc b/Validation/EventGenerator/plugins/DuplicationChecker.cc index 1c4296dafe7b6..bf85430052898 100644 --- a/Validation/EventGenerator/plugins/DuplicationChecker.cc +++ b/Validation/EventGenerator/plugins/DuplicationChecker.cc @@ -12,9 +12,13 @@ using namespace edm; DuplicationChecker::DuplicationChecker(const edm::ParameterSet& iPSet): - generatedCollection_(iPSet.getParameter("generatedCollection")), + _wmanager(iPSet), + generatedCollection_(iPSet.getParameter("hepmcCollection")), searchForLHE_(iPSet.getParameter("searchForLHE")) -{ +{ + if (searchForLHE_) { + lheEventProduct_ = iPSet.getParameter("lheEventProduct"); + } dbe = 0; dbe = edm::Service().operator->(); @@ -41,11 +45,13 @@ void DuplicationChecker::analyze(const edm::Event& iEvent,const edm::EventSetup& { double bjorken = 0; - + + double weight = 1.; + if (searchForLHE_) { Handle evt; - iEvent.getByType( evt ); + iEvent.getByLabel(lheEventProduct_, evt); const lhef::HEPEUP hepeup_ = evt->hepeup(); @@ -56,10 +62,12 @@ void DuplicationChecker::analyze(const edm::Event& iEvent,const edm::EventSetup& bjorken+=(pz1/(pz1+pz2)); } else { + //change teh weight in this case + weight = _wmanager.weight(iEvent); edm::Handle evt; iEvent.getByLabel(generatedCollection_, evt); - + const HepMC::PdfInfo *pdf = evt->GetEvent()->pdf_info(); if(pdf){ bjorken = ((pdf->x1())/((pdf->x1())+(pdf->x2()))); @@ -69,7 +77,7 @@ void DuplicationChecker::analyze(const edm::Event& iEvent,const edm::EventSetup& xBjorkenHistory.insert(std::pair(bjorken,iEvent.id())); - xBjorkenME->Fill(bjorken); + xBjorkenME->Fill(bjorken,weight); }//analyze diff --git a/Validation/EventGenerator/plugins/HiggsValidation.cc b/Validation/EventGenerator/plugins/HiggsValidation.cc new file mode 100644 index 0000000000000..e7eedeb1b32d0 --- /dev/null +++ b/Validation/EventGenerator/plugins/HiggsValidation.cc @@ -0,0 +1,148 @@ +/*class HiggsValidation + * + * Class to fill dqm monitor elements from existing EDM file + * + * $Date: 2012/08/12 16:13:29 $ + * $Revision: 1.1 $ + */ + +#include "Validation/EventGenerator/interface/HiggsValidation.h" + +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "CLHEP/Units/defs.h" +#include "CLHEP/Units/PhysicalConstants.h" + +#include "DataFormats/Math/interface/LorentzVector.h" + +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" +#include "Validation/EventGenerator/interface/PdtPdgMini.h" + +using namespace edm; + +HiggsValidation::HiggsValidation(const edm::ParameterSet& iPSet): + _wmanager(iPSet), + hepmcCollection_(iPSet.getParameter("hepmcCollection")), + particle_id(iPSet.getParameter("pdg_id")), + particle_name(iPSet.getParameter("particleName")) +{ + dbe = 0; + dbe = edm::Service().operator->(); + + monitoredDecays = new MonitoredDecays(iPSet); + +} + +HiggsValidation::~HiggsValidation() {} + +void HiggsValidation::beginJob() +{ + if(dbe){ + ///Setting the DQM top directories + TString dir="Generator/"; + dir+=particle_name; + dbe->setCurrentFolder(dir.Data()); + + // Number of analyzed events + nEvt = dbe->book1D("nEvt", "n analyzed Events", 1, 0., 1.); + + //decay type + + std::string channel = particle_name+"_DecayChannels"; + HiggsDecayChannels = dbe->book1D(channel.c_str(),(particle_name+" decay channels").c_str(),monitoredDecays->size(),0,monitoredDecays->size()); + + for(size_t i = 0; i < monitoredDecays->size(); ++i){ + HiggsDecayChannels->setBinLabel(1+i,monitoredDecays->channel(i)); + } + } + + //Kinematics + Higgs_pt = dbe->book1D((particle_name+"_pt"),(particle_name+" p_{t}"),50,0,250); + Higgs_eta = dbe->book1D((particle_name+"_eta"),(particle_name+" #eta"),50,-5,5); + Higgs_mass = dbe->book1D((particle_name+"_m"),(particle_name+" M"),500,0,500); + + int idx=0; + for(unsigned int i=0;iNDecayParticles();i++){ + HiggsDecayProd_pt.push_back(dbe->book1D((monitoredDecays->ConvertIndex(idx)+"_pt"),(monitoredDecays->ConvertIndex(idx)+" p_{t}"),50,0,250)); + HiggsDecayProd_eta.push_back(dbe->book1D((monitoredDecays->ConvertIndex(idx)+"_eta"),(monitoredDecays->ConvertIndex(idx)+" #eta"),50,-5,5)); + idx++; + } + + return; +} + +void HiggsValidation::endJob(){ + return; +} + +void HiggsValidation::beginRun(const edm::Run& iRun,const edm::EventSetup& iSetup) +{ + ///Get PDT Table + iSetup.getData( fPDGTable ); + return; +} +void HiggsValidation::endRun(const edm::Run& iRun,const edm::EventSetup& iSetup){return;} +void HiggsValidation::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup) +{ + double weight = _wmanager.weight(iEvent); + nEvt->Fill(0.5,weight); + + //Gathering the HepMCProduct information + edm::Handle evt; + iEvent.getByLabel(hepmcCollection_, evt); + + //Get EVENT + HepMC::GenEvent *myGenEvent = new HepMC::GenEvent(*(evt->GetEvent())); + + // loop over all particles + bool filled = false; + for(HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin(); + iter!= myGenEvent->particles_end() && !filled; ++iter) { + if(particle_id == fabs((*iter)->pdg_id())){ + std::vector decayprod; + int channel = findHiggsDecayChannel(*iter,decayprod); + HiggsDecayChannels->Fill(channel,weight); + Higgs_pt->Fill((*iter)->momentum().perp(),weight); + Higgs_eta->Fill((*iter)->momentum().eta(),weight); + Higgs_mass->Fill((*iter)->momentum().m(),weight); + for(unsigned int i=0;iisDecayParticle(decayprod.at(i)->pdg_id()); + if(0<=idx && idx<=(int)HiggsDecayProd_pt.size()){ + HiggsDecayProd_pt.at(idx)->Fill(decayprod.at(i)->momentum().perp(),weight); + HiggsDecayProd_eta.at(idx)->Fill(decayprod.at(i)->momentum().eta(),weight); + } + } + filled = true; + } + } + + delete myGenEvent; + +}//analyze + +int HiggsValidation::findHiggsDecayChannel(const HepMC::GenParticle* genParticle,std::vector &decayprod){ + + if(genParticle->status() == 1) return monitoredDecays->stable(); + + std::vector children; + if ( genParticle->end_vertex() ) { + HepMC::GenVertex::particle_iterator des; + for(des = genParticle->end_vertex()->particles_begin(HepMC::descendants); + des!= genParticle->end_vertex()->particles_end(HepMC::descendants);++des ) { + + if((*des)->pdg_id() == genParticle->pdg_id()) continue; + + HepMC::GenVertex::particle_iterator mother = (*des)->production_vertex()->particles_begin(HepMC::parents); + if((*mother)->pdg_id() == genParticle->pdg_id()){ + children.push_back((*des)->pdg_id()); + decayprod.push_back((*des)); + } + } + } + + if(children.size() == 2 && children.at(0) != 0 && children.at(1) != 0) return monitoredDecays->position(children.at(0),children.at(1)); + return monitoredDecays->undetermined(); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(HiggsValidation); diff --git a/Validation/EventGenerator/plugins/MBUEandQCDValidation.cc b/Validation/EventGenerator/plugins/MBUEandQCDValidation.cc index 5eee3220493a3..93b660a766289 100644 --- a/Validation/EventGenerator/plugins/MBUEandQCDValidation.cc +++ b/Validation/EventGenerator/plugins/MBUEandQCDValidation.cc @@ -18,7 +18,8 @@ using namespace edm; -MBUEandQCDValidation::MBUEandQCDValidation(const edm::ParameterSet& iPSet): +MBUEandQCDValidation::MBUEandQCDValidation(const edm::ParameterSet& iPSet): + _wmanager(iPSet), hepmcCollection_(iPSet.getParameter("hepmcCollection")), genchjetCollection_(iPSet.getParameter("genChjetsCollection")), genjetCollection_(iPSet.getParameter("genjetsCollection")), @@ -236,6 +237,9 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu //Get HepMC EVENT HepMC::GenEvent *myGenEvent = new HepMC::GenEvent(*(evt->GetEvent())); + double weight = _wmanager.weight(iEvent); + + if ( verbosity_ > 0 ) { myGenEvent->print(); } double binW = 1.; @@ -244,7 +248,7 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu hepmcCharge.clear(); for (unsigned int i = 0; i < eneInCell.size(); i++) { eneInCell[i] = 0.; } - nEvt->Fill(0.5); + nEvt->Fill(0.5,weight); //Looping through HepMC::GenParticle collection to search for status 1 particles double charge = 0.; @@ -327,16 +331,16 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu if ( nChaVtx >= 3 && nBSCm > 0 && eneHFp < 8. ) { sel7 = true; } // Fill selection histograms - if ( sel1 ) nEvt1->Fill(0.5); - if ( sel2 ) nEvt2->Fill(0.5); - if ( sel3 ) nNoFwdTrig->Fill(0.5); - if ( sel4 ) nSaFwdTrig->Fill(0.5); - if ( sel6 ) nHFflow->Fill(0.5); - if ( sel7 ) nHFSD->Fill(0.5); + if ( sel1 ) nEvt1->Fill(0.5,weight); + if ( sel2 ) nEvt2->Fill(0.5,weight); + if ( sel3 ) nNoFwdTrig->Fill(0.5,weight); + if ( sel4 ) nSaFwdTrig->Fill(0.5,weight); + if ( sel6 ) nHFflow->Fill(0.5,weight); + if ( sel7 ) nHFSD->Fill(0.5,weight); - if ( nb > 0 ) nbquark->Fill(0.5); - if ( nb > 0 && nc > 0 ) ncandbquark->Fill(0.5); - if ( nb == 0 && nc > 0 ) ncnobquark->Fill(0.5); + if ( nb > 0 ) nbquark->Fill(0.5,weight); + if ( nb > 0 && nc > 0 ) ncandbquark->Fill(0.5,weight); + if ( nb == 0 && nc > 0 ) ncnobquark->Fill(0.5,weight); // track analyses double ptMax = 0.; @@ -371,19 +375,19 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu // identified charged particle if (std::abs(pdgId) == 2212) { ppbar++; - pPPbar->Fill(std::log10(pt)); + pPPbar->Fill(std::log10(pt),weight); } else if (std::abs(pdgId) == 321) { kpm++; - pKpm->Fill(std::log10(pt)); + pKpm->Fill(std::log10(pt),weight); } else if (std::abs(pdgId) == 3312) { xim++; - pXim->Fill(std::log10(pt)); + pXim->Fill(std::log10(pt),weight); } else if (std::abs(pdgId) == 3334) { omega++; - pOmega->Fill(std::log10(pt)); + pOmega->Fill(std::log10(pt),weight); } else if (std::abs(pdgId) == 11) { ele++; @@ -398,21 +402,21 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu else if ( sel2 && isNeutral(i) && std::fabs(eta) < 2.5 ) { if (std::abs(pdgId) == 310) { k0s++; - pK0s->Fill(std::log10(pt)); + pK0s->Fill(std::log10(pt),weight); } else if (std::abs(pdgId) == 3122) { l0++; - pL0->Fill(std::log10(pt)); + pL0->Fill(std::log10(pt),weight); } } else if ( sel2 && isNeutral(i) && std::fabs(eta) < 5.19 ) { if (std::abs(pdgId) == 2112) { nnbar++; - pNNbar->Fill(std::log10(pt)); + pNNbar->Fill(std::log10(pt),weight); } else if (std::abs(pdgId) == 22) { gamma++; - pGamma->Fill(std::log10(pt)); + pGamma->Fill(std::log10(pt),weight); } } unsigned int iBin = getHFbin(eta); @@ -420,20 +424,20 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu hfMB[iBin] += hepmcGPCollection[i]->momentum().rho(); } } - nPPbar->Fill(ppbar); - nNNbar->Fill(nnbar); - nKpm->Fill(kpm); - nK0s->Fill(k0s); - nL0->Fill(l0); - nXim->Fill(xim); - nOmega->Fill(omega); - nGamma->Fill(gamma); + nPPbar->Fill(ppbar,weight); + nNNbar->Fill(nnbar,weight); + nKpm->Fill(kpm,weight); + nK0s->Fill(k0s,weight); + nL0->Fill(l0,weight); + nXim->Fill(xim,weight); + nOmega->Fill(omega,weight); + nGamma->Fill(gamma,weight); - if ( ele > 0 ) elePt->Fill(std::log10(hepmcGPCollection[eleMax]->momentum().perp())); - if ( muo > 0 ) muoPt->Fill(std::log10(hepmcGPCollection[muoMax]->momentum().perp())); + if ( ele > 0 ) elePt->Fill(std::log10(hepmcGPCollection[eleMax]->momentum().perp()),weight); + if ( muo > 0 ) muoPt->Fill(std::log10(hepmcGPCollection[muoMax]->momentum().perp()),weight); - leadTrackpt->Fill(hepmcGPCollection[iMax]->momentum().perp()); - leadTracketa->Fill(hepmcGPCollection[iMax]->momentum().eta()); + leadTrackpt->Fill(hepmcGPCollection[iMax]->momentum().perp(),weight); + leadTracketa->Fill(hepmcGPCollection[iMax]->momentum().eta(),weight); std::vector theEtaRanges(theCalo->getEtaRanges()); @@ -462,9 +466,9 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu } - EmpzHFm->Fill(empz); - ntHFm->Fill(nCellOvTh); - eneHFmSel->Fill(eneHFm); + EmpzHFm->Fill(empz,weight); + ntHFm->Fill(nCellOvTh,weight); + eneHFmSel->Fill(eneHFm,weight); } @@ -497,9 +501,10 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu } } } - nCha->Fill(nChaTra); + nCha->Fill(nChaTra,weight); binW = dNchdSpt->getTH1()->GetBinWidth(1); dNchdSpt->Fill(sptTra,1.); + //how do one apply weights to a profile? MonitorElement doesn't allow to nChaDenLpt->Fill(hepmcGPCollection[iMax]->momentum().perp(),nChaTra/4./CLHEP::twopi); sptDenLpt->Fill(hepmcGPCollection[iMax]->momentum().perp(),sptTra/4./CLHEP::twopi); for ( unsigned int i = 0; i < nphiBin; i++ ) { @@ -538,10 +543,10 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu } } - nChj->Fill(nJets); + nChj->Fill(nJets,weight); if ( nJets > 0 && ij1 != genChJets->end() ) { - leadChjpt->Fill(pt1); - leadChjeta->Fill((*ij1).eta()); + leadChjpt->Fill(pt1,weight); + leadChjeta->Fill((*ij1).eta(),weight); if ( nJets > 1 && ij2 != genChJets->end() ) { pt1pt2optotch->Fill(pt1+pt2,(pt1+pt2)/ptot); } @@ -636,20 +641,20 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu } if(jm25njets>3) { - _JM25njets ->Fill(jm25njets); - _JM25ht ->Fill(jm25HT); - _JM25pt1 ->Fill(jm25pt1); - _JM25pt2 ->Fill(jm25pt2); - _JM25pt3 ->Fill(jm25pt3); - _JM25pt4 ->Fill(jm25pt4); + _JM25njets ->Fill(jm25njets,weight); + _JM25ht ->Fill(jm25HT,weight); + _JM25pt1 ->Fill(jm25pt1,weight); + _JM25pt2 ->Fill(jm25pt2,weight); + _JM25pt3 ->Fill(jm25pt3,weight); + _JM25pt4 ->Fill(jm25pt4,weight); } if(jm80njets>3) { - _JM80njets ->Fill(jm80njets); - _JM80ht ->Fill(jm80HT); - _JM80pt1 ->Fill(jm80pt1); - _JM80pt2 ->Fill(jm80pt2); - _JM80pt3 ->Fill(jm80pt3); - _JM80pt4 ->Fill(jm80pt4); + _JM80njets ->Fill(jm80njets,weight); + _JM80ht ->Fill(jm80HT,weight); + _JM80pt1 ->Fill(jm80pt1,weight); + _JM80pt2 ->Fill(jm80pt2,weight); + _JM80pt3 ->Fill(jm80pt3,weight); + _JM80pt4 ->Fill(jm80pt4,weight); } } @@ -660,10 +665,10 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu if ( (*ij1).pt() > 25. && (*ij1).pt() > 25. ) { double deltaPhi = std::fabs((*ij1).phi()-(*ij2).phi())/CLHEP::degree; if ( deltaPhi > 180. ) deltaPhi = 360.-deltaPhi; - pt1pt2Dphi->Fill(deltaPhi); + pt1pt2Dphi->Fill(deltaPhi,weight); if ( std::fabs(deltaPhi) > 2.5*CLHEP::degree ) { - nDijet->Fill(0.5); + nDijet->Fill(0.5,weight); for (unsigned int i = 0; i < hepmcGPCollection.size(); i++ ){ double eta = hepmcGPCollection[i]->momentum().eta(); @@ -685,10 +690,10 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu double invMass = (*ij1).energy()*(*ij2).energy()-(*ij1).px()*(*ij2).px()-(*ij1).py()*(*ij2).py()-(*ij1).pz()*(*ij2).pz(); invMass = std::sqrt(invMass); - pt1pt2InvM->Fill(invMass); + pt1pt2InvM->Fill(invMass,weight); - sumPt->Fill(sumPartPt); - sumChPt->Fill(sumChPartPt); + sumPt->Fill(sumPartPt,weight); + sumChPt->Fill(sumChPartPt,weight); unsigned int nSelJets = 0; for (reco::GenJetCollection::const_iterator iter=genJets->begin();iter!=genJets->end();++iter){ @@ -697,24 +702,24 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu if ( std::fabs(eta) < 5. ) { nSelJets++; binW = dNjdeta->getTH1()->GetBinWidth(1); - dNjdeta->Fill(eta,1./binW); + dNjdeta->Fill(eta,1./binW*weight); binW = dNjdpt->getTH1()->GetBinWidth(1); - dNjdpt->Fill(pt,1./binW); + dNjdpt->Fill(pt,1./binW*weight); sumJetEt += (*iter).pt(); jpx += (*iter).px(); jpy += (*iter).py(); } } - nj->Fill(nSelJets); + nj->Fill(nSelJets,weight); double mEt = std::sqrt(jpx*jpx+jpy*jpy); - sumJEt->Fill(sumJetEt); - missEtosumJEt->Fill(mEt/sumJetEt); + sumJEt->Fill(sumJetEt,weight); + missEtosumJEt->Fill(mEt/sumJetEt,weight); - if ( nSelJets >= 3 ) { pt3Frac->Fill((*ij3).pt()/(pt1+pt2)); } + if ( nSelJets >= 3 ) { pt3Frac->Fill((*ij3).pt()/(pt1+pt2),weight); } pt1pt2optot->Fill(pt1+pt2,(pt1+pt2)/sumJetEt); - pt1pt2balance->Fill((pt1-pt2)/(pt1+pt2)); + pt1pt2balance->Fill((pt1-pt2)/(pt1+pt2),weight); } } } @@ -739,10 +744,10 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu //compute jets fastjet::ClusterSequence cseq(vecs, fastjet::JetDefinition(fastjet::kt_algorithm, 1., fastjet::E_scheme)); //access the cluster sequence and get the relevant info - djr10->Fill(std::log10(sqrt(cseq.exclusive_dmerge(0)))); - djr21->Fill(std::log10(sqrt(cseq.exclusive_dmerge(1)))); - djr32->Fill(std::log10(sqrt(cseq.exclusive_dmerge(2)))); - djr43->Fill(std::log10(sqrt(cseq.exclusive_dmerge(3)))); + djr10->Fill(std::log10(sqrt(cseq.exclusive_dmerge(0))),weight); + djr21->Fill(std::log10(sqrt(cseq.exclusive_dmerge(1))),weight); + djr32->Fill(std::log10(sqrt(cseq.exclusive_dmerge(2))),weight); + djr43->Fill(std::log10(sqrt(cseq.exclusive_dmerge(3))),weight); // compute sumEt for all stable particles @@ -782,17 +787,17 @@ void MBUEandQCDValidation::analyze(const edm::Event& iEvent,const edm::EventSetu } if(sumEt>0.) - _sumEt->Fill(sumEt); + _sumEt->Fill(sumEt,weight); if(sumEt1>0.) - _sumEt1->Fill(sumEt1); + _sumEt1->Fill(sumEt1,weight); if(sumEt2>0.) - _sumEt2->Fill(sumEt2); + _sumEt2->Fill(sumEt2,weight); if(sumEt3>0.) - _sumEt3->Fill(sumEt3); + _sumEt3->Fill(sumEt3,weight); if(sumEt4>0.) - _sumEt4->Fill(sumEt4); + _sumEt4->Fill(sumEt4,weight); if(sumEt5>0.) - _sumEt5->Fill(sumEt5); + _sumEt5->Fill(sumEt5,weight); delete myGenEvent; }//analyze diff --git a/Validation/EventGenerator/plugins/Module.cc b/Validation/EventGenerator/plugins/Module.cc index 905a43070f887..43f7b5b95e80c 100755 --- a/Validation/EventGenerator/plugins/Module.cc +++ b/Validation/EventGenerator/plugins/Module.cc @@ -4,6 +4,9 @@ #include "Validation/EventGenerator/interface/BasicHepMCValidation.h" DEFINE_FWK_MODULE (BasicHepMCValidation); +#include "Validation/EventGenerator/interface/BasicHepMCHeavyIonValidation.h" +DEFINE_FWK_MODULE (BasicHepMCHeavyIonValidation); + #include "Validation/EventGenerator/interface/BasicGenParticleValidation.h" DEFINE_FWK_MODULE(BasicGenParticleValidation); @@ -21,3 +24,17 @@ DEFINE_FWK_MODULE (WValidation); #include "Validation/EventGenerator/interface/TauValidation.h" DEFINE_FWK_MODULE (TauValidation); + +#include "Validation/EventGenerator/interface/TTbar_GenJetAnalyzer.h" +DEFINE_FWK_MODULE(TTbar_GenJetAnalyzer); + +#include "Validation/EventGenerator/interface/TTbar_GenLepAnalyzer.h" +DEFINE_FWK_MODULE(TTbar_GenLepAnalyzer); + +#include "Validation/EventGenerator/interface/TTbar_Kinematics.h" + +#include "Validation/EventGenerator/interface/TTbar_Kinematics.h" +DEFINE_FWK_MODULE(TTbar_Kinematics); + +#include "Validation/EventGenerator/interface/TTbar_P4Violation.h" +DEFINE_FWK_MODULE(TTbar_P4Violation); diff --git a/Validation/EventGenerator/plugins/TTbarSpinCorrHepMCAnalyzer.cc b/Validation/EventGenerator/plugins/TTbarSpinCorrHepMCAnalyzer.cc new file mode 100644 index 0000000000000..9a21dae64a3dc --- /dev/null +++ b/Validation/EventGenerator/plugins/TTbarSpinCorrHepMCAnalyzer.cc @@ -0,0 +1,154 @@ +#include "Validation/EventGenerator/interface/TTbarSpinCorrHepMCAnalyzer.h" + +// +// constructors and destructor +// +TTbarSpinCorrHepMCAnalyzer::TTbarSpinCorrHepMCAnalyzer(const edm::ParameterSet& iConfig) : + genEventInfoProductTag_(iConfig.getParameter("genEventInfoProductTag")), + genParticlesTag_(iConfig.getParameter("genParticlesTag")) +{ + dbe = 0; + dbe = edm::Service().operator->(); +} + + +TTbarSpinCorrHepMCAnalyzer::~TTbarSpinCorrHepMCAnalyzer() +{ + + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) + +} + + +// +// member functions +// + +// ------------ method called for each event ------------ +void +TTbarSpinCorrHepMCAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + using namespace edm; + + // --- the MC weights --- + Handle evt_info; + iEvent.getByLabel(genEventInfoProductTag_, evt_info); + if (evt_info.failedToGet()) + return; + + weight = evt_info->weight() ; + + // --- get genParticles --- + Handle genParticles; + iEvent.getByLabel(genParticlesTag_, genParticles); + + const reco::GenParticle * _lepton (0) ; + const reco::GenParticle * _leptonBar(0) ; + + bool hasTop(false), hasTopbar(false); + for(size_t i = 0; i < genParticles->size(); ++ i) { + const reco::GenParticle & p = (*genParticles)[i]; + if(p.pdgId() == 6) hasTop=true; + if(p.pdgId() == -6) hasTopbar=true; + } + + if(hasTop && hasTopbar){ + // --- get status 3 leptons + for(size_t i = 0; i < genParticles->size(); ++ i) { + const reco::GenParticle & p = (*genParticles)[i]; + if ( (p.pdgId() == 11 || + p.pdgId() == 13 || + p.pdgId() == 15) && p.status() == 3) { _lepton = &p ; } + if ( (p.pdgId() == -11 || + p.pdgId() == -13 || + p.pdgId() == -15) && p.status() == 3) { _leptonBar = &p ; } + + if (_lepton && _leptonBar) break; + } + + if (_lepton && _leptonBar) { + + math::XYZTLorentzVector lepton = _lepton ->p4() ; + math::XYZTLorentzVector leptonBar = _leptonBar->p4() ; + + double deltaPhi = fabs(TVector2::Phi_mpi_pi(lepton.phi() - leptonBar.phi())) ; + _h_deltaPhi->Fill(deltaPhi, weight) ; + + double asym = ( deltaPhi > CLHEP::halfpi ) ? 0.5 : -0.5 ; + _h_asym->Fill(asym, weight) ; + + math::XYZTLorentzVector llpair = lepton + leptonBar ; + + double llpairPt = llpair.pt() ; + _h_llpairPt->Fill(llpairPt, weight) ; + + double llpairM = llpair.M() ; + _h_llpairM ->Fill(llpairM , weight) ; + + } + nEvt->Fill(0.5 , weight) ; + } +} + + +// ------------ method called once each job just before starting event loop ------------ +void +TTbarSpinCorrHepMCAnalyzer::beginJob() +{ + if(dbe){ + ///Setting the DQM top directories + TString dir="Generator/"; + dir+="TTbarSpinCorr"; + dbe->setCurrentFolder(dir.Data()); + + // Number of analyzed events + nEvt = dbe->book1D("nEvt", "n analyzed Events", 1, 0., 1.); + + _h_asym = dbe->book1D("TTbar_asym","Asymmetr", 2, -1., 1.); + _h_asym->setAxisTitle("Asymmetry"); + + _h_deltaPhi = dbe->book1D("TTbar_deltaPhi","#Delta#phi(ll)", 320, 0, 3.2); + _h_deltaPhi->setAxisTitle("#Delta#phi(ll)"); + + _h_llpairPt = dbe->book1D("TTbar_llpairPt","Lepton pair transverse momentum", 1000, 0, 1000); + _h_llpairPt->setAxisTitle("p_{T}(ll)"); + + _h_llpairM = dbe->book1D("TTbar_llpairM","Lepton pair invariant mass", 1000, 0, 1000); + _h_llpairM->setAxisTitle("M(ll)"); + + } +} + +// ------------ method called once each job just after ending the event loop ------------ +void +TTbarSpinCorrHepMCAnalyzer::endJob() +{ +} + +// ------------ method called when starting to processes a run ------------ +void +TTbarSpinCorrHepMCAnalyzer::beginRun(edm::Run const&, edm::EventSetup const&) +{ +} + +// ------------ method called when ending the processing of a run ------------ +void +TTbarSpinCorrHepMCAnalyzer::endRun(edm::Run const&, edm::EventSetup const&) +{ +} + +// ------------ method called when starting to processes a luminosity block ------------ +void +TTbarSpinCorrHepMCAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) +{ +} + +// ------------ method called when ending the processing of a luminosity block ------------ +void +TTbarSpinCorrHepMCAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) +{ +} + +//define this as a plug-in +DEFINE_FWK_MODULE(TTbarSpinCorrHepMCAnalyzer); diff --git a/Validation/EventGenerator/plugins/TTbar_GenJetAnalyzer.cc b/Validation/EventGenerator/plugins/TTbar_GenJetAnalyzer.cc new file mode 100644 index 0000000000000..335f674454bca --- /dev/null +++ b/Validation/EventGenerator/plugins/TTbar_GenJetAnalyzer.cc @@ -0,0 +1,129 @@ +#include "Validation/EventGenerator/interface/TTbar_GenJetAnalyzer.h" + + +TTbar_GenJetAnalyzer::TTbar_GenJetAnalyzer(const edm::ParameterSet& iConfig): + jets_(iConfig.getParameter("jets")), + genEventInfoProductTag_(iConfig.getParameter("genEventInfoProductTag")) +{ + //now do what ever initialization is needed + dbe = 0; + dbe = edm::Service().operator->(); +} + + +TTbar_GenJetAnalyzer::~TTbar_GenJetAnalyzer() +{ + + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) + +} + + +// +// member functions +// + +// ------------ method called for each event ------------ +void + +TTbar_GenJetAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + using namespace edm; + + // --- the MC weights --- + Handle evt_info; + iEvent.getByLabel(genEventInfoProductTag_, evt_info); + if(!evt_info.isValid()) return; + weight = evt_info->weight() ; + + // Gather information in the GenJet collection + edm::Handle > jets; + iEvent.getByLabel(jets_, jets ); + + if(!jets.isValid()) return; + // loop Jet collection and fill histograms + int njets = 0; + for(std::vector::const_iterator jet_it=jets->begin(); jet_it!=jets->end(); ++jet_it){ + + ++njets; + + hists_["jetPtAll" ]->Fill( jet_it->pt() , weight ); + hists_["jetEtaAll"]->Fill( jet_it->eta(), weight ); + + if (njets == 1) { hists_["jetPt1" ]->Fill( jet_it->pt() , weight ); + hists_["jetEta1"]->Fill( jet_it->eta(), weight ); + } + if (njets == 2) { hists_["jetPt2" ]->Fill( jet_it->pt() , weight ); + hists_["jetEta2"]->Fill( jet_it->eta(), weight ); + } + if (njets == 3) { hists_["jetPt3" ]->Fill( jet_it->pt() , weight ); + hists_["jetEta3"]->Fill( jet_it->eta(), weight ); + } + if (njets == 4) { hists_["jetPt4" ]->Fill( jet_it->pt() , weight ); + hists_["jetEta4"]->Fill( jet_it->eta(), weight ); + } + } + +} + + +// ------------ method called once each job just before starting event loop ------------ +void +TTbar_GenJetAnalyzer::beginJob() +{ + if(!dbe) return; + dbe->setCurrentFolder("Generator/TTbar"); + hists_["jetPtAll" ] = dbe->book1D("TTbar_jetPtAll" , "pt" , 1000, 0., 1000.); + hists_["jetPt1" ] = dbe->book1D("TTbar_jetPt1" , "pt" , 1000, 0., 1000.); + hists_["jetPt2" ] = dbe->book1D("TTbar_jetPt2" , "pt" , 1000, 0., 1000.); + hists_["jetPt3" ] = dbe->book1D("TTbar_jetPt3" , "pt" , 1000, 0., 1000.); + hists_["jetPt4" ] = dbe->book1D("TTbar_jetPt4" , "pt" , 1000, 0., 1000.); + + hists_["jetEtaAll"] = dbe->book1D("TTbar_jetEtaAll", "eta", 100, -5., 5.); + hists_["jetEta1" ] = dbe->book1D("TTbar_jetEta1" , "eta", 100, -5., 5.); + hists_["jetEta2" ] = dbe->book1D("TTbar_jetEta2" , "eta", 100, -5., 5.); + hists_["jetEta3" ] = dbe->book1D("TTbar_jetEta3" , "eta", 100, -5., 5.); + hists_["jetEta4" ] = dbe->book1D("TTbar_jetEta4" , "eta", 100, -5., 5.); +} + +// ------------ method called once each job just after ending the event loop ------------ +void +TTbar_GenJetAnalyzer::endJob() +{ +} + +// ------------ method called when starting to processes a run ------------ +void +TTbar_GenJetAnalyzer::beginRun(edm::Run const&, edm::EventSetup const&) +{ +} + +// ------------ method called when ending the processing of a run ------------ +void +TTbar_GenJetAnalyzer::endRun(edm::Run const&, edm::EventSetup const&) +{ +} + +// ------------ method called when starting to processes a luminosity block ------------ +void +TTbar_GenJetAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) +{ +} + +// ------------ method called when ending the processing of a luminosity block ------------ +void +TTbar_GenJetAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) +{ +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void +TTbar_GenJetAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + //The following says we do not know what parameters are allowed so do no validation + // Please change this to state exactly what you do use, even if it is no parameters + edm::ParameterSetDescription desc; + desc.setUnknown(); + descriptions.addDefault(desc); +} + diff --git a/Validation/EventGenerator/plugins/TTbar_GenLepAnalyzer.cc b/Validation/EventGenerator/plugins/TTbar_GenLepAnalyzer.cc new file mode 100644 index 0000000000000..113a50c16c409 --- /dev/null +++ b/Validation/EventGenerator/plugins/TTbar_GenLepAnalyzer.cc @@ -0,0 +1,127 @@ +#include "Validation/EventGenerator/interface/TTbar_GenLepAnalyzer.h" +#include "DQMServices/Core/interface/DQMStore.h" +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" +#include "Validation/EventGenerator/interface/PdtPdgMini.h" + +TTbar_GenLepAnalyzer::TTbar_GenLepAnalyzer(const edm::ParameterSet& iConfig): + leps_(iConfig.getParameter("leptons")) +{ + //now do what ever initialization is needed + dbe = 0; + dbe = edm::Service().operator->(); + +} + + +TTbar_GenLepAnalyzer::~TTbar_GenLepAnalyzer() +{ + + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) + +} + + +// +// member functions +// + +// ------------ method called for each event ------------ +void +TTbar_GenLepAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + + // Handle to the Leptons collections + edm::Handle< edm::View > leps; + iEvent.getByLabel(leps_, leps); + if(!leps.isValid()) return; + + // loop Jet collection and fill histograms + int nleps = 0; + for(edm::View::const_iterator lep_it=leps->begin(); lep_it!=leps->end(); ++lep_it){ + + ++nleps; + + if (nleps > 0) { hists_["lepPtAll" ]->Fill( lep_it->p4().pt() ); + hists_["lepEtaAll"]->Fill( lep_it->p4().eta() ); + } + if (nleps == 1) { hists_["lepPt1" ]->Fill( lep_it->p4().pt() ); + hists_["lepEta1"]->Fill( lep_it->p4().eta() ); + } + if (nleps == 2) { hists_["lepPt2" ]->Fill( lep_it->p4().pt() ); + hists_["lepEta2"]->Fill( lep_it->p4().eta() ); + } + if (nleps == 3) { hists_["lepPt3" ]->Fill( lep_it->p4().pt() ); + hists_["lepEta3"]->Fill( lep_it->p4().eta() ); + } + if (nleps == 4) { hists_["lepPt4" ]->Fill( lep_it->p4().pt() ); + hists_["lepEta4"]->Fill( lep_it->p4().eta() ); + } + } + + hists_["lepN" ]->Fill( nleps ) ; + + +} + + +// ------------ method called once each job just before starting event loop ------------ +void +TTbar_GenLepAnalyzer::beginJob() +{ + if(!dbe) return; + dbe->setCurrentFolder("Generator/TTbar"); + hists_["lepN" ] = dbe->book1D("TTbar_lepN" , "N" , 10, -.5, 9.5 ); + + hists_["lepPtAll" ] = dbe->book1D("TTbar_lepPtAll_"+leps_.label() , "pt" , 1000, 0., 1000.); + hists_["lepPt1" ] = dbe->book1D("TTbar_lepPt1_"+leps_.label() , "pt" , 1000, 0., 1000.); + hists_["lepPt2" ] = dbe->book1D("TTbar_lepPt2_"+leps_.label() , "pt" , 1000, 0., 1000.); + hists_["lepPt3" ] = dbe->book1D("TTbar_lepPt3_"+leps_.label() , "pt" , 1000, 0., 1000.); + hists_["lepPt4" ] = dbe->book1D("TTbar_lepPt4_"+leps_.label() , "pt" , 1000, 0., 1000.); + + hists_["lepEtaAll"] = dbe->book1D("TTbar_lepEtaAll", "eta", 100, -5., 5.); + hists_["lepEta1" ] = dbe->book1D("TTbar_lepEta1" , "eta", 100, -5., 5.); + hists_["lepEta2" ] = dbe->book1D("TTbar_lepEta2" , "eta", 100, -5., 5.); + hists_["lepEta3" ] = dbe->book1D("TTbar_lepEta3" , "eta", 100, -5., 5.); + hists_["lepEta4" ] = dbe->book1D("TTbar_lepEta4" , "eta", 100, -5., 5.); +} + +// ------------ method called once each job just after ending the event loop ------------ +void +TTbar_GenLepAnalyzer::endJob() +{ +} + +// ------------ method called when starting to processes a run ------------ +void +TTbar_GenLepAnalyzer::beginRun(edm::Run const&, edm::EventSetup const&) +{ +} + +// ------------ method called when ending the processing of a run ------------ +void +TTbar_GenLepAnalyzer::endRun(edm::Run const&, edm::EventSetup const&) +{ +} + +// ------------ method called when starting to processes a luminosity block ------------ +void +TTbar_GenLepAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) +{ +} + +// ------------ method called when ending the processing of a luminosity block ------------ +void +TTbar_GenLepAnalyzer::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) +{ +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void +TTbar_GenLepAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + //The following says we do not know what parameters are allowed so do no validation + // Please change this to state exactly what you do use, even if it is no parameters + edm::ParameterSetDescription desc; + desc.setUnknown(); + descriptions.addDefault(desc); +} diff --git a/Validation/EventGenerator/plugins/TTbar_Kinematics.cc b/Validation/EventGenerator/plugins/TTbar_Kinematics.cc new file mode 100644 index 0000000000000..a39fc1433a547 --- /dev/null +++ b/Validation/EventGenerator/plugins/TTbar_Kinematics.cc @@ -0,0 +1,227 @@ +#include "Validation/EventGenerator/interface/TTbar_Kinematics.h" +#include "DQMServices/Core/interface/DQMStore.h" +#include "Validation/EventGenerator/interface/PdtPdgMini.h" +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" + + +using namespace edm; +TTbar_Kinematics::TTbar_Kinematics(const edm::ParameterSet& iConfig) : + genEventInfoProductTag_(iConfig.getParameter("genEventInfoProductTag")) +{ + dbe = 0; + dbe = edm::Service().operator->(); +} + + +TTbar_Kinematics::~TTbar_Kinematics() +{ + + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) + +} + + +// +// member functions +// + +// ------------ method called for each event ------------ +void +TTbar_Kinematics::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + + // --- the MC weights --- + Handle evt_info; + iEvent.getByLabel(genEventInfoProductTag_, evt_info); + if(!evt_info.isValid()) return; + weight = evt_info->weight() ; + + // --- get TopQuarkAnalysis TtGenEvent + Handle genEvt; + iEvent.getByLabel("genEvt", genEvt); + + if(!genEvt.isValid())return; + + const reco::GenParticle* top = 0; + const reco::GenParticle* antitop = 0; + const reco::GenParticle* bottom = 0; + const reco::GenParticle* antibottom = 0; + const reco::GenParticle* Wplus = 0; + const reco::GenParticle* Wmin = 0; + + top = genEvt->top(); + antitop = genEvt->topBar(); + bottom = genEvt->b(); + antibottom = genEvt->bBar(); + Wplus = genEvt->wPlus(); + Wmin = genEvt->wMinus(); + + tlv_Top = TLorentzVector(0,0,0,0) ; + tlv_TopBar = TLorentzVector(0,0,0,0) ; + tlv_Bottom = TLorentzVector(0,0,0,0) ; + tlv_BottomBar = TLorentzVector(0,0,0,0) ; + tlv_Wplus = TLorentzVector(0,0,0,0) ; + tlv_Wmin = TLorentzVector(0,0,0,0) ; + tlv_TTbar = TLorentzVector(0,0,0,0); + + if(top) tlv_Top.SetPxPyPzE(top->p4().px(),top->p4().py(),top->p4().pz(),top->p4().e()); + if(antitop) tlv_TopBar.SetPxPyPzE(antitop->p4().px(),antitop->p4().py(),antitop->p4().pz(),antitop->p4().e()); + if(bottom) tlv_Bottom.SetPxPyPzE(bottom->p4().px(),bottom->p4().py(),bottom->p4().pz(),bottom->p4().e()); + if(antibottom) tlv_BottomBar.SetPxPyPzE(antibottom->p4().px(),antibottom->p4().py(),antibottom->p4().pz(),antibottom->p4().e()); + if(Wplus) tlv_Wplus.SetPxPyPzE(Wplus->p4().px(),Wplus->p4().py(),Wplus->p4().pz(),Wplus->p4().e()); + if(Wmin) tlv_Wmin.SetPxPyPzE(Wmin->p4().px(),Wmin->p4().py(),Wmin->p4().pz(),Wmin->p4().e()); + tlv_TTbar = tlv_Top + tlv_TopBar ; + + //---topquarkquantities--- + nEvt->Fill(0.5,weight); + if(top && antitop){ + hTopPt->Fill(tlv_Top.Pt(),weight); + hTopPt->Fill(tlv_TopBar.Pt(),weight); + + hTopY->Fill(tlv_Top.Rapidity(),weight); + hTopY->Fill(tlv_TopBar.Rapidity(),weight); + + hTopMass->Fill(tlv_Top.M(),weight); + hTopMass->Fill(tlv_TopBar.M(),weight); + + //---ttbarpairquantities--- + hTTbarPt->Fill(tlv_TTbar.Pt(),weight); + hTTbarPt->Fill(tlv_TTbar.Pt(),weight); + + hTTbarY->Fill(tlv_TTbar.Rapidity(),weight); + hTTbarY->Fill(tlv_TTbar.Rapidity(),weight); + + hTTbarMass->Fill(tlv_TTbar.M(),weight); + hTTbarMass->Fill(tlv_TTbar.M(),weight); + } + if(bottom && antibottom){ + hBottomPt->Fill(tlv_Bottom.Pt(),weight); + hBottomPt->Fill(tlv_BottomBar.Pt(),weight); + + hBottomEta->Fill(tlv_Bottom.Eta(),weight); + hBottomEta->Fill(tlv_BottomBar.Eta(),weight); + + //hBottomY->Fill(math::XYZTLorentzVector(bottom->momentum()).Rapidity(),weight); + //hBottomY->Fill(math::XYZTLorentzVector(antibottom->momentum()).Rapidity(),weight); + + hBottomY->Fill(tlv_Bottom.Rapidity(),weight); + hBottomY->Fill(tlv_BottomBar.Rapidity(),weight); + + hBottomPz->Fill(tlv_Bottom.Pz(),weight); + hBottomPz->Fill(tlv_BottomBar.Pz(),weight); + + hBottomE->Fill(tlv_Bottom.E(),weight); + hBottomE->Fill(tlv_BottomBar.E(),weight); + + hBottomMass->Fill(tlv_Bottom.M(),weight); + hBottomMass->Fill(tlv_BottomBar.M(),weight); + + hBottomPtPz->Fill(tlv_Bottom.Pt(),tlv_Bottom.Pz(),weight); + hBottomPtPz->Fill(tlv_BottomBar.Pt(),tlv_BottomBar.Pz(),weight); + + hBottomEtaPz->Fill(tlv_Bottom.Eta(),tlv_Bottom.Pz(),weight); + hBottomEtaPz->Fill(tlv_BottomBar.Eta(),tlv_BottomBar.Pz(),weight); + + hBottomEtaPt->Fill(tlv_Bottom.Eta(),tlv_Bottom.Pt(),weight); + hBottomEtaPt->Fill(tlv_BottomBar.Eta(),tlv_BottomBar.Pt(),weight); + + hBottomYPz->Fill(tlv_Bottom.Rapidity(),tlv_Bottom.Pz(),weight); + hBottomYPz->Fill(tlv_BottomBar.Rapidity(),tlv_BottomBar.Pz(),weight); + + hBottomMassPz->Fill(tlv_Bottom.M(),tlv_Bottom.Pz(),weight); + hBottomMassPz->Fill(tlv_BottomBar.M(),tlv_BottomBar.Pz(),weight); + + hBottomMassEta->Fill(tlv_Bottom.M(),tlv_Bottom.Eta(),weight); + hBottomMassEta->Fill(tlv_BottomBar.M(),tlv_BottomBar.Eta(),weight); + + hBottomMassY->Fill(tlv_Bottom.M(),tlv_Bottom.Rapidity(),weight); + hBottomMassY->Fill(tlv_BottomBar.M(),tlv_BottomBar.Rapidity(),weight); + + hBottomMassDeltaY->Fill(tlv_Bottom.M(),tlv_Bottom.Eta()-tlv_Bottom.Rapidity(),weight); + hBottomMassDeltaY->Fill(tlv_BottomBar.M(),tlv_BottomBar.Eta()-tlv_BottomBar.Rapidity(),weight); + } + if(Wplus && Wmin){ + hWplusPz->Fill(tlv_Wplus.Pz(),weight); + hWminPz->Fill(tlv_Wmin.Pz(),weight); + } +} + + +// ------------ method called once each job just before starting event loop ------------ +void +TTbar_Kinematics::beginJob() +{ + if(!dbe) return; + dbe->setCurrentFolder("Generator/TTbar"); + + nEvt = dbe->book1D("nEvt", "n analyzed Events", 1, 0., 1.); + + hTopPt = dbe->book1D("TTbar_TopPt","t quark transverse momentum",1000,0.,1000.); hTopPt->setAxisTitle("t quark transverse momentum"); + hTopY = dbe->book1D("TTbar_TopY","t quark rapidity",200,-5.,5.); hTopY->setAxisTitle("t quark rapidity"); + hTopMass = dbe->book1D("TTbar_TopMass","t quark mass",500,0.,500.); hTopMass->setAxisTitle("t quark mass"); + + hTTbarPt = dbe->book1D("TTbar_TTbarPt","tt pair transverse momentum",1000,0.,1000.); hTTbarPt->setAxisTitle("tt pair transverse momentum"); + hTTbarY = dbe->book1D("TTbar_TTbarY","tt pair rapidity",200,-5.,5.); hTTbarY->setAxisTitle("tt pair rapidity"); + hTTbarMass = dbe->book1D("TTbar_TTbarMass","tt pair mass",1000,0.,1000.); hTTbarMass->setAxisTitle("tt pair mass"); + + hBottomPt = dbe->book1D("TTbar_BottomPt","b quark transverse momentum",1000,0.,1000.); hBottomPt->setAxisTitle("b quark transverse momentum"); + hBottomEta = dbe->book1D("TTbar_BottomEta","b quark pseudo-rapidity",200,-5.,5.); hBottomEta->setAxisTitle("b quark pseudo-rapidity"); + hBottomY = dbe->book1D("TTbar_BottomY","b quark rapidity",200,-5.,5.); hBottomY->setAxisTitle("b quark rapidity"); + hBottomPz = dbe->book1D("TTbar_BottomPz","b quark longitudinal momentum",200,-100.,100.); hBottomPz->setAxisTitle("b quark longitudinal momentum"); + hBottomE = dbe->book1D("TTbar_BottomE","b quark energy",1000,0.,1000.); hBottomE->setAxisTitle("b quark energy"); + hBottomMass = dbe->book1D("TTbar_BottomMass","b quark mass",50,0.,5.); hBottomMass->setAxisTitle("b quark mass"); + + hBottomPtPz = dbe->book2D("TTbar_BottomPtPz","b quark longitudinal vs transverse momentum",1000,0.,1000.,200,-100.,100.); hBottomPtPz->setAxisTitle("P_{z} (GeV)",1);hBottomPtPz->setAxisTitle("P_{t} (GeV)",2); + hBottomEtaPz = dbe->book2D("TTbar_BottomEtaPz","b quark longitudinal momentum vs pseudorapidity",200,-5.,5.,200,-100.,100.); hBottomEtaPz->setAxisTitle("#eta",1);hBottomEtaPz->setAxisTitle("P_{z} (GeV)",1); + hBottomEtaPt = dbe->book2D("TTbar_BottomEtaPt"," quark transveral momentum vs pseudorapidity",200,-5.,5.,1000,0.,1000.); hBottomEtaPt->setAxisTitle("#eta");hBottomEtaPt->setAxisTitle("P_{t} (GeV)"); + hBottomYPz = dbe->book2D("TTbar_BottomYPz","b quark longitudinal momentum vs rapidity",200,-5.,5.,200,-100.,100.); hBottomYPz->setAxisTitle("Y");hBottomYPz->setAxisTitle("P_{z} (GeV)"); + hBottomMassPz = dbe->book2D("TTbar_BottomMassPz","b quark longitudinal momentum vs mass",50,0.,5.,200,-100.,100.); hBottomMassPz->setAxisTitle("M (GeV)");hBottomMassPz->setAxisTitle("P_{z} (GeV)"); + hBottomMassEta = dbe->book2D("TTbar_BottomMassEta","b quark pseudorapidity vs mass",50,0.,5.,200,-5.,5.); hBottomMassEta->setAxisTitle("M (GeV)");hBottomMassEta->setAxisTitle("#eta"); + hBottomMassY = dbe->book2D("TTbar_BottomMassY","b quark rapidity vs mass",50,0.,5.,200,-5.,5.); hBottomMassY->setAxisTitle("M (GeV)"); hBottomMassY->setAxisTitle("Y"); + hBottomMassDeltaY = dbe->book2D("TTbar_BottomMassDeltaY","b quark pseudorapidity - rapidity vs mass",50,0.,50.,2000,-5.,5.); hBottomMassDeltaY->setAxisTitle("M (GeV)");hBottomMassDeltaY->setAxisTitle("Y"); + + hWplusPz = dbe->book1D("TTbar_WplusPz","W+ boson longitudinal momentum",200,-100.,100.); hWplusPz->setAxisTitle("W+ boson longitudinal momentum"); + hWminPz = dbe->book1D("TTbar_WminPz","W- boson longitudinal momentum",200,-100.,100.); hWminPz->setAxisTitle("W- boson longitudinal momentum"); + +} + +// ------------ method called once each job just after ending the event loop ------------ +void +TTbar_Kinematics::endJob() +{ +} + +// ------------ method called when starting to processes a run ------------ +void +TTbar_Kinematics::beginRun(edm::Run const&, edm::EventSetup const&) +{ +} + +// ------------ method called when ending the processing of a run ------------ +void +TTbar_Kinematics::endRun(edm::Run const&, edm::EventSetup const&) +{ +} + +// ------------ method called when starting to processes a luminosity block ------------ +void +TTbar_Kinematics::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) +{ +} + +// ------------ method called when ending the processing of a luminosity block ------------ +void +TTbar_Kinematics::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) +{ +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void +TTbar_Kinematics::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + //The following says we do not know what parameters are allowed so do no validation + // Please change this to state exactly what you do use, even if it is no parameters + edm::ParameterSetDescription desc; + desc.setUnknown(); + descriptions.addDefault(desc); +} diff --git a/Validation/EventGenerator/plugins/TTbar_P4Violation.cc b/Validation/EventGenerator/plugins/TTbar_P4Violation.cc new file mode 100644 index 0000000000000..4c7d87d65a0ed --- /dev/null +++ b/Validation/EventGenerator/plugins/TTbar_P4Violation.cc @@ -0,0 +1,127 @@ +#include "Validation/EventGenerator/interface/TTbar_P4Violation.h" + +// +// constants, enums and typedefs +// + +// +// static data member definitions +// + +// +// constructors and destructor +// +TTbar_P4Violation::TTbar_P4Violation(const edm::ParameterSet& iConfig) +{ + //now do what ever initialization is needed + +} + + +TTbar_P4Violation::~TTbar_P4Violation() +{ + + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) + +} + + +// +// member functions +// + +// ------------ method called on each new Event ------------ +bool +TTbar_P4Violation::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) +{ + using namespace edm; + + // --- get TopQuarkAnalysis TtGenEvent + Handle genEvt; + iEvent.getByLabel("genEvt", genEvt); + + if(!genEvt.isValid()) return false; + + const reco::GenParticle* top = 0; + const reco::GenParticle* antitop = 0; + const reco::GenParticle* bottom = 0; + const reco::GenParticle* antibottom = 0; + const reco::GenParticle* Wplus = 0; + const reco::GenParticle* Wmin = 0; + + top = genEvt->top(); + antitop = genEvt->topBar(); + bottom = genEvt->b(); + antibottom = genEvt->bBar(); + Wplus = genEvt->wPlus(); + Wmin = genEvt->wMinus(); + + + if(top && antitop && bottom && antibottom && Wplus && Wmin){ + const reco::Particle::LorentzVector topP4 = bottom->p4() + Wplus->p4() ; + const reco::Particle::LorentzVector antitopP4 = antibottom->p4() + Wmin ->p4() ; + + double tolerance = 0.1 ; + + bool topViolated = false ; + bool antitopViolated = false ; + + if ( (top->p4().px() - topP4.px() > tolerance) || + (top->p4().py() - topP4.py() > tolerance) || + (top->p4().pz() - topP4.pz() > tolerance) || + (top->p4().e () - topP4.e () > tolerance) ) { + + topViolated = true ; + + //printf( "momentum not conserved for top:\n" ) ; + //printf( " %5.5f\t %5.5f \t %5.5f \t %5.5f \n", top->p4().px(), top->p4().py(), top->p4().pz(), top->p4().e() ) ; + //printf( " %5.5f\t %5.5f \t %5.5f \t %5.5f \n", topP4.px(), topP4.py(), topP4.pz(), topP4.e() ) ; + } + + if ( (antitop->p4().px() - antitopP4.px() > tolerance) || + (antitop->p4().py() - antitopP4.py() > tolerance) || + (antitop->p4().pz() - antitopP4.pz() > tolerance) || + (antitop->p4().e () - antitopP4.e () > tolerance) ) { + + antitopViolated = true ; + + //printf( "momentum not conserved for anti-top:\n" ) ; + //printf( " %5.5f\t %5.5f \t %5.5f \t %5.5f \n ", antitop->p4().px(), antitop->p4().py(), antitop->p4().pz(), antitop->p4().e() ) ; + //printf( " %5.5f\t %5.5f \t %5.5f \t %5.5f \n ", antitopP4.px(), antitopP4.py(), antitopP4.pz(), antitopP4.e() ) ; + } + + return (topViolated || antitopViolated); + + + // GOSSIE temp + bool bottomOK = true ; + bool antibottomOK = true ; + if ( fabs( bottom->p4().pz()) < 1. ) bottomOK = false ; + if ( fabs(antibottom->p4().pz()) < 1. ) antibottomOK = false ; + return (bottomOK && antibottomOK); + } + return false; +} + +// ------------ method called once each job just before starting event loop ------------ +void +TTbar_P4Violation::beginJob() +{ +} + +// ------------ method called once each job just after ending the event loop ------------ +void +TTbar_P4Violation::endJob() { +} + +// ------------ method fills 'descriptions' with the allowed parameters for the module ------------ +void +TTbar_P4Violation::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + //The following says we do not know what parameters are allowed so do no validation + // Please change this to state exactly what you do use, even if it is no parameters + edm::ParameterSetDescription desc; + desc.setUnknown(); + descriptions.addDefault(desc); +} + diff --git a/Validation/EventGenerator/plugins/TauValidation.cc b/Validation/EventGenerator/plugins/TauValidation.cc index 4c1e7618f0b2f..00a395abc7c36 100644 --- a/Validation/EventGenerator/plugins/TauValidation.cc +++ b/Validation/EventGenerator/plugins/TauValidation.cc @@ -14,12 +14,19 @@ #include "DataFormats/Math/interface/LorentzVector.h" #include "DataFormats/HepMCCandidate/interface/GenParticle.h" +#include "Validation/EventGenerator/interface/TauDecay_CMSSW.h" +#include "Validation/EventGenerator/interface/PdtPdgMini.h" using namespace edm; -TauValidation::TauValidation(const edm::ParameterSet& iPSet): - hepmcCollection_(iPSet.getParameter("hepmcCollection")), - tauEtCut(iPSet.getParameter("tauEtCutForRtau")) +TauValidation::TauValidation(const edm::ParameterSet& iPSet): + _wmanager(iPSet) + ,hepmcCollection_(iPSet.getParameter("hepmcCollection")) + ,tauEtCut(iPSet.getParameter("tauEtCutForRtau")) + ,NJAKID(22) + ,zsbins(20) + ,zsmin(-0.5) + ,zsmax(0.5) { dbe = 0; dbe = edm::Service().operator->(); @@ -34,26 +41,33 @@ void TauValidation::beginJob() dbe->setCurrentFolder("Generator/Tau"); // Number of analyzed events - nEvt = dbe->book1D("nEvt", "n analyzed Events", 1, 0., 1.); + nTaus = dbe->book1D("nTaus", "n analyzed Taus", 1, 0., 1.); + nPrimeTaus = dbe->book1D("nPrimeTaus", "n analyzed prime Taus", 1, 0., 1.); //Kinematics TauPt = dbe->book1D("TauPt","Tau pT", 100 ,0,100); TauEta = dbe->book1D("TauEta","Tau eta", 100 ,-2.5,2.5); + TauPhi = dbe->book1D("TauPhi","Tau phi", 100 ,-3.14,3.14); TauProngs = dbe->book1D("TauProngs","Tau n prongs", 7 ,0,7); - TauDecayChannels = dbe->book1D("TauDecayChannels","Tau decay channels", 10 ,0,10); + TauDecayChannels = dbe->book1D("TauDecayChannels","Tau decay channels", 13 ,0,13); TauDecayChannels->setBinLabel(1+undetermined,"?"); TauDecayChannels->setBinLabel(1+electron,"e"); TauDecayChannels->setBinLabel(1+muon,"mu"); TauDecayChannels->setBinLabel(1+pi,"#pi^{#pm}"); + TauDecayChannels->setBinLabel(1+rho,"#rho^{#pm}"); + TauDecayChannels->setBinLabel(1+a1,"a_{1}^{#pm}"); TauDecayChannels->setBinLabel(1+pi1pi0,"#pi^{#pm}#pi^{0}"); TauDecayChannels->setBinLabel(1+pinpi0,"#pi^{#pm}n#pi^{0}"); TauDecayChannels->setBinLabel(1+tripi,"3#pi^{#pm}"); TauDecayChannels->setBinLabel(1+tripinpi0,"3#pi^{#pm}n#pi^{0}"); TauDecayChannels->setBinLabel(1+K,"K"); + TauDecayChannels->setBinLabel(1+Kstar,"K^{*}"); TauDecayChannels->setBinLabel(1+stable,"Stable"); TauMothers = dbe->book1D("TauMothers","Tau mother particles", 10 ,0,10); TauMothers->setBinLabel(1+other,"?"); + TauMothers->setBinLabel(1+B,"B Decays"); + TauMothers->setBinLabel(1+D,"D Decays"); TauMothers->setBinLabel(1+gamma,"#gamma"); TauMothers->setBinLabel(1+Z,"Z"); TauMothers->setBinLabel(1+W,"W"); @@ -62,25 +76,73 @@ void TauValidation::beginJob() TauMothers->setBinLabel(1+A0,"A^{0}"); TauMothers->setBinLabel(1+Hpm,"H^{#pm}"); - TauRtauW = dbe->book1D("TauRtauW","W->Tau p(leading track)/E(visible tau)", 50 ,0,1); - TauRtauW->setAxisTitle("rtau"); - TauRtauHpm = dbe->book1D("TauRtauHpm","Hpm->Tau p(leading track)/E(visible tau)", 50 ,0,1); - TauRtauHpm->setAxisTitle("rtau"); - TauSpinEffectsW = dbe->book1D("TauSpinEffectsW","Pion energy in W rest frame", 50 ,0,1); - TauSpinEffectsW->setAxisTitle("Energy"); - TauSpinEffectsHpm = dbe->book1D("TauSpinEffectsHpm","Pion energy in Hpm rest frame", 50 ,0,1); - TauSpinEffectsHpm->setAxisTitle("Energy"); - - TauPhotons = dbe->book1D("TauPhoton","Photons radiating from tau", 2 ,0,2); - TauPhotons->setBinLabel(1,"Fraction of taus radiating photons"); - TauPhotons->setBinLabel(2,"Fraction of tau pt radiated by photons"); - } + TauRtauW = dbe->book1D("TauRtauW","W->Tau p(leading track)/E(visible tau)", 50 ,0,1); TauRtauW->setAxisTitle("rtau"); + TauRtauHpm = dbe->book1D("TauRtauHpm","Hpm->Tau p(leading track)/E(visible tau)", 50 ,0,1); TauRtauHpm->setAxisTitle("rtau"); + + TauSpinEffectsW_X = dbe->book1D("TauSpinEffectsWX","Pion energy in W rest frame", 50 ,0,1); TauSpinEffectsW_X->setAxisTitle("X"); + TauSpinEffectsHpm_X = dbe->book1D("TauSpinEffectsHpmX","Pion energy in Hpm rest frame", 50 ,0,1); TauSpinEffectsHpm_X->setAxisTitle("X"); + + TauSpinEffectsW_eX = dbe->book1D("TauSpinEffectsWeX","e energy in W rest frame", 50 ,0,1); TauSpinEffectsW_eX->setAxisTitle("X"); + TauSpinEffectsHpm_eX = dbe->book1D("TauSpinEffectsHpmeX","e energy in Hpm rest frame", 50 ,0,1); TauSpinEffectsHpm_eX->setAxisTitle("X"); + + TauSpinEffectsW_muX = dbe->book1D("TauSpinEffectsWmuX","mu energy in W rest frame", 50 ,0,1); TauSpinEffectsW_muX->setAxisTitle("X"); + TauSpinEffectsHpm_muX = dbe->book1D("TauSpinEffectsHpmmuX","mu energy in Hpm rest frame", 50 ,0,1); TauSpinEffectsHpm_muX->setAxisTitle("X"); + + TauSpinEffectsW_UpsilonRho = dbe->book1D("TauSpinEffectsWUpsilonRho","#Upsilon for #rho", 50 ,-1,1); TauSpinEffectsW_UpsilonRho->setAxisTitle("#Upsilon"); + TauSpinEffectsHpm_UpsilonRho = dbe->book1D("TauSpinEffectsHpmUpsilonRho","#Upsilon for #rho", 50 ,-1,1); TauSpinEffectsHpm_UpsilonRho->setAxisTitle("#Upsilon"); + + TauSpinEffectsW_UpsilonA1 = dbe->book1D("TauSpinEffectsWUpsilonA1","#Upsilon for a1", 50 ,-1,1); TauSpinEffectsW_UpsilonA1->setAxisTitle("#Upsilon"); + TauSpinEffectsHpm_UpsilonA1 = dbe->book1D("TauSpinEffectsHpmUpsilonA1","#Upsilon for a1", 50 ,-1,1); TauSpinEffectsHpm_UpsilonA1->setAxisTitle("#Upsilon"); + + TauSpinEffectsZ_MVis = dbe->book1D("TauSpinEffectsZMVis","Mass of pi+ pi-", 25 ,0,1.1); TauSpinEffectsZ_MVis->setAxisTitle("M_{#pi^{+}#pi^{-}}"); + TauSpinEffectsH_MVis = dbe->book1D("TauSpinEffectsHMVis","Mass of pi+ pi-", 25 ,0,1.1); TauSpinEffectsZ_MVis->setAxisTitle("M_{#pi^{+}#pi^{-}}"); + + TauSpinEffectsZ_Zs = dbe->book1D("TauSpinEffectsZZs","Z_{s}", zsbins ,zsmin,zsmax); TauSpinEffectsZ_Zs->setAxisTitle("Z_{s}"); + TauSpinEffectsH_Zs = dbe->book1D("TauSpinEffectsHZs","Z_{s}", zsbins ,zsmin,zsmax); TauSpinEffectsZ_Zs->setAxisTitle("Z_{s}"); - nTaus = 0; - nTausWithPhotons = 0; - tauPtSum = 0; - photonFromTauPtSum = 0; + TauSpinEffectsZ_Xf = dbe->book1D("TauSpinEffectsZXf","X of forward emitted #tau^{-}", 25 ,0,1.0); TauSpinEffectsZ_Xf->setAxisTitle("X_{f}"); + TauSpinEffectsH_Xf = dbe->book1D("TauSpinEffectsHXf","X of forward emitted #tau^{-}", 25 ,0,1.0); TauSpinEffectsZ_Xf->setAxisTitle("X_{f}"); + TauSpinEffectsZ_Xb = dbe->book1D("TauSpinEffectsZXb","X of backward emitted #tau^{-}", 25 ,0,1.0); TauSpinEffectsZ_Xb->setAxisTitle("X_{b}"); + TauSpinEffectsH_Xb = dbe->book1D("TauSpinEffectsHXb","X of backward emitted #tau^{-}", 25 ,0,1.0); TauSpinEffectsZ_Xb->setAxisTitle("X_{b}"); + + TauSpinEffectsZ_eX = dbe->book1D("TauSpinEffectsZeX","e energy in Z rest frame", 50 ,0,1); TauSpinEffectsZ_eX->setAxisTitle("X"); + TauSpinEffectsH_eX = dbe->book1D("TauSpinEffectsHeX","e energy in H rest frame", 50 ,0,1); TauSpinEffectsH_eX->setAxisTitle("X"); + + TauSpinEffectsZ_muX = dbe->book1D("TauSpinEffectsZmuX","mu energy in z rest frame", 50 ,0,1); TauSpinEffectsZ_muX->setAxisTitle("X"); + TauSpinEffectsH_muX = dbe->book1D("TauSpinEffectsHmuX","mu energy in H rest frame", 50 ,0,1); TauSpinEffectsH_muX->setAxisTitle("X"); + + + TauFSRPhotonsN=dbe->book1D("TauFSRPhotonsN","FSR Photons radiating from/with tau (Gauge Boson)", 5 ,-0.5,4.5); + TauFSRPhotonsN->setAxisTitle("N FSR Photons radiating from/with tau"); + TauFSRPhotonsPt=dbe->book1D("TauFSRPhotonsPt","Pt of FSR Photons radiating from/with tau (Gauge Boson)", 100 ,0,100); + TauFSRPhotonsPt->setAxisTitle("P_{t} of FSR Photons radiating from/with tau [per tau]"); + TauFSRPhotonsPtSum=dbe->book1D("TauFSRPhotonsPtSum","Pt of FSR Photons radiating from/with tau (Gauge Boson)", 100 ,0,100); + TauFSRPhotonsPtSum->setAxisTitle("P_{t} of FSR Photons radiating from/with tau [per tau]"); + + TauBremPhotonsN=dbe->book1D("TauBremPhotonsN","Brem. Photons radiating in tau decay", 5 ,-0.5,4.5); + TauBremPhotonsN->setAxisTitle("N FSR Photons radiating from/with tau"); + TauBremPhotonsPt=dbe->book1D("TauBremPhotonsPt","Sum Brem Pt ", 100 ,0,100); + TauFSRPhotonsPt->setAxisTitle("P_{t} of Brem. Photons radiating in tau decay"); + TauBremPhotonsPtSum =dbe->book1D("TauBremPhotonsPtSum","Sum of Brem Pt ", 100 ,0,100); + TauFSRPhotonsPtSum->setAxisTitle("Sum P_{t} of Brem. Photons radiating in tau decay"); + + JAKID =dbe->book1D("JAKID","JAK ID",NJAKID+1,-0.5,NJAKID+0.5); + for(unsigned int i=0; i()); + TString tmp="JAKID"; + tmp+=i; + JAKInvMass.at(i).push_back(dbe->book1D("M"+tmp,"M_{"+tmp+"} (GeV)", 80 ,0,2.0)); + if(i==TauDecay::JAK_A1_3PI || + i==TauDecay::JAK_KPIK || + i==TauDecay::JAK_KPIPI ){ + JAKInvMass.at(i).push_back(dbe->book1D("M13"+tmp,"M_{13,"+tmp+"} (GeV)", 80 ,0,2.0)); + JAKInvMass.at(i).push_back(dbe->book1D("M23"+tmp,"M_{23,"+tmp+"} (GeV)", 80 ,0,2.0)); + JAKInvMass.at(i).push_back(dbe->book1D("M12"+tmp,"M_{12,"+tmp+"} (GeV)", 80 ,0,2.0)); + } + } + } + return; } @@ -97,162 +159,465 @@ void TauValidation::beginRun(const edm::Run& iRun,const edm::EventSetup& iSetup) void TauValidation::endRun(const edm::Run& iRun,const edm::EventSetup& iSetup){return;} void TauValidation::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup) { - - ///Gathering the HepMCProduct information + ///Gathering the HepMCProduct information edm::Handle evt; iEvent.getByLabel(hepmcCollection_, evt); //Get EVENT HepMC::GenEvent *myGenEvent = new HepMC::GenEvent(*(evt->GetEvent())); - nEvt->Fill(0.5); + double weight = _wmanager.weight(iEvent); + + ////////////////////////////////////////////// + /* + edm::Handle WT; + iEvent.getByLabel(edm::InputTag("TauSpinnerGen","TauSpinnerWT"),WT); + weight = 1.0; + if(*(WT.product())>1e-3 && *(WT.product())<=10.0) weight=(*(WT.product())); + else {weight=1.0;} + */ + /////////////////////////////////////////////// // find taus - for(HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin(); iter != myGenEvent->particles_end(); ++iter) { - if((*iter)->status()==3) { - if(abs((*iter)->pdg_id())==15){ - TauPt->Fill((*iter)->momentum().perp()); - TauEta->Fill((*iter)->momentum().eta()); - int mother = tauMother(*iter); - int decaychannel = tauDecayChannel(*iter); - tauProngs(*iter); - rtau(*iter,mother,decaychannel); - spinEffects(*iter,mother,decaychannel); - photons(*iter); + for(HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin(); iter != myGenEvent->particles_end(); iter++) { + if(abs((*iter)->pdg_id())==23){ + spinEffectsZ(*iter,weight); + } + if(abs((*iter)->pdg_id())==15){ + if(isLastTauinChain(*iter)){ + nTaus->Fill(0.5,weight); + int mother = tauMother(*iter,weight); + int decaychannel = tauDecayChannel(*iter,weight); + tauProngs(*iter, weight); + if(mother>-1){ // exclude B, D and other non-signal decay modes + nPrimeTaus->Fill(0.5,weight); + TauPt->Fill((*iter)->momentum().perp(),weight); + TauEta->Fill((*iter)->momentum().eta(),weight); + TauPhi->Fill((*iter)->momentum().phi(),weight); + rtau(*iter,mother,decaychannel,weight); + photons(*iter,weight); + } + /////////////////////////////////////////////// + //Adding JAKID and Mass information + // + TauDecay_CMSSW TD; + unsigned int jak_id, TauBitMask; + if(TD.AnalyzeTau((*iter),jak_id,TauBitMask,false,false)){ + JAKID->Fill(jak_id,weight); + if(jak_id<=NJAKID){ + int tcharge=(*iter)->pdg_id()/abs((*iter)->pdg_id()); + std::vector part=TD.Get_TauDecayProducts(); + spinEffects(*iter,mother,jak_id,part,weight); + TLorentzVector LVQ(0,0,0,0); + TLorentzVector LVS12(0,0,0,0); + TLorentzVector LVS13(0,0,0,0); + TLorentzVector LVS23(0,0,0,0); + bool haspart1=false; + for(unsigned int i=0;ipdg_id()) && + abs(part.at(i)->pdg_id())!=PdtPdgMini::nu_e && + abs(part.at(i)->pdg_id())!=PdtPdgMini::nu_mu && + abs(part.at(i)->pdg_id())!=PdtPdgMini::nu_tau ){ + TLorentzVector LV(part.at(i)->momentum().px(),part.at(i)->momentum().py(),part.at(i)->momentum().pz(),part.at(i)->momentum().e()); + LVQ+=LV; + if(jak_id==TauDecay::JAK_A1_3PI || + jak_id==TauDecay::JAK_KPIK || + jak_id==TauDecay::JAK_KPIPI + ){ + if((tcharge==part.at(i)->pdg_id()/abs(part.at(i)->pdg_id()) && TD.nProng(TauBitMask)==3) || (jak_id==TauDecay::JAK_A1_3PI && TD.nProng(TauBitMask)==1 && abs(part.at(i)->pdg_id())==PdtPdgMini::pi_plus) ){ + LVS13+=LV; + LVS23+=LV; + } + else{ + LVS12+=LV; + if(!haspart1 && ((jak_id==TauDecay::JAK_A1_3PI) || (jak_id!=TauDecay::JAK_A1_3PI && abs(part.at(i)->pdg_id())==PdtPdgMini::K_plus) )){ + LVS13+=LV; + haspart1=true; + } + else{ + LVS23+=LV; + } + } + } + } + } + part.clear(); + JAKInvMass.at(jak_id).at(0)->Fill(LVQ.M(),weight); + if(jak_id==TauDecay::JAK_A1_3PI || + jak_id==TauDecay::JAK_KPIK || + jak_id==TauDecay::JAK_KPIPI + ){ + JAKInvMass.at(jak_id).at(1)->Fill(LVS13.M(),weight); + JAKInvMass.at(jak_id).at(2)->Fill(LVS23.M(),weight); + JAKInvMass.at(jak_id).at(3)->Fill(LVS12.M(),weight); + } + } + } + else{ + JAKID->Fill(jak_id,weight); + } } } } - delete myGenEvent; }//analyze -int TauValidation::tauMother(const HepMC::GenParticle* tau){ - int mother_pid = 0; +const HepMC::GenParticle* TauValidation::GetMother(const HepMC::GenParticle* tau){ + if ( tau->production_vertex() ) { + HepMC::GenVertex::particle_iterator mother; + for (mother = tau->production_vertex()->particles_begin(HepMC::parents); mother!= tau->production_vertex()->particles_end(HepMC::parents); mother++ ) { + if((*mother)->pdg_id() == tau->pdg_id()) return GetMother(*mother); + return (*mother); + } + } + return tau; +} - if ( tau->production_vertex() ) { - HepMC::GenVertex::particle_iterator mother; - for (mother = tau->production_vertex()->particles_begin(HepMC::parents); - mother!= tau->production_vertex()->particles_end(HepMC::parents); ++mother ) { - mother_pid = (*mother)->pdg_id(); - //std::cout << " parent " << mother_pid << std::endl; - } - } - int label = other; - if(abs(mother_pid) == 24) label = W; - if(abs(mother_pid) == 23) label = Z; - if(abs(mother_pid) == 22) label = gamma; - if(abs(mother_pid) == 25) label = HSM; - if(abs(mother_pid) == 35) label = H0; - if(abs(mother_pid) == 36) label = A0; - if(abs(mother_pid) == 37) label = Hpm; +const std::vector TauValidation::GetMothers(const HepMC::GenParticle* boson){ + std::vector mothers; + if ( boson->production_vertex() ) { + HepMC::GenVertex::particle_iterator mother; + for (mother = boson->production_vertex()->particles_begin(HepMC::parents); mother!= boson->production_vertex()->particles_end(HepMC::parents); mother++ ) { + if((*mother)->pdg_id() == boson->pdg_id()) return GetMothers(*mother); + mothers.push_back(*mother); + } + } + return mothers; +} - TauMothers->Fill(label); - return mother_pid; +int TauValidation::findMother(const HepMC::GenParticle* tau){ + int mother_pid = 0; + if ( tau->production_vertex() ) { + HepMC::GenVertex::particle_iterator mother; + for (mother = tau->production_vertex()->particles_begin(HepMC::parents); mother!= tau->production_vertex()->particles_end(HepMC::parents); mother++ ) { + mother_pid = (*mother)->pdg_id(); + if(mother_pid == tau->pdg_id()) return findMother(*mother); //mother_pid = -1; Make recursive to look for last tau in chain + } + } + return mother_pid; } -int TauValidation::tauProngs(const HepMC::GenParticle* tau){ - - int nProngs = 0; - if ( tau->end_vertex() ) { - HepMC::GenVertex::particle_iterator des; - for(des = tau->end_vertex()->particles_begin(HepMC::descendants); - des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) { - int pid = (*des)->pdg_id(); - if(abs(pid) == 15) return tauProngs(*des); - if((*des)->status() != 1) continue; // dont count unstable particles - - const HepPDT::ParticleData* pd = fPDGTable->particle((*des)->pdg_id ()); - int charge = (int) pd->charge(); - if(charge == 0) continue; - //std::cout << "TauValidation::tauProngs barcode=" << (*des)->barcode() << " pid=" - // << pid << " mom=" << tauMother(*des) << " status=" - // << (*des)->status() << " charge=" << charge << std::endl; - nProngs++; - } - } - TauProngs->Fill(nProngs); - return nProngs; -} -int TauValidation::tauDecayChannel(const HepMC::GenParticle* tau){ +bool TauValidation::isLastTauinChain(const HepMC::GenParticle* tau){ + if ( tau->end_vertex() ) { + HepMC::GenVertex::particle_iterator dau; + for (dau = tau->end_vertex()->particles_begin(HepMC::children); dau!= tau->end_vertex()->particles_end(HepMC::children); dau++ ) { + int dau_pid = (*dau)->pdg_id(); + if(dau_pid == tau->pdg_id()) return false; + } + } + return true; +} - int channel = undetermined; - if(tau->status() == 1) channel = stable; - int eCount = 0, - muCount = 0, - pi0Count = 0, - piCount = 0; +void TauValidation::findTauList(const HepMC::GenParticle* tau,std::vector &TauList){ + TauList.insert(TauList.begin(),tau); + if ( tau->production_vertex() ) { + HepMC::GenVertex::particle_iterator mother; + for (mother = tau->production_vertex()->particles_begin(HepMC::parents); mother!= tau->production_vertex()->particles_end(HepMC::parents);mother++) { + if((*mother)->pdg_id() == tau->pdg_id()){ + findTauList(*mother,TauList); + } + } + } +} - if ( tau->end_vertex() ) { - HepMC::GenVertex::particle_iterator des; - for(des = tau->end_vertex()->particles_begin(HepMC::descendants); - des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) { +void TauValidation::findFSRandBrem(const HepMC::GenParticle* p, bool doBrem, std::vector &ListofFSR, + std::vector &ListofBrem){ + // note this code split the FSR and Brem based one if the tau decays into a tau+photon or not with the Fortran Tauola Interface, this is not 100% correct because photos puts the tau with the regular tau decay products. + if(abs(p->pdg_id())==15){ + if(isLastTauinChain(p)){ doBrem=true;} + else{ doBrem=false;} + } + int photo_ID=22; + if ( p->end_vertex() ) { + HepMC::GenVertex::particle_iterator dau; + for (dau = p->end_vertex()->particles_begin(HepMC::children); dau!= p->end_vertex()->particles_end(HepMC::children); dau++ ) { + //if(doBrem) std::cout << "true " << (*dau)->pdg_id() << " " << std::endl; + //else std::cout << "false " << (*dau)->pdg_id() << " " << std::endl; + if(abs((*dau)->pdg_id()) == abs(photo_ID) && !doBrem){ListofFSR.push_back(*dau);} + if(abs((*dau)->pdg_id()) == abs(photo_ID) && doBrem){ListofBrem.push_back(*dau);} + if((*dau)->end_vertex() && (*dau)->end_vertex()->particles_out_size()>0 && abs((*dau)->pdg_id()) != 111 && abs((*dau)->pdg_id()) != 221/* remove pi0 and eta decays*/){ + findFSRandBrem(*dau,doBrem,ListofFSR,ListofBrem); + } + } + } +} - //if(abs(tauMother(*des)) != 15) continue; - int pid = (*des)->pdg_id(); - //std::cout << " barcode=" << (*des)->barcode() << " pid=" - // << pid << " mom=" << tauMother(*des) << " status=" - // << (*des)->status() << std::endl; - if(abs(pid) == 15) return tauDecayChannel(*des); - if(abs(pid) == 11) eCount++; - if(abs(pid) == 13) muCount++; - if(abs(pid) == 111) pi0Count++; - if(abs(pid) == 211) piCount++; +void TauValidation::FindPhotosFSR(const HepMC::GenParticle* p,std::vector &ListofFSR,double &BosonScale){ + BosonScale=0.0; + const HepMC::GenParticle* m=GetMother(p); + double mother_pid=m->pdg_id(); + if(m->end_vertex() && mother_pid!=p->pdg_id()){ + HepMC::GenVertex::particle_iterator dau; + for (dau = m->end_vertex()->particles_begin(HepMC::children); dau!= m->end_vertex()->particles_end(HepMC::children); dau++ ) { + int dau_pid = (*dau)->pdg_id(); + if(fabs(dau_pid) == 22) { + ListofFSR.push_back(*dau); + } + } + } + if(abs(mother_pid) == 24) BosonScale=1.0; // W + if(abs(mother_pid) == 23) BosonScale=2.0; // Z; + if(abs(mother_pid) == 22) BosonScale=2.0; // gamma; + if(abs(mother_pid) == 25) BosonScale=2.0; // HSM; + if(abs(mother_pid) == 35) BosonScale=2.0; // H0; + if(abs(mother_pid) == 36) BosonScale=2.0; // A0; + if(abs(mother_pid) == 37) BosonScale=1.0; //Hpm; +} - } - } - if(piCount == 1 && pi0Count == 0) channel = pi; - if(piCount == 1 && pi0Count == 1) channel = pi1pi0; - if(piCount == 1 && pi0Count > 1) channel = pinpi0; +int TauValidation::tauMother(const HepMC::GenParticle* tau, double weight){ - if(piCount == 3 && pi0Count == 0) channel = tripi; - if(piCount == 3 && pi0Count > 0) channel = tripinpi0; + if(abs(tau->pdg_id()) != 15 ) return -3; + + int mother_pid = findMother(tau); + if(mother_pid == -2) return -2; + + int label = other; + if(abs(mother_pid) == 24) label = W; + if(abs(mother_pid) == 23) label = Z; + if(abs(mother_pid) == 22) label = gamma; + if(abs(mother_pid) == 25) label = HSM; + if(abs(mother_pid) == 35) label = H0; + if(abs(mother_pid) == 36) label = A0; + if(abs(mother_pid) == 37) label = Hpm; + + int mother_shortpid=(abs(mother_pid)%10000); + if(mother_shortpid>500 && mother_shortpid<600 )label = B; + if(mother_shortpid>400 && mother_shortpid<500)label = D; + TauMothers->Fill(label,weight); + if(label==B || label == D || label == other) return -1; + + return mother_pid; +} - if(eCount == 1) channel = electron; - if(muCount == 1) channel = muon; +int TauValidation::tauProngs(const HepMC::GenParticle* tau, double weight){ + int nProngs = 0; + if ( tau->end_vertex() ) { + HepMC::GenVertex::particle_iterator des; + for(des = tau->end_vertex()->particles_begin(HepMC::descendants); + des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) { + int pid = (*des)->pdg_id(); + if(abs(pid) == 15) return tauProngs(*des, weight); + if((*des)->status() != 1) continue; // dont count unstable particles + + const HepPDT::ParticleData* pd = fPDGTable->particle((*des)->pdg_id ()); + int charge = (int) pd->charge(); + if(charge == 0) continue; + nProngs++; + } + } + TauProngs->Fill(nProngs,weight); + return nProngs; +} - TauDecayChannels->Fill(channel); - return channel; +int TauValidation::tauDecayChannel(const HepMC::GenParticle* tau, double weight){ + + int channel = undetermined; + if(tau->status() == 1) channel = stable; + int allCount = 0, + eCount = 0, + muCount = 0, + pi0Count = 0, + piCount = 0, + rhoCount = 0, + a1Count = 0, + KCount = 0, + KstarCount = 0; + + if ( tau->end_vertex() ) { + HepMC::GenVertex::particle_iterator des; + for(des = tau->end_vertex()->particles_begin(HepMC::descendants); + des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) { + int pid = (*des)->pdg_id(); + if(abs(pid) == 15) return tauDecayChannel(*des,weight); + + allCount++; + if(abs(pid) == 11) eCount++; + if(abs(pid) == 13) muCount++; + if(abs(pid) == 111) pi0Count++; + if(abs(pid) == 211) piCount++; + if(abs(pid) == 213) rhoCount++; + if(abs(pid) == 20213) a1Count++; + if(abs(pid) == 321) KCount++; + if(abs(pid) == 323) KstarCount++; + + } + } + // resonances + if(KCount >= 1) channel = K; + if(KstarCount >= 1) channel = Kstar; + if(a1Count >= 1) channel = a1; + if(rhoCount >= 1) channel = rho; + if(channel!=undetermined && weight!=0.0) TauDecayChannels->Fill(channel,weight); + + // final state products + if(piCount == 1 && pi0Count == 0) channel = pi; + if(piCount == 1 && pi0Count == 1) channel = pi1pi0; + if(piCount == 1 && pi0Count > 1) channel = pinpi0; + if(piCount == 3 && pi0Count == 0) channel = tripi; + if(piCount == 3 && pi0Count > 0) channel = tripinpi0; + if(eCount == 1) channel = electron; + if(muCount == 1) channel = muon; + if(weight!=0.0) TauDecayChannels->Fill(channel,weight); + return channel; } -void TauValidation::rtau(const HepMC::GenParticle* tau,int mother, int decay){ + +void TauValidation::rtau(const HepMC::GenParticle* tau,int mother, int decay, double weight){ if(decay != pi1pi0) return; // polarization only for 1-prong hadronic taus with one neutral pion to make a clean case if(tau->momentum().perp() < tauEtCut) return; // rtau visible only for boosted taus double rTau = 0; - double ltrack = leadingPionMomentum(tau); + double ltrack = leadingPionMomentum(tau, weight); double visibleTauE = visibleTauEnergy(tau); if(visibleTauE != 0) rTau = ltrack/visibleTauE; - if(abs(mother) == 23) TauRtauW->Fill(rTau); - if(abs(mother) == 37) TauRtauHpm->Fill(rTau); + if(abs(mother) == 24) TauRtauW->Fill(rTau,weight); + if(abs(mother) == 37) TauRtauHpm->Fill(rTau,weight); } -void TauValidation::spinEffects(const HepMC::GenParticle* tau,int mother, int decay){ - - if(decay != pi) return; // polarization only for 1-prong hadronic taus with no neutral pions - - TLorentzVector momP4 = motherP4(tau); - TLorentzVector pionP4 = leadingPionP4(tau); +void TauValidation::spinEffects(const HepMC::GenParticle* tau,int mother, int decay, std::vector &part,double weight){ + if(decay == TauDecay::JAK_PION || decay == TauDecay::JAK_MUON || decay == TauDecay::JAK_ELECTRON){ // polarization only for 1-prong hadronic taus with no neutral pions + TLorentzVector momP4 = motherP4(tau); + TLorentzVector pionP4 = leadingPionP4(tau); + pionP4.Boost(-1*momP4.BoostVector()); + double energy = pionP4.E()/(momP4.M()/2); + if(decay == TauDecay::JAK_PION){ + if(abs(mother) == 24) TauSpinEffectsW_X->Fill(energy,weight); + if(abs(mother) == 37) TauSpinEffectsHpm_X->Fill(energy,weight); + } + if(decay == TauDecay::JAK_MUON){ + if(abs(mother) == 24) TauSpinEffectsW_muX->Fill(energy,weight); + if(abs(mother) == 37) TauSpinEffectsHpm_muX->Fill(energy,weight); + } + if(decay == TauDecay::JAK_ELECTRON){ + if(abs(mother) == 24) TauSpinEffectsW_eX->Fill(energy,weight); + if(abs(mother) == 37) TauSpinEffectsHpm_eX->Fill(energy,weight); + } - pionP4.Boost(-1*momP4.BoostVector()); + } + else if(decay==TauDecay::JAK_RHO_PIPI0){ + TLorentzVector rho(0,0,0,0),pi(0,0,0,0); + for(unsigned int i=0;imomentum().px(),part.at(i)->momentum().py(),part.at(i)->momentum().pz(),part.at(i)->momentum().e()); + if(abs(part.at(i)->pdg_id())==PdtPdgMini::pi_plus){pi+=LV; rho+=LV;} + if(abs(part.at(i)->pdg_id())==PdtPdgMini::pi0){rho+=LV;} + } + if(abs(mother) == 24) TauSpinEffectsW_UpsilonRho->Fill(2*pi.Pt()/rho.Pt()-1,weight); + if(abs(mother) == 37) TauSpinEffectsHpm_UpsilonRho->Fill(2*pi.Pt()/rho.Pt()-1,weight); + } + else if(decay==TauDecay::JAK_A1_3PI){ // only for pi2pi0 for now + TLorentzVector a1(0,0,0,0),pi_p(0,0,0,0),pi_m(0,0,0,0); + int nplus(0),nminus(0); + for(unsigned int i=0;imomentum().px(),part.at(i)->momentum().py(),part.at(i)->momentum().pz(),part.at(i)->momentum().e()); + if(part.at(i)->pdg_id()==PdtPdgMini::pi_plus){ pi_p+=LV; a1+=LV; nplus++;} + if(part.at(i)->pdg_id()==PdtPdgMini::pi_minus){pi_m+=LV; a1+=LV; nminus++;} + } + double gamma=0; + if(nplus+nminus==3 && nplus==1) gamma=2*pi_p.Pt()/a1.Pt()-1; + if(nplus+nminus==3 && nminus==1) gamma=2*pi_m.Pt()/a1.Pt()-1; + else{ + pi_p+=pi_m; gamma=2*pi_p.Pt()/a1.Pt()-1; + } + if(abs(mother) == 24) TauSpinEffectsW_UpsilonA1->Fill(gamma,weight); + if(abs(mother) == 37) TauSpinEffectsHpm_UpsilonA1->Fill(gamma,weight); + } +} - double energy = pionP4.E()/(momP4.M()/2); +void TauValidation::spinEffectsZ(const HepMC::GenParticle* boson, double weight){ + + TLorentzVector tautau(0,0,0,0); + TLorentzVector pipi(0,0,0,0); + TLorentzVector taum(0,0,0,0); + int nSinglePionDecays(0),nSingleMuonDecays(0),nSingleElectronDecays(0); + double x1(0),x2(0); + TLorentzVector Zboson(boson->momentum().px(),boson->momentum().py(),boson->momentum().pz(),boson->momentum().e()); + if ( boson->end_vertex() ) { + HepMC::GenVertex::particle_iterator des; + for(des = boson->end_vertex()->particles_begin(HepMC::children); des!= boson->end_vertex()->particles_end(HepMC::children);++des ) { + int pid = (*des)->pdg_id(); + if(abs(findMother(*des)) != 15 && abs(pid) == 15 && (tauDecayChannel(*des) == pi || tauDecayChannel(*des) == muon || tauDecayChannel(*des) == electron )){ + if(tauDecayChannel(*des) == pi)nSinglePionDecays++; + if(tauDecayChannel(*des) == muon)nSingleMuonDecays++; + if(tauDecayChannel(*des) == electron)nSingleElectronDecays++; + TLorentzVector LVtau((*des)->momentum().px(),(*des)->momentum().py(),(*des)->momentum().pz(),(*des)->momentum().e()); + tautau += LVtau; + TLorentzVector LVpi=leadingPionP4(*des); + pipi+=LVpi; + const HepPDT::ParticleData* pd = fPDGTable->particle((*des)->pdg_id ()); + int charge = (int) pd->charge(); + LVtau.Boost(-1*Zboson.BoostVector()); + LVpi.Boost(-1*Zboson.BoostVector()); + if(charge<0){x1=LVpi.P()/LVtau.E(); taum=LVtau;} + else{ x2=LVpi.P()/LVtau.E();} + } + } + } + if(nSingleMuonDecays==2){ + if(abs(boson->pdg_id())==PdtPdgMini::Z0) TauSpinEffectsZ_muX->Fill(x1,weight); + if(abs(boson->pdg_id())==PdtPdgMini::Higgs0) TauSpinEffectsH_muX->Fill(x1,weight); + } + if(nSingleElectronDecays==2){ + if(abs(boson->pdg_id())==PdtPdgMini::Z0) TauSpinEffectsZ_eX->Fill(x1,weight); + if(abs(boson->pdg_id())==PdtPdgMini::Higgs0) TauSpinEffectsH_eX->Fill(x1,weight); + } + if(nSinglePionDecays == 2 && tautau.M()!= 0) { + for(int i=0;ialow && x2-x1pdg_id())==PdtPdgMini::Z0) TauSpinEffectsZ_Zs->Fill(zs,weight); + if(abs(boson->pdg_id())==PdtPdgMini::Higgs0) TauSpinEffectsH_Zs->Fill(zs,weight); + break; + } + } + if(abs(boson->pdg_id())==PdtPdgMini::Z0) TauSpinEffectsZ_MVis->Fill(pipi.M()/tautau.M(),weight); + if(abs(boson->pdg_id())==PdtPdgMini::Higgs0) TauSpinEffectsH_MVis->Fill(pipi.M()/tautau.M(),weight); + + if(x1!=0){ + const std::vector m=GetMothers(boson); + int q(0),qbar(0); + TLorentzVector Z(0,0,0,0); + for(unsigned int i=0;ipdg_id()==PdtPdgMini::d || m.at(i)->pdg_id()==PdtPdgMini::u ){q++;} + if(m.at(i)->pdg_id()==PdtPdgMini::anti_d || m.at(i)->pdg_id()==PdtPdgMini::anti_u ){qbar++;} + } + if(q==1 && qbar==1){// assume q has largest E (valence vs see quarks) + if(taum.Vect().Dot(Zboson.Vect())/(Zboson.P()*taum.P())>0){ + if(abs(boson->pdg_id())==PdtPdgMini::Z0) TauSpinEffectsZ_Xf->Fill(x1,weight); + if(abs(boson->pdg_id())==PdtPdgMini::Higgs0) TauSpinEffectsH_Xf->Fill(x1,weight); + } + else{ + if(abs(boson->pdg_id())==PdtPdgMini::Z0) TauSpinEffectsZ_Xb->Fill(x1,weight); + if(abs(boson->pdg_id())==PdtPdgMini::Higgs0) TauSpinEffectsH_Xb->Fill(x1,weight); + } + } + } + } +} - if(abs(mother) == 23) TauSpinEffectsW->Fill(energy); - if(abs(mother) == 37) TauSpinEffectsHpm->Fill(energy); +double TauValidation::Zstoa(double zs){ + double a=1-sqrt(fabs(1.0-2*fabs(zs))); + if(zs<0){ + a*=-1.0; + } + return a; } -double TauValidation::leadingPionMomentum(const HepMC::GenParticle* tau){ + +double TauValidation::leadingPionMomentum(const HepMC::GenParticle* tau, double weight){ return leadingPionP4(tau).P(); } @@ -268,7 +633,7 @@ TLorentzVector TauValidation::leadingPionP4(const HepMC::GenParticle* tau){ if(abs(pid) == 15) return leadingPionP4(*des); - if(abs(pid) != 211) continue; + if(!(abs(pid)==211 || abs(pid)==13 || abs(pid)==11)) continue; if((*des)->momentum().rho() > p4.P()) { p4 = TLorentzVector((*des)->momentum().px(), @@ -283,23 +648,8 @@ TLorentzVector TauValidation::leadingPionP4(const HepMC::GenParticle* tau){ } TLorentzVector TauValidation::motherP4(const HepMC::GenParticle* tau){ - - TLorentzVector p4(0,0,0,0); - - if ( tau->production_vertex() ) { - HepMC::GenVertex::particle_iterator mother; - for (mother = tau->production_vertex()->particles_begin(HepMC::parents); - mother!= tau->production_vertex()->particles_end(HepMC::parents); ++mother ) { - //mother_pid = (*mother)->pdg_id(); - //std::cout << " parent " << mother_pid << std::endl; - p4 = TLorentzVector((*mother)->momentum().px(), - (*mother)->momentum().py(), - (*mother)->momentum().pz(), - (*mother)->momentum().e()); - } - } - - return p4; + const HepMC::GenParticle* m=GetMother(tau); + return TLorentzVector(m->momentum().px(),m->momentum().py(),m->momentum().pz(),m->momentum().e()); } double TauValidation::visibleTauEnergy(const HepMC::GenParticle* tau){ @@ -328,31 +678,45 @@ double TauValidation::visibleTauEnergy(const HepMC::GenParticle* tau){ return p4.E(); } -void TauValidation::photons(const HepMC::GenParticle* tau){ - - if ( tau->end_vertex() ) { - bool photonFromTau = false; - HepMC::GenVertex::particle_iterator des; - for(des = tau->end_vertex()->particles_begin(HepMC::descendants); - des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) { - int pid = (*des)->pdg_id(); - if(pid == 22) { - photonFromTauPtSum += (*des)->momentum().perp(); - photonFromTau = true; - } - } - nTaus++; - if(photonFromTau) { - tauPtSum += tau->momentum().perp(); - nTausWithPhotons++; - } - - double nFrac = double(nTausWithPhotons)/nTaus; - double ptFrac = 0; - if(tauPtSum > 0) ptFrac = photonFromTauPtSum/tauPtSum; - - TauPhotons->setBinContent(1,nFrac); - TauPhotons->setBinContent(2,ptFrac); - } +void TauValidation::photons(const HepMC::GenParticle* tau, double weight){ + // Find First tau in chain + std::vector TauList; + findTauList(tau,TauList); + + // Get List of Gauge Boson to tau(s) FSR and Brem + bool passedW=false; + std::vector ListofFSR; ListofFSR.clear(); + std::vector ListofBrem; ListofBrem.clear(); + std::vector FSR_photos; FSR_photos.clear(); + double BosonScale(1); + if(TauList.size()>0){ + TauValidation::findFSRandBrem(TauList.at(0),passedW,ListofFSR,ListofBrem); + TauValidation::FindPhotosFSR(TauList.at(0),FSR_photos,BosonScale); + + // Add the Tau Brem. information + TauBremPhotonsN->Fill(ListofBrem.size(),weight); + double photonPtSum=0; + for(unsigned int i=0;imomentum().perp(); + TauBremPhotonsPt->Fill(ListofBrem.at(i)->momentum().perp(),weight); + } + TauBremPhotonsPtSum->Fill(photonPtSum,weight); + + // Now add the Gauge Boson FSR information + if(BosonScale!=0){ + TauFSRPhotonsN->Fill(ListofFSR.size(),weight); + photonPtSum=0; + for(unsigned int i=0;imomentum().perp(); + TauFSRPhotonsPt->Fill(ListofFSR.at(i)->momentum().perp(),weight); + } + double FSR_photosSum(0); + for(unsigned int i=0;imomentum().perp(); + TauFSRPhotonsPt->Fill(FSR_photos.at(i)->momentum().perp()/BosonScale,weight*BosonScale); + } + TauFSRPhotonsPtSum->Fill(photonPtSum+FSR_photosSum/BosonScale,weight); + } + } } diff --git a/Validation/EventGenerator/plugins/VVVValidation.cc b/Validation/EventGenerator/plugins/VVVValidation.cc new file mode 100644 index 0000000000000..a736408ccd65e --- /dev/null +++ b/Validation/EventGenerator/plugins/VVVValidation.cc @@ -0,0 +1,679 @@ + +#include "Validation/EventGenerator/interface/VVVValidation.h" +#include "Validation/EventGenerator/interface/HepMCValidationHelper.h" + + +#include "CLHEP/Units/defs.h" +#include "CLHEP/Units/PhysicalConstants.h" + + +using namespace edm; +using namespace std; + +VVVValidation::VVVValidation(const edm::ParameterSet& iPSet): + _wmanager(iPSet), + hepmcCollection_(iPSet.getParameter("hepmcCollection")), + genparticleCollection_(iPSet.getParameter("genparticleCollection")), + genjetCollection_(iPSet.getParameter("genjetsCollection")), + matchPr_(iPSet.getParameter("matchingPrecision")), + _lepStatus(iPSet.getParameter("lepStatus")), + verbosity_(iPSet.getUntrackedParameter("verbosity",0)) +{ + dbe = 0; + dbe = edm::Service().operator->(); +} + +VVVValidation::~VVVValidation() {} + +void VVVValidation::beginJob() +{ + + + + if(dbe){ + + dbe->setCurrentFolder("Generator/VVVJets"); + + + TH1::SetDefaultSumw2(); + nEvt = dbe->book1D("nEvt", "n analyzed Events", 1, 0., 1.); + + genJetMult = dbe->book1D("genJetMult", "GenJet multiplicity", 50, 0, 50); + genJetEnergy = dbe->book1D("genJetEnergy", "Log10(GenJet energy)", 60, -1, 5); + genJetPt = dbe->book1D("genJetPt", "Log10(GenJet pt)", 60, -1, 5); + genJetEta = dbe->book1D("genJetEta", "GenJet eta", 220, -11, 11); + genJetPhi = dbe->book1D("genJetPhi", "GenJet phi", 360, -180, 180); + genJetDeltaEtaMin = dbe->book1D("genJetDeltaEtaMin", "GenJet minimum rapidity gap", 30, 0, 30); + + genJetPto1 = dbe->book1D("genJetPto1", "GenJet multiplicity above 1 GeV", 50, 0, 50); + genJetPto30 = dbe->book1D("genJetPto30", "GenJet multiplicity above 30 GeV", 10, -0.5, 9.5); + genJetPto50 = dbe->book1D("genJetPto50", "GenJet multiplicity above 50 GeV", 10, -0.5, 9.5); + genJetPto100 = dbe->book1D("genJetPto100", "GenJet multiplicity above 100 GeV", 10, -0.5, 9.5); + genJetCentral = dbe->book1D("genJetCentral", "GenJet multiplicity |eta|.lt.2.5", 10, -0.5, 9.5); + + WW_TwoJEt_JetsM= dbe->book1D("WW_TwoJEt_JetsM", "2 jet invariant mass in WW 2 J events", 200, 0, 2000); + h_l_jet_eta = dbe->book1D("h_l_jet_eta", "leading jet eta", 30, -5.2, 5.2); + h_l_jet_pt = dbe->book1D("h_l_jet_pt", "leading jet pt", 50, 0, 300); + h_sl_jet_eta = dbe->book1D("h_sl_jet_eta", "leading jet eta", 30, -5.2, 5.2); + h_sl_jet_pt = dbe->book1D("h_sl_jet_pt", "leading jet pt", 50, 0, 300); + h_ssl_jet_eta = dbe->book1D("h_ssl_jet_eta", "leading jet eta", 30, -5.2, 5.2); + h_ssl_jet_pt = dbe->book1D("h_ssl_jet_pt", "leading jet pt", 50, 0, 300); + + + genJetTotPt = dbe->book1D("genJetTotPt", "Log10(GenJet total pt)", 100, 0, 1000); + + h_dr = dbe->book1D("h_dr", "DeltaR between leptons and jets", 30, 0, 2); + h_mWplus = dbe->book1D("h_mWplus", "M W^{+}", 50, 0, 200); + h_phiWplus= dbe->book1D("h_phiWplus", "#phi W^{+}", 30, -3.5, 3.5); + h_ptWplus = dbe->book1D("h_ptWplus", "P_{T} W^{+}", 50, 0, 200); + h_yWplus = dbe->book1D("h_yWplus", "Y W^{+}", 30, -3.5, 3.5); + + h_mWminus= dbe->book1D("h_mWminus", "M W^{-}", 50, 0, 200); + h_phiWminus= dbe->book1D("h_phiWminus", "#phi W^{-}", 30, -3.5, 3.5); + h_ptWminus= dbe->book1D("h_ptWminus", "P_{T} W^{-}", 50, 0, 200); + h_yWminus= dbe->book1D("h_yWminus", "Y W^{-}", 30, -3.5, 3.5); + + h_mZ= dbe->book1D("h_mZ", "M Z", 50, 0, 200); + h_phiZ= dbe->book1D("h_phiZ", "#phi Z", 30, -3.5, 3.5); + h_ptZ= dbe->book1D("h_ptZ", "P_{T} Z", 50, 0, 200); + h_yZ= dbe->book1D("h_yZ", "Y Z", 30, -3.5, 3.5); + + h_mWplus_3b = dbe->book1D("h_mWplus_3b", "M W^{+}", 50, 0, 200); + h_phiWplus_3b= dbe->book1D("h_phiWplus_3b", "#phi W^{+}", 30, -3.5, 3.5); + h_ptWplus_3b = dbe->book1D("h_ptWplus_3b", "P_{T} W^{+}", 50, 0, 200); + h_yWplus_3b = dbe->book1D("h_yWplus_3b", "Y W^{+}", 30, -3.5, 3.5); + + h_mWminus_3b= dbe->book1D("h_mWminus_3b", "M W^{-}", 50, 0, 200); + h_phiWminus_3b= dbe->book1D("h_phiWminus_3b", "#phi W^{-}", 30, -3.5, 3.5); + h_ptWminus_3b= dbe->book1D("h_ptWminus_3b", "P_{T} W^{-}", 50, 0, 200); + h_yWminus_3b= dbe->book1D("h_yWminus_3b", "Y W^{-}", 30, -3.5, 3.5); + + h_mZ_3b= dbe->book1D("h_mZ_3b", "M Z", 50, 0, 200); + h_phiZ_3b= dbe->book1D("h_phiZ_3b", "#phi Z", 30, -3.5, 3.5); + h_ptZ_3b= dbe->book1D("h_ptZ_3b", "P_{T} Z", 50, 0, 200); + h_yZ_3b= dbe->book1D("h_yZ_3b", "Y Z", 30, -3.5, 3.5); + + h_mWW= dbe->book1D("h_mWW", "M W^{-}W^{+}", 200, 0, 2000); + h_phiWW= dbe->book1D("h_phiWW", "#phi W^{-}W^{+}", 30, -3.5, 3.5); + h_ptWW= dbe->book1D("h_ptWW", "P_{T} W^{-}W^{+}", 50, 0, 2000); + h_yWW =dbe->book1D("h_yWW", "Y W^{-}W^{+}", 30, -3.5, 3.5); + + h_mWZ= dbe->book1D("h_mWZ", "M W Z", 200, 0, 2000); + h_phiWZ= dbe->book1D("h_phiWZ", "#phi W Z", 30, -3.5, 3.5); + h_ptWZ= dbe->book1D("h_ptWZ", "P_{T} W Z", 50, 0, 2000); + h_yWZ =dbe->book1D("h_yWZ", "Y W Z", 30, -3.5, 3.5); + + h_mZZ= dbe->book1D("h_mZZ", "M Z Z", 200, 0, 2000); + h_phiZZ= dbe->book1D("h_phiZZ", "#phi Z Z", 30, -3.5, 3.5); + h_ptZZ= dbe->book1D("h_ptZZ", "P_{T} Z Z", 50, 0, 2000); + h_yZZ =dbe->book1D("h_yZZ", "Y Z Z", 30, -3.5, 3.5); + + h_mWWW= dbe->book1D("h_mWWW", "M W W W ", 200, 0, 2000); + h_phiWWW= dbe->book1D("h_phiWWW", "#phi W W W", 30, -3.5, 3.5); + h_ptWWW= dbe->book1D("h_ptWWW", "P_{T} W W W", 50, 0, 2000); + h_yWWW =dbe->book1D("h_yWWW", "Y W W W", 30, -3.5, 3.5); + + h_mWWZ= dbe->book1D("h_mWWZ", "M W W Z ", 200, 0, 2000); + h_phiWWZ= dbe->book1D("h_phiWWZ", "#phi W W Z", 30, -3.5, 3.5); + h_ptWWZ= dbe->book1D("h_ptWWZ", "P_{T} W W Z", 50, 0, 2000); + h_yWWZ =dbe->book1D("h_yWWZ", "Y W W Z", 30, -3.5, 3.5); + + h_mWZZ= dbe->book1D("h_mWZZ", "M W Z Z ", 200, 0, 2000); + h_phiWZZ= dbe->book1D("h_phiWZZ", "#phi W Z Z", 30, -3.5, 3.5); + h_ptWZZ= dbe->book1D("h_ptWZZ", "P_{T} W Z Z", 50, 0, 2000); + h_yWZZ =dbe->book1D("h_yWZZ", "Y W Z Z", 30, -3.5, 3.5); + + h_mZZZ= dbe->book1D("h_mZZZ", "M Z Z Z ", 200, 0, 2000); + h_phiZZZ= dbe->book1D("h_phiZZZ", "#phi Z Z Z", 30, -3.5, 3.5); + h_ptZZZ= dbe->book1D("h_ptZZZ", "P_{T} Z Z Z", 50, 0, 2000); + h_yZZZ =dbe->book1D("h_yZZZ", "Y Z Z Z", 30, -3.5, 3.5); + + + + leading_l_pt = dbe->book1D("leading_l_pt", "leading lepton pt", 50, 0, 200); + subleading_l_pt = dbe->book1D("subleading_l_pt", "subleading lepton pt", 50, 0, 200); + subsubleading_l_pt = dbe->book1D("subsubleading_l_pt", "subsubleading lepton pt", 50, 0, 200); + leading_l_eta = dbe->book1D("leading_l_eta", "leading lepton eta", 30, -3.5, 3.5); + subleading_l_eta = dbe->book1D("subleading_l_eta", "subleading lepton eta", 30, -3.5, 3.5); + subsubleading_l_eta = dbe->book1D("subsubleading_l_eta", "subsubleading lepton eta", 30, -3.5, 3.5); + mll= dbe->book1D("mll", "ll mass (all combinations)", 50, 0, 200); + ptll= dbe->book1D("ptll", "ll Transverse Momentum (all combinations)", 50, 0, 200); + mlll= dbe->book1D("mlll", "lll mass ", 50, 0, 200); + ptlll= dbe->book1D("ptlll", "lll Transverse Momentum ", 50, 0, 2000); + mlllnununu= dbe->book1D("mlllnununu", "lll nununu mass ", 50, 0, 2000); + mtlllnununu= dbe->book1D("mtlllnununu", "lll nununu transverse mass ", 50, 0, 2000); + ptlllnununu= dbe->book1D("ptlllnununu", "lll nununu Transverse Momentum ", 50, 0, 2000); + + + } + return; +} + +void VVVValidation::endJob(){return;} +void VVVValidation::beginRun(const edm::Run& iRun,const edm::EventSetup& iSetup) +{ + iSetup.getData( fPDGTable ); + return; +} +void VVVValidation::endRun(const edm::Run& iRun,const edm::EventSetup& iSetup){return;} +void VVVValidation::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup) +{ + + unsigned int initSize = 1000; + + edm::Handle evt; + iEvent.getByLabel(hepmcCollection_, evt); + + HepMC::GenEvent *myGenEvent = new HepMC::GenEvent(*(evt->GetEvent())); + + double weight = _wmanager.weight(iEvent); + + nEvt->Fill(0.5, weight); + + int st_3_leptons=0; + int n_particles=0; + int Wpst3=0; + int Wmst3=0; + int taust3=0; + + std::vector mothercoll; + std::vector GenLeptons; + std::vector GenNeutrinos; + mothercoll.reserve(initSize); + GenLeptons.reserve(initSize); + GenNeutrinos.reserve(initSize); + for (HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin(); iter != myGenEvent->particles_end(); ++iter){ + double id = (*iter)->pdg_id(); + + if((*iter)->status()==3&&(fabs(id)==11 ||fabs(id)==13) && (*iter)->momentum().perp()>20.&& fabs((*iter)->momentum().eta())<2.5){ + st_3_leptons++; + } + if((*iter)->status()==1&&(fabs(id)==16))taust3++; + if((*iter)->status()==3&&(id==24))Wpst3++; + if((*iter)->status()==3&&(id==-24))Wmst3++; + if((*iter)->status()==3&&(fabs(id)==24 || fabs(id)==23)){ + mothercoll.push_back(*iter); + } + + if((*iter)->status()==_lepStatus && (*iter)->momentum().perp()>20.&& fabs((*iter)->momentum().eta())<2.5 ){ + n_particles ++; + if (fabs(id)==11 ||fabs(id)==13){ + GenLeptons.push_back(*iter); + } + if (fabs(id)==12 ||fabs(id)==14){ + GenNeutrinos.push_back(*iter); + } + } + } + + vector wpluss; + vector wmins; + vector z; + wpluss.clear(); + wmins.clear(); + z.clear(); + int Wmin=0; + int Wpl=0; + int Z=0; + int l_bcode[3]; + int nu_bcode[3]; + + + if(taust3>0)return; + + for(unsigned int i = 0 ; i< mothercoll.size();i++){ + double id = mothercoll[i]->pdg_id(); + + //////////////////// + //&&&&W bosons&&&&// + //////////////////// + if(fabs(id)==24){ + double dr_min=999.; + double dr=999.; + for(unsigned int k=0 ; k< GenLeptons.size() ;k++){ + for(unsigned int kl=0 ; kl< GenNeutrinos.size() ;kl++){ + double lepton_px=GenLeptons[k]->momentum().px(); + double lepton_py=GenLeptons[k]->momentum().py(); + double lepton_pz=GenLeptons[k]->momentum().pz(); + double lepton_e=GenLeptons[k]->momentum().e(); + TLorentzVector l; + l.SetPxPyPzE(lepton_px,lepton_py,lepton_pz,lepton_e); + double nu_px=GenNeutrinos[kl]->momentum().px(); + double nu_py=GenNeutrinos[kl]->momentum().py(); + double nu_pz=GenNeutrinos[kl]->momentum().pz(); + double nu_e=GenNeutrinos[kl]->momentum().e(); + TLorentzVector nu; + nu.SetPxPyPzE(nu_px,nu_py,nu_pz,nu_e); + double l_id= GenLeptons[k]->pdg_id(); + double nu_id= GenNeutrinos[kl]->pdg_id(); + dr= deltaR((l+nu).PseudoRapidity(),(l+nu).Phi(),mothercoll[i]->momentum().eta(),mothercoll[i]->momentum().phi()); + if((id*l_id)<0 &&(l_id*nu_id)<0 &&( fabs(nu_id)== (fabs(l_id)+1) )&& dr<0.5/*&& (l+nu).M()>6.*/){ + if(drdr_min)continue; + } + } + } + for(unsigned int k=0 ; k< GenLeptons.size() ;k++){ + for(unsigned int kl=0 ; kl< GenNeutrinos.size() ;kl++){ + double lepton_px=GenLeptons[k]->momentum().px(); + double lepton_py=GenLeptons[k]->momentum().py(); + double lepton_pz=GenLeptons[k]->momentum().pz(); + double lepton_e=GenLeptons[k]->momentum().e(); + TLorentzVector l; + l.SetPxPyPzE(lepton_px,lepton_py,lepton_pz,lepton_e); + double nu_px=GenNeutrinos[kl]->momentum().px(); + double nu_py=GenNeutrinos[kl]->momentum().py(); + double nu_pz=GenNeutrinos[kl]->momentum().pz(); + double nu_e=GenNeutrinos[kl]->momentum().e(); + TLorentzVector nu; + nu.SetPxPyPzE(nu_px,nu_py,nu_pz,nu_e); + double l_id= GenLeptons[k]->pdg_id(); + double nu_id= GenNeutrinos[kl]->pdg_id(); + double der= deltaR((l+nu).PseudoRapidity(),(l+nu).Phi(),mothercoll[i]->momentum().eta(),mothercoll[i]->momentum().phi()); + if((id*l_id)<0 && (l_id*nu_id)<0 &&( fabs(nu_id)== (fabs(l_id)+1) )&& der==dr_min){ + l_bcode[i]=GenLeptons[k]->barcode(); + nu_bcode[i]=GenNeutrinos[kl]->barcode(); + if((i==0)|| (i==1 && (l_bcode[i]!=l_bcode[i-1]) && (nu_bcode[i]!=nu_bcode[i-1]) )|| + (i==2 && (l_bcode[i]!=l_bcode[i-1]) && (nu_bcode[i]!=nu_bcode[i-1]) && (l_bcode[i]!=l_bcode[i-2]) && (nu_bcode[i]!=nu_bcode[i-2]) ) + ){ + if(id==24){ + Wpl++; + wpluss.push_back((l+nu)); + h_mWplus->Fill((l+nu).M(),weight); + h_phiWplus->Fill((l+nu).Phi(),weight); + h_ptWplus->Fill((l+nu).Pt(),weight); + h_yWplus->Fill((l+nu).Rapidity(),weight); + } + if(id==-24){ + Wmin++; + wmins.push_back((l+nu)); + h_mWminus->Fill((l+nu).M(),weight); + h_phiWminus->Fill((l+nu).Phi(),weight); + h_ptWminus->Fill((l+nu).Pt(),weight); + h_yWminus->Fill((l+nu).Rapidity(),weight); + } + } + } + } + } + } + + //////////////////// + //&&&&Z bosons&&&&// + //////////////////// + if(fabs(id)==23){ + double dr_min=999.; + double dr=999.; + for(unsigned int k=0 ; k< GenLeptons.size() ;k++){ + for(unsigned int kl=k ; kl< GenLeptons.size() ;kl++){ + if(k==kl)continue; + double lepton_px=GenLeptons[k]->momentum().px(); + double lepton_py=GenLeptons[k]->momentum().py(); + double lepton_pz=GenLeptons[k]->momentum().pz(); + double lepton_e=GenLeptons[k]->momentum().e(); + TLorentzVector l; + l.SetPxPyPzE(lepton_px,lepton_py,lepton_pz,lepton_e); + double nu_px=GenLeptons[kl]->momentum().px(); + double nu_py=GenLeptons[kl]->momentum().py(); + double nu_pz=GenLeptons[kl]->momentum().pz(); + double nu_e=GenLeptons[kl]->momentum().e(); + TLorentzVector nu; + nu.SetPxPyPzE(nu_px,nu_py,nu_pz,nu_e); + double l_id= GenLeptons[k]->pdg_id(); + double nu_id= GenLeptons[kl]->pdg_id(); + dr= deltaR((l+nu).PseudoRapidity(),(l+nu).Phi(),mothercoll[i]->momentum().eta(),mothercoll[i]->momentum().phi()); + if((l_id*nu_id)<0 &&( fabs(nu_id)== (fabs(l_id)) && dr<0.5)/*&& (l+nu).M()>6.*/){ + if(drdr_min)continue; + } + } + } + for(unsigned int k=0 ; k< GenLeptons.size() ;k++){ + for(unsigned int kl=k ; kl< GenLeptons.size() ;kl++){ + if(k==kl)continue; + double lepton_px=GenLeptons[k]->momentum().px(); + double lepton_py=GenLeptons[k]->momentum().py(); + double lepton_pz=GenLeptons[k]->momentum().pz(); + double lepton_e=GenLeptons[k]->momentum().e(); + TLorentzVector l; + l.SetPxPyPzE(lepton_px,lepton_py,lepton_pz,lepton_e); + double nu_px=GenLeptons[kl]->momentum().px(); + double nu_py=GenLeptons[kl]->momentum().py(); + double nu_pz=GenLeptons[kl]->momentum().pz(); + double nu_e=GenLeptons[kl]->momentum().e(); + TLorentzVector nu; + nu.SetPxPyPzE(nu_px,nu_py,nu_pz,nu_e); + double l_id= GenLeptons[k]->pdg_id(); + double nu_id= GenLeptons[kl]->pdg_id(); + double der= deltaR((l+nu).PseudoRapidity(),(l+nu).Phi(),mothercoll[i]->momentum().eta(),mothercoll[i]->momentum().phi()); + if((l_id*nu_id)<0 &&( fabs(nu_id)== (fabs(l_id)) )&& der==dr_min ){ + l_bcode[i]=GenLeptons[k]->barcode(); + nu_bcode[i]=GenLeptons[kl]->barcode(); + if((i==0)|| (i==1 && (l_bcode[i]!=l_bcode[i-1]) && (nu_bcode[i]!=nu_bcode[i-1]) )|| + (i==2 && (l_bcode[i]!=l_bcode[i-1]) && (nu_bcode[i]!=nu_bcode[i-1]) && (l_bcode[i]!=l_bcode[i-2]) && (nu_bcode[i]!=nu_bcode[i-2]) ) + ){ + Z++; + z.push_back((l+nu)); + h_mZ->Fill((l+nu).M(),weight); + h_phiZ->Fill((l+nu).Phi(),weight); + h_ptZ->Fill((l+nu).Pt(),weight); + h_yZ->Fill((l+nu).Rapidity(),weight); + } + } + } + } + } + } + + + if((Wmin+Wpl)>3) cout<<"3ten fazla W adayı?!?"<Fill(wmins[i].M(),weight); + h_phiWminus_3b->Fill(wmins[i].Phi(),weight); + h_ptWminus_3b->Fill(wmins[i].Pt(),weight); + h_yWminus_3b->Fill(wmins[i].Rapidity(),weight); + } + for(unsigned int i=0; iFill(wpluss[i].M(),weight); + h_phiWplus_3b->Fill(wpluss[i].Phi(),weight); + h_ptWplus_3b->Fill(wpluss[i].Pt(),weight); + h_yWplus_3b->Fill(wpluss[i].Rapidity(),weight); + } + for(unsigned int i=0; iFill(z[i].M(),weight); + h_phiZ_3b->Fill(z[i].Phi(),weight); + h_ptZ_3b->Fill(z[i].Pt(),weight); + h_yZ_3b->Fill(z[i].Rapidity(),weight); + } + + if((Wmin+Wpl)==3){ + TLorentzVector W1; + TLorentzVector W2; + TLorentzVector W3; + if(Wmin==2 && Wpl==1){ + W1=wmins[0]; + W2=wmins[1]; + W3=wpluss[0]; + } + if(Wmin==1 && Wpl==2){ + W1=wmins[0]; + W2=wpluss[0]; + W3=wpluss[1]; + } + if(W1.M()<10. ||W2.M()<10.||W3.M()<10.)cout<Fill((W1+W2+W3).M(),weight); + h_phiWWW->Fill((W1+W2+W3).Phi(),weight); + h_ptWWW->Fill((W1+W2+W3).Pt(),weight); + h_yWWW->Fill((W1+W2+W3).Rapidity(),weight); + + h_mWW->Fill((W1+W2).M(),weight); + h_mWW->Fill((W1+W3).M(),weight); + h_mWW->Fill((W2+W3).M(),weight); + + h_phiWW->Fill((W1+W2).Phi(),weight); + h_phiWW->Fill((W1+W3).Phi(),weight); + h_phiWW->Fill((W2+W3).Phi(),weight); + + h_ptWW->Fill((W1+W2).Pt(),weight); + h_ptWW->Fill((W1+W3).Pt(),weight); + h_ptWW->Fill((W2+W3).Pt(),weight); + + h_yWW->Fill((W1+W2).Rapidity(),weight); + h_yWW->Fill((W1+W3).Rapidity(),weight); + h_yWW->Fill((W2+W3).Rapidity(),weight); + + + } + if((Wmin+Wpl)==2 && Z==1){ + TLorentzVector W1; + TLorentzVector W2; + TLorentzVector Z1; + Z1=z[0]; + if(Wmin==1 &&Wpl==1){ + W1=wmins[0]; + W2=wpluss[0]; + } + if(Wmin==2 &&Wpl==0){ + W1=wmins[0]; + W2=wmins[1]; + } + if(Wmin==0 &&Wpl==2){ + W1=wpluss[0]; + W2=wpluss[1]; + } + h_mWW->Fill((W1+W2).M(),weight); + h_phiWW->Fill((W1+W2).Phi(),weight); + h_ptWW->Fill((W1+W2).Pt(),weight); + h_yWW->Fill((W1+W2).Rapidity(),weight); + + h_mWZ->Fill((W1+Z1).M(),weight); + h_mWZ->Fill((W2+Z1).M(),weight); + + h_phiWZ->Fill((W1+Z1).Phi(),weight); + h_phiWZ->Fill((W2+Z1).Phi(),weight); + + h_ptWZ->Fill((W1+Z1).Pt(),weight); + h_ptWZ->Fill((W2+Z1).Pt(),weight); + + h_yWZ->Fill((W1+Z1).Rapidity(),weight); + h_yWZ->Fill((W2+Z1).Rapidity(),weight); + + h_mWWZ->Fill((W1+W2+Z1).M(),weight); + h_phiWWZ->Fill((W1+W2+Z1).Phi(),weight); + + h_ptWWZ->Fill((W1+W2+Z1).Pt(),weight); + h_yWWZ->Fill((W1+W2+Z1).Rapidity(),weight); + + + } + + if((Wmin+Wpl)==1 && Z==2){ + TLorentzVector Z1; + TLorentzVector Z2; + TLorentzVector W1; + Z1=z[0]; + Z2=z[1]; + if(Wmin==1){ + W1=wmins[0]; + } + if(Wpl==1){ + W1=wpluss[0]; + } + h_mZZ->Fill((Z1+Z2).M(),weight); + h_phiZZ->Fill((Z1+Z2).Phi(),weight); + h_ptZZ->Fill((Z1+Z2).Pt(),weight); + h_yZZ->Fill((Z1+Z2).Rapidity(),weight); + + h_mWZ->Fill((W1+Z1).M(),weight); + h_mWZ->Fill((W1+Z2).M(),weight); + + h_phiWZ->Fill((W1+Z1).Phi(),weight); + h_phiWZ->Fill((W1+Z2).Phi(),weight); + + h_ptWZ->Fill((W1+Z1).Pt(),weight); + h_ptWZ->Fill((W1+Z2).Pt(),weight); + + h_yWZ->Fill((W1+Z1).Rapidity(),weight); + h_yWZ->Fill((W1+Z2).Rapidity(),weight); + + h_mWZZ->Fill((Z1+Z2+W1).M(),weight); + h_phiWZZ->Fill((Z1+Z2+W1).Phi(),weight); + h_ptWZZ->Fill((Z1+Z2+W1).Pt(),weight); + h_yWZZ->Fill((Z1+Z2+W1).Rapidity(),weight); + + + } + + if(Z==3){ + TLorentzVector Z1; + TLorentzVector Z2; + TLorentzVector Z3; + + Z1=z[0]; + Z2=z[1]; + Z3=z[2]; + + if(Z1.M()<10. ||Z2.M()<10.||Z3.M()<10.)cout<Fill((Z1+Z2+Z3).M(),weight); + h_phiZZZ->Fill((Z1+Z2+Z3).Phi(),weight); + h_ptZZZ->Fill((Z1+Z2+Z3).Pt(),weight); + h_yZZZ->Fill((Z1+Z2+Z3).Rapidity(),weight); + + h_mZZ->Fill((Z1+Z2).M(),weight); + h_mZZ->Fill((Z1+Z3).M(),weight); + h_mZZ->Fill((Z2+Z3).M(),weight); + + h_phiZZ->Fill((Z1+Z2).Phi(),weight); + h_phiZZ->Fill((Z1+Z3).Phi(),weight); + h_phiZZ->Fill((Z2+Z3).Phi(),weight); + + h_ptZZ->Fill((Z1+Z2).Pt(),weight); + h_ptZZ->Fill((Z1+Z3).Pt(),weight); + h_ptZZ->Fill((Z2+Z3).Pt(),weight); + + h_yZZ->Fill((Z1+Z2).Rapidity(),weight); + h_yZZ->Fill((Z1+Z3).Rapidity(),weight); + h_yZZ->Fill((Z2+Z3).Rapidity(),weight); + + } + + + + edm::Handle genJets; + iEvent.getByLabel(genjetCollection_, genJets ); + + std::vector selected_jets; + selected_jets.reserve(initSize); + + int nJets = 0; + int nJetso1 = 0; + int nJetso30 = 0; + int nJetso50 = 0; + int nJetso100 = 0; + int nJetsCentral = 0; + double totPt = 0.; + double dr=99.; + std::vector jetEta; + jetEta.reserve(initSize); + for (reco::GenJetCollection::const_iterator iter=genJets->begin();iter!=genJets->end();++iter){ + dr=0; + bool matched_lepton=false; + for(unsigned int i=0 ; i< GenLeptons.size() ;i++){ + dr= deltaR(GenLeptons[i]->momentum().eta(),GenLeptons[i]->momentum().phi(),(*iter).eta(),(*iter).phi()); + h_dr->Fill(dr,weight); + if(dr<0.5)matched_lepton=true; + } + if(matched_lepton)continue; + selected_jets.push_back(&*iter); + nJets++; + double pt = (*iter).pt(); + totPt += pt; + if (pt > 1.) nJetso1++; + double eta = (*iter).eta(); + if (std::fabs(eta) < 5.&&pt > 30.) nJetso30++; + if (std::fabs(eta) < 5.&&pt > 50.) nJetso50++; + if (std::fabs(eta) < 5.&&pt > 100.) nJetso100++; + if ( std::fabs(eta) < 2.5 ) nJetsCentral++; + jetEta.push_back(eta); + + genJetEnergy->Fill(std::log10((*iter).energy()),weight); + genJetPt->Fill(std::log10(pt),weight); + genJetEta->Fill(eta,weight); + genJetPhi->Fill((*iter).phi()/CLHEP::degree,weight); + } + if(nJetso30==2){ + + TLorentzVector j1; + TLorentzVector j2; + j1.SetPtEtaPhiE(selected_jets[0]->pt(),selected_jets[0]->eta(),selected_jets[0]->phi(),selected_jets[0]->energy()); + j2.SetPtEtaPhiE(selected_jets[1]->pt(),selected_jets[1]->eta(),selected_jets[1]->phi(),selected_jets[1]->energy()); + WW_TwoJEt_JetsM->Fill((j1+j2).M(),weight); + } + if(nJetso30>0)h_l_jet_eta->Fill(selected_jets[0]->eta()); + if(nJetso30>0)h_l_jet_pt->Fill(selected_jets[0]->pt()); + if(nJetso30>1)h_sl_jet_eta->Fill(selected_jets[1]->eta()); + if(nJetso30>1)h_sl_jet_pt->Fill(selected_jets[1]->pt()); + if(nJetso30>2)h_ssl_jet_eta->Fill(selected_jets[2]->eta()); + if(nJetso30>2)h_ssl_jet_pt->Fill(selected_jets[2]->pt()); + + genJetMult->Fill(nJets,weight); + genJetPto1->Fill(nJetso1,weight); + genJetPto30->Fill(nJetso30,weight); + genJetPto50->Fill(nJetso50,weight); + genJetPto100->Fill(nJetso100,weight); + genJetCentral->Fill(nJetsCentral,weight); + + genJetTotPt->Fill(totPt,weight); + + double deltaEta = 999.; + if ( jetEta.size() > 1 ) { + for (unsigned int i = 0; i < jetEta.size(); i++){ + for (unsigned int j = i+1; j < jetEta.size(); j++){ + deltaEta = std::min(deltaEta,std::fabs(jetEta[i]-jetEta[j])); + } + } + } + + genJetDeltaEtaMin->Fill(deltaEta,weight); + } + + if(GenLeptons.size()>0 && GenNeutrinos.size()>0 ){ + std::sort(GenLeptons.begin(), GenLeptons.end(), HepMCValidationHelper::sortByPt); + std::sort(GenNeutrinos.begin(), GenNeutrinos.end(), HepMCValidationHelper::sortByPt); + if(GenLeptons.size()>0) leading_l_pt->Fill(GenLeptons[0]->momentum().perp(),weight); + if(GenLeptons.size()>1) subleading_l_pt->Fill(GenLeptons[1]->momentum().perp(),weight); + if(GenLeptons.size()>2) subsubleading_l_pt->Fill(GenLeptons[2]->momentum().perp(),weight); + if(GenLeptons.size()>0) leading_l_eta->Fill(GenLeptons[0]->momentum().eta(),weight); + if(GenLeptons.size()>1) subleading_l_eta->Fill(GenLeptons[1]->momentum().eta(),weight); + if(GenLeptons.size()>2) subsubleading_l_eta->Fill(GenLeptons[2]->momentum().eta(),weight); + } + if(GenLeptons.size()>1 ){ + for(unsigned int i = 0; imomentum().x(), GenLeptons[i]->momentum().y(), GenLeptons[i]->momentum().z(), GenLeptons[i]->momentum().t()); + TLorentzVector lep2(GenLeptons[j]->momentum().x(), GenLeptons[j]->momentum().y(), GenLeptons[j]->momentum().z(), GenLeptons[j]->momentum().t()); + mll->Fill((lep1+lep2).M(),weight); + ptll->Fill((lep1+lep2).Pt(),weight); + } + } + } + if(GenLeptons.size()>2 && GenNeutrinos.size()>2 ){ + TLorentzVector lep1(GenLeptons[0]->momentum().x(), GenLeptons[0]->momentum().y(), GenLeptons[0]->momentum().z(), GenLeptons[0]->momentum().t()); + TLorentzVector lep2(GenLeptons[1]->momentum().x(), GenLeptons[1]->momentum().y(), GenLeptons[1]->momentum().z(), GenLeptons[1]->momentum().t()); + TLorentzVector lep3(GenLeptons[2]->momentum().x(), GenLeptons[2]->momentum().y(), GenLeptons[2]->momentum().z(), GenLeptons[2]->momentum().t()); + TLorentzVector nu1(GenNeutrinos[0]->momentum().x(), GenNeutrinos[0]->momentum().y(), GenNeutrinos[0]->momentum().z(), GenNeutrinos[0]->momentum().t()); + TLorentzVector nu2(GenNeutrinos[1]->momentum().x(), GenNeutrinos[1]->momentum().y(), GenNeutrinos[1]->momentum().z(), GenNeutrinos[1]->momentum().t()); + TLorentzVector nu3(GenNeutrinos[2]->momentum().x(), GenNeutrinos[2]->momentum().y(), GenNeutrinos[2]->momentum().z(), GenNeutrinos[2]->momentum().t()); + mlll->Fill((lep1+lep2+lep3).M(),weight); + ptlll->Fill((lep1+lep2+lep3).Pt(),weight); + mlllnununu->Fill((lep1+lep2+lep3+nu1+nu2+nu3).M(),weight); + mtlllnununu->Fill((lep1+lep2+lep3+nu1+nu2+nu3).Mt(),weight); + ptlllnununu->Fill((lep1+lep2+lep3+nu1+nu2+nu3).Pt(),weight); + + } + + delete myGenEvent; +} +int VVVValidation::getParentBarcode(HepMC::GenParticle* it) +{ + int id = 0; + if ( (it)->production_vertex() && (it)-> status()==3) { + for ( HepMC::GenVertex::particle_iterator mother + = (it)->production_vertex()->particles_begin(HepMC::parents);mother != (it)->production_vertex()->particles_end(HepMC::parents); ++mother ) { + + if((fabs((*mother)->pdg_id())==24)) id = (*mother)->barcode(); + } + } + return id; +} +#include "FWCore/PluginManager/interface/ModuleDef.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +DEFINE_FWK_MODULE (VVVValidation); + diff --git a/Validation/EventGenerator/plugins/WValidation.cc b/Validation/EventGenerator/plugins/WValidation.cc index 73964dea019dc..44e5383fde575 100644 --- a/Validation/EventGenerator/plugins/WValidation.cc +++ b/Validation/EventGenerator/plugins/WValidation.cc @@ -17,7 +17,8 @@ using namespace edm; -WValidation::WValidation(const edm::ParameterSet& iPSet): +WValidation::WValidation(const edm::ParameterSet& iPSet): + _wmanager(iPSet), hepmcCollection_(iPSet.getParameter("hepmcCollection")), _flavor(iPSet.getParameter("decaysTo")), _name(iPSet.getParameter("name")) @@ -83,7 +84,9 @@ void WValidation::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup //Get EVENT const HepMC::GenEvent *myGenEvent = evt->GetEvent(); - nEvt->Fill(0.5); + double weight = _wmanager.weight(iEvent); + + nEvt->Fill(0.5,weight); std::vector allleptons; std::vector allneutrinos; @@ -126,8 +129,8 @@ void WValidation::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup std::vector fsrphotons; HepMCValidationHelper::findFSRPhotons(selectedLepton, myGenEvent, 0.1, fsrphotons); - Wdaughters->Fill(allleptons.front()->pdg_id()); - Wdaughters->Fill(allneutrinos.front()->pdg_id()); + Wdaughters->Fill(allleptons.front()->pdg_id(),weight); + Wdaughters->Fill(allneutrinos.front()->pdg_id(),weight); //assemble FourMomenta TLorentzVector lep1(allleptons[0]->momentum().x(), allleptons[0]->momentum().y(), allleptons[0]->momentum().z(), allleptons[0]->momentum().t()); @@ -138,29 +141,29 @@ void WValidation::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup for (unsigned int ipho = 0; ipho < fsrphotons.size(); ++ipho){ TLorentzVector phomom(fsrphotons[ipho]->momentum().x(), fsrphotons[ipho]->momentum().y(), fsrphotons[ipho]->momentum().z(), fsrphotons[ipho]->momentum().t()); dilepton_andphoton_mom += phomom; - Wdaughters->Fill(fsrphotons[ipho]->pdg_id()); + Wdaughters->Fill(fsrphotons[ipho]->pdg_id(),weight); gammasMomenta.push_back(phomom); } //Fill "true" W histograms - Wmass->Fill(dilepton_andphoton_mom.M()); - WmassPeak->Fill(dilepton_andphoton_mom.M()); - Wpt->Fill(dilepton_andphoton_mom.Pt()); - WptLog->Fill(log10(dilepton_andphoton_mom.Pt())); - Wrap->Fill(dilepton_andphoton_mom.Rapidity()); + Wmass->Fill(dilepton_andphoton_mom.M(),weight); + WmassPeak->Fill(dilepton_andphoton_mom.M(),weight); + Wpt->Fill(dilepton_andphoton_mom.Pt(),weight); + WptLog->Fill(log10(dilepton_andphoton_mom.Pt()),weight); + Wrap->Fill(dilepton_andphoton_mom.Rapidity(),weight); TLorentzVector met_mom = HepMCValidationHelper::genMet(myGenEvent, -3., 3.); TLorentzVector lep1T(lep1.Px(), lep1.Py(), 0., lep1.Et()); TLorentzVector lepmet_mom = lep1T + met_mom; //Fill lepmet histograms - lepmet_mT->Fill(lepmet_mom.M()); - lepmet_mTPeak->Fill(lepmet_mom.M()); - lepmet_pt->Fill(lepmet_mom.Pt()); - lepmet_ptLog->Fill(log10(lepmet_mom.Pt())); + lepmet_mT->Fill(lepmet_mom.M(),weight); + lepmet_mTPeak->Fill(lepmet_mom.M(),weight); + lepmet_pt->Fill(lepmet_mom.Pt(),weight); + lepmet_ptLog->Fill(log10(lepmet_mom.Pt()),weight); //Fill lepton histograms - leppt->Fill(lep1.Pt()); - lepeta->Fill(lep1.Eta()); - met->Fill(met_mom.Pt()); + leppt->Fill(lep1.Pt(),weight); + lepeta->Fill(lep1.Eta(),weight); + met->Fill(met_mom.Pt(),weight); //boost everything in the W frame TVector3 boost = dilepton_andphoton_mom.BoostVector(); @@ -174,9 +177,9 @@ void WValidation::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup //fill gamma histograms if (gammasMomenta.size() != 0 && dilepton_andphoton_mom.M() > 50.) { - gamma_energy->Fill(gammasMomenta.front().E()); + gamma_energy->Fill(gammasMomenta.front().E(),weight); double dphi = lep1.DeltaR(gammasMomenta.front()); - cos_theta_gamma_lepton->Fill(cos(dphi)); + cos_theta_gamma_lepton->Fill(cos(dphi),weight); } diff --git a/Validation/EventGenerator/python/BasicGenParticleValidation_cfi.py b/Validation/EventGenerator/python/BasicGenParticleValidation_cfi.py index 8872aea8505e6..80dae4df692f2 100644 --- a/Validation/EventGenerator/python/BasicGenParticleValidation_cfi.py +++ b/Validation/EventGenerator/python/BasicGenParticleValidation_cfi.py @@ -5,5 +5,6 @@ genparticleCollection = cms.InputTag("genParticles",""), genjetsCollection = cms.InputTag("ak5GenJets",""), matchingPrecision = cms.double(0.001), - verbosity = cms.untracked.uint32(0) + verbosity = cms.untracked.uint32(0), + UseWeightFromHepMC = cms.bool(True) ) diff --git a/Validation/EventGenerator/python/BasicGenValidation_cff.py b/Validation/EventGenerator/python/BasicGenValidation_cff.py index c34a5c820f8a3..4479faa2da95e 100644 --- a/Validation/EventGenerator/python/BasicGenValidation_cff.py +++ b/Validation/EventGenerator/python/BasicGenValidation_cff.py @@ -2,6 +2,7 @@ # Basic HepMC/GenParticle/GenJet validation modules from Validation.EventGenerator.BasicHepMCValidation_cfi import * +from Validation.EventGenerator.BasicHepMCHeavyIonValidation_cfi import * from Validation.EventGenerator.BasicGenParticleValidation_cfi import * # Analyzer for MB/UE studies @@ -19,13 +20,23 @@ # simple analyzer for tau decays validation from Validation.EventGenerator.TauValidation_cfi import * +#TTbar Analyzer +from Validation.EventGenerator.TTbar_Validation_cfi import * + + +#Higgs +from Validation.EventGenerator.HiggsValidation_cfi import * + # define sequences... -basicGenTest_seq = cms.Sequence(basicHepMCValidation+basicGenParticleValidation) +basicGenTest_seq = cms.Sequence(basicHepMCValidation+basicHepMCHeavyIonValidation+basicGenParticleValidation) duplicationChecker_seq = cms.Sequence(duplicationChecker) mbueAndqcdValidation_seq = cms.Sequence(mbueAndqcd_seq) drellYanValidation_seq = cms.Sequence(drellYanEleValidation+drellYanMuoValidation) wValidation_seq = cms.Sequence(wEleValidation+wMuoValidation) tauValidation_seq = cms.Sequence(tauValidation) +genLeptons_seq = cms.Sequence(genParticlesShortList*genParticlesMuons*genParticlesElectrons*genParticlesNeutrinos) +analyzeGenLeptons_seq = cms.Sequence(analyzeGenMuons*analyzeGenElecs*analyzeGenNtrns) +TTbarfull_seq = cms.Sequence(TTbarAnalyzeSpinCorr*makeGenEvt*analyzeTopKinematics*genLeptons_seq*analyzeGenLeptons_seq*analyzeGenJets) # master sequences for different processes/topologies validation @@ -33,3 +44,5 @@ genvalid_qcd = cms.Sequence(basicGenTest_seq+mbueAndqcdValidation_seq) genvalid_dy = cms.Sequence(basicGenTest_seq+mbueAndqcdValidation_seq+drellYanValidation_seq+tauValidation_seq) genvalid_w = cms.Sequence(basicGenTest_seq+mbueAndqcdValidation_seq+wValidation_seq+tauValidation_seq) +genvalid_all = cms.Sequence(basicGenTest_seq+mbueAndqcdValidation_seq+drellYanValidation_seq+wValidation_seq+tauValidation_seq+TTbarfull_seq+higgsValidation) +genvalid_all_and_dup_check = cms.Sequence(duplicationChecker_seq+genvalid_all) diff --git a/Validation/EventGenerator/python/BasicHepMCHeavyIonValidation_cfi.py b/Validation/EventGenerator/python/BasicHepMCHeavyIonValidation_cfi.py new file mode 100644 index 0000000000000..5522d5d83b1ab --- /dev/null +++ b/Validation/EventGenerator/python/BasicHepMCHeavyIonValidation_cfi.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +basicHepMCHeavyIonValidation = cms.EDAnalyzer("BasicHepMCHeavyIonValidation", + hepmcCollection = cms.InputTag("generator",""), + UseWeightFromHepMC = cms.bool(True) +) diff --git a/Validation/EventGenerator/python/BasicHepMCValidation_cfi.py b/Validation/EventGenerator/python/BasicHepMCValidation_cfi.py index 5710ae230ff63..3aef3edc684d9 100644 --- a/Validation/EventGenerator/python/BasicHepMCValidation_cfi.py +++ b/Validation/EventGenerator/python/BasicHepMCValidation_cfi.py @@ -1,5 +1,6 @@ import FWCore.ParameterSet.Config as cms basicHepMCValidation = cms.EDAnalyzer("BasicHepMCValidation", - hepmcCollection = cms.InputTag("generator","") + hepmcCollection = cms.InputTag("generator",""), + UseWeightFromHepMC = cms.bool(True) ) diff --git a/Validation/EventGenerator/python/DrellYanValidation_cfi.py b/Validation/EventGenerator/python/DrellYanValidation_cfi.py index ba5cda44445fc..8418af49ae1ef 100644 --- a/Validation/EventGenerator/python/DrellYanValidation_cfi.py +++ b/Validation/EventGenerator/python/DrellYanValidation_cfi.py @@ -3,5 +3,6 @@ drellYanValidation = cms.EDAnalyzer("DrellYanValidation", hepmcCollection = cms.InputTag("generator",""), decaysTo = cms.int32(11), - name = cms.string("Electrons") + name = cms.string("Electrons"), + UseWeightFromHepMC = cms.bool(True) ) diff --git a/Validation/EventGenerator/python/DuplicationChecker_cfi.py b/Validation/EventGenerator/python/DuplicationChecker_cfi.py index e7453454651dc..19b7c50310488 100644 --- a/Validation/EventGenerator/python/DuplicationChecker_cfi.py +++ b/Validation/EventGenerator/python/DuplicationChecker_cfi.py @@ -1,6 +1,7 @@ import FWCore.ParameterSet.Config as cms duplicationChecker = cms.EDAnalyzer("DuplicationChecker", - generatedCollection = cms.InputTag("generator",""), - searchForLHE = cms.bool(False) + hepmcCollection = cms.InputTag("generator",""), + searchForLHE = cms.bool(False), + UseWeightFromHepMC = cms.bool(True) ) diff --git a/Validation/EventGenerator/python/HiggsValidation_cfi.py b/Validation/EventGenerator/python/HiggsValidation_cfi.py new file mode 100644 index 0000000000000..1ec21f23a12c3 --- /dev/null +++ b/Validation/EventGenerator/python/HiggsValidation_cfi.py @@ -0,0 +1,22 @@ +import FWCore.ParameterSet.Config as cms + +Z0testValidation = cms.EDAnalyzer("HiggsValidation", + hepmcCollection = cms.InputTag("generator",""), + pdg_id = cms.int32(25), + particleName = cms.string("Higgs"), + monitorDecays = cms.vstring("tau+tau","mu+mu","e+e","b+b","gamma+gamma","W+W","Z+Z"), + UseWeightFromHepMC = cms.bool(True) +) + +hplusValidation = cms.EDAnalyzer("HiggsValidation", + hepmcCollection = cms.InputTag("generator",""), + pdg_id = cms.int32(37), + particleName = cms.string("Hplus"), + monitorDecays = cms.vstring("tau+taunu","mu+munu","e+enu","t+b","c+s"), + UseWeightFromHepMC = cms.bool(True) +) + +higgsValidation = cms.Sequence( + Z0testValidation* + hplusValidation +) diff --git a/Validation/EventGenerator/python/MBUEandQCDValidation_cff.py b/Validation/EventGenerator/python/MBUEandQCDValidation_cff.py index 806ad4e7749f8..3ae82b630c1ec 100644 --- a/Validation/EventGenerator/python/MBUEandQCDValidation_cff.py +++ b/Validation/EventGenerator/python/MBUEandQCDValidation_cff.py @@ -12,4 +12,4 @@ chargedak5GenJets = ak5GenJets.clone( src = cms.InputTag("chargedParticles") ) -mbueAndqcd_seq = cms.Sequence(chargedParticles*chargedak5GenJets*mbueAndqcdValidation) +mbueAndqcd_seq = cms.Sequence(cms.ignore(chargedParticles)*chargedak5GenJets*mbueAndqcdValidation) diff --git a/Validation/EventGenerator/python/MBUEandQCDValidation_cfi.py b/Validation/EventGenerator/python/MBUEandQCDValidation_cfi.py index 9223839bc0433..c3242a43679d3 100644 --- a/Validation/EventGenerator/python/MBUEandQCDValidation_cfi.py +++ b/Validation/EventGenerator/python/MBUEandQCDValidation_cfi.py @@ -4,5 +4,6 @@ hepmcCollection = cms.InputTag("generator",""), genChjetsCollection = cms.InputTag("chargedak5GenJets",""), genjetsCollection = cms.InputTag("ak5GenJets",""), - verbosity = cms.untracked.uint32(0) + verbosity = cms.untracked.uint32(0), + UseWeightFromHepMC = cms.bool(True) ) diff --git a/Validation/EventGenerator/python/PostProcessor_cff.py b/Validation/EventGenerator/python/PostProcessor_cff.py index 7ae306bce0658..ae623887a6d4a 100755 --- a/Validation/EventGenerator/python/PostProcessor_cff.py +++ b/Validation/EventGenerator/python/PostProcessor_cff.py @@ -18,6 +18,7 @@ "bbarNumber nEvt", "tbarNumber nEvt", "eminusNumber nEvt", + "partonNumber nEvt", "nueNumber nEvt", "muminusNumber nEvt", "numuNumber nEvt", @@ -80,6 +81,7 @@ "tauplusMomentum nEvt", "nutaubarMomentum nEvt", "gluMomentum nEvt", + "partonpT nEvt", "WplusMomentum nEvt", "WminusMomentum nEvt", "ZMomentum nEvt", @@ -120,7 +122,9 @@ "vrtxRadius nEvt", "unknownPDTNumber nEvt", "genPtclStatus nEvt", - "Bjorken_x nEvt") + "Bjorken_x nEvt", + "status1ShortLived nEvt", + "gluonMomentum nEvt") ) postProcessorBasicGenParticleValidation = cms.EDAnalyzer( @@ -201,32 +205,33 @@ "EmpzHFm nHFSD", "ntHFm nHFSD", "eneHFmSel nHFSD", - "_JM25njets nHFflow", - "_JM25ht nHFflow", - "_JM25pt1 nHFflow", - "_JM25pt2 nHFflow", - "_JM25pt3 nHFflow", - "_JM25pt4 nHFflow", - "_JM80njets nHFflow", - "_JM80ht nHFflow", - "_JM80pt1 nHFflow", - "_JM80pt2 nHFflow", - "_JM80pt3 nHFflow", - "_JM80pt4 nHFflow", + "JM25njets nHFflow", + "JM25ht nHFflow", + "JM25pt1 nHFflow", + "JM25pt2 nHFflow", + "JM25pt3 nHFflow", + "JM25pt4 nHFflow", + "JM80njets nHFflow", + "JM80ht nHFflow", + "JM80pt1 nHFflow", + "JM80pt2 nHFflow", + "JM80pt3 nHFflow", + "JM80pt4 nHFflow", "djr10 nEvt", "djr21 nEvt", "djr32 nEvt", "djr43 nEvt", - "_sumEt nEvt", - "_sumEt1 nEvt", - "_sumEt2 nEvt", - "_sumEt3 nEvt", - "_sumEt4 nEvt", - "_sumEt5 nEvt", + "sumET nEvt", + "sumET1 nEvt", + "sumET2 nEvt", + "sumET3 nEvt", + "sumET4 nEvt", + "sumET5 nEvt", "nEvt1 nEvt", "nEvt2 nEvt", "nHFflow nEvt", - "nHFSD nEvt") + "nHFSD nEvt", + "Tracketa nEvt") ) postProcessorWValidation = cms.EDAnalyzer( @@ -248,7 +253,9 @@ "cos_theta_gamma_lepton nEvt", "leppt nEvt", "met nEvt", - "lepeta nEvt") + "lepeta nEvt", + "leadpt nEvt", + "leadeta nEvt") ) postProcessorDrellYanValidation = cms.EDAnalyzer( @@ -280,13 +287,220 @@ subDirs = cms.untracked.vstring("Generator/Tau*"), efficiency = cms.vstring(""), resolution = cms.vstring(""), - normalization = cms.untracked.vstring("TauProngs nEvt", - "TauDecayChannels nEvt", - "TauMothers nEvt", - "TauRtauW nEvt", - "TauRtauHpm nEvt", - "TauSpinEffectsW nEvt", - "TauSpinEffectsHpm nEvt") -) + normalization = cms.untracked.vstring("JAKID nTaus", + "M12JAKID14 nTaus", + "M12JAKID18 nTaus", + "M12JAKID5 nTaus", + "M13JAKID14 nTaus", + "M13JAKID18 nTaus", + "M13JAKID5 nTaus", + "M23JAKID14 nTaus", + "M23JAKID18 nTaus", + "M23JAKID5 nTaus", + "MJAKID0 nTaus", + "MJAKID1 nTaus", + "MJAKID10 nTaus", + "MJAKID11 nTaus", + "MJAKID12 nTaus", + "MJAKID13 nTaus", + "MJAKID14 nTaus", + "MJAKID15 nTaus", + "MJAKID16 nTaus", + "MJAKID17 nTaus", + "MJAKID18 nTaus", + "MJAKID19 nTaus", + "MJAKID2 nTaus", + "MJAKID20 nTaus", + "MJAKID21 nTaus", + "MJAKID22 nTaus", + "MJAKID3 nTaus", + "MJAKID4 nTaus", + "MJAKID5 nTaus", + "MJAKID6 nTaus", + "MJAKID7 nTaus", + "MJAKID8 nTaus", + "MJAKID9 nTaus", + "TauDecayChannels nTaus", + "TauProngs nTaus", + "TauMothers nTaus", + "TauEta nPrimeTaus", + "TauPhi nPrimeTaus", + "TauISRPhotonsN nPrimeTaus", + "TauISRPhotonsPt nPrimeTaus", + "TauISRPhotonsPtRatio nPrimeTaus", + "TauFSRPhotonsN nPrimeTaus", + "TauFSRPhotonsPt nPrimeTaus", + "TauFSRPhotonsPtRatio nPrimeTaus", + "TauPt nPrimeTaus", + "TauRtauHpm nPrimeTaus", + "TauRtauW nPrimeTaus", + "TauSpinEffectsW_X nPrimeTaus", + "TauSpinEffectsW_eX nPrimeTaus", + "TauSpinEffectsW_muX nPrimeTaus", + "TauSpinEffectsW_UpsilonRho nPrimeTaus", + "TauSpinEffectsW_UpsilonA1 nPrimeTaus", + "TauSpinEffectsHpm_X nPrimeTaus", + "TauSpinEffectsHpm_eX nPrimeTaus", + "TauSpinEffectsHpm_muX nPrimeTaus", + "TauSpinEffectsHpm_UpsilonRho nPrimeTaus", + "TauSpinEffectsHpm_UpsilonA1 nPrimeTaus", + "TauSpinEffectsZ_MVis nPrimeTaus", + "TauSpinEffectsZ_Zs nPrimeTaus", + "TauSpinEffectsZ_Xf nPrimeTaus", + "TauSpinEffectsZ_Xb nPrimeTaus", + "TauSpinEffectsZ_eX nPrimeTaus", + "TauSpinEffectsZ_muX nPrimeTaus", + "TauSpinEffectsH_MVis nPrimeTaus", + "TauSpinEffectsH_Zs nPrimeTaus", + "TauSpinEffectsH_Xf nPrimeTaus", + "TauSpinEffectsH_Xb nPrimeTaus", + "TauSpinEffectsH_eX nPrimeTaus", + "TauSpinEffectsH_muX nPrimeTaus" + ) + ) + +postProcessorTTbarValidation = cms.EDAnalyzer( + "DQMGenericClient", + subDirs = cms.untracked.vstring("Generator/TTbar*"), + efficiency = cms.vstring(""), + resolution = cms.vstring(""), + normalization = cms.untracked.vstring("TTbar_BottomE nEvt", + "TTbar_BottomEta nEvt", + "TTbar_BottomMass nEvt", + "TTbar_BottomPt nEvt", + "TTbar_BottomPz nEvt", + "TTbar_BottomY nEvt", + "TTbar_TTbarMass nEvt", + "TTbar_TTbarPt nEvt", + "TTbar_TTbarY nEvt", + "TTbar_TopMass nEvt", + "TTbar_TopPt nEvt", + "TTbar_TopY nEvt", + "TTbar_WminPz nEvt", + "TTbar_WplusPz nEvt", + "TTbar_jetEta1 nEvt", + "TTbar_jetEta2 nEvt", + "TTbar_jetEta3 nEvt", + "TTbar_jetEta4 nEvt", + "TTbar_jetEtaAll nEvt", + "TTbar_jetPt1 nEvt", + "TTbar_jetPt2 nEvt", + "TTbar_jetPt3 nEvt", + "TTbar_jetPt4 nEvt", + "TTbar_jetPtAll nEvt", + "TTbar_lepEta1 nEvt", + "TTbar_lepEta2 nEvt", + "TTbar_lepEta3 nEvt", + "TTbar_lepEta4 nEvt", + "TTbar_lepEtaAll nEvt", + "TTbar_lepN nEvt", + "TTbar_lepPt1_genParticlesElectrons nEvt", + "TTbar_lepPt1_genParticlesMuons nEvt", + "TTbar_lepPt1_genParticlesNeutrinos nEvt", + "TTbar_lepPt2_genParticlesElectrons nEvt", + "TTbar_lepPt2_genParticlesMuons nEvt", + "TTbar_lepPt2_genParticlesNeutrinos nEvt", + "TTbar_lepPt3_genParticlesElectrons nEvt", + "TTbar_lepPt3_genParticlesMuons nEvt", + "TTbar_lepPt3_genParticlesNeutrinos nEvt", + "TTbar_lepPt4_genParticlesElectrons nEvt", + "TTbar_lepPt4_genParticlesMuons nEvt", + "TTbar_lepPt4_genParticlesNeutrinos nEvt", + "TTbar_lepPtAll_genParticlesElectrons nEvt", + "TTbar_lepPtAll_genParticlesMuons nEvt", + "TTbar_lepPtAll_genParticlesNeutrinos nEvt" + ) + ) + +postProcessorTTbarSpinCorr = cms.EDAnalyzer("DQMGenericClient", + subDirs = cms.untracked.vstring("Generator/TTbarSpinCorr*"), + efficiency = cms.vstring(""), + resolution = cms.vstring(""), + normalization = cms.untracked.vstring("TTbar_asym nEvt", + "TTbar_deltaPhi nEvt", + "TTbar_llpairM nEvt", + "TTbar_llpairPt nEvt" + ) + ) + + +postProcessorHiggsValidation = cms.EDAnalyzer( + "DQMGenericClient", + subDirs = cms.untracked.vstring("Generator/Higgs*"), + efficiency = cms.vstring(""), + resolution = cms.vstring(""), + normalization = cms.untracked.vstring("Higgs_DecayChannels nEvt", + "Higgs_eta nEvt", + "Higgs_m nEvt", + "Higgs_pt nEvt", + "W_eta nEvt", + "W_pt nEvt", + "Z_eta nEvt", + "Z_pt nEvt", + "b_eta nEvt", + "b_pt nEvt", + "c_eta nEvt", + "c_pt nEvt", + "d_eta nEvt", + "d_pt nEvt", + "e_eta nEvt", + "e_pt nEvt", + "gamma_eta nEvt", + "gamma_pt nEvt", + "mu_eta nEvt", + "mu_pt nEvt", + "nEvt nEvt", + "nu_eta nEvt", + "nu_pt nEvt", + "s_eta nEvt", + "s_pt nEvt", + "t_eta nEvt", + "t_pt nEvt", + "tau_eta nEvt", + "tau_pt nEvt", + "u_eta nEvt", + "u_pt nEvt" + ) + ) + +postProcessorHplusValidation = cms.EDAnalyzer( + "DQMGenericClient", + subDirs = cms.untracked.vstring("Generator/Hplus*"), + efficiency = cms.vstring(""), + resolution = cms.vstring(""), + normalization = cms.untracked.vstring("Hplus_DecayChannels nEvt", + "Hplus_eta nEvt", + "Hplus_m nEvt", + "Hplus_pt nEvt", + "W_eta nEvt", + "W_pt nEvt", + "Z_eta nEvt", + "Z_pt nEvt", + "b_eta nEvt", + "b_pt nEvt", + "c_eta nEvt", + "c_pt nEvt", + "d_eta nEvt", + "d_pt nEvt", + "e_eta nEvt", + "e_pt nEvt", + "gamma_eta nEvt", + "gamma_pt nEvt", + "mu_eta nEvt", + "mu_pt nEvt", + "nEvt nEvt", + "nu_eta nEvt", + "nu_pt nEvt", + "s_eta nEvt", + "s_pt nEvt", + "t_eta nEvt", + "t_pt nEvt", + "tau_eta nEvt", + "tau_pt nEvt", + "u_eta nEvt", + "u_pt nEvt" + ) + ) + -EventGeneratorPostProcessor = cms.Sequence(postProcessorBasicHepMCValidation+postProcessorBasicGenParticleValidation+postProcessorMBUEandQCDValidation+postProcessorWValidation+postProcessorDrellYanValidation+postProcessorTauValidation) +EventGeneratorPostProcessor = cms.Sequence(postProcessorBasicHepMCValidation+postProcessorBasicGenParticleValidation+postProcessorMBUEandQCDValidation+postProcessorWValidation+postProcessorDrellYanValidation+postProcessorTauValidation+postProcessorTTbarValidation+postProcessorTTbarSpinCorr+postProcessorHiggsValidation+postProcessorHplusValidation) diff --git a/Validation/EventGenerator/python/TTbar_Validation_cfi.py b/Validation/EventGenerator/python/TTbar_Validation_cfi.py new file mode 100644 index 0000000000000..6dee5f2f4df5d --- /dev/null +++ b/Validation/EventGenerator/python/TTbar_Validation_cfi.py @@ -0,0 +1,83 @@ +import FWCore.ParameterSet.Config as cms + +TTbarAnalyzeSpinCorr = cms.EDAnalyzer("TTbarSpinCorrHepMCAnalyzer", + genEventInfoProductTag = cms.InputTag("generator"), + genParticlesTag = cms.InputTag("genParticles") + ) + +from GeneratorInterface.LHEInterface.lheCOMWeightProducer import * +lheCOMWeightProducer.NewECMS = cms.double(8000) + +## produce TtGenEvt +from TopQuarkAnalysis.TopEventProducers.sequences.ttGenEvent_cff import * +decaySubset.fillMode = "kME" +decaySubset.addRadiation = False + +## get lorentzvectors +analyzeTopKinematics = cms.EDAnalyzer('TTbar_Kinematics', + SaveTree = cms.untracked.bool(False), + genEventInfoProductTag = cms.InputTag("generator") + ) + +## analyze genjets +analyzeGenJets = cms.EDAnalyzer("TTbar_GenJetAnalyzer", + jets = cms.InputTag('ak5GenJets' ), + genEventInfoProductTag = cms.InputTag("generator") + ) + +# --- Create list of interesting genParticles --- +from SimGeneral.HepPDTESSource.pythiapdt_cfi import * + +# --- ShortList is to prevent running multiple times over full particle list --- +#see https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideGenParticlePruner + +genParticlesShortList = cms.EDProducer("GenParticlePruner", + src = cms.InputTag("genParticles",""), + select = cms.vstring("drop * ", + "keep pdgId = {mu+} & status = 1", + "keep pdgId = {mu-} & status = 1", + "keep pdgId = {e+} & status = 1", + "keep pdgId = {e-} & status = 1", + "keep pdgId = {nu_e} & status = 1", + "keep pdgId = {nu_ebar} & status = 1", + "keep pdgId = {nu_mu} & status = 1", + "keep pdgId = {nu_mubar} & status = 1" + ) + ) + +#see https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideGenParticlePruner +genParticlesMuons = cms.EDProducer("GenParticlePruner", + src = cms.InputTag("genParticlesShortList"), + select = cms.vstring("drop * ", + "keep pdgId = {mu+} & status = 1 & pt > 30 & abs(eta) < 2.5", + "keep pdgId = {mu-} & status = 1 & pt > 30 & abs(eta) < 2.5" + ) + ) + +#see https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideGenParticlePruner +genParticlesElectrons = cms.EDProducer("GenParticlePruner", + src = cms.InputTag("genParticlesShortList"), + select = cms.vstring("drop * ", + "keep pdgId = {e+} & status = 1 & pt > 30 & abs(eta) < 2.5", + "keep pdgId = {e-} & status = 1 & pt > 30 & abs(eta) < 2.5" + ) + ) + +#see https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideGenParticlePruner +genParticlesNeutrinos = cms.EDProducer("GenParticlePruner", + src = cms.InputTag("genParticlesShortList"), + select = cms.vstring("drop * ", + "keep pdgId = {nu_e} & status = 1", + "keep pdgId = {nu_ebar} & status = 1", + "keep pdgId = {nu_mu} & status = 1", + "keep pdgId = {nu_mubar} & status = 1" + ) + ) + +## analyze gen leptons +analyzeGenMuons = cms.EDAnalyzer("TTbar_GenLepAnalyzer", leptons = cms.InputTag('genParticlesMuons' )) +analyzeGenElecs = cms.EDAnalyzer("TTbar_GenLepAnalyzer", leptons = cms.InputTag('genParticlesElectrons' )) +analyzeGenNtrns = cms.EDAnalyzer("TTbar_GenLepAnalyzer", leptons = cms.InputTag('genParticlesNeutrinos' )) + + + diff --git a/Validation/EventGenerator/python/TauValidation_cfi.py b/Validation/EventGenerator/python/TauValidation_cfi.py index dfe63811a8dea..97068154bfefd 100644 --- a/Validation/EventGenerator/python/TauValidation_cfi.py +++ b/Validation/EventGenerator/python/TauValidation_cfi.py @@ -2,5 +2,6 @@ tauValidation = cms.EDAnalyzer("TauValidation", hepmcCollection = cms.InputTag("generator",""), - tauEtCutForRtau = cms.double(50) + tauEtCutForRtau = cms.double(50), + UseWeightFromHepMC = cms.bool(True) ) diff --git a/Validation/EventGenerator/python/VVVValidation_cfi.py b/Validation/EventGenerator/python/VVVValidation_cfi.py new file mode 100644 index 0000000000000..7a04a4b5794c1 --- /dev/null +++ b/Validation/EventGenerator/python/VVVValidation_cfi.py @@ -0,0 +1,12 @@ +import FWCore.ParameterSet.Config as cms + +vvvValidation = cms.EDAnalyzer("VVVValidation", + hepmcCollection = cms.InputTag("generator",""), + genparticleCollection = cms.InputTag("genParticles",""), + genjetsCollection = cms.InputTag("ak5GenJets",""), + matchingPrecision = cms.double(0.001), + lepStatus= cms.double(1), + motherStatus= cms.double(1), + verbosity = cms.untracked.uint32(0), + UseWeightFromHepMC = cms.bool(True) +) diff --git a/Validation/EventGenerator/python/WValidation_cfi.py b/Validation/EventGenerator/python/WValidation_cfi.py index 0aab2df4bb82e..1f772a128b173 100644 --- a/Validation/EventGenerator/python/WValidation_cfi.py +++ b/Validation/EventGenerator/python/WValidation_cfi.py @@ -3,5 +3,6 @@ wValidation = cms.EDAnalyzer("WValidation", hepmcCollection = cms.InputTag("generator",""), decaysTo = cms.int32(11), - name = cms.string("Electrons") + name = cms.string("Electrons"), + UseWeightFromHepMC = cms.bool(True) ) diff --git a/Validation/EventGenerator/python/__init__.py b/Validation/EventGenerator/python/__init__.py new file mode 100644 index 0000000000000..2ecc034489d30 --- /dev/null +++ b/Validation/EventGenerator/python/__init__.py @@ -0,0 +1,3 @@ +#Automatically created by SCRAM +import os +__path__.append(os.path.dirname(os.path.abspath(__file__).rsplit('/Validation/EventGenerator/',1)[0])+'/cfipython/slc5_amd64_gcc462/Validation/EventGenerator') diff --git a/Validation/EventGenerator/python/genvalidTools.py b/Validation/EventGenerator/python/genvalidTools.py new file mode 100644 index 0000000000000..983f616d41eda --- /dev/null +++ b/Validation/EventGenerator/python/genvalidTools.py @@ -0,0 +1,47 @@ +import FWCore.ParameterSet.Config as cms + +#function to switch to an external weight producer for an analyzer in the validation chain +def useExternalWeight(process, analyzerName, vWeightProducerTags): + analyzer = getattr(process,analyzerName) + if analyzer != None: + print "Changing weight in "+analyzerName + analyzer.UseWeightFromHepMC = cms.bool(False) + analyzer.genEventInfos = vWeightProducerTags + setattr(process, analyzerName, analyzer) + +#function to switch to an external weight producer for all analyzers in the validation chain +def useExternalWeightForValidation(process, vWeightProducerTags): + useExternalWeight(process, "basicGenParticleValidation", vWeightProducerTags) + useExternalWeight(process, "mbueAndqcdValidation", vWeightProducerTags) + useExternalWeight(process, "basicHepMCValidation", vWeightProducerTags) + useExternalWeight(process, "drellYanEleValidation", vWeightProducerTags) + useExternalWeight(process, "drellYanMuoValidation", vWeightProducerTags) + useExternalWeight(process, "wMinusEleValidation", vWeightProducerTags) + useExternalWeight(process, "wPlusEleValidation", vWeightProducerTags) + useExternalWeight(process, "wMinusMuoValidation", vWeightProducerTags) + useExternalWeight(process, "wPlusMuoValidation", vWeightProducerTags) + useExternalWeight(process, "tauValidation", vWeightProducerTags) + useExternalWeight(process, "duplicationChecker", vWeightProducerTags) + +#function to switch to an alternative gen source (default is "generator") for an analyzer in the validation chain +def switchGenSource(process, analyzerName, source): + analyzer = getattr(process,analyzerName) + if analyzer != None: + print "Changing inputSource in "+analyzerName + analyzer.hepmcCollection = source + setattr(process, analyzerName, analyzer) + +#function to switch to an alternative gen source (default is "generator") for all analyzers in the validation chain +def switchGenSourceForValidation(process, source): + process.genParticles.src = 'lhe2HepMCConverter' + switchGenSource(process, "basicGenParticleValidation", source) + switchGenSource(process, "mbueAndqcdValidation", source) + switchGenSource(process, "basicHepMCValidation", source) + switchGenSource(process, "drellYanEleValidation", source) + switchGenSource(process, "drellYanMuoValidation", source) + switchGenSource(process, "wMinusEleValidation", source) + switchGenSource(process, "wPlusEleValidation", source) + switchGenSource(process, "wMinusMuoValidation", source) + switchGenSource(process, "wPlusMuoValidation", source) + switchGenSource(process, "tauValidation", source) + switchGenSource(process, "duplicationChecker", source) diff --git a/Validation/EventGenerator/src/PdtPdgMini.cc b/Validation/EventGenerator/src/PdtPdgMini.cc new file mode 100755 index 0000000000000..c9c3c35816d5f --- /dev/null +++ b/Validation/EventGenerator/src/PdtPdgMini.cc @@ -0,0 +1 @@ +#include "Validation/EventGenerator/interface/PdtPdgMini.h" diff --git a/Validation/EventGenerator/src/TauDecay.cc b/Validation/EventGenerator/src/TauDecay.cc new file mode 100755 index 0000000000000..69fa26e6d2fc8 --- /dev/null +++ b/Validation/EventGenerator/src/TauDecay.cc @@ -0,0 +1,268 @@ +#include "Validation/EventGenerator/interface/TauDecay.h" +#include "Validation/EventGenerator/interface/PdtPdgMini.h" + + +#include +#include +#include + +TauDecay::TauDecay(){ + Reset(); +} + +TauDecay::~TauDecay(){ + +} + +void TauDecay::Reset(){ + n_pi=0; + n_pi0=0; + n_K=0; + n_K0L=0; + n_K0S=0; + n_gamma=0; + n_nu=0; + n_e=0; + n_mu=0; + n_a1=0; + n_a10=0; + n_rho=0; + n_rho0=0; + n_eta=0; + n_omega=0; + n_Kstar0=0; + n_Kstar=0; + unknown=0; +} + +bool TauDecay::isTauFinalStateParticle(int pdgid){ + int id=abs(pdgid); + if(id==PdtPdgMini::e_minus) return true; // e+- + if(id==PdtPdgMini::nu_e) return true; // nu_e + if(id==PdtPdgMini::mu_minus) return true; // mu+- + if(id==PdtPdgMini::nu_mu) return true; // nu_mu + if(id==PdtPdgMini::nu_tau) return true; // nu_tau + if(id==PdtPdgMini::gamma) return true; // gamma happends in generator + if(id==PdtPdgMini::pi0) return true; // pi0 + if(id==PdtPdgMini::pi_plus) return true; // pi+- + if(id==PdtPdgMini::K_L0) return true; // K0L + if(id==PdtPdgMini::K_S0) return true; // KS + if(id==PdtPdgMini::K_plus) return true; // K+- + return false; +} + +bool TauDecay::isTauParticleCounter(int pdgid){ + int id=abs(pdgid); + //count particles + if(id==PdtPdgMini::pi_plus) { n_pi++; return true;} + if(id==PdtPdgMini::pi0) { n_pi0++; return true;} + if(id==PdtPdgMini::K_plus) { n_K++; return true;} + if(id==PdtPdgMini::K_L0) { n_K0L++; return true;} + if(id==PdtPdgMini::K_S0) { n_K0S++; return true;} + if(id==PdtPdgMini::gamma) { n_gamma++; return true;} + if(id==PdtPdgMini::nu_tau || + id==PdtPdgMini::nu_e || + id==PdtPdgMini::nu_mu) { n_nu++; return true;} + if(id==PdtPdgMini::e_minus) { n_e++; return true;} + if(id==PdtPdgMini::mu_minus) { n_mu++; return true;} + return false; +} + +bool TauDecay::isTauResonanceCounter(int pdgid){ + int id=abs(pdgid); + //count resonances + if(id==PdtPdgMini::a_1_plus) { n_a1++; return true;} + if(id==PdtPdgMini::a_10) { n_a10++; return true;} + if(id==PdtPdgMini::rho_plus) { n_rho++; return true;} + if(id==PdtPdgMini::rho0) { n_rho0++; return true;} + if(id==PdtPdgMini::eta) { n_eta++; return true;} + if(id==PdtPdgMini::omega) { n_omega++; return true;} + //if(id==PdtPdgMini::K_S0) { n_K0S++; return true;} + if(id==PdtPdgMini::K_star0) { n_Kstar0++; return true;} + if(id==PdtPdgMini::K_star_plus){ n_Kstar++; return true;} + if(id==PdtPdgMini::W_plus) { return true;} + unknown++; + return false; +} + +void TauDecay::ClassifyDecayMode(unsigned int &JAK_ID,unsigned int &TauBitMask){ + //Reset Bits + JAK_ID=0; + TauBitMask=0; + // Classify according to JAK and TauDecayStructure + /////////////////////////////////////////////////////// + // + // Exlusive modes remove first + // + if(n_pi>=1 && n_pi0>=1 && n_nu==1 && n_eta==1){ // eta modes + JAK_ID=JAK_ETAPIPI0; + TauBitMask=OneProng; + if(n_pi0==1)TauBitMask+=OnePi0; + if(n_pi0==2)TauBitMask+=TwoPi0; + if(n_pi0==3)TauBitMask+=ThreePi0; + ClassifyDecayResonance(TauBitMask); + return; + } + //JAK_K0BK0PI + if ((n_K0S+n_K0L==2 && n_pi==1 && n_pi0==0 && n_K==0 && n_nu==1) || (n_pi>=1 && n_pi0==0 && n_K0L+n_K0S==2 && n_K==0 && n_nu==1) ){ + JAK_ID=JAK_K0BK0PI; + TauBitMask=OneProng; + if(n_pi>1)TauBitMask+=KS0_to_pipi; + ClassifyDecayResonance(TauBitMask); + return; + } + //if(n_Kstar==1){ //JAK_KSTAR K0SPi && KPi0 + if(n_e==0 && n_mu==0 && n_pi>=1 && n_pi0==0 && n_K==0 && n_K0L+n_K0S==1 && n_nu==1){ + JAK_ID=JAK_KSTAR; + TauBitMask=OneProng; + if(n_pi==3)TauBitMask+=KS0_to_pipi; + ClassifyDecayResonance(TauBitMask); + return; + } + if(n_e==0 && n_mu==0 && n_pi==0 && n_pi0==1 && n_K==1 && n_K0L==0 && n_K0S==0 && n_nu==1){ + JAK_ID=JAK_KSTAR; + TauBitMask=OneProng; + ClassifyDecayResonance(TauBitMask); + return; + } + //} + //JAK_PIK0PI0 + if(n_e==0 && n_mu==0 && n_pi>=1 && n_pi0==1 && n_K==0 && n_K0L+n_K0S==1 && n_nu==1){ + JAK_ID=JAK_PIK0PI0; + TauBitMask=OneProng; + TauBitMask+=OnePi0; + if(n_pi==3)TauBitMask+=KS0_to_pipi; + ClassifyDecayResonance(TauBitMask); + return; + } + //JAK_KK0B + if(n_e==0 && n_mu==0 && n_pi0==0 && n_K==1 && n_K0L+n_K0S==1 && n_nu==1){ + JAK_ID=JAK_KK0B; + TauBitMask=OneProng; + if(n_pi==2)TauBitMask+=KS0_to_pipi; + return; + } + //JAK_ID=JAK_KK0BPI0 + if(n_e==0 && n_mu==0 && n_pi0==1 && n_K==1 && n_K0L+n_K0S==1 && n_nu==1){ + JAK_ID=JAK_KK0BPI0; + TauBitMask=OneProng; + TauBitMask+=OnePi0; + if(n_pi==2)TauBitMask+=KS0_to_pipi; + ClassifyDecayResonance(TauBitMask); + return; + } + + + //Safty handelling for exlusive modes + if (n_K0L!=0){ + std::cout << "Unknown mode with KL0: n_e " << n_e << " n_mu " << n_mu << " n_pi " << n_pi << " n_pi0 " << n_pi0 << " n_K " << n_K << " n_K0L " << n_K0L << " n_K0S " << n_K0S << " n_nu " << n_nu << " n_gamma " << n_gamma + << std::endl; + return; + } + if (n_K0S!=0){ + std::cout << "Unknown mode with KS0: n_e " << n_e << " n_mu " << n_mu << " n_pi " << n_pi << " n_pi0 " << n_pi0 << " n_K " << n_K << " n_K0L " << n_K0L << " n_K0S " << n_K0S << " n_nu " << n_nu << " n_gamma " << n_gamma + << std::endl; + return; + } + if (n_eta!=0){ + std::cout << "Unknown mode with eta: n_e " << n_e << " n_mu " << n_mu << " n_pi " << n_pi << " n_pi0 " << n_pi0 << " n_K " << n_K << " n_K0L " << n_K0L << " n_K0S " << n_K0S << " n_nu " << n_nu << " n_gamma " << n_gamma + << std::endl; + return; + } + + + + if(n_pi+n_K+n_e+n_mu==1)TauBitMask=OneProng; + if(n_pi+n_K==3)TauBitMask=ThreeProng; + if(n_pi+n_K==5)TauBitMask=FiveProng; + if(n_pi0==1)TauBitMask+=OnePi0; + if(n_pi0==2)TauBitMask+=TwoPi0; + if(n_pi0==3)TauBitMask+=ThreePi0; + ClassifyDecayResonance(TauBitMask); + /////////////////////////////////////////////////// + // + // Standard modes + // + if(n_e==1 && n_mu==0 && n_pi==0 && n_pi0==0 && n_K==0 && n_K0L==0 && n_K0S==0 && n_nu==2){ + JAK_ID=JAK_ELECTRON; + return; + } + if(n_e==0 && n_mu==1 && n_pi==0 && n_pi0==0 && n_K==0 && n_K0L==0 && n_K0S==0 && n_nu==2){ + JAK_ID=JAK_MUON; + return; + } + if(n_e==0 && n_mu==0 && n_pi==1 && n_pi0==0 && n_K==0 && n_K0L==0 && n_K0S==0 && n_nu==1){ + JAK_ID=JAK_PION; + return; + } + if(n_e==0 && n_mu==0 && n_pi==1 && n_pi0==1 && n_K==0 && n_K0L==0 && n_K0S==0 && n_nu==1 && n_rho==1){ + JAK_ID=JAK_RHO_PIPI0; + return; + } + if(n_e==0 && n_mu==0 && n_pi==1 && n_pi0==2 && n_K==0 && n_K0L==0 && n_K0S==0 && n_nu==1){ + JAK_ID=JAK_A1_3PI; + return; + } + if(n_e==0 && n_mu==0 && n_pi==3 && n_pi0==0 && n_K==0 && n_K0L==0 && n_K0S==0 && n_nu==1){ + JAK_ID=JAK_A1_3PI; + return; + } + if(n_e==0 && n_mu==0 && n_pi==0 && n_pi0==0 && n_K==1 && n_K0L==0 && n_K0S==0 && n_nu==1){ + JAK_ID=JAK_KAON; + return; + } + if(n_e==0 && n_mu==0 && n_pi==3 && n_pi0==1 && n_K==0 && n_K0L==0 && n_K0S==0 && n_nu==1){ + JAK_ID=JAK_3PIPI0; + return; + } + if(n_e==0 && n_mu==0 && n_pi==1 && n_pi0==3 && n_K==0 && n_K0L==0 && n_K0S==0 && n_nu==1){ + JAK_ID=JAK_PI3PI0; + return; + } + if(n_e==0 && n_mu==0 && n_pi==3 && n_pi0==2 && n_K==0 && n_K0L==0 && n_K0S==0 && n_nu==1){ + JAK_ID=JAK_3PI2PI0; + return; + } + if(n_e==0 && n_mu==0 && n_pi==5 && n_pi0==0 && n_K==0 && n_K0L==0 && n_K0S==0 && n_nu==1){ + JAK_ID=JAK_5PI; + return; + } + if(n_e==0 && n_mu==0 && n_pi==5 && n_pi0==1 && n_K==0 && n_K0L==0 && n_K0S==0 && n_nu==1){ + JAK_ID=JAK_5PIPI0; + return; + } + if(n_e==0 && n_mu==0 && n_pi==3 && n_pi0==3 && n_K==0 && n_K0L==0 && n_K0S==0 && n_nu==1){ + JAK_ID=JAK_3PI3PI0; + return; + } + if(n_e==0 && n_mu==0 && n_pi==1 && n_pi0==0 && n_K==2 && n_K0L==0 && n_K0S==0 && n_nu==1){ + JAK_ID=JAK_KPIK; + return; + } + if(n_e==0 && n_mu==0 && n_pi==0 && n_pi0==2 && n_K==1 && n_K0L==0 && n_K0S==0 && n_nu==1){ + JAK_ID=JAK_K2PI0; + return; + } + if(n_e==0 && n_mu==0 && n_pi==2 && n_pi0==0 && n_K==1 && n_K0L==0 && n_K0S==0 && n_nu==1){ + JAK_ID=JAK_KPIPI; + return; + } + if(n_e==0 && n_mu==0 && n_pi==1 && n_pi0==1 && n_K==0 && n_K0L==0 && n_K0S==0 && n_nu==1 && n_gamma>=1 && n_rho==0){ + JAK_ID=JAK_PIPI0GAM; + return; + } + std::cout << "Tau Mode not found: n_e " << n_e << " n_mu " << n_mu << " n_pi " << n_pi << " n_pi0 " << n_pi0 << " n_K " << n_K << " n_K0L " << n_K0L << " n_K0S " << n_K0S << " n_nu " << n_nu << " n_gamma " << n_gamma << std::endl; + JAK_ID=JAK_UNKNOWN; +} + +void TauDecay::ClassifyDecayResonance(unsigned int &TauBitMask){ + // Add Resonance info to TauBitMask + if(n_a1>0) TauBitMask+=Res_a1_pm; + if(n_a10>0) TauBitMask+=Res_a1_0; + if(n_rho>0) TauBitMask+=Res_rho_pm; + if(n_rho0>0) TauBitMask+=Res_rho_0; + if(n_eta>0) TauBitMask+=Res_eta; + if(n_omega>0) TauBitMask+=Res_omega; + if(n_Kstar>0) TauBitMask+=Res_Kstar_pm; + if(n_Kstar0>0) TauBitMask+=Res_Kstar_0; +} diff --git a/Validation/EventGenerator/src/TauDecay_CMSSW.cc b/Validation/EventGenerator/src/TauDecay_CMSSW.cc new file mode 100755 index 0000000000000..6847c4618d538 --- /dev/null +++ b/Validation/EventGenerator/src/TauDecay_CMSSW.cc @@ -0,0 +1,67 @@ +#include "Validation/EventGenerator/interface/TauDecay_CMSSW.h" +#include "Validation/EventGenerator/interface/PdtPdgMini.h" + +#include +#include + +TauDecay_CMSSW::TauDecay_CMSSW(): + TauDecay() +{ + +} + +TauDecay_CMSSW::~TauDecay_CMSSW(){ + +} + +bool TauDecay_CMSSW::AnalyzeTau(HepMC::GenParticle *Tau,unsigned int &JAK_ID,unsigned int &TauBitMask,bool dores, bool dopi0){ + Reset(); + MotherIdx.clear(); + TauDecayProducts.clear(); + if(abs(Tau->pdg_id())==PdtPdgMini::tau_minus){ // check that it is a tau + unsigned int Tauidx=TauDecayProducts.size(); + HepMC::GenVertex::particle_iterator des; + if( Tau->end_vertex()){ + for(des = Tau->end_vertex()->particles_begin(HepMC::children); + des!= Tau->end_vertex()->particles_end(HepMC::children);++des ) { + Analyze((*des),Tauidx,dores,dopi0); + } + ClassifyDecayMode(JAK_ID,TauBitMask); + return true; + } + } + return false; +} + + + + +void TauDecay_CMSSW::Analyze(HepMC::GenParticle *Particle,unsigned int midx, bool dores, bool dopi0){ + unsigned int pdgid=abs(Particle->pdg_id()); + isTauResonanceCounter(pdgid); + if(isTauFinalStateParticle(pdgid)){ + if(!isTauParticleCounter(pdgid)) std::cout << "TauDecay_CMSSW::Analyze WARNING: Unknow Final State Particle in Tau Decay... " << pdgid << std::endl; + TauDecayProducts.push_back(Particle); + MotherIdx.push_back(midx); + return; + } + HepMC::GenVertex::particle_iterator des; + for(des = Particle->end_vertex()->particles_begin(HepMC::children); + des!= Particle->end_vertex()->particles_end(HepMC::children) && Particle->end_vertex()-> particles_out_size()>0;++des ) { + Analyze((*des),midx,dores,dopi0); + } +} + + +void TauDecay_CMSSW::AddPi0Info(HepMC::GenParticle *Particle,unsigned int midx){ + if(Particle->status()==1){ + TauDecayProducts.push_back(Particle); + MotherIdx.push_back(midx); + return; + } + HepMC::GenVertex::particle_iterator des; + for(des = Particle->end_vertex()->particles_begin(HepMC::children); + des!= Particle->end_vertex()->particles_end(HepMC::children);++des ) { + AddPi0Info((*des),midx); + } +} diff --git a/Validation/EventGenerator/src/WeightManager.cc b/Validation/EventGenerator/src/WeightManager.cc new file mode 100644 index 0000000000000..9de8b58d7c55b --- /dev/null +++ b/Validation/EventGenerator/src/WeightManager.cc @@ -0,0 +1,40 @@ +#include "Validation/EventGenerator/interface/WeightManager.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/Common/interface/Handle.h" +#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" +#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h" + + +using namespace edm; + +WeightManager::WeightManager(const ParameterSet& iConfig): +_useHepMC(iConfig.getParameter("UseWeightFromHepMC")) +{ + if (_useHepMC) + _hepmcCollection = iConfig.getParameter("hepmcCollection"); + else + _genEventInfos = iConfig.getParameter >("genEventInfos"); +} + +double WeightManager::weight(const Event& iEvent){ + if (_useHepMC){ + edm::Handle evt; + iEvent.getByLabel(_hepmcCollection, evt); + const HepMC::GenEvent *myGenEvent = evt->GetEvent(); + + double weight = 1.; + if (myGenEvent->weights().size() > 0) + weight = myGenEvent->weights()[0]; + return weight; + } else { + double weight = 1.; + for (unsigned int i = 0; i < _genEventInfos.size(); ++i){ + edm::Handle info; + iEvent.getByLabel(_genEventInfos[i], info); + weight *= info->weight(); + } + return weight; + } +} diff --git a/Validation/EventGenerator/test/DetailedCompare.C b/Validation/EventGenerator/test/DetailedCompare.C new file mode 100644 index 0000000000000..e4fc2928d042f --- /dev/null +++ b/Validation/EventGenerator/test/DetailedCompare.C @@ -0,0 +1,364 @@ +// F. Cossutti +// $Date: 2012/02/10 15:11:41 $ +// $Revision: 1.1 $ +// +// ROOT macro for graphical compariosn of Monitor Elements in a user +// supplied directory between two files with the same histogram content + +#include + +class HistoCompare { + + public: + + HistoCompare() { std::cout << "Initializing HistoCompare... " << std::endl;printresy=0.96; } ; + + void PVCompute(TH1 * oldHisto , TH1 * newHisto , TText * te ); + void PVCompute(TH2 * oldHisto , TH2 * newHisto , TText * te ); + void PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te ); + + private: + + Double_t mypv; + + TH1 * myoldHisto1; + TH1 * mynewHisto1; + + TH2 * myoldHisto2; + TH2 * mynewHisto2; + + TProfile * myoldProfile; + TProfile * mynewProfile; + + TText * myte; + + void printRes(TString theName, Double_t thePV, TText * te); + double printresy; +}; + +HistoCompare::printRes(TString theName, Double_t thePV, TText * te) +{ + myte->DrawTextNDC(0.1,printresy,theName ); + std::cout << "[Compatibility test] " << theName << std::endl; + printresy+=-0.04; +} + + +HistoCompare::PVCompute(TH1 * oldHisto , TH1 * newHisto , TText * te ) +{ + + myoldHisto1 = oldHisto; + mynewHisto1 = newHisto; + myte = te; + + Double_t *res; + + Double_t mypvchi = myoldHisto1->Chi2Test(mynewHisto1,"WW",res); + + char str [128]; + sprintf(str,"chi^2 P Value: %f",mypvchi); + TString title = str; + printRes(title, mypvchi, myte); + Double_t mypvKS = myoldHisto1->KolmogorovTest(mynewHisto1,""); + sprintf(str,"KS (prob): %f",mypvKS); + TString title = str; + std::strstream buf; + std::string value; + + printRes(title, mypvKS, myte); + + return; + +} + +HistoCompare::PVCompute(TH2 * oldHisto , TH2 * newHisto , TText * te ) +{ + + myoldHisto2 = oldHisto; + mynewHisto2 = newHisto; + myte = te; + + Double_t *res ; + Double_t mypvchi = myoldHisto2->Chi2Test(mynewHisto2,"WW",res); + char str [128]; + sprintf(str,"chi^2 P Value: %f",mypvchi); + TString title = str; + printRes(title, mypvchi, myte); + + return; + +} + + +HistoCompare::PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te ) +{ + + myoldProfile = oldHisto; + mynewProfile = newHisto; + myte = te; + + Double_t *res ; + + Double_t mypv = myoldProfile->Chi2Test(mynewProfile,"WW",res); + TString title = "chi^2 P Value: "; + printRes(title, mypv, myte); + return; + +} + +#include "TObject.h" +#include "TDirectory.h" +#include "TKey.h" +#include "TFile.h" +#include "TTree.h" +#include "TText.h" + + +void DetailedCompare( TString currentfile = "new.root", + TString referencefile = "ref.root", + TString theDir = "DQMData/Run 1/Generator/Run summary/Tau") +{ + std::cout << "Note: This code correct the Histograms errors to sqrt(N) - this is not correct for samples with weights" << std::endl; + std::vector theList = histoList(currentfile, theDir); + + gROOT ->Reset(); + char* rfilename = referencefile ; + char* sfilename = currentfile ; + + delete gROOT->GetListOfFiles()->FindObject(rfilename); + delete gROOT->GetListOfFiles()->FindObject(sfilename); + + TFile * rfile = new TFile(rfilename); + TFile * sfile = new TFile(sfilename); + + char* baseDir=theDir; + + rfile->cd(baseDir); + gDirectory->ls(); + + sfile->cd(baseDir); + gDirectory->ls(); + + gStyle->SetLabelFont(63,"X"); + gStyle->SetLabelSize(30,"X"); + gStyle->SetTitleOffset(1.25,"X"); + gStyle->SetTitleFont(63,"X"); + gStyle->SetTitleSize(35,"X"); + gStyle->SetLabelFont(63,"Y"); + gStyle->SetLabelSize(30,"Y"); + gStyle->SetTitleOffset(3.0,"Y"); + gStyle->SetTitleFont(63,"Y"); + gStyle->SetTitleSize(35,"Y"); + gStyle->SetLabelFont(63,"Z"); + gStyle->SetLabelSize(30,"Z"); + + + for ( unsigned int index = 0; index < theList.size() ; index++ ) { + + std::cout << index << std::endl; + + TString theName = theDir+"/"+theList[index]; + std::cout << theName << std::endl; + + TH1* href_; + rfile->GetObject(theName,href_); + href_; + double nentries=href_->GetEntries(); + double integral=href_->Integral(0,href_->GetNbinsX()+1); + if(integral!=0)href_->Scale(nentries/integral); + href_->Sumw2(); + + + TH1* hnew_; + sfile->GetObject(theName,hnew_); + hnew_; + // Set errors to sqrt(# entries) + double nentries=hnew_->GetEntries(); + double integral=hnew_->Integral(0,hnew_->GetNbinsX()+1); + if(integral!=0)hnew_->Scale(nentries/integral); + hnew_->Sumw2(); + cout << referencefile << " " << nentries << " " << integral << endl; + + + DetailedComparePlot(href_, hnew_, currentfile, referencefile, theDir, theList[index]); + + } + +} + +void DetailedComparePlot(TH1 * href_, TH1 * hnew_, TString currentfile, TString referencefile, TString theDir, TString theHisto ) +{ + + gStyle->SetOptTitle(0); + + TString theName = theDir+"/"+theHisto; + std::cout << "Histogram name = " << theName << std::endl; + + HistoCompare * myPV = new HistoCompare(); + + int rcolor = 2; + int scolor = 4; + + int rmarker = 21; + int smarker = 20; + + Double_t markerSize = 0.75; + + href_->SetLineColor(rcolor); + href_->SetMarkerStyle(rmarker); + href_->SetMarkerSize(markerSize); + href_->SetMarkerColor(rcolor); + + hnew_->SetLineColor(scolor); + hnew_->SetMarkerStyle(smarker); + hnew_->SetMarkerSize(markerSize); + hnew_->SetMarkerColor(scolor); + + if ( href_ && hnew_ ) { + + + TCanvas *myPlot = new TCanvas("myPlot","Histogram comparison",200,10,700,900); + TPad *pad0 = new TPad("pad0","The pad with the function ",0.0,0.9,0.0,1.0); + TPad *pad1 = new TPad("pad1","The pad with the function ",0.0,0.6,0.5,0.9); + TPad *pad2 = new TPad("pad2","The pad with the histogram",0.5,0.6,1.0,0.9); + TPad *pad3 = new TPad("pad3","The pad with the histogram",0.0,0.3,0.5,0.6); + TPad *pad4 = new TPad("pad4","The pad with the histogram",0.5,0.3,1.0,0.6); + TPad *pad5 = new TPad("pad5","The pad with the histogram",0.0,0.0,0.5,0.3); + TPad *pad6 = new TPad("pad6","The pad with the histogram",0.5,0.0,1.0,0.3); + + pad1->Draw(); + pad2->Draw(); + pad3->Draw(); + pad4->Draw(); + pad5->Draw(); + pad6->Draw(); + + + // Draw a global picture title + TText titte; + titte.SetTextSize(0.02); + titte.DrawTextNDC(0.1,0.98,theName); + titte.DrawTextNDC(0.1,0.96,"Reference File (A):"); + titte.DrawTextNDC(0.1,0.94,referencefile); + titte.DrawTextNDC(0.1,0.92,"Current File (B):"); + titte.DrawTextNDC(0.1,0.90,currentfile); + + hnew_->SetXTitle(href_->GetTitle()); + href_->SetXTitle(href_->GetTitle()); + hnew_->SetTitleOffset(1.5,"Y"); + href_->SetTitleOffset(1.5,"Y"); + + + // Draw reference + pad1->cd(); + href_->SetYTitle("Events (A)"); + href_->DrawCopy("e1"); + + + // Draw new + pad2->cd(); + hnew_->SetYTitle("Events (B)"); + hnew_->DrawCopy("e1"); + + gStyle->SetOptStat("nemruoi"); + + // Draw the two overlayed Normalized display region to 1 + pad3->cd(); + + pad3->SetGridx(); + pad3->SetGridy(); + TH1 *hnew_c=hnew_->Clone(); + TH1 *href_c=href_->Clone(); + double integral=href_c->Integral(1,href_c->GetNbinsX()); + if(integral!=0)href_c->Scale(1/integral); + double integral=hnew_c->Integral(1,href_c->GetNbinsX()); + if(integral!=0)hnew_c->Scale(1/integral); + href_c->SetYTitle("Comparison of A and B"); + href_c->DrawCopy("e1"); + hnew_c->DrawCopy("e1same"); + TText* te = new TText(); + te->SetTextSize(0.04); + myPV->PVCompute( href_ , hnew_ , te ); + + + + TH1 *ratio_=hnew_c->Clone(); + ratio_->Divide(href_c); + ratio_->SetYTitle("Ratio: B/A"); + pad4->cd(); + pad4->SetGridx(); + pad4->SetGridy(); + ratio_->DrawCopy("e1"); + + TH1 *diff_=hnew_c->Clone(); + diff_->Add(href_c,-1); + diff_->SetYTitle("Difference: B-A"); + pad5->cd(); + pad5->SetGridx(); + pad5->SetGridy(); + diff_->DrawCopy("e1"); + + + TH1 *sigma_=diff_->Clone(); + for(unsigned int i=1; i<=sigma_->GetNbinsX(); i++ ){ + double v=sigma_->GetBinContent(i); + double e=sigma_->GetBinError(i); + // cout << v << "+/-" << e << " " << v/fabs(e) << endl; + if(e!=0)sigma_->SetBinContent(i,v/fabs(e)); + else sigma_->SetBinContent(i,0); + } + sigma_->SetYTitle("Sigma on Difference: (B-A)/sigma(B-A)"); + pad6->cd(); + pad6->SetGridx(); + pad6->SetGridy(); + sigma_->DrawCopy("phisto"); + + + + pad0->cd(); + + gStyle->SetOptStat(0000000); + + } + TString plotFile = theHisto+".eps"; + myPlot->Print(plotFile); + + delete myPV; + delete myPlot; + + } + +std::vector histoList( TString currentfile, TString theDir ) +{ + + gROOT ->Reset(); + char* sfilename = currentfile ; + + delete gROOT->GetListOfFiles()->FindObject(sfilename); + + TFile * sfile = new TFile(sfilename); + + char* baseDir=theDir; + + sfile->cd(baseDir); + + TDirectory * d = gDirectory; + + std::vector theHistList; + + TIter i( d->GetListOfKeys() ); + TKey *k; + while( (k = (TKey*)i())) { + TClass * c1 = gROOT->GetClass(k->GetClassName()); + if ( !c1->InheritsFrom("TH1")) continue; + theHistList.push_back(k->GetName()); + } + + std::cout << "Histograms considered: " << std::endl; + for (unsigned int index = 0; index < theHistList.size() ; index++ ) { + std::cout << index << " " << theHistList[index] << std::endl; + } + + return theHistList; + +} diff --git a/Validation/EventGenerator/test/convertLHE2HepMCReweightandValidate8TeV_cfg.py b/Validation/EventGenerator/test/convertLHE2HepMCReweightandValidate8TeV_cfg.py new file mode 100644 index 0000000000000..484a81600a5fa --- /dev/null +++ b/Validation/EventGenerator/test/convertLHE2HepMCReweightandValidate8TeV_cfg.py @@ -0,0 +1,84 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("convertLHE2HepMC") +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.MessageLogger.categories=cms.untracked.vstring('FwkJob' + ,'FwkReport' + ,'FwkSummary' + ,'Root_NoDictionary' + ,'Generator' + ,'LHEInterface' + ) + + +process.MessageLogger.cerr.INFO = cms.untracked.PSet(limit = cms.untracked.int32(-1)) +process.MessageLogger.cerr.Generator = cms.untracked.PSet(limit = cms.untracked.int32(0)) +process.MessageLogger.cerr.LHEInterface = cms.untracked.PSet(limit = cms.untracked.int32(0)) +process.MessageLogger.cerr.FwkReport.reportEvery = cms.untracked.int32(10000) + + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(10000) +) +process.source = cms.Source("LHESource", + fileNames = cms.untracked.vstring() +) +process.source.fileNames = ([ +'/store/eos/user/lenzip/Madgraph/8TeV/W1JetsToLNu_8TeV-madgraph/W1JetsToLNu_8TeV-madgraph_10001.lhe', +'/store/eos/user/lenzip/Madgraph/8TeV/W1JetsToLNu_8TeV-madgraph/W1JetsToLNu_8TeV-madgraph_10002.lhe', +'/store/eos/user/lenzip/Madgraph/8TeV/W1JetsToLNu_8TeV-madgraph/W1JetsToLNu_8TeV-madgraph_10003.lhe', +'/store/eos/user/lenzip/Madgraph/8TeV/W1JetsToLNu_8TeV-madgraph/W1JetsToLNu_8TeV-madgraph_10004.lhe', +'/store/eos/user/lenzip/Madgraph/8TeV/W1JetsToLNu_8TeV-madgraph/W1JetsToLNu_8TeV-madgraph_10005.lhe', +'/store/eos/user/lenzip/Madgraph/8TeV/W1JetsToLNu_8TeV-madgraph/W1JetsToLNu_8TeV-madgraph_10006.lhe', +'/store/eos/user/lenzip/Madgraph/8TeV/W1JetsToLNu_8TeV-madgraph/W1JetsToLNu_8TeV-madgraph_10007.lhe', +'/store/eos/user/lenzip/Madgraph/8TeV/W1JetsToLNu_8TeV-madgraph/W1JetsToLNu_8TeV-madgraph_10008.lhe', +'/store/eos/user/lenzip/Madgraph/8TeV/W1JetsToLNu_8TeV-madgraph/W1JetsToLNu_8TeV-madgraph_10009.lhe', +'/store/eos/user/lenzip/Madgraph/8TeV/W1JetsToLNu_8TeV-madgraph/W1JetsToLNu_8TeV-madgraph_10010.lhe' +]) + +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration/StandardSequences/EndOfProcess_cff') +process.load("GeneratorInterface.LHEInterface.lheCOMWeightProducer") +process.load('Configuration.StandardSequences.Generator_cff') +process.load("GeneratorInterface.LHEInterface.lhe2HepMCConverter_cfi") +process.genParticles.src = 'lhe2HepMCConverter' +process.load("Validation.EventGenerator.BasicGenValidation_cff") +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +ANALYSISEventContent = cms.PSet( + outputCommands = cms.untracked.vstring('drop *') +) +ANALYSISEventContent.outputCommands.extend(process.MEtoEDMConverterFEVT.outputCommands) + +process.out = cms.OutputModule("PoolOutputModule", + fileName = cms.untracked.string('output8TeVReweight.root'), + outputCommands = ANALYSISEventContent.outputCommands +) + +# DQM Services + +from DQMServices.Components.DQMEnvironment_cfi import * + +DQMStore = cms.Service("DQMStore") + +dqmSaver.convention = 'Offline' +dqmSaver.workflow = '/BasicHepMCValidation/Workflow/GEN' + +from Validation.EventGenerator.genvalidTools import * + +switchGenSourceForValidation(process, cms.InputTag('lhe2HepMCConverter')) +useExternalWeightForValidation(process, cms.VInputTag(cms.InputTag('lheCOMWeightProducer', 'comTo7000'))) + + +process.out = cms.OutputModule("PoolOutputModule", + fileName = cms.untracked.string('output8TeVReweight.root'), + outputCommands = ANALYSISEventContent.outputCommands +) + + +process.gen = cms.Sequence(process.GeneInfo+process.genJetMET) +process.p = cms.Path( process.lheCOMWeightProducer + + process.lhe2HepMCConverter + + process.gen + + process.genvalid_all + + process.endOfProcess ) +process.e = cms.EndPath(process.out) diff --git a/Validation/EventGenerator/test/convertLHE2HepMCandValidate_cfg.py b/Validation/EventGenerator/test/convertLHE2HepMCandValidate_cfg.py new file mode 100644 index 0000000000000..36b5fc3b2ae62 --- /dev/null +++ b/Validation/EventGenerator/test/convertLHE2HepMCandValidate_cfg.py @@ -0,0 +1,62 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("convertLHE2HepMC") +process.load("FWCore.MessageLogger.MessageLogger_cfi") + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(-1) +) +process.source = cms.Source("LHESource", + fileNames = cms.untracked.vstring() +) +process.source.fileNames = ([ + '/store/lhe/3589/7TeV_wz2l2q_run50001_unweighted_events_qcut18_mgPostv2.lhe', + '/store/lhe/3589/7TeV_wz2l2q_run50002_unweighted_events_qcut18_mgPostv2.lhe', + '/store/lhe/3589/7TeV_wz2l2q_run50003_unweighted_events_qcut18_mgPostv2.lhe', +]) + +process.load("GeneratorInterface.LHEInterface.lhe2HepMCConverter_cfi") +process.load("PhysicsTools.HepMCCandAlgos.genParticles_cfi") +process.genParticles.src = 'lhe2HepMCConverter' +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load("RecoJets.Configuration.RecoGenJets_cff") +process.load("RecoMET.Configuration.RecoGenMET_cff") +process.load("RecoJets.Configuration.GenJetParticles_cff") +process.load("RecoMET.Configuration.GenMETParticles_cff") + + +#process.load("Validation.EventGenerator.MBUEandQCDValidation_cff") +process.load("Validation.EventGenerator.BasicHepMCValidation_cff") +#process.mbueAndqcdValidation.hepmcCollection = 'lhe2HepMCConverter' +process.basicHepMCValidation.hepmcCollection = 'lhe2HepMCConverter' +process.load('Configuration.EventContent.EventContent_cff') +process.load('Configuration/StandardSequences/EndOfProcess_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +ANALYSISEventContent = cms.PSet( + outputCommands = cms.untracked.vstring('drop *') + ) +ANALYSISEventContent.outputCommands.extend(process.MEtoEDMConverterFEVT.outputCommands) + +process.out = cms.OutputModule("PoolOutputModule", + fileName = cms.untracked.string('output.root'), + outputCommands = ANALYSISEventContent.outputCommands + ) + +# DQM Services + +from DQMServices.Components.DQMEnvironment_cfi import * + +DQMStore = cms.Service("DQMStore") + +dqmSaver.convention = 'Offline' +dqmSaver.workflow = '/BasicHepMCValidation/Workflow/GEN' + +process.p = cms.Path(process.lhe2HepMCConverter + + process.genParticles + + process.genJetParticles + + process.recoGenJets + + process.genMETParticles + + process.recoGenMET + +process.basicHepMCValidation+process.endOfProcess + ) +process.e = cms.EndPath(process.out) diff --git a/Validation/EventGenerator/test/testTauValidation_cfg.py b/Validation/EventGenerator/test/testTauValidation_cfg.py index 6a236c3365b64..7e79d4f900243 100644 --- a/Validation/EventGenerator/test/testTauValidation_cfg.py +++ b/Validation/EventGenerator/test/testTauValidation_cfg.py @@ -18,6 +18,7 @@ # 'file:gen.root' # '/store/relval/CMSSW_3_6_0_pre5/RelValHiggs200ChargedTaus/GEN-SIM-DIGI-RAW-HLTDEBUG/START36_V3-v1/0010/E09B3F44-E13D-DF11-995D-00304867BFA8.root' 'rfio:/castor/cern.ch/user/s/slehti/HiggsAnalysisData/test_H120_100_1_08t_RAW_RECO.root' +# 'rfio:/castor/cern.ch/user/s/slehti/testData/DYToTauTau_M_20_TuneZ2_7TeV_pythia6_tauola_Fall10_START38_V12_v2_GEN_SIM_RECO_100ev.root' ) )