CMS 3D CMS Logo

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

#include <GenMuonRadCorrAnalyzer.h>

Inheritance diagram for GenMuonRadCorrAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  plotEntryType
 

Public Member Functions

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

Private Types

typedef std::vector
< edm::InputTag
vInputTag
 

Private Attributes

double beamEnergy_
 
std::string directory_
 
GenMuonRadiationAlgorithmmuonRadiationAlgo_
 
int numWarnings_
 
std::vector< plotEntryType * > plotEntries_
 
edm::InputTag srcGenParticles_
 
edm::InputTag srcSelectedMuons_
 
vInputTag srcWeights_
 
int verbosity_
 

Additional Inherited Members

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

Detailed Description

Definition at line 24 of file GenMuonRadCorrAnalyzer.h.

Member Typedef Documentation

typedef std::vector<edm::InputTag> GenMuonRadCorrAnalyzer::vInputTag
private

Definition at line 37 of file GenMuonRadCorrAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 17 of file GenMuonRadCorrAnalyzer.cc.

References edm::ParameterSet::addParameter(), directory_, edm::hlt::Exception, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), muonRadiationAlgo_, plotEntries_, srcGenParticles_, srcSelectedMuons_, srcWeights_, AlCaHLTBitMon_QueryRunRegistry::string, and verbosity_.

18  : beamEnergy_(cfg.getParameter<double>("beamEnergy")),
20  numWarnings_(0)
21 {
22  srcSelectedMuons_ = cfg.getParameter<edm::InputTag>("srcSelectedMuons");
23  srcGenParticles_ = cfg.getParameter<edm::InputTag>("srcGenParticles");
24 
25  srcWeights_ = cfg.getParameter<vInputTag>("srcWeights");
26 
27  directory_ = cfg.getParameter<std::string>("directory");
28 
29  verbosity_ = ( cfg.exists("verbosity") ) ?
30  cfg.getParameter<int>("verbosity") : 0;
31 
32  typedef std::vector<double> vdouble;
33  vdouble binningMuonEn = cfg.getParameter<vdouble>("binningMuonEn");
34  int numBinsMuonEn = binningMuonEn.size() - 1;
35  if ( !(numBinsMuonEn >= 1) ) throw cms::Exception("Configuration")
36  << " Invalid Configuration Parameter 'binningMuonEn', must define at least one bin !!\n";
37 
38  unsigned numBinsRadDivMuonEn = cfg.getParameter<unsigned>("numBinsRadDivMuonEn");
39  double minRadDivMuonEn = cfg.getParameter<double>("minRadDivMuonEn");
40  double maxRadDivMuonEn = cfg.getParameter<double>("maxRadDivMuonEn");
41 
42  for ( int iBinMuPlusEn = 0; iBinMuPlusEn < numBinsMuonEn; ++iBinMuPlusEn ) {
43  double minMuPlusEn = binningMuonEn[iBinMuPlusEn];
44  double maxMuPlusEn = binningMuonEn[iBinMuPlusEn + 1];
45  for ( int iBinMuMinusEn = 0; iBinMuMinusEn < numBinsMuonEn; ++iBinMuMinusEn ) {
46  double minMuMinusEn = binningMuonEn[iBinMuMinusEn];
47  double maxMuMinusEn = binningMuonEn[iBinMuMinusEn + 1];
48  plotEntryType* plotEntry =
49  new plotEntryType(minMuPlusEn, maxMuPlusEn, minMuMinusEn, maxMuMinusEn,
50  numBinsRadDivMuonEn, minRadDivMuonEn, maxRadDivMuonEn);
51  plotEntries_.push_back(plotEntry);
52  }
53  }
54 
55  std::string muonRadiationAlgo_string = cfg.getParameter<std::string>("muonRadiationAlgo");
56  if ( muonRadiationAlgo_string == "" ) {
58  } else if ( muonRadiationAlgo_string == "pythia" ) {
59  edm::ParameterSet cfgMuonRadiationAlgo_pythia(cfg);
60  cfgMuonRadiationAlgo_pythia.addParameter<std::string>("mode", "pythia");
61  cfgMuonRadiationAlgo_pythia.addParameter<int>("verbosity", verbosity_);
62  muonRadiationAlgo_ = new GenMuonRadiationAlgorithm(cfgMuonRadiationAlgo_pythia);
63  } else if ( muonRadiationAlgo_string == "photos" ) {
64  edm::ParameterSet cfgMuonRadiationAlgo_photos(cfg);
65  cfgMuonRadiationAlgo_photos.addParameter<std::string>("mode", "photos");
66  cfgMuonRadiationAlgo_photos.addParameter<int>("verbosity", verbosity_);
67  muonRadiationAlgo_ = new GenMuonRadiationAlgorithm(cfgMuonRadiationAlgo_photos);
68  } else throw cms::Exception("Configuration")
69  << " Invalid Configuration Parameter 'muonRadiationAlgo' = " << muonRadiationAlgo_string << " !!\n";
70 }
T getParameter(std::string const &) const
GenMuonRadiationAlgorithm * muonRadiationAlgo_
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< edm::InputTag > vInputTag
std::vector< plotEntryType * > plotEntries_
GenMuonRadCorrAnalyzer::~GenMuonRadCorrAnalyzer ( )

