CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PatElectronAnalyzer Class Reference
Inheritance diagram for PatElectronAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 PatElectronAnalyzer (const edm::ParameterSet &)
 
 ~PatElectronAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginJob () override
 
virtual void endJob () override
 

Private Attributes

TH1F * deltaPhi_
 
TH1F * deltaR_
 
std::string electronID_
 
edm::EDGetTokenT< std::vector< pat::Electron > > electronSrcToken_
 
TH1F * eta_
 
TH1F * genEta_
 
edm::ParameterSet genMatchMode_
 
TH1F * genPhi_
 
TH1F * genPt_
 
TH1F * invMass_
 
TH1F * isoTag_
 
double maxDeltaM_
 
double maxDeltaR_
 
double maxEta_
 
double maxTagIso_
 
double minPt_
 
unsigned int mode_
 
TH1I * nr_
 
edm::EDGetTokenT< reco::GenParticleCollectionparticleSrcToken_
 
TH1F * phi_
 
TH1F * pt_
 
edm::ParameterSet tagAndProbeMode_
 

Additional Inherited Members

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

Detailed Description

Definition at line 15 of file PatElectronAnalyzer.cc.

Constructor & Destructor Documentation

PatElectronAnalyzer::PatElectronAnalyzer ( const edm::ParameterSet cfg)
explicit

Definition at line 78 of file PatElectronAnalyzer.cc.

References deltaPhi_, deltaR_, eta_, genEta_, genMatchMode_, genPhi_, genPt_, edm::ParameterSet::getParameter(), invMass_, isoTag_, maxDeltaM_, maxDeltaR_, maxTagIso_, nr_, phi_, pt_, and tagAndProbeMode_.

78  :
79  minPt_ (cfg.getParameter<double>("minPt")),
80  maxEta_ (cfg.getParameter<double>("maxEta")),
81  mode_ (cfg.getParameter<unsigned int>("mode")),
82  electronID_ (cfg.getParameter<std::string>("electronID")),
83  electronSrcToken_ (consumes<std::vector<pat::Electron> >(cfg.getParameter<edm::InputTag>("electronSrc"))),
84  particleSrcToken_ (consumes<reco::GenParticleCollection>(cfg.getParameter<edm::InputTag>("particleSrc"))),
85  genMatchMode_(cfg.getParameter<edm::ParameterSet>("genMatchMode")),
86  tagAndProbeMode_(cfg.getParameter<edm::ParameterSet>("tagAndProbeMode"))
87 {
88  // complete the configuration of the analyzer
89  maxDeltaR_ = genMatchMode_ .getParameter<double>("maxDeltaR");
90  maxDeltaM_ = tagAndProbeMode_.getParameter<double>("maxDeltaM");
91  maxTagIso_ = tagAndProbeMode_.getParameter<double>("maxTagIso");
92 
93 
94  // register histograms to the TFileService
96  nr_ = fs->make<TH1I>("nr", "nr", 10, 0 , 10 );
97  pt_ = fs->make<TH1F>("pt", "pt", 20, 0., 100.);
98  eta_ = fs->make<TH1F>("eta", "eta", 30, -3., 3.);
99  phi_ = fs->make<TH1F>("phi", "phi", 35, -3.5, 3.5);
100  genPt_ = fs->make<TH1F>("genPt", "pt", 20, 0., 100.);
101  genEta_ = fs->make<TH1F>("genEta", "eta", 30, -3., 3.);
102  genPhi_ = fs->make<TH1F>("genPhi", "phi", 35, -3.5, 3.5);
103  deltaR_ = fs->make<TH1F>("deltaR", "log(dR)", 50, -5., 0.);
104  isoTag_ = fs->make<TH1F>("isoTag", "iso", 50, 0., 10.);
105  invMass_ = fs->make<TH1F>("invMass", "m", 100, 50., 150.);
106  deltaPhi_= fs->make<TH1F>("deltaPhi", "deltaPhi", 100, -3.5, 3.5);
107 }
T getParameter(std::string const &) const
edm::EDGetTokenT< std::vector< pat::Electron > > electronSrcToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::GenParticleCollection > particleSrcToken_
edm::ParameterSet tagAndProbeMode_
edm::ParameterSet genMatchMode_
PatElectronAnalyzer::~PatElectronAnalyzer ( )

Definition at line 109 of file PatElectronAnalyzer.cc.

