CMS 3D CMS Logo

ZMuMuMassConstraintParameterFinder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Alignment/MillePedeAlignmentAlgorithm
4 // Class: ZMuMuMassConstraintParameterFinder
5 //
18 //
19 // Original Author: Gregor Mittag
20 // Created: Fri, 17 Jun 2016 09:42:56 GMT
21 //
22 //
23 
24 // system include files
25 #include <cmath>
26 #include <cstdlib>
27 #include <vector>
28 
29 // ROOT include files
30 #include "TTree.h"
31 
32 // user include files
42 
43 //
44 // class declaration
45 //
46 
47 class ZMuMuMassConstraintParameterFinder : public edm::one::EDAnalyzer<edm::one::SharedResources> {
48 public:
51 
52  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
53 
54 private:
56  class DiMuonInfo {
57  public:
58  DiMuonInfo(double, double);
60  void fill();
61  std::vector<reco::GenParticle>& muons() { return muons_; }
62 
63  private:
64  TTree* tree_{nullptr};
65  std::vector<reco::GenParticle> muons_;
66  double diMuonMass_{-1.0};
67  int pdgMother_{0};
68  bool passed_{false};
69 
70  const double minMassPair_;
71  const double maxMassPair_;
72  };
73 
74  void analyze(const edm::Event&, const edm::EventSetup&) override;
75 
76  // ----------member data ---------------------------
78 
79  // particle IDs
80  const int muonPdg_{13};
81  const int zBosonPdg_{23};
82 
83  // muon cuts
84  const double pMin_;
85  const double ptMin_;
86  const double etaMin_;
87  const double etaMax_;
88  const double phiMin_;
89  const double phiMax_;
90 
91  // di-muon cuts
92  const double minMassPair_;
93  const double maxMassPair_;
94 
97 };
98 
99 //
100 // constructors and destructor
101 //
103  : genParticlesToken_(consumes<reco::GenParticleCollection>(edm::InputTag{"genParticles"})),
104  pMin_(iConfig.getParameter<double>("pMin")),
105  ptMin_(iConfig.getParameter<double>("ptMin")),
106  etaMin_(iConfig.getParameter<double>("etaMin")),
107  etaMax_(iConfig.getParameter<double>("etaMax")),
108  phiMin_(iConfig.getParameter<double>("phiMin")),
109  phiMax_(iConfig.getParameter<double>("phiMax")),
110  minMassPair_(iConfig.getParameter<double>("minMassPair")),
111  maxMassPair_(iConfig.getParameter<double>("maxMassPair")),
112  muonInfo_(minMassPair_, maxMassPair_),
113  muonInfoFromZ_(minMassPair_, maxMassPair_) {
114  usesResource(TFileService::kSharedResource);
116  muonInfo_.setupTree("di_muon", fs);
117  muonInfoFromZ_.setupTree("di_muon_from_Z", fs);
118 }
119 
121 
122 //
123 // member functions
124 //
125 
126 // ------------ method called for each event ------------
130 
131  for (const auto& particle : *(genParticles.product())) {
132  if (std::abs(particle.pdgId()) != muonPdg_ || particle.status() != 1)
133  continue;
134  if (particle.p() < pMin_)
135  continue;
136  if (particle.pt() < ptMin_)
137  continue;
138  if (particle.eta() < etaMin_ || particle.eta() > etaMax_)
139  continue;
140  if (particle.phi() < phiMin_ || particle.phi() > phiMax_)
141  continue;
142 
143  muonInfo_.muons().push_back(particle);
144  if (particle.mother()->pdgId() == zBosonPdg_) {
145  muonInfoFromZ_.muons().push_back(particle);
146  }
147  }
148 
149  muonInfo_.fill();
151 }
152 
153 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
156  desc.setComment("Extract information on 'Z -> mu mu' decays.");
157  desc.add<double>("pMin", 3.0);
158  desc.add<double>("ptMin", 15.0);
159  desc.add<double>("etaMin", -3.0);
160  desc.add<double>("etaMax", 3.0);
161  desc.add<double>("phiMin", -3.1416);
162  desc.add<double>("phiMax", 3.1416);
163  desc.add<double>("minMassPair", 85.8);
164  desc.add<double>("maxMassPair", 95.8);
165  descriptions.add("zMuMuMassConstraintParameterFinder", desc);
166 }
167 
168 // ------------ helper class definition ------------
169 ZMuMuMassConstraintParameterFinder ::DiMuonInfo ::DiMuonInfo(double minMass, double maxMass)
170  : minMassPair_{minMass}, maxMassPair_{maxMass} {}
171 
172 void ZMuMuMassConstraintParameterFinder ::DiMuonInfo ::setupTree(const std::string& name,
174  tree_ = fs->make<TTree>(name.c_str(), name.c_str());
175  tree_->Branch("muons", &muons_);
176  tree_->Branch("di_muon_mass", &diMuonMass_);
177  tree_->Branch("pdg_mother", &pdgMother_);
178  tree_->Branch("in_mass_window", &passed_);
179 }
180 
182  if (muons_.size() == 2) {
183  diMuonMass_ = (muons_[0].p4() + muons_[1].p4()).M();
184  pdgMother_ = muons_[0].mother()->pdgId();
185  if (diMuonMass_ > minMassPair_ && diMuonMass_ < maxMassPair_)
186  passed_ = true;
187  tree_->Fill();
188  }
189  muons_.clear();
190  diMuonMass_ = -1.0;
191  pdgMother_ = 0;
192  passed_ = false;
193 }
194 
195 //define this as a plug-in
ZMuMuMassConstraintParameterFinder::pMin_
const double pMin_
Definition: ZMuMuMassConstraintParameterFinder.cc:84
EDAnalyzer.h
ZMuMuMassConstraintParameterFinder::DiMuonInfo::muons
std::vector< reco::GenParticle > & muons()
Definition: ZMuMuMassConstraintParameterFinder.cc:61
genParticles2HepMC_cfi.genParticles
genParticles
Definition: genParticles2HepMC_cfi.py:4
ZMuMuMassConstraintParameterFinder::DiMuonInfo::fill
void fill()
Definition: ZMuMuMassConstraintParameterFinder.cc:181
ZMuMuMassConstraintParameterFinder::DiMuonInfo::setupTree
void setupTree(const std::string &, edm::Service< TFileService > &)
Definition: ZMuMuMassConstraintParameterFinder.cc:172
ZMuMuMassConstraintParameterFinder::zBosonPdg_
const int zBosonPdg_
Definition: ZMuMuMassConstraintParameterFinder.cc:81
edm::EDGetTokenT< reco::GenParticleCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
ZMuMuMassConstraintParameterFinder
Definition: ZMuMuMassConstraintParameterFinder.cc:47
reco::GenParticleCollection
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
Definition: GenParticleFwd.h:13
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ZMuMuMassConstraintParameterFinder::phiMin_
const double phiMin_
Definition: ZMuMuMassConstraintParameterFinder.cc:88
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::one::EDAnalyzer
Definition: EDAnalyzer.h:30
edm::Handle< reco::GenParticleCollection >
ZMuMuMassConstraintParameterFinder::DiMuonInfo::muons_
std::vector< reco::GenParticle > muons_
Definition: ZMuMuMassConstraintParameterFinder.cc:65
GenParticle.h
MakerMacros.h
ZMuMuMassConstraintParameterFinder::minMassPair_
const double minMassPair_
Definition: ZMuMuMassConstraintParameterFinder.cc:92
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
Service.h
GenParticleFwd.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
ntuplemaker.fill
fill
Definition: ntuplemaker.py:304
ZMuMuMassConstraintParameterFinder::muonPdg_
const int muonPdg_
Definition: ZMuMuMassConstraintParameterFinder.cc:80
edm::ParameterSet
Definition: ParameterSet.h:47
ZMuMuMassConstraintParameterFinder::DiMuonInfo::minMassPair_
const double minMassPair_
Definition: ZMuMuMassConstraintParameterFinder.cc:70
Event.h
ZMuMuMassConstraintParameterFinder::~ZMuMuMassConstraintParameterFinder
~ZMuMuMassConstraintParameterFinder() override
Definition: ZMuMuMassConstraintParameterFinder.cc:120
B2GTnPMonitor_cfi.maxMass
maxMass
Definition: B2GTnPMonitor_cfi.py:55
ZMuMuMassConstraintParameterFinder::ptMin_
const double ptMin_
Definition: ZMuMuMassConstraintParameterFinder.cc:85
ZMuMuMassConstraintParameterFinder::DiMuonInfo
helper class containing information about a di-muon system
Definition: ZMuMuMassConstraintParameterFinder.cc:56
ZMuMuMassConstraintParameterFinder::DiMuonInfo::pdgMother_
int pdgMother_
Definition: ZMuMuMassConstraintParameterFinder.cc:67
edm::Service< TFileService >
ZMuMuMassConstraintParameterFinder::DiMuonInfo::DiMuonInfo
DiMuonInfo(double, double)
Definition: ZMuMuMassConstraintParameterFinder.cc:169
iEvent
int iEvent
Definition: GenABIO.cc:224
ZMuMuMassConstraintParameterFinder::DiMuonInfo::diMuonMass_
double diMuonMass_
Definition: ZMuMuMassConstraintParameterFinder.cc:66
edm::EventSetup
Definition: EventSetup.h:57
ZMuMuMassConstraintParameterFinder::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: ZMuMuMassConstraintParameterFinder.cc:127
ZMuMuMassConstraintParameterFinder::ZMuMuMassConstraintParameterFinder
ZMuMuMassConstraintParameterFinder(const edm::ParameterSet &)
Definition: ZMuMuMassConstraintParameterFinder.cc:102
ZMuMuMassConstraintParameterFinder::genParticlesToken_
edm::EDGetTokenT< reco::GenParticleCollection > genParticlesToken_
Definition: ZMuMuMassConstraintParameterFinder.cc:77
ZMuMuMassConstraintParameterFinder::etaMin_
const double etaMin_
Definition: ZMuMuMassConstraintParameterFinder.cc:86
ZMuMuMassConstraintParameterFinder::DiMuonInfo::maxMassPair_
const double maxMassPair_
Definition: ZMuMuMassConstraintParameterFinder.cc:71
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
ZMuMuMassConstraintParameterFinder::DiMuonInfo::passed_
bool passed_
Definition: ZMuMuMassConstraintParameterFinder.cc:68
ZMuMuMassConstraintParameterFinder::etaMax_
const double etaMax_
Definition: ZMuMuMassConstraintParameterFinder.cc:87
ZMuMuMassConstraintParameterFinder::muonInfoFromZ_
DiMuonInfo muonInfoFromZ_
Definition: ZMuMuMassConstraintParameterFinder.cc:96
Frameworkfwd.h
ZMuMuMassConstraintParameterFinder::maxMassPair_
const double maxMassPair_
Definition: ZMuMuMassConstraintParameterFinder.cc:93
TFileService::kSharedResource
static const std::string kSharedResource
Definition: TFileService.h:76
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
B2GTnPMonitor_cfi.minMass
minMass
Definition: B2GTnPMonitor_cfi.py:54
ZMuMuMassConstraintParameterFinder::phiMax_
const double phiMax_
Definition: ZMuMuMassConstraintParameterFinder.cc:89
ZMuMuMassConstraintParameterFinder::DiMuonInfo::tree_
TTree * tree_
Definition: ZMuMuMassConstraintParameterFinder.cc:64
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
edm::Event
Definition: Event.h:73
ZMuMuMassConstraintParameterFinder::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: ZMuMuMassConstraintParameterFinder.cc:154
ZMuMuMassConstraintParameterFinder::muonInfo_
DiMuonInfo muonInfo_
Definition: ZMuMuMassConstraintParameterFinder.cc:95
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64