CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PatTriggerTagAndProbe Class Reference
Inheritance diagram for PatTriggerTagAndProbe:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 PatTriggerTagAndProbe (const edm::ParameterSet &iConfig)
 default constructor More...
 
 ~PatTriggerTagAndProbe ()
 default destructor More...
 
- 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
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup)
 everythin that needs to be done during the event loop More...
 
virtual void beginJob ()
 everythin that needs to be done before the event loop More...
 
virtual void endJob ()
 everythin that needs to be done after the event loop More...
 
void setErrors (TH1D &h, const TH1D &ref)
 helper function to set proper bin errors More...
 

Private Attributes

std::map< std::string, TH1D * > histos1D_
 management of 1d histograms More...
 
std::string muonMatch_
 input for trigger match objects More...
 
edm::EDGetTokenT
< pat::MuonCollection
muonsToken_
 input for muons More...
 
edm::EDGetTokenT
< pat::TriggerEvent
triggerEventToken_
 input for patTriggerEvent More...
 

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 16 of file PatTriggerTagAndProbe.cc.

Constructor & Destructor Documentation

PatTriggerTagAndProbe::PatTriggerTagAndProbe ( const edm::ParameterSet iConfig)
explicit

default constructor

Definition at line 53 of file PatTriggerTagAndProbe.cc.

53  :
54  // pat::TriggerEvent
55  triggerEventToken_( consumes< pat::TriggerEvent >( iConfig.getParameter< edm::InputTag >( "triggerEvent" ) ) ),
56  // muon input collection
57  muonsToken_( consumes< pat::MuonCollection >( iConfig.getParameter< edm::InputTag >( "muons" ) ) ),
58  // muon match objects
59  muonMatch_( iConfig.getParameter< std::string >( "muonMatch" ) ),
60  // histogram management
61  histos1D_()
62 {
63 }
T getParameter(std::string const &) const
edm::EDGetTokenT< pat::MuonCollection > muonsToken_
input for muons
edm::EDGetTokenT< pat::TriggerEvent > triggerEventToken_
input for patTriggerEvent
std::map< std::string, TH1D * > histos1D_
management of 1d histograms
std::string muonMatch_
input for trigger match objects
PatTriggerTagAndProbe::~PatTriggerTagAndProbe ( )

default destructor

Definition at line 65 of file PatTriggerTagAndProbe.cc.

66 {
67 }

Member Function Documentation

void PatTriggerTagAndProbe::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

everythin that needs to be done during the event loop

Implements edm::EDAnalyzer.

Definition at line 85 of file PatTriggerTagAndProbe.cc.

References edm::Event::getByToken(), histos1D_, muonMatch_, patZpeak::muons, muonsToken_, triggerEventToken_, and pat::helper::TriggerMatchHelper::triggerMatchObject().

86 {
87  // trigger event
89  iEvent.getByToken( triggerEventToken_, triggerEvent );
90  // pat candidate collection
92  iEvent.getByToken( muonsToken_, muons );
93 
94  // pat trigger helper to recieve for trigger
95  // matching information
96  const pat::helper::TriggerMatchHelper matchHelper;
97 
98  // ask for trigger accept of HLT_Mu9; otherwise we don't even start
99  if(!(triggerEvent->path("HLT_IsoMu17_v5")->wasRun() && triggerEvent->path("HLT_IsoMu17_v5")->wasAccept())){
100  return;
101  }
102 
103  // loop over muon references for the tag muon
104  for( size_t idxTag=0; idxTag<muons->size(); ++idxTag){
105  const pat::TriggerObjectRef trigRefTag( matchHelper.triggerMatchObject( muons, idxTag, muonMatch_, iEvent, *triggerEvent ) );
106  if( trigRefTag.isAvailable() ){
107  // loop over muon references for the probe/test muon
108  for( size_t idxProbe=0; idxProbe<muons->size() && idxProbe!=idxTag; ++idxProbe){
109  histos1D_[ "mass" ]->Fill( (muons->at(idxTag).p4()+muons->at(idxProbe).p4()).mass() );
110  if(fabs((muons->at(idxTag).p4()+muons->at(idxProbe).p4()).mass()-90)<5){
111  const pat::TriggerObjectRef trigRefProbe( matchHelper.triggerMatchObject( muons, idxProbe, muonMatch_, iEvent, *triggerEvent ) );
112  histos1D_[ "probePt" ]->Fill( muons->at(idxProbe).pt () );
113  histos1D_[ "probeEta" ]->Fill( muons->at(idxProbe).eta() );
114  if( trigRefProbe.isAvailable() ){
115  histos1D_[ "testPt" ]->Fill( muons->at(idxProbe).pt () );
116  histos1D_[ "testEta"]->Fill( muons->at(idxProbe).eta() );
117  }
118  }
119  }
120  }
121  }
122 }
TriggerObjectRef triggerMatchObject(const reco::CandidateBaseRef &candRef, const TriggerObjectMatch *matchResult, const edm::Event &event, const TriggerEvent &triggerEvent) const
Methods.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::EDGetTokenT< pat::MuonCollection > muonsToken_
input for muons
edm::EDGetTokenT< pat::TriggerEvent > triggerEventToken_
input for patTriggerEvent
std::map< std::string, TH1D * > histos1D_
management of 1d histograms
std::string muonMatch_
input for trigger match objects
tuple muons
Definition: patZpeak.py:38
void PatTriggerTagAndProbe::beginJob ( void  )
privatevirtual