110 {
111 }

Member Function Documentation

void PatElectronAnalyzer::analyze ( const edm::Event evt,
const edm::EventSetup setup 
)
overrideprivatevirtual

Definition at line 114 of file PatElectronAnalyzer.cc.

References funct::abs(), MuonCkfTrajectoryBuilder_cfi::deltaPhi, allConversions_cfi::DeltaPhi, deltaPhi_, deltaR(), HiRegitMuonDetachedTripletStep_cff::DeltaR, deltaR_, electronID_, genericTrackCleaner_cfi::electrons, electronSrcToken_, eta_, genEta_, genPhi_, genPt_, edm::Event::getByToken(), invMass_, isoTag_, ResonanceBuilder::mass, maxDeltaM_, maxDeltaR_, maxEta_, maxTagIso_, minPt_, mode_, nr_, HadronAndPartonSelector_cfi::particles, particleSrcToken_, phi_, and pt_.

115 {
116  // get electron collection
118  evt.getByToken(electronSrcToken_, electrons);
119  // get generator particle collection
121  evt.getByToken(particleSrcToken_, particles);
122 
123  nr_->Fill( electrons->size() );
124 
125  // ----------------------------------------------------------------------
126  //
127  // First Part Mode 0: genMatch
128  //
129  // ----------------------------------------------------------------------
130  if( mode_==0 ){
131  // loop generator particles
132  for(reco::GenParticleCollection::const_iterator part=particles->begin();
133  part!=particles->end(); ++part){
134  // only loop stable electrons
135  if( part->status()==1 && abs(part->pdgId())==11 ){
136  if( part->pt()>minPt_ && fabs(part->eta())<maxEta_ ){
137  genPt_ ->Fill( part->pt() );
138  genEta_->Fill( part->eta() );
139  genPhi_->Fill( part->phi() );
140  }
141  }
142  }
143 
144  // loop electrons
145  for( std::vector<pat::Electron>::const_iterator elec=electrons->begin(); elec!=electrons->end(); ++elec ){
146  if( elec->genLepton() ){
147  float deltaR = ROOT::Math::VectorUtil::DeltaR(elec->genLepton()->p4(), elec->p4());
148  deltaR_->Fill(TMath::Log10(deltaR));
149  if( deltaR<maxDeltaR_ ){
150  if( electronID_.compare("none")!=0 ){
151  if( elec->electronID(electronID_)<0.5 )
152  continue;
153  }
154  if( elec->pt()>minPt_ && fabs(elec->eta())<maxEta_ ){
155  pt_ ->Fill( elec->pt() );
156  eta_->Fill( elec->eta() );
157  phi_->Fill( elec->phi() );
158  }
159  }
160  }
161  }
162  }
163 
164  // ----------------------------------------------------------------------
165  //
166  // Second Part Mode 1: tagAndProbe
167  //
168  // ----------------------------------------------------------------------
169  if( mode_==1 ){
170  // loop tag electron
171  for( std::vector<pat::Electron>::const_iterator elec=electrons->begin(); elec!=electrons->end(); ++elec ){
172  isoTag_->Fill(elec->trackIso());
173  if( elec->trackIso()<maxTagIso_ && elec->electronID("eidTight")>0.5 ){
174  // loop probe electron
175  for( std::vector<pat::Electron>::const_iterator probe=electrons->begin(); probe!=electrons->end(); ++probe ){
176  // skip the tag electron itself
177  if( probe==elec ) continue;
178 
179  float zMass = (probe->p4()+elec->p4()).mass();
180  invMass_ ->Fill(zMass);
181  float deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(elec->p4(), probe->p4());
182  deltaPhi_->Fill(deltaPhi);
183 
184  // check for the Z mass
185  if( fabs( zMass-90. )<maxDeltaM_ ){
186  if( electronID_.compare("none")!=0 ){
187  if( probe->electronID(electronID_)<0.5 )
188  continue;
189  }
190  if( probe->pt()>minPt_ && fabs(probe->eta())<maxEta_ ){
191  pt_ ->Fill( probe->pt() );
192  eta_->Fill( probe->eta() );
193  phi_->Fill( probe->phi() );
194  }
195  }
196  }
197  }
198  }
199  }
200 }
edm::EDGetTokenT< std::vector< pat::Electron > > electronSrcToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< reco::GenParticleCollection > particleSrcToken_
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
part
Definition: HCALResponse.h:20
void PatElectronAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 202 of file PatElectronAnalyzer.cc.

