test
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  *
18  */
31 #include "TH1.h"
32 #include <iostream>
33 #include <iterator>
34 using namespace edm;
35 using namespace std;
36 using namespace reco;
37 
39 
41 public:
43 private:
44  virtual void analyze(const edm::Event& event, const edm::EventSetup& setup) override;
45  virtual void endJob() override;
46 
57  double isocut_, etacut_, ptcut_,ptSTAcut_, minZmass_, maxZmass_;
58  TH1D * h_zMuMu_mass_, * h_zMuSingleTrack_mass_, * h_zMuSingleStandAlone_mass_,* h_zMuSingleStandAloneOverlap_mass_,
59  * h_zMuMuMatched_mass_,
61  * h_zMuSingleStandAloneMatched_mass_,
62  * h_zMuSingleStandAloneOverlapMatched_mass_;
63 };
64 
66  zMuMuToken_( consumes< CandidateCollection >( pset.getParameter<InputTag>( "zMuMu" ) ) ),
67  zMuTrackToken_( consumes< CandidateCollection >( pset.getParameter<InputTag>( "zMuTrack" ) ) ),
68  zMuStandAloneToken_( consumes< CandidateCollection >( pset.getParameter<InputTag>( "zMuStandAlone" ) ) ),
69  muIsoToken_( consumes< IsolationCollection >( pset.getParameter<InputTag>( "muIso" ) ) ),
70  trackIsoToken_( consumes< IsolationCollection >( pset.getParameter<InputTag>( "trackIso" ) ) ),
71  standAloneIsoToken_( consumes< IsolationCollection >( pset.getParameter<InputTag>( "standAloneIso" ) ) ),
72  zMuMuMapToken_( mayConsume< CandMatchMap >( pset.getParameter<InputTag>( "zMuMuMap" ) ) ),
73  zMuTrackMapToken_( mayConsume< CandMatchMap >( pset.getParameter<InputTag>( "zMuTrackMap" ) ) ),
74  zMuStandAloneMapToken_( mayConsume< CandMatchMap >( pset.getParameter<InputTag>( "zMuStandAloneMap" ) ) ),
75  isocut_( pset.getParameter<double>( "isocut" ) ),
76  etacut_( pset.getParameter<double>( "etacut" ) ),
77  ptcut_( pset.getParameter<double>( "ptcut" ) ),
78  ptSTAcut_( pset.getParameter<double>( "ptSTAcut" ) ),
79 
80  minZmass_( pset.getParameter<double>( "minZmass" )),
81  maxZmass_( pset.getParameter<double>( "maxZmass" )) {
82 
84  h_zMuMu_mass_ = fs->make<TH1D>( "ZMuMumass", "ZMuMu mass(GeV)", 200, 0., 200. );
85  h_zMuSingleTrack_mass_ = fs->make<TH1D>( "ZMuSingleTrackmass", "ZMuSingleTrack mass(GeV)", 100, 0., 200. );
86  h_zMuSingleStandAlone_mass_ = fs->make<TH1D>( "ZMuSingleStandAlonemass", "ZMuSingleStandAlone mass(GeV)", 50, 0., 200. );
87  h_zMuSingleStandAloneOverlap_mass_ = fs->make<TH1D>( "ZMuSingleStandAloneOverlapmass", "ZMuSingleStandAloneOverlap mass(GeV)", 50, 0., 200. );
88 
89 
90  h_zMuMuMatched_mass_ = fs->make<TH1D>( "ZMuMuMatchedmass", "ZMuMu Matched mass(GeV)", 200, 0., 200. );
91  h_zMuSingleTrackMatched_mass_ = fs->make<TH1D>( "ZMuSingleTrackmassMatched", "ZMuSingleTrackMatched mass(GeV)", 100, 0., 200. );
92  h_zMuSingleStandAloneMatched_mass_ = fs->make<TH1D>( "ZMuSingleStandAlonemassMatched", "ZMuSingleStandAloneMatched mass(GeV)", 50, 0., 200. );
93  h_zMuSingleStandAloneOverlapMatched_mass_ = fs->make<TH1D>( "ZMuSingleStandAloneOverlapmassMatched", "ZMuSingleStandAloneMatched Overlap mass(GeV)", 50, 0., 200. );
94 }
95 
98  event.getByToken(zMuMuToken_, zMuMu);
100  event.getByToken( zMuTrackToken_, zMuTrack );
101  Handle<CandidateCollection> zMuStandAlone;
102  event.getByToken( zMuStandAloneToken_, zMuStandAlone );
103 
104  unsigned int nZMuMu = zMuMu->size();
105  unsigned int nZTrackMu = zMuTrack->size();
106  unsigned int nZStandAloneMu = zMuStandAlone->size();
107  static const double zMass = 91.1876; // PDG Z mass
108 
109  // cout << "nZMuMu = " << nZMuMu << endl;
110  // cout << "nZTrackMu = " << nZTrackMu << endl;
111  // cout << "nZStandAloneMu = " << nZStandAloneMu << endl;
112 
113  Handle<CandMatchMap> zMuMuMap;
114  if( nZMuMu > 0 ) {
115  event.getByToken(zMuMuMapToken_, zMuMuMap);
116  }
117 
118  Handle<CandMatchMap> zMuTrackMap;
119  if( nZTrackMu > 0 ) {
120  event.getByToken( zMuTrackMapToken_, zMuTrackMap );
121  }
122 
123  Handle<CandMatchMap> zMuStandAloneMap;
124  if( nZStandAloneMu > 0 ) {
125  event.getByToken( zMuStandAloneMapToken_, zMuStandAloneMap );
126  }
127 
129  event.getByToken(muIsoToken_, muIso);
130  ProductID muIsoId = muIso->keyProduct().id();
132  event.getByToken(trackIsoToken_, trackIso);
133  ProductID trackIsoId = trackIso->keyProduct().id();
134 
135  Handle<IsolationCollection> standAloneIso;
136  event.getByToken(standAloneIsoToken_, standAloneIso);
137  ProductID standAloneIsoId = standAloneIso->keyProduct().id();
138 
139  if (nZMuMu > 0) {
140  double mass = 1000000.;
141  for( unsigned int i = 0; i < nZMuMu; i++ ) {
142  const Candidate & zmmCand = (*zMuMu)[ i ];
143  CandidateRef CandRef(zMuMu,i);
146 
147  const double iso1 = muIso->value( lep1.key() );
148  const double iso2 = muIso->value( lep2.key() );
149 
150  double m = zmmCand.mass();
151  if (lep1->pt()>ptcut_ && lep2->pt()>ptcut_ &&
152  fabs(lep1->eta())<etacut_ && fabs(lep2->eta())<etacut_ &&
153  m>minZmass_ && m<maxZmass_ && iso1 < isocut_ && iso2 <isocut_) {
154  if ( fabs( mass - zMass ) > fabs( m - zMass ) ) {
155  mass = m;
156  }
157 
158  h_zMuMu_mass_->Fill( mass );
159  CandMatchMap::const_iterator m0 = zMuMuMap->find(CandRef);
160  if( m0 != zMuMuMap->end()) {
161  h_zMuMuMatched_mass_->Fill( mass );
162  }
163  }
164  }
165  }
166 
167  //ZmuSingleTRack
168  if (nZMuMu ==0 && nZTrackMu>0) {
169  for( unsigned int j = 0; j < nZTrackMu; j++ ) {
170  const Candidate & ztmCand = (*zMuTrack)[ j ];
171  CandidateRef CandRef(zMuTrack,j);
174 
175  ProductID id1 = lep1.id();
176  ProductID id2 = lep2.id();
177  double iso1 = -1;
178  double iso2 = -1;
179 
180  if( id1 == muIsoId )
181  iso1 = muIso->value( lep1.key() );
182  else if ( id1 == trackIsoId )
183  iso1 = trackIso->value( lep1.key() );
184 
185  if( id2 == muIsoId )
186  iso2 = muIso->value( lep2.key() );
187  else if ( id2 == trackIsoId )
188  iso2 = trackIso->value( lep2.key() );
189 
190  double mt = ztmCand.mass();
191  if (lep1->pt()>ptcut_ && lep2->pt()>ptcut_ &&
192  fabs(lep1->eta())<etacut_ && fabs(lep2->eta())<etacut_ &&
193  mt>minZmass_ && mt<maxZmass_ && iso1<isocut_ && iso2 <isocut_) {
194  h_zMuSingleTrack_mass_->Fill( mt );
195  CandMatchMap::const_iterator m0 = zMuTrackMap->find(CandRef);
196  if( m0 != zMuTrackMap->end()) {
197  h_zMuSingleTrackMatched_mass_->Fill( mt );
198  }
199  }
200  }
201  }
202 
203  //ZmuSingleStandAlone
204  if (nZMuMu ==0 && nZStandAloneMu>0) {
205  // unsigned int index = 1000;
206  for( unsigned int j = 0; j < nZStandAloneMu; j++ ) {
207  const Candidate & zsmCand = (*zMuStandAlone)[ j ];
208  CandidateRef CandRef(zMuStandAlone,j);
211 
212  ProductID id1 = lep1.id();
213  ProductID id2 = lep2.id();
214  double iso1 = -1;
215  double iso2 = -1;
216 
217  if( id1 == muIsoId )
218  iso1 = muIso->value( lep1.key() );
219  else if ( id1 == standAloneIsoId )
220  iso1 = standAloneIso->value( lep1.key() );
221 
222  if( id2 == muIsoId )
223  iso2 = muIso->value( lep2.key() );
224  else if ( id2 == standAloneIsoId )
225  iso2 = standAloneIso->value( lep2.key() );
226 
227  double ms = zsmCand.mass();
228  if (lep1->pt()>ptSTAcut_ && lep2->pt()>ptSTAcut_ &&
229  fabs(lep1->eta())<etacut_ && fabs(lep2->eta())<etacut_ &&
230  ms>minZmass_ && ms<maxZmass_ && iso1<isocut_ && iso2 <isocut_) {
231  h_zMuSingleStandAlone_mass_->Fill( ms );
232  CandMatchMap::const_iterator m0 = zMuStandAloneMap->find(CandRef);
233  if( m0 != zMuStandAloneMap->end()) {
235  }
236 
237  bool noOverlap = true;
238  for( unsigned int j = 0; j < zMuTrack->size(); j++ ) {
239  const Candidate & ztmCand = (*zMuTrack)[ j ];
240  CandidateRef CandReft(zMuTrack,j);
241 
242  CandidateRef lep1 = ztmCand.daughter( 0 )->masterClone().castTo<CandidateRef>();
243  CandidateRef lep2 = ztmCand.daughter( 1 )->masterClone().castTo<CandidateRef>();
244 
245  ProductID id1 = lep1.id();
246  ProductID id2 = lep2.id();
247  double iso1 = -1;
248  double iso2 = -1;
249 
250  if( id1 == muIsoId )
251  iso1 = muIso->value( lep1.key() );
252  else if ( id1 == trackIsoId )
253  iso1 = trackIso->value( lep1.key() );
254 
255  if( id2 == muIsoId )
256  iso2 = muIso->value( lep2.key() );
257  else if ( id2 == trackIsoId )
258  iso2 = trackIso->value( lep2.key() );
259 
260  double mt = ztmCand.mass();
261  if (lep1->pt()>ptcut_ && lep2->pt()>ptcut_ &&
262  fabs(lep1->eta())<etacut_ && fabs(lep2->eta())<etacut_ &&
263  mt>minZmass_ && mt<maxZmass_ && iso1<isocut_ && iso2 <isocut_) {
264 
265  if ( overlap_( ztmCand, zsmCand ) ) {
266  noOverlap = false;
267  break;
268  }
269  if (!noOverlap ) {
271  CandMatchMap::const_iterator m1 = zMuTrackMap->find(CandReft);
272  CandMatchMap::const_iterator m2 = zMuStandAloneMap->find(CandRef);
273 
274  if( m1 != zMuTrackMap->end() && m2 != zMuStandAloneMap->end() ) {
276  }
277  }
278  }
279  }
280  }
281  }
282  }
283 }
284 
286  double Nzmm = h_zMuMu_mass_->GetEntries() ;
287  double Nzsm = h_zMuSingleStandAlone_mass_->GetEntries() ;
288  double Nzsnom = h_zMuSingleStandAloneOverlap_mass_->GetEntries() ;
289  double Nztm = h_zMuSingleTrack_mass_->GetEntries();
290 
291  double NzmmMatch = h_zMuMuMatched_mass_->GetEntries() ;
292  double NzsmMatch = h_zMuSingleStandAloneMatched_mass_->GetEntries() ;
293  double NzsnomMatch = h_zMuSingleStandAloneOverlapMatched_mass_->GetEntries() ;
294  double NztmMatch = h_zMuSingleTrackMatched_mass_->GetEntries();
295 
296  cout<<"-- N SingleTrackMu = "<<Nztm<<endl;
297  cout<<"-----N SinglStandAloneMu = "<<Nzsm<<endl;
298  cout<<"-----N SingleStandAloneOverlapMu = "<<Nzsnom<<endl;
299  cout<<"------- N MuMu = "<<Nzmm<<endl;
300 
301  cout<<"-- N SingleTrackMuMatched = "<<NztmMatch<<endl;
302  cout<<"-----N SinglStandAloneMuMatched = "<<NzsmMatch<<endl;
303  cout<<"-----N SingleStandAloneOverlapMuMatched = "<<NzsnomMatch<<endl;
304  cout<<"------- N MuMu Matched = "<<NzmmMatch<<endl;
305 }
306 
308 
310 
int i
Definition: DBlmapReader.cc:9
EDGetTokenT< IsolationCollection > standAloneIsoToken_
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
ProductID id() const
Definition: HandleBase.cc:15
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual double mass() const =0
mass
TH1D * h_zMuMu_mass_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup) override
EDGetTokenT< IsolationCollection > muIsoToken_
key_type key() const
Accessor for product key.
Definition: Ref.h:264
EDGetTokenT< CandidateCollection > zMuStandAloneToken_
ZMuMuAnalyzer(const edm::ParameterSet &pset)
ProductID id() const
Accessor for product ID.
Definition: Ref.h:258
edm::ValueMap< float > IsolationCollection
tuple lep1
print &#39;MRbb(1b)&#39;,event.mr_bb
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
EDGetTokenT< CandMatchMap > zMuStandAloneMapToken_
OverlapChecker overlap_
EDGetTokenT< CandMatchMap > zMuTrackMapToken_
TH1D * h_zMuSingleTrack_mass_
EDGetTokenT< CandidateCollection > zMuTrackToken_
TH1D * h_zMuMuMatched_mass_
virtual void endJob() override
REF castTo() const
Definition: RefToBase.h:271
TH1D * h_zMuSingleStandAlone_mass_
susybsm::MuonSegment ms
Definition: classes.h:31
EDGetTokenT< IsolationCollection > trackIsoToken_
TH1D * h_zMuSingleStandAloneOverlapMatched_mass_
EDGetTokenT< CandMatchMap > zMuMuMapToken_
TH1D * h_zMuSingleTrackMatched_mass_
tuple cout
Definition: gather_cfg.py:145
ProductIndex id() const
Definition: ProductID.h:38
TH1D * h_zMuSingleStandAloneMatched_mass_
tuple zMuMu
zMuMu vector of PSet is common to all categories except zMuTrk category
EDGetTokenT< CandidateCollection > zMuMuToken_
virtual const CandidateBaseRef & masterClone() const =0