everythin that needs to be done before the event loop

Reimplemented from edm::EDAnalyzer.

Definition at line 69 of file PatTriggerTagAndProbe.cc.

References fileService, histos1D_, and TFileService::make().

70 {
72 
73  // mass plot around Z peak
74  histos1D_[ "mass" ] = fileService->make< TH1D >( "mass" , "Mass_{Z} (GeV)", 90, 30., 120.);
75  // pt for test candidate
76  histos1D_[ "testPt" ] = fileService->make< TH1D >( "testPt" , "p_{T} (GeV)" , 100, 0., 100.);
77  // pt for probe candidate
78  histos1D_[ "probePt" ] = fileService->make< TH1D >( "probePt" , "p_{T} (GeV)" , 100, 0., 100.);
79  // eta for test candidate
80  histos1D_[ "testEta" ] = fileService->make< TH1D >( "testEta" , "#eta" , 48, -2.4, 2.4);
81  // eta for probe candidate
82  histos1D_[ "probeEta"] = fileService->make< TH1D >( "probeEta", "#eta" , 48, -2.4, 2.4);
83 }
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::map< std::string, TH1D * > histos1D_
management of 1d histograms
edm::Service< TFileService > fileService
void PatTriggerTagAndProbe::endJob ( void  )
privatevirtual

everythin that needs to be done after the event loop

Reimplemented from edm::EDAnalyzer.

Definition at line 124 of file PatTriggerTagAndProbe.cc.

References histos1D_, and setErrors().

125 {
126  // normalize the entries of the histograms
127  histos1D_[ "testPt" ]->Divide(histos1D_ [ "probePt" ]);
128  setErrors(*histos1D_["testPt" ],*histos1D_[ "probePt" ]);
129  histos1D_[ "testEta" ]->Divide(histos1D_ [ "probeEta" ]);
130  setErrors(*histos1D_["testEta"],*histos1D_[ "probeEta" ]);
131 }
void setErrors(TH1D &h, const TH1D &ref)
helper function to set proper bin errors
std::map< std::string, TH1D * > histos1D_
management of 1d histograms
void PatTriggerTagAndProbe::setErrors ( TH1D &  h,
const TH1D &  ref 
)
private

helper function to set proper bin errors

Definition at line 133 of file PatTriggerTagAndProbe.cc.

References newFWLiteAna::bin, and mathSSE::sqrt().

Referenced by endJob().

134 {
135  for(int bin=0; bin<h.GetNbinsX(); ++bin){
136  if(ref.GetBinContent(bin+1)>0){
137  h.SetBinError(bin+1, sqrt((h.GetBinContent(bin+1)*(1.-h.GetBinContent(bin+1)))/ref.GetBinContent(bin+1)));
138  } else{ h.SetBinError(bin+1, 0.); }
139  }
140 }
T sqrt(T t)
Definition: SSEVec.h:48
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

Member Data Documentation

std::map< std::string, TH1D* > PatTriggerTagAndProbe::histos1D_
private

management of 1d histograms

Definition at line 42 of file PatTriggerTagAndProbe.cc.

Referenced by analyze(), beginJob(), and endJob().

std::string PatTriggerTagAndProbe::muonMatch_
private

input for trigger match objects

Definition at line 40 of file PatTriggerTagAndProbe.cc.

Referenced by analyze().

edm::EDGetTokenT< pat::MuonCollection > PatTriggerTagAndProbe::muonsToken_
private

input for muons

Definition at line 38 of file PatTriggerTagAndProbe.cc.

Referenced by analyze().

edm::EDGetTokenT< pat::TriggerEvent > PatTriggerTagAndProbe::triggerEventToken_
private

input for patTriggerEvent

Definition at line 36 of file PatTriggerTagAndProbe.cc.

Referenced by analyze().