203 {
204 }
void PatElectronAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 206 of file PatElectronAnalyzer.cc.

References DEFINE_FWK_MODULE.

207 {
208 }

Member Data Documentation

TH1F* PatElectronAnalyzer::deltaPhi_
private

Definition at line 73 of file PatElectronAnalyzer.cc.

Referenced by analyze(), and PatElectronAnalyzer().

TH1F* PatElectronAnalyzer::deltaR_
private

Definition at line 70 of file PatElectronAnalyzer.cc.

Referenced by analyze(), and PatElectronAnalyzer().

std::string PatElectronAnalyzer::electronID_
private

Definition at line 46 of file PatElectronAnalyzer.cc.

Referenced by analyze().

edm::EDGetTokenT<std::vector<pat::Electron> > PatElectronAnalyzer::electronSrcToken_
private

Definition at line 49 of file PatElectronAnalyzer.cc.

Referenced by analyze().

TH1F* PatElectronAnalyzer::eta_
private

Definition at line 65 of file PatElectronAnalyzer.cc.

Referenced by analyze(), and PatElectronAnalyzer().

TH1F* PatElectronAnalyzer::genEta_
private

Definition at line 68 of file PatElectronAnalyzer.cc.

Referenced by analyze(), and PatElectronAnalyzer().

edm::ParameterSet PatElectronAnalyzer::genMatchMode_
private

Definition at line 53 of file PatElectronAnalyzer.cc.

Referenced by PatElectronAnalyzer().

TH1F* PatElectronAnalyzer::genPhi_
private

Definition at line 69 of file PatElectronAnalyzer.cc.

Referenced by analyze(), and PatElectronAnalyzer().

TH1F* PatElectronAnalyzer::genPt_
private

Definition at line 67 of file PatElectronAnalyzer.cc.

Referenced by analyze(), and PatElectronAnalyzer().

TH1F* PatElectronAnalyzer::invMass_
private

Definition at line 72 of file PatElectronAnalyzer.cc.

Referenced by analyze(), and PatElectronAnalyzer().

TH1F* PatElectronAnalyzer::isoTag_
private

Definition at line 71 of file PatElectronAnalyzer.cc.

Referenced by analyze(), and PatElectronAnalyzer().

double PatElectronAnalyzer::maxDeltaM_
private

Definition at line 59 of file PatElectronAnalyzer.cc.

Referenced by analyze(), and PatElectronAnalyzer().

double PatElectronAnalyzer::maxDeltaR_
private

Definition at line 58 of file PatElectronAnalyzer.cc.

Referenced by analyze(), and PatElectronAnalyzer().

double PatElectronAnalyzer::maxEta_
private

Definition at line 31 of file PatElectronAnalyzer.cc.

Referenced by analyze().

double PatElectronAnalyzer::maxTagIso_
private

Definition at line 60 of file PatElectronAnalyzer.cc.

Referenced by analyze(), and PatElectronAnalyzer().

double PatElectronAnalyzer::minPt_
private

Definition at line 30 of file PatElectronAnalyzer.cc.

Referenced by analyze().

unsigned int PatElectronAnalyzer::mode_
private

Definition at line 36 of file PatElectronAnalyzer.cc.

Referenced by analyze().

TH1I* PatElectronAnalyzer::nr_
private

Definition at line 63 of file PatElectronAnalyzer.cc.

Referenced by analyze(), and PatElectronAnalyzer().

edm::EDGetTokenT<reco::GenParticleCollection> PatElectronAnalyzer::particleSrcToken_
private

Definition at line 51 of file PatElectronAnalyzer.cc.

Referenced by analyze().

TH1F* PatElectronAnalyzer::phi_
private

Definition at line 66 of file PatElectronAnalyzer.cc.

Referenced by analyze(), and PatElectronAnalyzer().

TH1F* PatElectronAnalyzer::pt_
private

Definition at line 64 of file PatElectronAnalyzer.cc.

Referenced by analyze(), and PatElectronAnalyzer().

edm::ParameterSet PatElectronAnalyzer::tagAndProbeMode_
private

Definition at line 54 of file PatElectronAnalyzer.cc.

Referenced by PatElectronAnalyzer().