CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
46 using namespace edm;
47 using namespace std;
48 using namespace reco;
49 using namespace isodeposit;
50 
52 public:
54 private:
55  virtual void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
56  virtual void endJob() override;
57 
58  edm::InputTag zMuMu_, zMuMuMatchMap_, zMuTk_, zMuTkMatchMap_,zMuSa_, zMuSaMatchMap_;
59  double dRVeto_, dRTrk_, ptThreshold_;
60  //histograms
61  TH2D *h_gamma_pt_eta_, *h_mu_pt_eta_FSR_, *h_mu_pt_eta_no_FSR_;
62 
63  //boolean
64  bool FSR_mu, FSR_tk, FSR_mu0, FSR_mu1;
65 
66  //counter
67  int zmmcounter , zmscounter, zmtcounter,numOfEvent,numofGamma;
68  };
69 
70 
72 
74  zMuMu_(pset.getParameter<InputTag>("zMuMu")),
75  zMuMuMatchMap_(pset.getParameter<InputTag>("zMuMuMatchMap")),
76  zMuTk_(pset.getParameter<InputTag>("zMuTk")),
77  zMuTkMatchMap_(pset.getParameter<InputTag>("zMuTkMatchMap")),
78  zMuSa_(pset.getParameter<InputTag>("zMuSa")),
79  zMuSaMatchMap_(pset.getParameter<InputTag>("zMuSaMatchMap")){
80  zmmcounter=0;
81  zmscounter=0;
82  zmtcounter=0;
83  numOfEvent=0;
84  numofGamma=0;
86 
87  // general histograms
88  h_gamma_pt_eta_= fs->make<TH2D>("h_gamma_pt_eta","pt vs eta of gamma",100,20,100,100,-2.0,2.0);
89  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 );
90  h_mu_pt_eta_no_FSR_= 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);
91 }
92 
94  Handle<CandidateView> zMuMu; //Collection of Z made by Mu global + Mu global
95  Handle<GenParticleMatch> zMuMuMatchMap; //Map of Z made by Mu global + Mu global with MC
96  event.getByLabel(zMuMu_, zMuMu);
97  Handle<CandidateView> zMuTk; //Collection of Z made by Mu global + Track
98  Handle<GenParticleMatch> zMuTkMatchMap;
99  event.getByLabel(zMuTk_, zMuTk);
100  Handle<CandidateView> zMuSa; //Collection of Z made by Mu global + Sa
101  Handle<GenParticleMatch> zMuSaMatchMap;
102  event.getByLabel(zMuSa_, zMuSa);
103  numOfEvent++;
104  // ZMuMu
105  if (zMuMu->size() > 0 ) {
106  event.getByLabel(zMuMuMatchMap_, zMuMuMatchMap);
107  for(unsigned int i = 0; i < zMuMu->size(); ++i) { //loop on candidates
108 
109  const Candidate & zMuMuCand = (*zMuMu)[i]; //the candidate
110  CandidateBaseRef zMuMuCandRef = zMuMu->refAt(i);
111 
112 
113  CandidateBaseRef dau0 = zMuMuCand.daughter(0)->masterClone();
114  CandidateBaseRef dau1 = zMuMuCand.daughter(1)->masterClone();
115  const pat::Muon& mu0 = dynamic_cast<const pat::Muon&>(*dau0);//cast in patMuon
116  const pat::Muon& mu1 = dynamic_cast<const pat::Muon&>(*dau1);
117 
118  double zmass= zMuMuCand.mass();
119  double pt0 = mu0.pt();
120  double pt1 = mu1.pt();
121  double eta0 = mu0.eta();
122  double eta1 = mu1.eta();
123  if(pt0>20 && pt1 > 20 && abs(eta0)<2 && abs(eta1)<2 && zmass > 20 && zmass < 200){
124  GenParticleRef zMuMuMatch = (*zMuMuMatchMap)[zMuMuCandRef];
125  if(zMuMuMatch.isNonnull()) { // ZMuMu matched
126  zmmcounter++;
127  FSR_mu0 = false;
128  FSR_mu1 = false;
129 
130  //MonteCarlo Study
131  const reco::GenParticle * muMc0 = mu0.genLepton();
132  const reco::GenParticle * muMc1 = mu1.genLepton();
133  const Candidate * motherMu0 = muMc0->mother();
134  const Candidate * motherMu1 = muMc1->mother();
135  int num_dau_muon0 = motherMu0->numberOfDaughters();
136  int num_dau_muon1 = motherMu1->numberOfDaughters();
137  if( num_dau_muon0 > 1 ){
138  for(int j = 0; j < num_dau_muon0; ++j){
139  int id =motherMu0 ->daughter(j)->pdgId();
140  if(id == 22){
141  double etaG = motherMu0 ->daughter(j)->eta();
142  double ptG = motherMu0 ->daughter(j)->pt();
143  h_gamma_pt_eta_->Fill(ptG,etaG);
144  h_mu_pt_eta_FSR_->Fill(pt0,eta0);
145  FSR_mu0=true;
146  numofGamma++;
147  }
148  }
149  }//end check of gamma
150  if(!FSR_mu0) h_mu_pt_eta_no_FSR_->Fill(pt0,eta0);
151  if( num_dau_muon1 > 1 ){
152  for(int j = 0; j < num_dau_muon1; ++j){
153  int id = motherMu1->daughter(j)->pdgId();
154  if(id == 22){
155  double etaG = motherMu1 ->daughter(j)->eta();
156  double ptG = motherMu1 ->daughter(j)->pt();
157  h_gamma_pt_eta_->Fill(ptG,etaG);
158  h_mu_pt_eta_FSR_->Fill(pt1,eta1);
159  FSR_mu1=true;
160  numofGamma++;
161  }
162  }
163  }//end check of gamma
164  if(!FSR_mu1) h_mu_pt_eta_no_FSR_->Fill(pt1,eta1);
165  }// end MC match
166  }//end of cuts
167  }// end loop on ZMuMu cand
168  }// end if ZMuMu size > 0
169 
170  // ZMuSa
171  if (zMuSa->size() > 0 ) {
172  event.getByLabel(zMuSaMatchMap_, zMuSaMatchMap);
173  for(unsigned int i = 0; i < zMuSa->size(); ++i) { //loop on candidates
174 
175  const Candidate & zMuSaCand = (*zMuSa)[i]; //the candidate
176  CandidateBaseRef zMuSaCandRef = zMuSa->refAt(i);
177 
178 
179  CandidateBaseRef dau0 = zMuSaCand.daughter(0)->masterClone();
180  CandidateBaseRef dau1 = zMuSaCand.daughter(1)->masterClone();
181  const pat::Muon& mu0 = dynamic_cast<const pat::Muon&>(*dau0);//cast in patMuon
182  const pat::Muon& mu1 = dynamic_cast<const pat::Muon&>(*dau1);
183 
184  double zmass= zMuSaCand.mass();
185  double pt0 = mu0.pt();
186  double pt1 = mu1.pt();
187  double eta0 = mu0.eta();
188  double eta1 = mu1.eta();
189  if(pt0>20 && pt1 > 20 && abs(eta0)<2 && abs(eta1)<2 && zmass > 20 && zmass < 200){
190  GenParticleRef zMuSaMatch = (*zMuSaMatchMap)[zMuSaCandRef];
191  if(zMuSaMatch.isNonnull()) { // ZMuSa matched
192  FSR_mu0 = false;
193  FSR_mu1 = false;
194  zmscounter++;
195  //MonteCarlo Study
196  const reco::GenParticle * muMc0 = mu0.genLepton();
197  const reco::GenParticle * muMc1 = mu1.genLepton();
198  const Candidate * motherMu0 = muMc0->mother();
199  const Candidate * motherMu1 = muMc1->mother();
200  int num_dau_muon0 = motherMu0->numberOfDaughters();
201  int num_dau_muon1 = motherMu1->numberOfDaughters();
202  if( num_dau_muon0 > 1 ){
203  for(int j = 0; j < num_dau_muon0; ++j){
204  int id =motherMu0 ->daughter(j)->pdgId();
205  if(id == 22){
206  double etaG = motherMu0 ->daughter(j)->eta();
207  double ptG = motherMu0 ->daughter(j)->pt();
208  h_gamma_pt_eta_->Fill(ptG,etaG);
209  h_mu_pt_eta_FSR_->Fill(pt0,eta0);
210  numofGamma++;
211  FSR_mu0=true;
212  }
213  }
214  }//end check of gamma
215  if(!FSR_mu0) h_mu_pt_eta_no_FSR_->Fill(pt0,eta0);
216  if( num_dau_muon1 > 1 ){
217  for(int j = 0; j < num_dau_muon1; ++j){
218  int id = motherMu1->daughter(j)->pdgId();
219  if(id == 22){
220  double etaG = motherMu1 ->daughter(j)->eta();
221  double ptG = motherMu1 ->daughter(j)->pt();
222  h_gamma_pt_eta_->Fill(ptG,etaG);
223  h_mu_pt_eta_FSR_->Fill(pt1,eta1);
224  numofGamma++;
225  FSR_mu1=true;
226  }
227  }
228  }//end check of gamma
229  if(!FSR_mu1) h_mu_pt_eta_no_FSR_->Fill(pt1,eta1);
230  }// end MC match
231  }//end of cuts
232  }// end loop on ZMuSa cand
233  }// end if ZMuSa size > 0
234 
235 
236 
237  //ZMuTk
238  if (zMuTk->size() > 0 ) {
239  event.getByLabel(zMuTkMatchMap_, zMuTkMatchMap);
240  for(unsigned int i = 0; i < zMuTk->size(); ++i) { //loop on candidates
241  const Candidate & zMuTkCand = (*zMuTk)[i]; //the candidate
242  CandidateBaseRef zMuTkCandRef = zMuTk->refAt(i);
243 
244 
245  CandidateBaseRef dau0 = zMuTkCand.daughter(0)->masterClone();
246  CandidateBaseRef dau1 = zMuTkCand.daughter(1)->masterClone();
247  const pat::Muon& mu0 = dynamic_cast<const pat::Muon&>(*dau0);//cast in patMuon
248  const pat::GenericParticle& mu1 = dynamic_cast<const pat::GenericParticle &>(*dau1);
249 
250 
251  double zmass= zMuTkCand.mass();
252  double pt0 = mu0.pt();
253  double pt1 = mu1.pt();
254  double eta0 = mu0.eta();
255  double eta1 = mu1.eta();
256  if(pt0>20 && pt1 > 20 && abs(eta0)<2 && abs(eta1)<2 && zmass > 20 && zmass < 200){//kinematical cuts
257  GenParticleRef zMuTkMatch = (*zMuTkMatchMap)[zMuTkCandRef];
258  if(zMuTkMatch.isNonnull()) { // ZMuTk matched
259  FSR_mu = false;
260  FSR_tk = false;
261  zmtcounter++;
262  //MonteCarlo Study
263  const reco::GenParticle * muMc0 = mu0.genLepton();
264  const reco::GenParticle * muMc1 = mu1.genParticle() ;
265  const Candidate * motherMu0 = muMc0->mother();
266  const Candidate * motherMu1 = muMc1->mother();
267  int num_dau_muon0 = motherMu0->numberOfDaughters();
268  int num_dau_muon1 = motherMu1->numberOfDaughters();
269  if( num_dau_muon0 > 1 ){
270  for(int j = 0; j < num_dau_muon0; ++j){
271  int id = motherMu0->daughter(j)->pdgId();
272  if(id == 22){
273  double etaG = motherMu0 ->daughter(j)->eta();
274  double ptG = motherMu0 ->daughter(j)->pt();
275  h_gamma_pt_eta_->Fill(ptG,etaG);
276  h_mu_pt_eta_FSR_->Fill(pt0,eta0);
277  numofGamma++;
278  FSR_mu0=true;
279  }
280  }
281  }//end check of gamma
282  if(!FSR_mu0) h_mu_pt_eta_no_FSR_->Fill(pt0,eta0);
283  if( num_dau_muon1 > 1 ){
284  for(int j = 0; j < num_dau_muon1; ++j){
285  int id = motherMu1->daughter(j)->pdgId();
286  if(id == 22){
287  double etaG = motherMu1 ->daughter(j)->eta();
288  double ptG = motherMu1 ->daughter(j)->pt();
289  h_gamma_pt_eta_->Fill(ptG,etaG);
290  h_mu_pt_eta_FSR_->Fill(pt1,eta1);
291  numofGamma++;
292  FSR_mu1=true;
293  }
294  }
295  }//end check of gamma
296  if(!FSR_mu1) h_mu_pt_eta_no_FSR_->Fill(pt1,eta1);
297  }// end MC match
298  }//end Kine-cuts
299  }// end loop on ZMuTk cand
300  }// end if ZMuTk size > 0
301 }// end analyze
302 
303 
304 
306  cout <<" ============= Summary =========="<<endl;
307  cout <<" Numero di eventi = "<< numOfEvent << endl;
308  cout <<" 1)Numero di ZMuMu matched dopo i tagli cinematici = "<< zmmcounter << endl;
309  cout <<" 2)Numero di ZMuSa matched dopo i tagli cinematici = "<< zmscounter << endl;
310  cout <<" 3)Numero di ZMuTk matched dopo i tagli cinematici = "<< zmtcounter << endl;
311  cout <<" 4)Number of gamma = "<< numofGamma << endl;
312  }
313 
315 
gamma_radiative_analyzer(const edm::ParameterSet &pset)
int i
Definition: DBlmapReader.cc:9
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
const reco::GenParticle * genLepton() const
Definition: Lepton.h:42
virtual float mass() const =0
mass
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup) override
const reco::GenParticle * genParticle(size_t idx=0) const
Definition: PATObject.h:236
virtual float eta() const =0
momentum pseudorapidity
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
virtual void endJob() override
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed) ...
virtual size_type numberOfDaughters() const =0
number of daughters
virtual float pt() const =0
transverse momentum
edm::ValueMap< float > IsolationCollection
tuple zMuSa
zMUSa vector of PSet is specific for zMuSa category
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
virtual int pdgId() const =0
PDG identifier.
tuple cout
Definition: gather_cfg.py:121
virtual float pt() const GCC11_FINAL
transverse momentum
Analysis-level muon class.
Definition: Muon.h:50
virtual const Candidate * mother(size_type=0) const
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple zMuMu
zMuMu vector of PSet is common to all categories except zMuTrk category
virtual const CandidateBaseRef & masterClone() const =0