Definition at line 72 of file GenMuonRadCorrAnalyzer.cc.

References muonRadiationAlgo_, and plotEntries_.

73 {
74  for ( std::vector<plotEntryType*>::iterator it = plotEntries_.begin();
75  it != plotEntries_.end(); ++it ) {
76  delete (*it);
77  }
78 
79  delete muonRadiationAlgo_;
80 }
GenMuonRadiationAlgorithm * muonRadiationAlgo_
std::vector< plotEntryType * > plotEntries_

Member Function Documentation

void GenMuonRadCorrAnalyzer::analyze ( const edm::Event evt,
const edm::EventSetup es 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 93 of file GenMuonRadCorrAnalyzer.cc.

References reco::LeafCandidate::charge(), GenMuonRadiationAlgorithm::compFSR(), compGenMuonP4afterRad(), alignCSCRings::e, findGenParticleForMCEmbedding(), genParticleCandidates2GenParticles_cfi::genParticles, edm::Event::getByLabel(), getSelMuons(), muonRadiationAlgo_, reco::LeafCandidate::p4(), plotEntries_, ValidateTausOnRealMuonsData_cff::selectedMuons, srcGenParticles_, srcSelectedMuons_, srcWeights_, edm::Event::streamID(), and histoStyle::weight.

94 {
95  double evtWeight = 1.0;
96  for ( vInputTag::const_iterator srcWeight = srcWeights_.begin();
97  srcWeight != srcWeights_.end(); ++srcWeight ) {
99  evt.getByLabel(*srcWeight, weight);
100  evtWeight *= (*weight);
101  }
102 
103  if ( evtWeight < 1.e-3 || evtWeight > 1.e+3 || TMath::IsNaN(evtWeight) ) return;
104 
105  std::vector<reco::CandidateBaseRef> selectedMuons = getSelMuons(evt, srcSelectedMuons_);
106 
108  evt.getByLabel(srcGenParticles_, genParticles);
109 
110  reco::Candidate::LorentzVector genMuonPlusP4_beforeRad;
111  reco::Candidate::LorentzVector genMuonPlusP4_afterRad;
112  bool genMuonPlus_found = false;
113  reco::Candidate::LorentzVector genMuonMinusP4_beforeRad;
114  reco::Candidate::LorentzVector genMuonMinusP4_afterRad;
115  bool genMuonMinus_found = false;
116 
117  std::vector<int> muonPdgIds;
118  muonPdgIds.push_back(-13);
119  muonPdgIds.push_back(+13);
120 
121  for ( std::vector<reco::CandidateBaseRef>::const_iterator selectedMuon = selectedMuons.begin();
122  selectedMuon != selectedMuons.end(); ++selectedMuon ) {
123  const reco::GenParticle* genMuon_matched = findGenParticleForMCEmbedding((*selectedMuon)->p4(), *genParticles, 0.3, -1, &muonPdgIds, true);
124  if ( genMuon_matched && genMuon_matched->charge() > +0.5 ) {
125  genMuonPlusP4_beforeRad = genMuon_matched->p4();
126  genMuonPlusP4_afterRad = genMuonPlusP4_beforeRad;
127  compGenMuonP4afterRad(genMuon_matched, genMuonPlusP4_afterRad);
128  genMuonPlus_found = true;
129  }
130  if ( genMuon_matched && genMuon_matched->charge() < -0.5 ) {
131  genMuonMinusP4_beforeRad = genMuon_matched->p4();
132  genMuonMinusP4_afterRad = genMuonMinusP4_beforeRad;
133  compGenMuonP4afterRad(genMuon_matched, genMuonMinusP4_afterRad);
134  genMuonMinus_found = true;
135  }
136  }
137 
138  if ( !(genMuonPlus_found && genMuonMinus_found) ) return;
139 
140  double muonPlusRad = 0.;
141  int muonPlusRad_error = 0;
142  double muonMinusRad = 0.;
143  int muonMinusRad_error = 0;
144  if ( muonRadiationAlgo_ ) {
145  muonPlusRad = muonRadiationAlgo_->compFSR(evt.streamID(), genMuonPlusP4_beforeRad, +1, genMuonMinusP4_beforeRad, muonPlusRad_error).E();
146  muonMinusRad = muonRadiationAlgo_->compFSR(evt.streamID(), genMuonMinusP4_beforeRad, -1, genMuonPlusP4_beforeRad, muonMinusRad_error).E();
147  } else {
148  muonPlusRad = genMuonPlusP4_beforeRad.E() - genMuonPlusP4_afterRad.E();
149  muonMinusRad = genMuonMinusP4_beforeRad.E() - genMuonMinusP4_afterRad.E();
150  }
151 
152  if ( muonPlusRad_error || muonMinusRad_error ) return;
153 
154  for ( std::vector<plotEntryType*>::iterator plotEntry = plotEntries_.begin();
155  plotEntry != plotEntries_.end(); ++plotEntry ) {
156  (*plotEntry)->fillHistograms(genMuonPlusP4_afterRad.E(), muonPlusRad, genMuonMinusP4_afterRad.E(), muonMinusRad, evtWeight);
157  }
158 }
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
GenMuonRadiationAlgorithm * muonRadiationAlgo_
const reco::GenParticle * findGenParticleForMCEmbedding(const reco::Candidate::LorentzVector &, const reco::GenParticleCollection &, double, int, const std::vector< int > *, bool)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
void compGenMuonP4afterRad(const reco::GenParticle *, reco::Candidate::LorentzVector &)
reco::Candidate::LorentzVector compFSR(const edm::StreamID &streamID, const reco::Candidate::LorentzVector &, int, const reco::Candidate::LorentzVector &, int &)
virtual int charge() const GCC11_FINAL
electric charge
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
StreamID streamID() const
Definition: Event.h:75
std::vector< reco::CandidateBaseRef > getSelMuons(const edm::Event &, const edm::InputTag &)
int weight
Definition: histoStyle.py:50
std::vector< plotEntryType * > plotEntries_
void GenMuonRadCorrAnalyzer::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 82 of file GenMuonRadCorrAnalyzer.cc.

References dir, directory_, TFileService::mkdir(), plotEntries_, and TFileService::tFileDirectory().

83 {
85 
86  TFileDirectory dir = ( directory_ != "" ) ? fs->mkdir(directory_) : (fs->tFileDirectory());
87  for ( std::vector<plotEntryType*>::iterator plotEntry = plotEntries_.begin();
88  plotEntry != plotEntries_.end(); ++plotEntry ) {
89  (*plotEntry)->bookHistograms(dir);
90  }
91 }
TFileDirectory & tFileDirectory()
Definition: TFileService.h:42
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
dbl *** dir
Definition: mlp_gen.cc:35
std::vector< plotEntryType * > plotEntries_

Member Data Documentation

double GenMuonRadCorrAnalyzer::beamEnergy_
private

Definition at line 92 of file GenMuonRadCorrAnalyzer.h.

std::string GenMuonRadCorrAnalyzer::directory_
private

Definition at line 40 of file GenMuonRadCorrAnalyzer.h.

Referenced by beginJob(), and GenMuonRadCorrAnalyzer().

GenMuonRadiationAlgorithm* GenMuonRadCorrAnalyzer::muonRadiationAlgo_
private
int GenMuonRadCorrAnalyzer::numWarnings_
private

Definition at line 98 of file GenMuonRadCorrAnalyzer.h.

std::vector<plotEntryType*> GenMuonRadCorrAnalyzer::plotEntries_
private
edm::InputTag GenMuonRadCorrAnalyzer::srcGenParticles_
private

Definition at line 35 of file GenMuonRadCorrAnalyzer.h.

Referenced by analyze(), and GenMuonRadCorrAnalyzer().

edm::InputTag GenMuonRadCorrAnalyzer::srcSelectedMuons_
private

Definition at line 34 of file GenMuonRadCorrAnalyzer.h.

Referenced by analyze(), and GenMuonRadCorrAnalyzer().

vInputTag GenMuonRadCorrAnalyzer::srcWeights_
private

Definition at line 38 of file GenMuonRadCorrAnalyzer.h.

Referenced by analyze(), and GenMuonRadCorrAnalyzer().

int GenMuonRadCorrAnalyzer::verbosity_
private

Definition at line 96 of file GenMuonRadCorrAnalyzer.h.

Referenced by GenMuonRadCorrAnalyzer().