CMS 3D CMS Logo

gamma_radiative_analysis.cc
Go to the documentation of this file.
1 /* \class gamma_radiative_analyzer
2  *
3  * author: Pasquale Noli
4  *
5  * Gamma Radiative analyzer
6  *
7  *
8  */
37 #include <iostream>
38 #include <iterator>
39 #include <cmath>
40 #include <vector>
41 #include "TH1.h"
42 #include "TH2.h"
43 //#include "TH3.h"
44 
45 using namespace edm;
46 using namespace std;
47 using namespace reco;
48 using namespace isodeposit;
49 
51 
53 public:
55 
56 private:
57  void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
58  void endJob() override;
59 
66  double dRVeto_, dRTrk_, ptThreshold_;
67  //histograms
68  TH2D *h_gamma_pt_eta_, *h_mu_pt_eta_FSR_, *h_mu_pt_eta_no_FSR_;
69 
70  //boolean
71  bool FSR_mu, FSR_tk, FSR_mu0, FSR_mu1;
72 
73  //counter
74  int zmmcounter, zmscounter, zmtcounter, numOfEvent, numofGamma;
75 };
76 
78  : zMuMuToken_(consumes<CandidateView>(pset.getParameter<InputTag>("zMuMu"))),
79  zMuMuMatchMapToken_(mayConsume<GenParticleMatch>(pset.getParameter<InputTag>("zMuMuMatchMap"))),
80  zMuTkToken_(consumes<CandidateView>(pset.getParameter<InputTag>("zMuTk"))),
81  zMuTkMatchMapToken_(mayConsume<GenParticleMatch>(pset.getParameter<InputTag>("zMuTkMatchMap"))),
82  zMuSaToken_(consumes<CandidateView>(pset.getParameter<InputTag>("zMuSa"))),
83  zMuSaMatchMapToken_(mayConsume<GenParticleMatch>(pset.getParameter<InputTag>("zMuSaMatchMap"))) {
84  zmmcounter = 0;
85  zmscounter = 0;
86  zmtcounter = 0;
87  numOfEvent = 0;
88  numofGamma = 0;
90 
91  // general histograms
92  h_gamma_pt_eta_ = fs->make<TH2D>("h_gamma_pt_eta", "pt vs eta of gamma", 100, 20, 100, 100, -2.0, 2.0);
93  h_mu_pt_eta_FSR_ = fs->make<TH2D>("h_mu_pt_eta_FSR", "pt vs eta of muon with FSR", 100, 20, 100, 100, -2.0, 2.0);
95  fs->make<TH2D>("h_mu_pt_eta_no_FSR", "pt vs eta of of muon withot FSR", 100, 20, 100, 100, -2.0, 2.0);
96 }
97 
99  Handle<CandidateView> zMuMu; //Collection of Z made by Mu global + Mu global
100  Handle<GenParticleMatch> zMuMuMatchMap; //Map of Z made by Mu global + Mu global with MC
101  event.getByToken(zMuMuToken_, zMuMu);
102  Handle<CandidateView> zMuTk; //Collection of Z made by Mu global + Track
103  Handle<GenParticleMatch> zMuTkMatchMap;
104  event.getByToken(zMuTkToken_, zMuTk);
105  Handle<CandidateView> zMuSa; //Collection of Z made by Mu global + Sa
106  Handle<GenParticleMatch> zMuSaMatchMap;
107  event.getByToken(zMuSaToken_, zMuSa);
108  numOfEvent++;
109  // ZMuMu
110  if (!zMuMu->empty()) {
111  event.getByToken(zMuMuMatchMapToken_, zMuMuMatchMap);
112  for (unsigned int i = 0; i < zMuMu->size(); ++i) { //loop on candidates
113 
114  const Candidate& zMuMuCand = (*zMuMu)[i]; //the candidate
115  CandidateBaseRef zMuMuCandRef = zMuMu->refAt(i);
116 
117  CandidateBaseRef dau0 = zMuMuCand.daughter(0)->masterClone();
118  CandidateBaseRef dau1 = zMuMuCand.daughter(1)->masterClone();
119  const pat::Muon& mu0 = dynamic_cast<const pat::Muon&>(*dau0); //cast in patMuon
120  const pat::Muon& mu1 = dynamic_cast<const pat::Muon&>(*dau1);
121 
122  double zmass = zMuMuCand.mass();
123  double pt0 = mu0.pt();
124  double pt1 = mu1.pt();
125  double eta0 = mu0.eta();
126  double eta1 = mu1.eta();
127  if (pt0 > 20 && pt1 > 20 && abs(eta0) < 2 && abs(eta1) < 2 && zmass > 20 && zmass < 200) {
128  GenParticleRef zMuMuMatch = (*zMuMuMatchMap)[zMuMuCandRef];
129  if (zMuMuMatch.isNonnull()) { // ZMuMu matched
130  zmmcounter++;
131  FSR_mu0 = false;
132  FSR_mu1 = false;
133 
134  //MonteCarlo Study
135  const reco::GenParticle* muMc0 = mu0.genLepton();
136  const reco::GenParticle* muMc1 = mu1.genLepton();
137  const Candidate* motherMu0 = muMc0->mother();
138  const Candidate* motherMu1 = muMc1->mother();
139  int num_dau_muon0 = motherMu0->numberOfDaughters();
140  int num_dau_muon1 = motherMu1->numberOfDaughters();
141  if (num_dau_muon0 > 1) {
142  for (int j = 0; j < num_dau_muon0; ++j) {
143  int id = motherMu0->daughter(j)->pdgId();
144  if (id == 22) {
145  double etaG = motherMu0->daughter(j)->eta();
146  double ptG = motherMu0->daughter(j)->pt();
147  h_gamma_pt_eta_->Fill(ptG, etaG);
148  h_mu_pt_eta_FSR_->Fill(pt0, eta0);
149  FSR_mu0 = true;
150  numofGamma++;
151  }
152  }
153  } //end check of gamma
154  if (!FSR_mu0)
155  h_mu_pt_eta_no_FSR_->Fill(pt0, eta0);
156  if (num_dau_muon1 > 1) {
157  for (int j = 0; j < num_dau_muon1; ++j) {
158  int id = motherMu1->daughter(j)->pdgId();
159  if (id == 22) {
160  double etaG = motherMu1->daughter(j)->eta();
161  double ptG = motherMu1->daughter(j)->pt();
162  h_gamma_pt_eta_->Fill(ptG, etaG);
163  h_mu_pt_eta_FSR_->Fill(pt1, eta1);
164  FSR_mu1 = true;
165  numofGamma++;
166  }
167  }
168  } //end check of gamma
169  if (!FSR_mu1)
170  h_mu_pt_eta_no_FSR_->Fill(pt1, eta1);
171  } // end MC match
172  } //end of cuts
173  } // end loop on ZMuMu cand
174  } // end if ZMuMu size > 0
175 
176  // ZMuSa
177  if (!zMuSa->empty()) {
178  event.getByToken(zMuSaMatchMapToken_, zMuSaMatchMap);
179  for (unsigned int i = 0; i < zMuSa->size(); ++i) { //loop on candidates
180 
181  const Candidate& zMuSaCand = (*zMuSa)[i]; //the candidate
182  CandidateBaseRef zMuSaCandRef = zMuSa->refAt(i);
183 
184  CandidateBaseRef dau0 = zMuSaCand.daughter(0)->masterClone();
185  CandidateBaseRef dau1 = zMuSaCand.daughter(1)->masterClone();
186  const pat::Muon& mu0 = dynamic_cast<const pat::Muon&>(*dau0); //cast in patMuon
187  const pat::Muon& mu1 = dynamic_cast<const pat::Muon&>(*dau1);
188 
189  double zmass = zMuSaCand.mass();
190  double pt0 = mu0.pt();
191  double pt1 = mu1.pt();
192  double eta0 = mu0.eta();
193  double eta1 = mu1.eta();
194  if (pt0 > 20 && pt1 > 20 && abs(eta0) < 2 && abs(eta1) < 2 && zmass > 20 && zmass < 200) {
195  GenParticleRef zMuSaMatch = (*zMuSaMatchMap)[zMuSaCandRef];
196  if (zMuSaMatch.isNonnull()) { // ZMuSa matched
197  FSR_mu0 = false;
198  FSR_mu1 = false;
199  zmscounter++;
200  //MonteCarlo Study
201  const reco::GenParticle* muMc0 = mu0.genLepton();
202  const reco::GenParticle* muMc1 = mu1.genLepton();
203  const Candidate* motherMu0 = muMc0->mother();
204  const Candidate* motherMu1 = muMc1->mother();
205  int num_dau_muon0 = motherMu0->numberOfDaughters();
206  int num_dau_muon1 = motherMu1->numberOfDaughters();
207  if (num_dau_muon0 > 1) {
208  for (int j = 0; j < num_dau_muon0; ++j) {
209  int id = motherMu0->daughter(j)->pdgId();
210  if (id == 22) {
211  double etaG = motherMu0->daughter(j)->eta();
212  double ptG = motherMu0->daughter(j)->pt();
213  h_gamma_pt_eta_->Fill(ptG, etaG);
214  h_mu_pt_eta_FSR_->Fill(pt0, eta0);
215  numofGamma++;
216  FSR_mu0 = true;
217  }
218  }
219  } //end check of gamma
220  if (!FSR_mu0)
221  h_mu_pt_eta_no_FSR_->Fill(pt0, eta0);
222  if (num_dau_muon1 > 1) {
223  for (int j = 0; j < num_dau_muon1; ++j) {
224  int id = motherMu1->daughter(j)->pdgId();
225  if (id == 22) {
226  double etaG = motherMu1->daughter(j)->eta();
227  double ptG = motherMu1->daughter(j)->pt();
228  h_gamma_pt_eta_->Fill(ptG, etaG);
229  h_mu_pt_eta_FSR_->Fill(pt1, eta1);
230  numofGamma++;
231  FSR_mu1 = true;
232  }
233  }
234  } //end check of gamma
235  if (!FSR_mu1)
236  h_mu_pt_eta_no_FSR_->Fill(pt1, eta1);
237  } // end MC match
238  } //end of cuts
239  } // end loop on ZMuSa cand
240  } // end if ZMuSa size > 0
241 
242  //ZMuTk
243  if (!zMuTk->empty()) {
244  event.getByToken(zMuTkMatchMapToken_, zMuTkMatchMap);
245  for (unsigned int i = 0; i < zMuTk->size(); ++i) { //loop on candidates
246  const Candidate& zMuTkCand = (*zMuTk)[i]; //the candidate
247  CandidateBaseRef zMuTkCandRef = zMuTk->refAt(i);
248 
249  CandidateBaseRef dau0 = zMuTkCand.daughter(0)->masterClone();
250  CandidateBaseRef dau1 = zMuTkCand.daughter(1)->masterClone();
251  const pat::Muon& mu0 = dynamic_cast<const pat::Muon&>(*dau0); //cast in patMuon
252  const pat::GenericParticle& mu1 = dynamic_cast<const pat::GenericParticle&>(*dau1);
253 
254  double zmass = zMuTkCand.mass();
255  double pt0 = mu0.pt();
256  double pt1 = mu1.pt();
257  double eta0 = mu0.eta();
258  double eta1 = mu1.eta();
259  if (pt0 > 20 && pt1 > 20 && abs(eta0) < 2 && abs(eta1) < 2 && zmass > 20 && zmass < 200) { //kinematical cuts
260  GenParticleRef zMuTkMatch = (*zMuTkMatchMap)[zMuTkCandRef];
261  if (zMuTkMatch.isNonnull()) { // ZMuTk matched
262  FSR_mu = false;
263  FSR_tk = false;
264  zmtcounter++;
265  //MonteCarlo Study
266  const reco::GenParticle* muMc0 = mu0.genLepton();
267  const reco::GenParticle* muMc1 = mu1.genParticle();
268  const Candidate* motherMu0 = muMc0->mother();
269  const Candidate* motherMu1 = muMc1->mother();
270  int num_dau_muon0 = motherMu0->numberOfDaughters();
271  int num_dau_muon1 = motherMu1->numberOfDaughters();
272  if (num_dau_muon0 > 1) {
273  for (int j = 0; j < num_dau_muon0; ++j) {
274  int id = motherMu0->daughter(j)->pdgId();
275  if (id == 22) {
276  double etaG = motherMu0->daughter(j)->eta();
277  double ptG = motherMu0->daughter(j)->pt();
278  h_gamma_pt_eta_->Fill(ptG, etaG);
279  h_mu_pt_eta_FSR_->Fill(pt0, eta0);
280  numofGamma++;
281  FSR_mu0 = true;
282  }
283  }
284  } //end check of gamma
285  if (!FSR_mu0)
286  h_mu_pt_eta_no_FSR_->Fill(pt0, eta0);
287  if (num_dau_muon1 > 1) {
288  for (int j = 0; j < num_dau_muon1; ++j) {
289  int id = motherMu1->daughter(j)->pdgId();
290  if (id == 22) {
291  double etaG = motherMu1->daughter(j)->eta();
292  double ptG = motherMu1->daughter(j)->pt();
293  h_gamma_pt_eta_->Fill(ptG, etaG);
294  h_mu_pt_eta_FSR_->Fill(pt1, eta1);
295  numofGamma++;
296  FSR_mu1 = true;
297  }
298  }
299  } //end check of gamma
300  if (!FSR_mu1)
301  h_mu_pt_eta_no_FSR_->Fill(pt1, eta1);
302  } // end MC match
303  } //end Kine-cuts
304  } // end loop on ZMuTk cand
305  } // end if ZMuTk size > 0
306 } // end analyze
307 
309  cout << " ============= Summary ==========" << endl;
310  cout << " Numero di eventi = " << numOfEvent << endl;
311  cout << " 1)Numero di ZMuMu matched dopo i tagli cinematici = " << zmmcounter << endl;
312  cout << " 2)Numero di ZMuSa matched dopo i tagli cinematici = " << zmscounter << endl;
313  cout << " 3)Numero di ZMuTk matched dopo i tagli cinematici = " << zmtcounter << endl;
314  cout << " 4)Number of gamma = " << numofGamma << endl;
315 }
316 
318 
IsolationCollection
edm::ValueMap< float > IsolationCollection
Definition: gamma_radiative_analysis.cc:50
reco::Candidate::daughter
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode)
gamma_radiative_analyzer
Definition: gamma_radiative_analysis.cc:52
gamma_radiative_analyzer::zMuSaToken_
EDGetTokenT< CandidateView > zMuSaToken_
Definition: gamma_radiative_analysis.cc:64
gamma_radiative_analyzer::analyze
void analyze(const edm::Event &event, const edm::EventSetup &setup) override
Definition: gamma_radiative_analysis.cc:98
Handle.h
mps_fire.i
i
Definition: mps_fire.py:355
Muon.h
IsoDepositVetos.h
ZMuMuAnalysisNtupler_cff.zMuMu
zMuMu
zMuMu vector of PSet is common to all categories except zMuTrk category
Definition: ZMuMuAnalysisNtupler_cff.py:340
edm::View::empty
bool empty() const
reco::GenParticle
Definition: GenParticle.h:21
reco::Candidate::mass
virtual double mass() const =0
mass
edm::View::refAt
RefToBase< value_type > refAt(size_type i) const
reco::Candidate::eta
virtual double eta() const =0
momentum pseudorapidity
edm::EDGetTokenT< CandidateView >
reco::CompositeRefCandidateT::mother
const Candidate * mother(size_type=0) const override
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode)
edm
HLT enums.
Definition: AlignableModifier.h:19
Muon.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
GenericParticle.h
gamma_radiative_analyzer::zMuTkMatchMapToken_
EDGetTokenT< GenParticleMatch > zMuTkMatchMapToken_
Definition: gamma_radiative_analysis.cc:63
HLT_2018_cff.eta1
eta1
Definition: HLT_2018_cff.py:8220
gamma_radiative_analyzer::ptThreshold_
double ptThreshold_
Definition: gamma_radiative_analysis.cc:66
gamma_radiative_analyzer::zMuMuToken_
EDGetTokenT< CandidateView > zMuMuToken_
Definition: gamma_radiative_analysis.cc:60
HLT_2018_cff.pt1
pt1
Definition: HLT_2018_cff.py:8550
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
EDAnalyzer.h
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
pat::Muon
Analysis-level muon class.
Definition: Muon.h:51
Lepton.h
gamma_radiative_analyzer::zmtcounter
int zmtcounter
Definition: gamma_radiative_analysis.cc:74
edm::Handle
Definition: AssociativeIterator.h:50
RecoCandidate.h
IsoDepositDirection.h
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
CandMatchMap.h
edm::Ref< GenParticleCollection >
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
GenParticle.h
gamma_radiative_analyzer::zMuTkToken_
EDGetTokenT< CandidateView > zMuTkToken_
Definition: gamma_radiative_analysis.cc:62
CandidateFwd.h
gamma_radiative_analyzer::zmmcounter
int zmmcounter
Definition: gamma_radiative_analysis.cc:74
MakerMacros.h
gamma_radiative_analyzer::h_gamma_pt_eta_
TH2D * h_gamma_pt_eta_
Definition: gamma_radiative_analysis.cc:68
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
gamma_radiative_analyzer::zMuSaMatchMapToken_
EDGetTokenT< GenParticleMatch > zMuSaMatchMapToken_
Definition: gamma_radiative_analysis.cc:65
Service.h
ZMuMuAnalysisNtupler_cff.zMuSa
zMuSa
zMUSa vector of PSet is specific for zMuSa category
Definition: ZMuMuAnalysisNtupler_cff.py:591
Particle.h
reco::Candidate::numberOfDaughters
virtual size_type numberOfDaughters() const =0
number of daughters
pat::Lepton::genLepton
const reco::GenParticle * genLepton() const
Definition: Lepton.h:39
Isolation.h
gamma_radiative_analyzer::FSR_mu0
bool FSR_mu0
Definition: gamma_radiative_analysis.cc:71
IsoDeposit.h
edm::View::size
size_type size() const
TFileService.h
edm::View
Definition: CaloClusterFwd.h:14
pat::GenericParticle
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed)
Definition: GenericParticle.h:38
edm::ParameterSet
Definition: ParameterSet.h:36
CandAssociation.h
Event.h
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
gamma_radiative_analyzer::numOfEvent
int numOfEvent
Definition: gamma_radiative_analysis.cc:74
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
gamma_radiative_analyzer::h_mu_pt_eta_no_FSR_
TH2D * h_mu_pt_eta_no_FSR_
Definition: gamma_radiative_analysis.cc:68
edm::Service< TFileService >
gamma_radiative_analyzer::h_mu_pt_eta_FSR_
TH2D * h_mu_pt_eta_FSR_
Definition: gamma_radiative_analysis.cc:68
analyze
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
edm::Association
Definition: Association.h:18
edm::EventSetup
Definition: EventSetup.h:57
gamma_radiative_analyzer::zmscounter
int zmscounter
Definition: gamma_radiative_analysis.cc:74
gamma_radiative_analyzer::endJob
void endJob() override
Definition: gamma_radiative_analysis.cc:308
reco::Candidate::pdgId
virtual int pdgId() const =0
PDG identifier.
InputTag.h
reco::Candidate
Definition: Candidate.h:27
ValueMap.h
gamma_radiative_analyzer::zMuMuMatchMapToken_
EDGetTokenT< GenParticleMatch > zMuMuMatchMapToken_
Definition: gamma_radiative_analysis.cc:61
std
Definition: JetResolutionObject.h:76
gamma_radiative_analyzer::FSR_mu1
bool FSR_mu1
Definition: gamma_radiative_analysis.cc:71
pat::PATObject::genParticle
const reco::GenParticle * genParticle(size_t idx=0) const
Definition: PATObject.h:290
edm::ValueMap< float >
gamma_radiative_analyzer::numofGamma
int numofGamma
Definition: gamma_radiative_analysis.cc:74
EventSetup.h
edm::RefToBase< Candidate >
reco::Candidate::masterClone
virtual const CandidateBaseRef & masterClone() const =0
gamma_radiative_analyzer::FSR_tk
bool FSR_tk
Definition: gamma_radiative_analysis.cc:71
AssociationVector.h
OverlapChecker.h
Candidate.h
IsoDepositFwd.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
gamma_radiative_analyzer::FSR_mu
bool FSR_mu
Definition: gamma_radiative_analysis.cc:71
edm::InputTag
Definition: InputTag.h:15
gamma_radiative_analyzer::gamma_radiative_analyzer
gamma_radiative_analyzer(const edm::ParameterSet &pset)
Definition: gamma_radiative_analysis.cc:77
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
PATObject.h