CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZMuMuAnalyzer.cc
Go to the documentation of this file.
1 /* \class ZMuMuAnalyzer
2  *
3  * Z->mu+m- standard analysis for cross section
4  * measurements. Take as input the output of the
5  * standard EWK skim: zToMuMu
6  *
7  * Produces mass spectra and other histograms for
8  * the samples in input:
9  *
10  * + Z -> mu+mu-, both muons are "global" muons
11  * + Z -> mu+mu-, one muons is "global" muons, one unmatched tracks
12  * + Z -> mu+mu-, one muons is "global" muons, one unmatched stand-alone muon
13  *
14  *
15  * \author Michele de Gruttola, INFN Naples
16  *
17  * \id $Id: ZMuMuAnalyzer.cc,v 1.7 2010/02/19 02:46:28 wmtan Exp $
18  *
19  */
32 #include "TH1.h"
33 #include <iostream>
34 #include <iterator>
35 using namespace edm;
36 using namespace std;
37 using namespace reco;
38 
40 
42 public:
43  ZMuMuAnalyzer(const edm::ParameterSet& pset);
44 private:
45  virtual void analyze(const edm::Event& event, const edm::EventSetup& setup);
46  virtual void endJob();
47 
52  InputTag muIso_, trackIso_, standAloneIso_;
53  InputTag zMuMuMap_ ,zMuTrackMap_, zMuStandAloneMap_;
54  double isocut_, etacut_, ptcut_,ptSTAcut_, minZmass_, maxZmass_;
55  TH1D * h_zMuMu_mass_, * h_zMuSingleTrack_mass_, * h_zMuSingleStandAlone_mass_,* h_zMuSingleStandAloneOverlap_mass_,
56  * h_zMuMuMatched_mass_,
58  * h_zMuSingleStandAloneMatched_mass_,
59  * h_zMuSingleStandAloneOverlapMatched_mass_;
60 };
61 
63  zMuMu_( pset.getParameter<InputTag>( "zMuMu" ) ),
64  zMuTrack_( pset.getParameter<InputTag>( "zMuTrack" ) ),
65  zMuStandAlone_( pset.getParameter<InputTag>( "zMuStandAlone" ) ),
66  muIso_( pset.getParameter<InputTag>( "muIso" ) ),
67  trackIso_( pset.getParameter<InputTag>( "trackIso" ) ),
68  standAloneIso_( pset.getParameter<InputTag>( "standAloneIso" ) ),
69  zMuMuMap_( pset.getParameter<InputTag>( "zMuMuMap" ) ),
70  zMuTrackMap_( pset.getParameter<InputTag>( "zMuTrackMap" ) ),
71  zMuStandAloneMap_( pset.getParameter<InputTag>( "zMuStandAloneMap" ) ),
72  isocut_( pset.getParameter<double>( "isocut" ) ),
73  etacut_( pset.getParameter<double>( "etacut" ) ),
74  ptcut_( pset.getParameter<double>( "ptcut" ) ),
75  ptSTAcut_( pset.getParameter<double>( "ptSTAcut" ) ),
76 
77  minZmass_( pset.getParameter<double>( "minZmass" )),
78  maxZmass_( pset.getParameter<double>( "maxZmass" )) {
79 
81  h_zMuMu_mass_ = fs->make<TH1D>( "ZMuMumass", "ZMuMu mass(GeV)", 200, 0., 200. );
82  h_zMuSingleTrack_mass_ = fs->make<TH1D>( "ZMuSingleTrackmass", "ZMuSingleTrack mass(GeV)", 100, 0., 200. );
83  h_zMuSingleStandAlone_mass_ = fs->make<TH1D>( "ZMuSingleStandAlonemass", "ZMuSingleStandAlone mass(GeV)", 50, 0., 200. );
84  h_zMuSingleStandAloneOverlap_mass_ = fs->make<TH1D>( "ZMuSingleStandAloneOverlapmass", "ZMuSingleStandAloneOverlap mass(GeV)", 50, 0., 200. );
85 
86 
87  h_zMuMuMatched_mass_ = fs->make<TH1D>( "ZMuMuMatchedmass", "ZMuMu Matched mass(GeV)", 200, 0., 200. );
88  h_zMuSingleTrackMatched_mass_ = fs->make<TH1D>( "ZMuSingleTrackmassMatched", "ZMuSingleTrackMatched mass(GeV)", 100, 0., 200. );
89  h_zMuSingleStandAloneMatched_mass_ = fs->make<TH1D>( "ZMuSingleStandAlonemassMatched", "ZMuSingleStandAloneMatched mass(GeV)", 50, 0., 200. );
90  h_zMuSingleStandAloneOverlapMatched_mass_ = fs->make<TH1D>( "ZMuSingleStandAloneOverlapmassMatched", "ZMuSingleStandAloneMatched Overlap mass(GeV)", 50, 0., 200. );
91 }
92 
95  event.getByLabel(zMuMu_, zMuMu);
97  event.getByLabel( zMuTrack_, zMuTrack );
98  Handle<CandidateCollection> zMuStandAlone;
99  event.getByLabel( zMuStandAlone_, zMuStandAlone );
100 
101  unsigned int nZMuMu = zMuMu->size();
102  unsigned int nZTrackMu = zMuTrack->size();
103  unsigned int nZStandAloneMu = zMuStandAlone->size();
104  static const double zMass = 91.1876; // PDG Z mass
105 
106  // cout << "nZMuMu = " << nZMuMu << endl;
107  // cout << "nZTrackMu = " << nZTrackMu << endl;
108  // cout << "nZStandAloneMu = " << nZStandAloneMu << endl;
109 
110  Handle<CandMatchMap> zMuMuMap;
111  if( nZMuMu > 0 ) {
112  event.getByLabel(zMuMuMap_, zMuMuMap);
113  }
114 
115  Handle<CandMatchMap> zMuTrackMap;
116  if( nZTrackMu > 0 ) {
117  event.getByLabel( zMuTrackMap_, zMuTrackMap );
118  }
119 
120  Handle<CandMatchMap> zMuStandAloneMap;
121  if( nZStandAloneMu > 0 ) {
122  event.getByLabel( zMuStandAloneMap_, zMuStandAloneMap );
123  }
124 
126  event.getByLabel(muIso_, muIso);
127  ProductID muIsoId = muIso->keyProduct().id();
129  event.getByLabel(trackIso_, trackIso);
130  ProductID trackIsoId = trackIso->keyProduct().id();
131 
132  Handle<IsolationCollection> standAloneIso;
133  event.getByLabel(standAloneIso_, standAloneIso);
134  ProductID standAloneIsoId = standAloneIso->keyProduct().id();
135 
136  if (nZMuMu > 0) {
137  double mass = 1000000.;
138  for( unsigned int i = 0; i < nZMuMu; i++ ) {
139  const Candidate & zmmCand = (*zMuMu)[ i ];
140  CandidateRef CandRef(zMuMu,i);
141  CandidateRef lep1 = zmmCand.daughter( 0 )->masterClone().castTo<CandidateRef>();
142  CandidateRef lep2 = zmmCand.daughter( 1 )->masterClone().castTo<CandidateRef>();
143 
144  const double iso1 = muIso->value( lep1.key() );
145  const double iso2 = muIso->value( lep2.key() );
146 
147  double m = zmmCand.mass();
148  if (lep1->pt()>ptcut_ && lep2->pt()>ptcut_ &&
149  fabs(lep1->eta())<etacut_ && fabs(lep2->eta())<etacut_ &&
150  m>minZmass_ && m<maxZmass_ && iso1 < isocut_ && iso2 <isocut_) {
151  if ( fabs( mass - zMass ) > fabs( m - zMass ) ) {
152  mass = m;
153  }
154 
155  h_zMuMu_mass_->Fill( mass );
156  CandMatchMap::const_iterator m0 = zMuMuMap->find(CandRef);
157  if( m0 != zMuMuMap->end()) {
158  h_zMuMuMatched_mass_->Fill( mass );
159  }
160  }
161  }
162  }
163 
164  //ZmuSingleTRack
165  if (nZMuMu ==0 && nZTrackMu>0) {
166  for( unsigned int j = 0; j < nZTrackMu; j++ ) {
167  const Candidate & ztmCand = (*zMuTrack)[ j ];
168  CandidateRef CandRef(zMuTrack,j);
169  CandidateRef lep1 = ztmCand.daughter( 0 )->masterClone().castTo<CandidateRef>();
170  CandidateRef lep2 = ztmCand.daughter( 1 )->masterClone().castTo<CandidateRef>();
171 
172  ProductID id1 = lep1.id();
173  ProductID id2 = lep2.id();
174  double iso1 = -1;
175  double iso2 = -1;
176 
177  if( id1 == muIsoId )
178  iso1 = muIso->value( lep1.key() );
179  else if ( id1 == trackIsoId )
180  iso1 = trackIso->value( lep1.key() );
181 
182  if( id2 == muIsoId )
183  iso2 = muIso->value( lep2.key() );
184  else if ( id2 == trackIsoId )
185  iso2 = trackIso->value( lep2.key() );
186 
187  double mt = ztmCand.mass();
188  if (lep1->pt()>ptcut_ && lep2->pt()>ptcut_ &&
189  fabs(lep1->eta())<etacut_ && fabs(lep2->eta())<etacut_ &&
190  mt>minZmass_ && mt<maxZmass_ && iso1<isocut_ && iso2 <isocut_) {
191  h_zMuSingleTrack_mass_->Fill( mt );
192  CandMatchMap::const_iterator m0 = zMuTrackMap->find(CandRef);
193  if( m0 != zMuTrackMap->end()) {
194  h_zMuSingleTrackMatched_mass_->Fill( mt );
195  }
196  }
197  }
198  }
199 
200  //ZmuSingleStandAlone
201  if (nZMuMu ==0 && nZStandAloneMu>0) {
202  // unsigned int index = 1000;
203  for( unsigned int j = 0; j < nZStandAloneMu; j++ ) {
204  const Candidate & zsmCand = (*zMuStandAlone)[ j ];
205  CandidateRef CandRef(zMuStandAlone,j);
206  CandidateRef lep1 = zsmCand.daughter( 0 )->masterClone().castTo<CandidateRef>();
207  CandidateRef lep2 = zsmCand.daughter( 1 )->masterClone().castTo<CandidateRef>();
208 
209  ProductID id1 = lep1.id();
210  ProductID id2 = lep2.id();
211  double iso1 = -1;
212  double iso2 = -1;
213 
214  if( id1 == muIsoId )
215  iso1 = muIso->value( lep1.key() );
216  else if ( id1 == standAloneIsoId )
217  iso1 = standAloneIso->value( lep1.key() );
218 
219  if( id2 == muIsoId )
220  iso2 = muIso->value( lep2.key() );
221  else if ( id2 == standAloneIsoId )
222  iso2 = standAloneIso->value( lep2.key() );
223 
224  double ms = zsmCand.mass();
225  if (lep1->pt()>ptSTAcut_ && lep2->pt()>ptSTAcut_ &&
226  fabs(lep1->eta())<etacut_ && fabs(lep2->eta())<etacut_ &&
227  ms>minZmass_ && ms<maxZmass_ && iso1<isocut_ && iso2 <isocut_) {
228  h_zMuSingleStandAlone_mass_->Fill( ms );
229  CandMatchMap::const_iterator m0 = zMuStandAloneMap->find(CandRef);
230  if( m0 != zMuStandAloneMap->end()) {
232  }
233 
234  bool noOverlap = true;
235  for( unsigned int j = 0; j < zMuTrack->size(); j++ ) {
236  const Candidate & ztmCand = (*zMuTrack)[ j ];
237  CandidateRef CandReft(zMuTrack,j);
238 
239  CandidateRef lep1 = ztmCand.daughter( 0 )->masterClone().castTo<CandidateRef>();
240  CandidateRef lep2 = ztmCand.daughter( 1 )->masterClone().castTo<CandidateRef>();
241 
242  ProductID id1 = lep1.id();
243  ProductID id2 = lep2.id();
244  double iso1 = -1;
245  double iso2 = -1;
246 
247  if( id1 == muIsoId )
248  iso1 = muIso->value( lep1.key() );
249  else if ( id1 == trackIsoId )
250  iso1 = trackIso->value( lep1.key() );
251 
252  if( id2 == muIsoId )
253  iso2 = muIso->value( lep2.key() );
254  else if ( id2 == trackIsoId )
255  iso2 = trackIso->value( lep2.key() );
256 
257  double mt = ztmCand.mass();
258  if (lep1->pt()>ptcut_ && lep2->pt()>ptcut_ &&
259  fabs(lep1->eta())<etacut_ && fabs(lep2->eta())<etacut_ &&
260  mt>minZmass_ && mt<maxZmass_ && iso1<isocut_ && iso2 <isocut_) {
261 
262  if ( overlap_( ztmCand, zsmCand ) ) {
263  noOverlap = false;
264  break;
265  }
266  if (!noOverlap ) {
268  CandMatchMap::const_iterator m1 = zMuTrackMap->find(CandReft);
269  CandMatchMap::const_iterator m2 = zMuStandAloneMap->find(CandRef);
270 
271  if( m1 != zMuTrackMap->end() && m2 != zMuStandAloneMap->end() ) {
273  }
274  }
275  }
276  }
277  }
278  }
279  }
280 }
281 
283  double Nzmm = h_zMuMu_mass_->GetEntries() ;
284  double Nzsm = h_zMuSingleStandAlone_mass_->GetEntries() ;
285  double Nzsnom = h_zMuSingleStandAloneOverlap_mass_->GetEntries() ;
286  double Nztm = h_zMuSingleTrack_mass_->GetEntries();
287 
288  double NzmmMatch = h_zMuMuMatched_mass_->GetEntries() ;
289  double NzsmMatch = h_zMuSingleStandAloneMatched_mass_->GetEntries() ;
290  double NzsnomMatch = h_zMuSingleStandAloneOverlapMatched_mass_->GetEntries() ;
291  double NztmMatch = h_zMuSingleTrackMatched_mass_->GetEntries();
292 
293  cout<<"-- N SingleTrackMu = "<<Nztm<<endl;
294  cout<<"-----N SinglStandAloneMu = "<<Nzsm<<endl;
295  cout<<"-----N SingleStandAloneOverlapMu = "<<Nzsnom<<endl;
296  cout<<"------- N MuMu = "<<Nzmm<<endl;
297 
298  cout<<"-- N SingleTrackMuMatched = "<<NztmMatch<<endl;
299  cout<<"-----N SinglStandAloneMuMatched = "<<NzsmMatch<<endl;
300  cout<<"-----N SingleStandAloneOverlapMuMatched = "<<NzsnomMatch<<endl;
301  cout<<"------- N MuMu Matched = "<<NzmmMatch<<endl;
302 }
303 
305 
307 
InputTag trackIso_
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) ...
InputTag zMuStandAlone_
ProductID id() const
Definition: HandleBase.cc:15
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
InputTag muIso_
virtual double mass() const =0
mass
TH1D * h_zMuMu_mass_
InputTag zMuTrack_
ZMuMuAnalyzer(const edm::ParameterSet &pset)
InputTag zMuStandAloneMap_
edm::ValueMap< float > IsolationCollection
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup)
InputTag zMuMu_
int j
Definition: DBlmapReader.cc:9
TH1D * h_zMuSingleStandAloneOverlap_mass_
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
InputTag zMuMuMap_
OverlapChecker overlap_
TH1D * h_zMuSingleTrack_mass_
virtual void endJob()
TH1D * h_zMuMuMatched_mass_
REF castTo() const
cast to a concrete type
Definition: RefToBase.h:241
key_type key() const
Accessor for product key.
Definition: Ref.h:266
TH1D * h_zMuSingleStandAlone_mass_
tuple mass
Definition: scaleCards.py:27
TH1D * h_zMuSingleStandAloneOverlapMatched_mass_
InputTag standAloneIso_
T * make() const
make new ROOT object
TH1D * h_zMuSingleTrackMatched_mass_
tuple cout
Definition: gather_cfg.py:121
ProductID id() const
Accessor for product ID.
Definition: Ref.h:256
ProductIndex id() const
Definition: ProductID.h:38
TH1D * h_zMuSingleStandAloneMatched_mass_
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
InputTag zMuTrackMap_
virtual const CandidateBaseRef & masterClone() const =0