ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Vuko/WZAnalysis/src/MuonAnalyzer.cc
(Generate patch)

Comparing UserCode/Vuko/WZAnalysis/src/MuonAnalyzer.cc (file contents):
Revision 1.1 by senka, Thu Mar 27 09:35:54 2008 UTC vs.
Revision 1.3 by senka, Fri Apr 4 08:51:22 2008 UTC

# Line 84 | Line 84 | MuonAnalyzer::MuonAnalyzer(const edm::Pa
84  
85    theLooseMuonCollection       = iConfig.getParameter<edm::InputTag>("LooseMuons");
86    theGoodMuonCollection        = iConfig.getParameter<edm::InputTag>("GoodMuons");
87 <  theLooseElectronCollection   = iConfig.getParameter<edm::InputTag>("LooseElectrons");
88 <  theGoodElectronCollection    = iConfig.getParameter<edm::InputTag>("GoodElectrons");
89 <  theTightLeptonCollection     = iConfig.getParameter<edm::InputTag>("TightLeptons");
90 <  //  theMediumElectronCollection  = iConfig.getParameter<edm::InputTag>("LooseElectrons");
91 <  //  theTightElectronCollection   = iConfig.getParameter<edm::InputTag>("TightElectrons");
87 >  //  theLooseElectronCollection   = iConfig.getParameter<edm::InputTag>("LooseElectrons");
88 >  //  theGoodElectronCollection    = iConfig.getParameter<edm::InputTag>("GoodElectrons");
89 >  //  theTightLeptonCollection     = iConfig.getParameter<edm::InputTag>("TightLeptons");
90    // Z's
91 <  theZeeCollection             = iConfig.getParameter<edm::InputTag>("ZtoEE");
92 <  theZmumuCollection           = iConfig.getParameter<edm::InputTag>("ZtoMuMu");
93 <  theZllCollection             = iConfig.getParameter<edm::InputTag>("ZtoLL");
91 >  //  theZeeCollection             = iConfig.getParameter<edm::InputTag>("ZtoEE");
92 >  //  theZmumuCollection           = iConfig.getParameter<edm::InputTag>("ZtoMuMu");
93 >  //  theZllCollection             = iConfig.getParameter<edm::InputTag>("ZtoLL");
94  
95    theJetCollection             = iConfig.getParameter<edm::InputTag>("Jets");
96  
# Line 102 | Line 100 | MuonAnalyzer::MuonAnalyzer(const edm::Pa
100    getAlpgenID = false;
101    getAlpgenID                  = iConfig.getParameter<bool>("getAlpgenID");
102  
105  storeHLTresults=false;
106  storeHLTresults              = iConfig.getParameter<bool>("storeHLTresults");
107
103    getEventWeight = false;
104    getEventWeight               = iConfig.getParameter<bool>("getEventWeight");
105  
111  triggerResultsTag            = iConfig.getParameter<edm::InputTag>("TriggerResults");
112  firstTriggerResult = true;
106   }
107  
108  
# Line 145 | Line 138 | MuonAnalyzer::analyze(const edm::Event&
138     RunNumber = iEvent.id().run();
139     EventID   = iEvent.id().event();
140  
148   // Reset a few things
149   for (map<string,wzana::LeptonProperties* >::iterator iter = leptonProperties.begin();
150        iter!=leptonProperties.end();   iter++)
151     {
152       iter->second->ResetValues();
153     }
154
155
156   const Candidate * theZCandidate = 0;
157   const Candidate * theWlepton    = 0;
158
159
141     ////////////////////////////////////////
142     // Get lists
143  
163   // Z->mumu
164   Handle<CandidateCollection> zmumuCands;
165   iEvent.getByLabel( theZmumuCollection , zmumuCands);
166
167
168   // Z->ee
169   Handle<CandidateCollection> zeeCands;
170   iEvent.getByLabel( theZeeCollection , zeeCands);
171
172   // Z->ee
173   Handle<CandidateCollection> zllCands;
174   iEvent.getByLabel( theZllCollection , zllCands);
175
176   // loose electrons
177   Handle<CandidateCollection> looseElectronCands;
178   iEvent.getByLabel( theLooseElectronCollection , looseElectronCands);
179
180   // good electrons
181   Handle<CandidateCollection> goodElectronCands;
182   iEvent.getByLabel( theGoodElectronCollection , goodElectronCands);
183
144     // loose muons
145     Handle<CandidateCollection> looseMuonCands;
146     iEvent.getByLabel( theLooseMuonCollection , looseMuonCands);
# Line 189 | Line 149 | MuonAnalyzer::analyze(const edm::Event&
149     Handle<CandidateCollection> goodMuonCands;
150     iEvent.getByLabel( theGoodMuonCollection , goodMuonCands);
151  
192
152     // tight leptons
153 <   Handle<CandidateCollection> tightLeptonCands;
154 <   iEvent.getByLabel( theTightLeptonCollection , tightLeptonCands);
153 >   //   Handle<CandidateCollection> tightLeptonCands;
154 >   //   iEvent.getByLabel( theTightLeptonCollection , tightLeptonCands);
155  
156     // jets
157  
# Line 234 | Line 193 | MuonAnalyzer::analyze(const edm::Event&
193       }
194     }
195  
237  
238    // get hold of TriggerResults
239   Handle<TriggerResults> HLTR;  //moja promjena: ovo prebaceno 2 reda nize!
240   if (storeHLTresults) {
241     //      Handle<TriggerResults> HLTR;
242     iEvent.getByLabel(triggerResultsTag,HLTR);
243     if (firstTriggerResult) {
244       firstTriggerResult = false;
245       trigNames.init((edm::TriggerResults&)*HLTR);
246       numTriggers = trigNames.size();
247     }
248   }  
249  
250
251   // MET corrected (P_muons, P_muons_calo_deposit)
252  
253   reco::Particle::LorentzVector MET=computeMET(iEvent, iSetup, looseMuonCands);
254   //     MET_energy=MET.energy();
255   MET_energy=MET.energy(); // this is Et!!
256   MET_pt=MET.pt();
257   MET_px=MET.px();
258   MET_py=MET.py();
259   MET_eta=MET.eta();
260  
261  
196     // selected muons
197  
198   //    cout << "\t # loose mu : " <<  looseMuonCands->size()
# Line 275 | Line 209 | MuonAnalyzer::analyze(const edm::Event&
209     N_looseElectrons=0;
210     N_goodMuonCands=0;
211     N_looseMuons = looseMuonCands->size();
278   N_looseElectrons = looseElectronCands->size();
212     N_goodMuonCands=goodMuonCands->size();
280
281
282   //
283   // Find best Z (in Z->ll collection (merged Z->ee & Z->mumu)
284   //
285   ::OverlapChecker overlap;
286
287
288  float dzmass_min = 100.;
289
290  n=1;  // number of non overlaping Zs
291  for(CandidateCollection::const_iterator z1 = zllCands->begin();
292      z1 != zllCands->end(); ++ z1 ) {
293
294    // Check that two leptons used to build the Z are not overlapping
295    if (overlap(*(z1->daughter(0)),*(z1->daughter(1))) ) {
296      continue;
297    }
298
299    float dzmass = fabs( z1->mass() - 91.188);
300    if (dzmass < dzmass_min) {
301      theZCandidate = &(*z1);
302      dzmass_min = dzmass;
303    }
304    //    
305    //Get back Electrons from Z and W
306    for(CandidateCollection::const_iterator z2 = z1;
307        z2 != zllCands->end(); ++ z2 ) {
308      if (z1 != z2) {
309        if (overlap(*z1,*z2)) {
310        } else {
311          n++;
312        }
313      }
314    }
315  }
316
317
318  zFlavour = 0;
319  wlFlavour = 0;
320  zMass = -10;
321  zPt  = -10;
322  zEta = -10;
323  zPhi = -10;
324
325  dPhi_WlZ_reco=-15.;    
326  dPhi_WZ_reco=-15.;
327
328
329  //---------------
330 //   matching(iEvent,looseMuonCands, 13);
331 //   matching(iEvent,looseElectronCands, 11);
332 //   MatchedGenParticle(&(*looseMuonCands)[0]);
333  //-------------------
334
335  int nwl_candidates=0;
336  if (theZCandidate) {
337
338
339    zMass      = theZCandidate->mass();
340    zFlavour  =  abs(theZCandidate->daughter(0)->pdgId());
341    zPt       = theZCandidate->pt();
342    zEta     = theZCandidate->eta();
343    zPhi      = theZCandidate->phi();
344
345    // Sanity check: can we identify the Z daughters with leptons from the loose lists
346
347    Handle<CandidateCollection> looseLeptonCands;
348    if (zFlavour == 11) {
349      looseLeptonCands = looseElectronCands;      
350    } else if (zFlavour == 13) {
351      looseLeptonCands = looseMuonCands;      
352    }
353    for (int i=0; i<2; i++) {
354      int noverlaps=0;
355      for(CandidateCollection::const_iterator l = looseLeptonCands->begin();
356          l != looseLeptonCands->end(); l++) {
357        if (overlap(*(theZCandidate->daughter(i)), *l) ) {
358          noverlaps++;
359        }
360      }
361    }
362
363    matching(iEvent,looseMuonCands, 13);
364    matching(iEvent,looseElectronCands, 11);
365
366        for (map< int,
367               std::vector<  matchedParticles >   > ::iterator iter = leptonMatching.begin();
368             iter!=leptonMatching.end();   iter++) // entire map
369          {
370            //      for (unsigned int j=0; j<iter->second.size(); j++){ // entire vector<class<>>
371              //              const reco::Candidate * nesto=iter->second[j].pair.second;
372              
373              if ((iter->first)==13)
374                cout <<"IDE PO CIJELOJ MAPI 13 za WZ TREE" << endl;
375              //            }
376          }
377    
378    if (zFlavour == 11) {
379      //--------------  
380      leptonProperties["ZEl1"]->FillProperties(theZCandidate->daughter(0), iEvent, iSetup,
381                                               MatchedGenParticle(theZCandidate->daughter(0)),dR(theZCandidate->daughter(0)));
382      leptonProperties["ZEl2"]->FillProperties(theZCandidate->daughter(1), iEvent, iSetup,
383                                               MatchedGenParticle(theZCandidate->daughter(1)),dR(theZCandidate->daughter(1)));
384    } else if (zFlavour == 13) {
385      //--------------  
386      const reco::Candidate * mcpart = MatchedGenParticle(theZCandidate->daughter(0));
387      //--------------  
388      leptonProperties["Zmu1"]->FillProperties(theZCandidate->daughter(0), iEvent, iSetup,
389                                               MatchedGenParticle(theZCandidate->daughter(0)),dR(theZCandidate->daughter(0)));
390      leptonProperties["Zmu2"]->FillProperties(theZCandidate->daughter(1), iEvent, iSetup,
391                                               MatchedGenParticle(theZCandidate->daughter(1)),dR(theZCandidate->daughter(1)));
392
393    }
394
395    float max_pt = 0.;
396
397    /// Find W lepton
398
399
400    // Now find lepton that will be associated to W
401    //   among leptons not used for the Z reconstruction
402    for(CandidateCollection::const_iterator lepton = tightLeptonCands->begin();
403        lepton != tightLeptonCands->end(); lepton++) {
404
405
406      if ( overlap(*theZCandidate, *lepton) )  continue; // Ignore if lepton used for the Z
407
408      nwl_candidates++;
409
410      // If more than one candidate: choose leading pt
411      if (lepton->pt() > max_pt) {
412        theWlepton = &(*lepton);
413        max_pt     = lepton->pt();
414      }
415
416      if(lepton->hasMasterClone()) {
417        //      cout << "SHOUT: TIGHT LEPTON IS SHALLOW COPY !!! (SHOULD NOT BE!) \n";
418      }
419      //
420    }
421    if (theWlepton) {
422      wlFlavour = theWlepton->pdgId();
423      wlCharge  = theWlepton->charge();
424      wlPt      = theWlepton->pt();
425      wlEta     = theWlepton->eta();
426      wlPhi     = theWlepton->phi();
427
428      if (abs(wlFlavour) == 11) {
429        leptonProperties["Wel"]->FillProperties(theWlepton, iEvent, iSetup, MatchedGenParticle(theWlepton),dR(theWlepton));
430      } else if (abs(wlFlavour) == 13) {
431        leptonProperties["Wmu"]->FillProperties(theWlepton, iEvent, iSetup, MatchedGenParticle(theWlepton),dR(theWlepton));
432      }
433
434      dPhi_WlZ_reco=acos(cos(theWlepton->phi()-theZCandidate->phi()));    
435      dPhi_WZ_reco=acos(cos((theWlepton->p4()+MET).phi()-theZCandidate->phi()));
436
437    }
438
439  }
213    
214    //  Handle <reco::GenParticleCandidateCollection> mccands;
215    Handle<CandidateCollection> mccands;
# Line 444 | Line 217 | MuonAnalyzer::analyze(const edm::Event&
217    
218    collectMCsummary(mccands);
219    
447  if (storeHLTresults) {
448    
449    //def: 1:single electron 2:single relaxed 3:double electron 4: double relaxed 5,6,7,8: muon e+mu: 9
450    
451    triggerBitmask=0;
452
453    for (size_t i=0; i<numTriggers; ++i) {
454
455        if (!HLTR->wasrun(i)) {
456                continue;
457        }
458        if (HLTR->error(i) ) {
459                continue;
460        }
461        if (HLTR->accept(i)) {
462                //if (triggerNames[i].compare("mcpath")!=0)
463                //TRaccept=true;
464        }else {
465                continue;
466        }
467        if (trigNames.triggerName(i).compare("HLT1Electron")==0) triggerBitmask |= 1;
468        if (trigNames.triggerName(i).compare("HLT1ElectronRelaxed")==0) triggerBitmask |= 2;
469        if (trigNames.triggerName(i).compare("HLT2Electron")==0) triggerBitmask |= 4;
470        if (trigNames.triggerName(i).compare("HLT2ElectronRelaxed")==0) triggerBitmask |= 8;
471
472        if (trigNames.triggerName(i).compare("HLT1MuonIso")==0) triggerBitmask |= 16;
473        if (trigNames.triggerName(i).compare("HLT1MuonNonIso")==0) triggerBitmask |= 32;
474        if (trigNames.triggerName(i).compare("HLT2MuonNonIso")==0) triggerBitmask |= 64;
475        if (trigNames.triggerName(i).compare("HLT2MuonZ")==0) triggerBitmask |= 128;
476
477        if (trigNames.triggerName(i).compare("HLTXElectronMuon")==0) triggerBitmask |= 256;
478        if (trigNames.triggerName(i).compare("HLTXElectronMuonRelaxed")==0) triggerBitmask |= 512;
479
480        if (trigNames.triggerName(i).compare("CandHLT2MuonIso")==0) triggerBitmask |= 1024;
481     }
482   }
483  
484  // Jet properties
485
486  float max_et = 0.;
487  float max2_et = 0.;
488  const Candidate * leadingJet   = 0;
489  const Candidate * secondJet    = 0;
490
491  bool matchedLept[3]={false,false,false};
492
493  //  for(CandidateCollection::const_iterator jet = jetCands->begin();
494  NbJets = 0;
495  NbJetsWithLeptons = 0;
496  NbJets_forMuonFakeRate=0;
497
498  for(CaloJetCollection::const_iterator jet = jetCands->begin();
499      jet != jetCands->end(); jet++) {
500
501        //ignore jets which are within dR 0.15 to a WZ lepton
502   {
503        float dPhi[3]={-1.0,-1.0,-1.0};
504        float dEta[3]={-1.0,-1.0,-1.0};
505        bool skipJet=false;
506
507        for (int ct=0;ct<2;ct++) {
508          if (theZCandidate)
509                if (theZCandidate->daughter(ct)->pt()>0
510                    && (abs(theZCandidate->daughter(ct)->pdgId())==13
511                        || abs(theZCandidate->daughter(ct)->pdgId())==11) ) {
512                        dPhi[ct]=fabs(theZCandidate->daughter(ct)->phi() - jet->phi());
513                        dEta[ct]=fabs(theZCandidate->daughter(ct)->eta() - jet->eta());
514                }
515        }
516        if (theWlepton)
517          if (theWlepton->pt()>0 && (abs(theWlepton->pdgId())==13 || abs(theWlepton->pdgId())==11 )) {
518                dPhi[2]=fabs(theWlepton->phi() - jet->phi());
519                dEta[2]=fabs(theWlepton->eta() - jet->eta());
520        }
521        for (int k=0;k<3;k++) {
522                if (matchedLept[k] || dPhi[k]<0.0 || dEta[k]<0.0) continue;
523
524                while (dPhi[k]>6.28318531) dPhi[k]-= 6.28318531;
525                if (dPhi[k]>3.14159265) dPhi[k]= 6.28318531-dPhi[k];
526
527                float deltaR=sqrt(dPhi[k]*dPhi[k]+dEta[k]*dEta[k]);
528                if (deltaR<0.15) {
529                        skipJet=true;
530                        matchedLept[k]=true;
531                        break;
532                }
533        }
534        if(jet->pt() > 10 && fabs(jet->eta())<2.5 )NbJetsWithLeptons++;
535        if (fabs(jet->eta())<2.5 ) NbJets_forMuonFakeRate++;
536        if (skipJet) continue;
537        if(jet->pt() > 10 && fabs(jet->eta())<2.5 )NbJets++;
538   }
220  
540    if (jet->et() > max_et ) {
541      if (leadingJet) {
542        secondJet = leadingJet;
543        max2_et   = max_et;
544      }
545      leadingJet = &(*jet);
546      max_et     = jet->et();
547
548    } else {
549      if (jet->et() > max2_et ) {
550        secondJet = &(*jet);
551        max2_et   = jet->et();
552      }
553    }
554  }
555  if (leadingJet) {
556    jet1Et  = leadingJet->et();
557    jet1Phi = leadingJet->phi();
558    jet1Eta = leadingJet->eta();
559
560  } else {
561    jet1Et  = -10;
562    jet1Phi = 0.;
563    jet1Eta = 0.;
564  }
565  if (secondJet) {
566    jet2Et  = secondJet->et();
567    jet2Phi = secondJet->phi();
568    jet2Eta = secondJet->eta();
569  } else {
570    jet2Et  = -10;
571    jet2Phi = 0.;
572    jet2Eta = 0.;
573
574  }
221  
222    // matching:
223  
224    matching(iEvent,looseMuonCands, 13);
579  matching(iEvent,looseElectronCands, 11);
225  
226    getMother(&(*mccands)[1]);
227  
583  numberOfElectronTrees  = 0;
584
585  //count number of electron treee entries which will be added
586 //   for(CandidateCollection::const_iterator el = looseElectronCands->begin();
587 //       el != looseElectronCands->end(); ++ el ) {
588 //      if (el->pt()>10 && fabs(el->eta())<2.5) {
589 //              numberOfElectronTrees++;
590 //      }
591 //   }
592
593
594
228    //  dodatak za muon fake rate:
229    matching_JetsWithMuons(iEvent, looseMuonCands, jetCands);
230    matching_JetsWithB(iEvent, jetCands);
# Line 665 | Line 298 | MuonAnalyzer::analyze(const edm::Event&
298      gen_muon_Pt=-10.;
299      muon_mother=0;
300      muon_mother_id=0;
301 +    W_mother_id=0;
302 +
303 +
304 +    muon_global_chi2=-10.;
305 +    muon_global_p=-10.;
306 +    muon_global_pt=-10.;
307 +    muon_global_outerP=-10.;  
308 +    muon_global_outerPt=-10.;
309 +    muon_global_ndof=-10.;
310 +    muon_global_normalizedChi2=-10.;
311 +    muon_global_recHitsSize=-10;
312 +    muon_global_numberOfLostHits=-10;
313 +    muon_global_numberOfValidHits=-10;
314 +    muon_global_innerPosition_x=-10.;
315 +    muon_global_innerPosition_y=-10.;
316 +    muon_global_innerPosition_z=-10.;
317 +    muon_global_outerPosition_x=-10.;
318 +    muon_global_outerPosition_y=-10.;
319 +    muon_global_outerPosition_z=-10.;
320 +    
321 +    muon_STA_chi2=-10.;
322 +    muon_STA_p=-10.;
323 +    muon_STA_pt=-10.;
324 +    muon_STA_outerP=-10.;  
325 +    muon_STA_outerPt=-10.;
326 +    muon_STA_ndof=-10.;
327 +    muon_STA_normalizedChi2=-10.;
328 +    muon_STA_recHitsSize=-10;
329 +    muon_STA_numberOfLostHits=-10;
330 +    muon_STA_numberOfValidHits=-10;
331 +    muon_STA_innerPosition_x=-10.;
332 +    muon_STA_innerPosition_y=-10.;
333 +    muon_STA_innerPosition_z=-10.;
334 +    muon_STA_outerPosition_x=-10.;
335 +    muon_STA_outerPosition_y=-10.;
336 +    muon_STA_outerPosition_z=-10.;
337 +    
338 +    muon_track_chi2=-10.;
339 +    muon_track_p=-10.;
340 +    muon_track_pt=-10.;
341 +    muon_track_outerP=-10.;  
342 +    muon_track_outerPt=-10.;
343 +    muon_track_ndof=-10.;
344 +    muon_track_normalizedChi2=-10.;
345 +    muon_track_recHitsSize=-10;
346 +    muon_track_numberOfLostHits=-10;
347 +    muon_track_numberOfValidHits=-10;
348 +    muon_track_innerPosition_x=-10.;
349 +    muon_track_innerPosition_y=-10.;
350 +    muon_track_innerPosition_z=-10.;
351 +    muon_track_outerPosition_x=-10.;
352 +    muon_track_outerPosition_y=-10.;
353 +    muon_track_outerPosition_z=-10.;
354 +
355  
356      //    if (fabs((*jetCands)[i].eta())<2.5) {
357      //      cout <<" jet passing eta cut" <<endl;
358        // if jet has matched muon and eta(muon)<2.5
672      if (MatchedMuonWithJet(&(*jetCands)[i])) {
673        cout <<" jet IMA matched muon !!!!!!!!!!!!!!" <<endl;
674        JetmatchedMuon=1;      
675        dr_muon=dR_Muon_Jet(&(*jetCands)[i]);
676        cout <<"       dr="<< dr_muon << "  dR_Muon_Jet(&(*jetCands)[i])="<<dR_Muon_Jet(&(*jetCands)[i])<< endl;
677        muon_Et=MatchedMuonWithJet(&(*jetCands)[i])->et();
678        muon_eta=MatchedMuonWithJet(&(*jetCands)[i])->eta();
679        muon_Pt=MatchedMuonWithJet(&(*jetCands)[i])->pt();
680        //      if (fabs(MatchedMuonWithJet(&(*jetCands)[i])->eta())<2.5) {
681        //        cout <<"   muon prolazi eta cut" <<endl;
359  
360 <        for (map< int,
360 >    const reco::Candidate * matchedmuon=MatchedMuonWithJet(&(*jetCands)[i]);
361 >    
362 >    if (MatchedMuonWithJet(&(*jetCands)[i])) {
363 >      cout <<" jet IMA matched muon !!!!!!!!!!!!!!" <<endl;
364 >      JetmatchedMuon=1;
365 >      dr_muon=dR_Muon_Jet(&(*jetCands)[i]);
366 >      cout <<"       dr="<< dr_muon << "  dR_Muon_Jet(&(*jetCands)[i])="<<dR_Muon_Jet(&(*jetCands)[i])<< endl;
367 >      //        muon_Et=MatchedMuonWithJet(&(*jetCands)[i])->et();
368 >      //        muon_eta=MatchedMuonWithJet(&(*jetCands)[i])->eta();
369 >      //        muon_Pt=MatchedMuonWithJet(&(*jetCands)[i])->pt();
370 >      //        muon_STA_chi2=MatchedMuonWithJet(&(*jetCands)[i])->standAloneMuon()->chi2();
371 >      muon_Et = matchedmuon->et();
372 >      muon_eta = matchedmuon->eta();
373 >      muon_Pt = matchedmuon->pt();
374 >      
375 >      const reco::Muon* matchedmuon_recoMuon = dynamic_cast<const reco::Muon *> (matchedmuon); // conversion of matchedmuon from reco::Candidate to reco::Muon
376 >      
377 >      muon_global_chi2 = matchedmuon_recoMuon->combinedMuon()->chi2();
378 >      muon_global_p = matchedmuon_recoMuon->combinedMuon()->p();
379 >      muon_global_pt = matchedmuon_recoMuon->combinedMuon()->pt();
380 >      muon_global_outerP = matchedmuon_recoMuon->combinedMuon()->outerP();
381 >      muon_global_outerPt = matchedmuon_recoMuon->combinedMuon()->outerPt();
382 >      muon_global_ndof = matchedmuon_recoMuon->combinedMuon()->ndof();
383 >      muon_global_normalizedChi2 = matchedmuon_recoMuon->combinedMuon()->normalizedChi2();
384 >      muon_global_recHitsSize = matchedmuon_recoMuon->combinedMuon()->recHitsSize();
385 >      muon_global_numberOfLostHits = matchedmuon_recoMuon->combinedMuon()->numberOfLostHits();
386 >      muon_global_numberOfValidHits = matchedmuon_recoMuon->combinedMuon()->numberOfValidHits();
387 >      muon_global_innerPosition_x = matchedmuon_recoMuon->combinedMuon()->innerPosition().x();
388 >      muon_global_innerPosition_y = matchedmuon_recoMuon->combinedMuon()->innerPosition().y();
389 >      muon_global_innerPosition_z = matchedmuon_recoMuon->combinedMuon()->innerPosition().z();
390 >      muon_global_outerPosition_x = matchedmuon_recoMuon->combinedMuon()->outerPosition().x();
391 >      muon_global_outerPosition_y = matchedmuon_recoMuon->combinedMuon()->outerPosition().y();
392 >      muon_global_outerPosition_z = matchedmuon_recoMuon->combinedMuon()->outerPosition().z();
393 >      
394 >      muon_STA_chi2 = matchedmuon_recoMuon->standAloneMuon()->chi2();
395 >      muon_STA_p = matchedmuon_recoMuon->standAloneMuon()->p();
396 >      muon_STA_pt = matchedmuon_recoMuon->standAloneMuon()->pt();
397 >      muon_STA_outerP = matchedmuon_recoMuon->standAloneMuon()->outerP();
398 >      muon_STA_outerPt = matchedmuon_recoMuon->standAloneMuon()->outerPt();
399 >      muon_STA_ndof = matchedmuon_recoMuon->standAloneMuon()->ndof();
400 >      muon_STA_normalizedChi2 = matchedmuon_recoMuon->standAloneMuon()->normalizedChi2();
401 >      muon_STA_recHitsSize = matchedmuon_recoMuon->standAloneMuon()->recHitsSize();
402 >      muon_STA_numberOfLostHits = matchedmuon_recoMuon->standAloneMuon()->numberOfLostHits();
403 >      muon_STA_numberOfValidHits = matchedmuon_recoMuon->standAloneMuon()->numberOfValidHits();
404 >      muon_STA_innerPosition_x = matchedmuon_recoMuon->standAloneMuon()->innerPosition().x();
405 >      muon_STA_innerPosition_y = matchedmuon_recoMuon->standAloneMuon()->innerPosition().y();
406 >      muon_STA_innerPosition_z = matchedmuon_recoMuon->standAloneMuon()->innerPosition().z();
407 >      muon_STA_outerPosition_x = matchedmuon_recoMuon->standAloneMuon()->outerPosition().x();
408 >      muon_STA_outerPosition_y = matchedmuon_recoMuon->standAloneMuon()->outerPosition().y();
409 >      muon_STA_outerPosition_z = matchedmuon_recoMuon->standAloneMuon()->outerPosition().z();
410 >      
411 >      muon_track_chi2 = matchedmuon_recoMuon->track()->chi2();
412 >      muon_track_p = matchedmuon_recoMuon->track()->p();
413 >      muon_track_pt = matchedmuon_recoMuon->track()->pt();
414 >      muon_track_outerP = matchedmuon_recoMuon->track()->outerP();
415 >      muon_track_outerPt = matchedmuon_recoMuon->track()->outerPt();
416 >      muon_track_ndof = matchedmuon_recoMuon->track()->ndof();
417 >      muon_track_normalizedChi2 = matchedmuon_recoMuon->track()->normalizedChi2();
418 >      muon_track_recHitsSize = matchedmuon_recoMuon->track()->recHitsSize();
419 >      muon_track_numberOfLostHits = matchedmuon_recoMuon->track()->numberOfLostHits();
420 >      muon_track_numberOfValidHits = matchedmuon_recoMuon->track()->numberOfValidHits();
421 >      muon_track_innerPosition_x = matchedmuon_recoMuon->track()->innerPosition().x();
422 >      muon_track_innerPosition_y = matchedmuon_recoMuon->track()->innerPosition().y();
423 >      muon_track_innerPosition_z = matchedmuon_recoMuon->track()->innerPosition().z();
424 >      muon_track_outerPosition_x = matchedmuon_recoMuon->track()->outerPosition().x();
425 >      muon_track_outerPosition_y = matchedmuon_recoMuon->track()->outerPosition().y();
426 >      muon_track_outerPosition_z = matchedmuon_recoMuon->track()->outerPosition().z();
427 >      
428 >      //        if (fabs(MatchedMuonWithJet(&(*jetCands)[i])->eta())<2.5) {
429 >      //          cout <<"   muon prolazi eta cut" <<endl;
430 >      
431 >      for (map< int,
432                 std::vector<  matchedParticles >   > ::iterator iter = leptonMatching.begin();
433 <             iter!=leptonMatching.end();   iter++) // entire map
434 <          {
435 <            //      for (unsigned int j=0; j<iter->second.size(); j++){ // entire vector<class<>>
436 <              //              const reco::Candidate * nesto=iter->second[j].pair.second;
437 <              
438 <              if ((iter->first)==13)
439 <                cout <<"IDE PO CIJELOJ MAPI 13" << endl;
440 <              //            }
441 <          }
433 >           iter!=leptonMatching.end();   iter++) // entire map
434 >        {
435 >          //        for (unsigned int j=0; j<iter->second.size(); j++){ // entire vector<class<>>
436 >          //          const reco::Candidate * nesto=iter->second[j].pair.second;
437 >          
438 >          if ((iter->first)==13)
439 >            cout <<"IDE PO CIJELOJ MAPI 13" << endl;
440 >          //        }
441 >        }
442 >      
443 >      // ako muon (matched with jet) ima matched gen_muon
444  
445 <          // ako muon (matched with jet) ima matched gen_muon
446 <        if (MatchedGenParticle(MatchedMuonWithJet(&(*jetCands)[i]))){
447 <          cout <<" muon has matched gen muon !!!!!!!!!!" <<endl;
448 <          MuonmatchedGenMuon=1;
449 <          gen_muon_Et=MatchedGenParticle(MatchedMuonWithJet(&(*jetCands)[i]))->et();
450 <          gen_muon_eta=MatchedGenParticle(MatchedMuonWithJet(&(*jetCands)[i]))->eta();
451 <          gen_muon_Pt=MatchedGenParticle(MatchedMuonWithJet(&(*jetCands)[i]))->pt();
452 <          MuonAnalyzer::LeptonOrigin origin = getMother(MatchedGenParticle(MatchedMuonWithJet(&(*jetCands)[i])));
453 <
454 <          if (origin == MuonAnalyzer::wboson ){
455 <            muon_mother=1;
456 <            cout << "MatchedGenFromW=true" <<endl;
707 <          }
708 <          else if (origin == MuonAnalyzer::zboson ){
709 <            muon_mother=2;
710 <            cout << "MatchedGenFromZ=true" <<endl;
445 >      if (MatchedGenParticle(matchedmuon)){
446 >        cout <<" muon has matched gen muon !!!!!!!!!!" <<endl;
447 >        MuonmatchedGenMuon=1;
448 >        gen_muon_Et=MatchedGenParticle(matchedmuon)->et();
449 >        gen_muon_eta=MatchedGenParticle(matchedmuon)->eta();
450 >        gen_muon_Pt=MatchedGenParticle(matchedmuon)->pt();
451 >        MuonAnalyzer::LeptonOrigin origin = getMother(MatchedGenParticle(matchedmuon));
452 >        
453 >        if (origin == MuonAnalyzer::wboson ){
454 >          muon_mother=1;
455 >          cout << "MatchedGenFromW=true" <<endl;
456 >          W_mother_id = getMother_Id(getMother_particle(MatchedGenParticle(matchedmuon)));
457            }
458 <          else if (origin == MuonAnalyzer::bdecay )    {            
459 <            muon_mother = 3;
458 >        else if (origin == MuonAnalyzer::zboson ){
459 >          muon_mother=2;
460 >          cout << "MatchedGenFromZ=true" <<endl;
461 >        }
462 >        else if (origin == MuonAnalyzer::bdecay )    {            
463 >          muon_mother = 3;
464              cout << "MatchedGenFromB=true" <<endl;
715          }
716          else if (origin == MuonAnalyzer::cdecay )    {            
717            muon_mother = 4;
718            cout << "MatchedGenFromC=true" <<endl;
719          }
720          muon_mother_id=getMother_Id(MatchedGenParticle(MatchedMuonWithJet(&(*jetCands)[i])));
721
722      
723          //      }
465          }
466 <        //      }
467 <        cout <<" jet nema matched muon" <<endl;
466 >        else if (origin == MuonAnalyzer::cdecay )    {            
467 >          muon_mother = 4;
468 >          cout << "MatchedGenFromC=true" <<endl;
469 >        }
470 >        else if (origin == MuonAnalyzer::tdecay )    {            
471 >          muon_mother = 5;
472 >          cout << "MatchedGenFromT=true" <<endl;
473 >        }
474 >        muon_mother_id=getMother_Id(MatchedGenParticle(matchedmuon));
475 >        
476 >        
477 >          //      }
478        }
479 <      
480 <      if (MatchedBhadronWithJet(&(*jetCands)[i])) {
479 >      //      }
480 >      cout <<" jet nema matched muon" <<endl;  
481 >    }
482 >    
483 >    if (MatchedBhadronWithJet(&(*jetCands)[i])) {
484          cout <<" ima matched B hadron !!!!!!!!" << endl;
485          /////////////////
486  
# Line 785 | Line 539 | MuonAnalyzer::analyze(const edm::Event&
539   //   }
540  
541    JetMuTree->Fill();
788  wzTree->Fill();
789
790
791  // Fill electrons in a tree
792  for(CandidateCollection::const_iterator el = looseElectronCands->begin();
793      el != looseElectronCands->end(); ++ el ) {
794
795    electronUse = 0;
796
797    if (theZCandidate) {
798
799      if (overlap(*theZCandidate, *el) ) {
800        electronUse = 23;
801      } else if (theWlepton) {
802        if (overlap(*theWlepton, *el) ) {
803          electronUse = 24;
804        }
805      }
806    }
807    if (el->pt()>10 && fabs(el->eta())<2.5) {
808      leptonProperties["electron"]->FillProperties(&(*el),
809                                                   iEvent, iSetup,
810                                                   MatchedGenParticle(&(*el)),dR(&(*el)));
811      electronTree->Fill();
812      
813    }
814    
815  }
542  
543  
544   }
# Line 828 | Line 554 | MuonAnalyzer::beginJob(const edm::EventS
554    //  theFile   = new TFile( "wz.root", "RECREATE" ) ;
555    theFile   = new TFile( fOutputFileName.c_str(), "RECREATE" ) ;
556  
831
832  wzTree = new TTree("WZTree","WZ informations");
833
834  electronTree = new TTree("ElTree","electron informations");
557    muonTree = new TTree("JetMuon_Tree","muon informations for fake rate");
558    JetMuTree = new TTree("JetMuEvent_Tree","event info");
559  
838  leptonProperties["electron"] = new ElectronProperties();
839
840  leptonProperties["Wel"]  = new ElectronProperties();
841  leptonProperties["ZEl1"] = new ElectronProperties();
842  leptonProperties["ZEl2"] = new ElectronProperties();
843
844  leptonProperties["Wmu"]  = new MuonProperties();
845  leptonProperties["Zmu1"] = new MuonProperties();
846  leptonProperties["Zmu2"] = new MuonProperties();
847
848
849  leptonProperties["Wel"]->CreateBranches(wzTree, "WEl_");
850  leptonProperties["ZEl1"]->CreateBranches(wzTree, "ZEl1_");
851  leptonProperties["ZEl2"]->CreateBranches(wzTree, "ZEl2_");
852
853  leptonProperties["Wmu"] ->CreateBranches(wzTree, "Wmu_");
854  leptonProperties["Zmu1"] ->CreateBranches(wzTree, "Zmul_");
855  leptonProperties["Zmu2"] ->CreateBranches(wzTree, "Zmu2_");
856  leptonProperties["electron"] ->CreateBranches(electronTree);
857
560    initialiseTree();
859  
860  //prepare HLT TriggerResults branch
861  if (storeHLTresults) {
862        wzTree->Branch("WZ_hltBitmask",&triggerBitmask,"WZ_hltBitmask/I");
863
864  }
865
866  // MET branch
867  wzTree->Branch("MET_Et",&MET_energy,"MET_Et/F");
868  wzTree->Branch("MET_pt",&MET_pt,"MET_pt/F");
869  wzTree->Branch("MET_eta",&MET_eta,"MET_eta/F");
870  wzTree->Branch("dPhi_WlZ_reco",&dPhi_WlZ_reco,"dPhi_WlZ_reco/F");
871  wzTree->Branch("dPhi_WZ_reco",&dPhi_WZ_reco,"dPhi_WZ_reco/F");
872
873  // # of non overlaping Zs
874  wzTree->Branch("N_nonOverlaping_Z",&n,"N_nonOverlaping_Z/I");  
875  wzTree->Branch("N_looseMuons",&N_looseMuons,"N_looseMuons/I");  
876  wzTree->Branch("N_looseElectrons",&N_looseElectrons,"N_looseElectrons/I");  
561  
562   }
563  
# Line 888 | Line 572 | MuonAnalyzer::endJob() {
572  
573  
574   void MuonAnalyzer::initialiseTree() {
891  // Event properties
892  wzTree->Branch("weight",    &eventWeight,  "weight/F");
893  wzTree->Branch("processID", &processID, "processID/I");
894  wzTree->Branch("alpgenID", &alpgenID, "alpgenID/I");
895  wzTree->Branch("genEventScale",    &eventScale,  "genEventScale/F");
896  wzTree->Branch("RunNumber", &RunNumber, "RunNumber/I");
897  wzTree->Branch("EventID", &EventID, "EventID/I");
898
899  // Z properties  
900  wzTree->Branch("Zmass",    &zMass,    "Zmass/F");
901  wzTree->Branch("ZId",      &zFlavour, "Zid/I");
902  wzTree->Branch("ZPt",      &zPt,      "ZPt/F");
903  wzTree->Branch("ZEta",     &zEta,     "ZEta/F");
904  wzTree->Branch("ZPhi",     &zPhi,     "ZPhi/F");
905
906  // W Properties
907  wzTree->Branch("WlId",     &wlFlavour, "Wlid/I");
908  wzTree->Branch("WlCharge", &wlCharge,  "WlCharge/I");
909  wzTree->Branch("WlPt",     &wlPt,      "WlPt/F");
910  
911  wzTree->Branch("MC_leptonZ1_pt", &MCleptZ1_pt,"MC_leptonZ1_pt/F");
912  wzTree->Branch("MC_leptonZ2_pt", &MCleptZ2_pt,"MC_leptonZ2_pt/F");
913  wzTree->Branch("MC_leptonW_pt",  &MCleptW_pt, "MC_leptonW_pt/F");
914
915  wzTree->Branch("MC_leptonZ1_eta", &MCleptZ1_eta,"MC_leptonZ1_eta/F");
916  wzTree->Branch("MC_leptonZ2_eta", &MCleptZ2_eta,"MC_leptonZ2_eta/F");
917  wzTree->Branch("MC_leptonW_eta",  &MCleptW_eta, "MC_leptonW_eta/F");
918
919  wzTree->Branch("MC_leptonZ1_phi", &MCleptZ1_phi,"MC_leptonZ1_phi/F");
920  wzTree->Branch("MC_leptonZ2_phi", &MCleptZ2_phi,"MC_leptonZ2_phi/F");
921  wzTree->Branch("MC_leptonW_phi",  &MCleptW_phi, "MC_leptonW_phi/F");
922
923  wzTree->Branch("MC_leptonZ1_pdgid", &MCleptZ1_pdgid,"MC_leptonZ1_pdgid/I");
924  wzTree->Branch("MC_leptonZ2_pdgid", &MCleptZ2_pdgid,"MC_leptonZ2_pdgid/I");
925  wzTree->Branch("MC_leptonW_pdgid",  &MCleptW_pdgid, "MC_leptonW_pdgid/I");
926
927  /*
928  wzTree->Branch("MC_leptonW_origin", &MCleptW_pdgid, "MC_leptonW_origin/I");
929  wzTree->Branch("MC_leptonZ1_origin", &MCleptW_pdgid, "MC_leptonZ1_origin/I");
930  wzTree->Branch("MC_leptonZ2_origin", &MCleptW_pdgid, "MC_leptonZ2_origin/I");
931  */
932
933  wzTree->Branch("MC_TauDecayType_fromZ1", &MC_tauDecayTypeZ1,"MC_TauDecayType_fromZ1/I");
934  wzTree->Branch("MC_TauDecayType_fromZ2", &MC_tauDecayTypeZ2,"MC_TauDecayType_fromZ2/I");
935  wzTree->Branch("MC_TauDecayType_fromW",  &MC_tauDecayTypeW, "MC_TauDecayType_fromW/I");
936
937  // MET properties
938
939  // Jet properties
940  wzTree->Branch("NbJets",     &NbJets,  "NbJets/I");
941
942  wzTree->Branch("Jet1Et",     &jet1Et,  "Jet1Et/F");
943  wzTree->Branch("Jet1Phi",    &jet1Phi, "Jet1Phi/F");
944  wzTree->Branch("Jet1Eta",    &jet1Eta, "Jet1Eta/F");
945
946  wzTree->Branch("Jet2Et",     &jet2Et,  "Jet2Et/F");
947  wzTree->Branch("Jet2Phi",    &jet2Phi, "Jet2Phi/F");
948  wzTree->Branch("Jet2Eta",    &jet2Eta, "Jet2Eta/F");
949  wzTree->Branch("ElectronTreesInEvent", &numberOfElectronTrees, "ElectronTreesInEvent/I");
950  //
951  electronTree->Branch("used",   &electronUse, "used/I");
952  electronTree->Branch("weight",    &eventWeight,  "weight/F");
953  electronTree->Branch("processID", &processID, "processID/I");
954  electronTree->Branch("alpgenID", &alpgenID, "alpgenID/I");
955  electronTree->Branch("genEventScale",    &eventScale,  "genEventScale/F");
956  electronTree->Branch("ElectronTreesInEvent", &numberOfElectronTrees, "ElectronTreesInEvent/I");
957
958  electronTree->Branch("RunNumber", &RunNumber, "RunNumber/I");
959  electronTree->Branch("EventID", &EventID, "EventID/I");
960  electronTree->Branch("NbJetsWithLeptons",     &NbJetsWithLeptons,  "NbJetsWithLeptons/I");
575  
576    // muon properties for fake rate
963  //  muonTree->Branch("RunNumber", &RunNumber, "RunNumber/I");
964  //  muonTree->Branch("EventID", &EventID, "EventID/I");
965  //  muonTree->Branch("NbJets_forMuonFakeRate",     &NbJets_forMuonFakeRate,  "NbJets_forMuonFakeRate/I");
966  //  muonTree->Branch("N_looseMuons",&N_looseMuons,"N_looseMuons/I");
967  //  muonTree->Branch("N_goodMuonCands",&N_goodMuonCands,"N_goodMuonCands/I");
968  //  muonTree->Branch("matchedMuon",&matchedMuon,"matchedMuon/I");
577  
578 <  //  muonTree->Branch("nb_jet",&nb_jet,"nb_jet/I");
578 >  muonTree->Branch("weight",    &eventWeight,  "weight/F");
579 >  muonTree->Branch("processID", &processID, "processID/I");
580 >  muonTree->Branch("alpgenID", &alpgenID, "alpgenID/I");
581 >  muonTree->Branch("genEventScale",    &eventScale,  "genEventScale/F");
582 >  muonTree->Branch("RunNumber", &RunNumber, "RunNumber/I");
583 >  muonTree->Branch("EventID", &EventID, "EventID/I");
584 >
585 >  muonTree->Branch("N_looseMuons",&N_looseMuons,"N_looseMuons/I");
586 >  muonTree->Branch("N_goodMuonCands",&N_goodMuonCands,"N_goodMuonCands/I");
587 >  muonTree->Branch("matchedMuon",&matchedMuon,"matchedMuon/I");
588 >
589 >  muonTree->Branch("nb_jet",&nb_jet,"nb_jet/I");
590 >  muonTree->Branch("nb_jet_eta_cut",&nb_jet_eta_cut,"nb_jet_eta_cut/I");
591 >  muonTree->Branch("nb_jet_eta_and_pt_cut",&nb_jet_eta_and_pt_cut,"nb_jet_eta_and_pt_cut/I");
592 >
593 >  muonTree->Branch("nb_muon",&nb_muon,"nb_muon/I");
594    
595    //  muonTree->Branch("NbJets",&,"/I");
596    muonTree->Branch("JetmatchedMuon",&JetmatchedMuon,"JetmatchedMuon/I");
# Line 1016 | Line 639 | void MuonAnalyzer::initialiseTree() {
639    muonTree->Branch("muon_mother",&muon_mother,"muon_mother/I");
640    muonTree->Branch("muon_mother_id",&muon_mother_id,"muon_mother_id/I");
641  
642 +  muonTree->Branch("W_mother_id",&W_mother_id,"W_mother_id/I");
643 +
644 +  muonTree->Branch("muon_global_chi2", &muon_global_chi2 , "muon_global_chi2/F");
645 +  muonTree->Branch("muon_global_p",&muon_global_p," muon_global_p/F");
646 +  muonTree->Branch("muon_global_pt",&muon_global_pt,  "muon_global_pt/F");
647 +  muonTree->Branch("muon_global_outerP",& muon_global_outerP,"muon_global_outerP/F");  
648 +  muonTree->Branch("muon_global_outerPt",& muon_global_outerPt,"muon_global_outerPt/F");
649 +  muonTree->Branch("muon_global_ndof",&muon_global_ndof,"muon_global_ndof/F");
650 +  muonTree->Branch("muon_global_normalizedChi2",& muon_global_normalizedChi2,"muon_global_normalizedChi2/F");
651 +  muonTree->Branch("muon_global_recHitsSize",&muon_global_recHitsSize,"muon_global_recHitsSize/I");
652 +  muonTree->Branch("muon_global_numberOfLostHits",& muon_global_numberOfLostHits,"muon_global_numberOfLostHits/I");
653 +  muonTree->Branch("muon_global_numberOfValidHits",&muon_global_numberOfValidHits,"muon_global_numberOfValidHits/I");
654 +  muonTree->Branch("muon_global_innerPosition_x",& muon_global_innerPosition_x,"muon_global_innerPosition_x/F");
655 +  muonTree->Branch("muon_global_innerPosition_y",& muon_global_innerPosition_y,"muon_global_innerPosition_y/F");
656 +  muonTree->Branch("muon_global_innerPosition_z",& muon_global_innerPosition_z,"muon_global_innerPosition_z/F");
657 +  muonTree->Branch("muon_global_outerPosition_x",& muon_global_outerPosition_x,"muon_global_outerPosition_x/F");
658 +  muonTree->Branch("muon_global_outerPosition_y",& muon_global_outerPosition_y,"muon_global_outerPosition_y/F");
659 +  muonTree->Branch("muon_global_outerPosition_z",& muon_global_outerPosition_z,"muon_global_outerPosition_z/F");
660 +
661 +  muonTree->Branch("muon_STA_chi2", &muon_STA_chi2 , "muon_STA_chi2/F");
662 +  muonTree->Branch("muon_STA_p",&muon_STA_p," muon_STA_p/F");
663 +  muonTree->Branch("muon_STA_pt",&muon_STA_pt,  "muon_STA_pt/F");
664 +  muonTree->Branch("muon_STA_outerP",& muon_STA_outerP,"muon_STA_outerP/F");  
665 +  muonTree->Branch("muon_STA_outerPt",& muon_STA_outerPt,"muon_STA_outerPt/F");
666 +  muonTree->Branch("muon_STA_ndof",&muon_STA_ndof,"muon_STA_ndof/F");
667 +  muonTree->Branch("muon_STA_normalizedChi2",& muon_STA_normalizedChi2,"muon_STA_normalizedChi2/F");
668 +  muonTree->Branch("muon_STA_recHitsSize",&muon_STA_recHitsSize,"muon_STA_recHitsSize/I");
669 +  muonTree->Branch("muon_STA_numberOfLostHits",& muon_STA_numberOfLostHits,"muon_STA_numberOfLostHits/I");
670 +  muonTree->Branch("muon_STA_numberOfValidHits",&muon_STA_numberOfValidHits,"muon_STA_numberOfValidHits/I");
671 +  muonTree->Branch("muon_STA_innerPosition_x",& muon_STA_innerPosition_x,"muon_STA_innerPosition_x/F");
672 +  muonTree->Branch("muon_STA_innerPosition_y",& muon_STA_innerPosition_y,"muon_STA_innerPosition_y/F");
673 +  muonTree->Branch("muon_STA_innerPosition_z",& muon_STA_innerPosition_z,"muon_STA_innerPosition_z/F");
674 +  muonTree->Branch("muon_STA_outerPosition_x",& muon_STA_outerPosition_x,"muon_STA_outerPosition_x/F");
675 +  muonTree->Branch("muon_STA_outerPosition_y",& muon_STA_outerPosition_y,"muon_STA_outerPosition_y/F");
676 +  muonTree->Branch("muon_STA_outerPosition_z",& muon_STA_outerPosition_z,"muon_STA_outerPosition_z/F");
677 +
678 +  muonTree->Branch("muon_track_chi2", &muon_track_chi2 , "muon_track_chi2/F");
679 +  muonTree->Branch("muon_track_p",&muon_track_p," muon_track_p/F");
680 +  muonTree->Branch("muon_track_pt",&muon_track_pt,  "muon_track_pt/F");
681 +  muonTree->Branch("muon_track_outerP",& muon_track_outerP,"muon_track_outerP/F");  
682 +  muonTree->Branch("muon_track_outerPt",& muon_track_outerPt,"muon_track_outerPt/F");
683 +  muonTree->Branch("muon_track_ndof",&muon_track_ndof,"muon_track_ndof/F");
684 +  muonTree->Branch("muon_track_normalizedChi2",& muon_track_normalizedChi2,"muon_track_normalizedChi2/F");
685 +  muonTree->Branch("muon_track_recHitsSize",&muon_track_recHitsSize,"muon_track_recHitsSize/I");
686 +  muonTree->Branch("muon_track_numberOfLostHits",& muon_track_numberOfLostHits,"muon_track_numberOfLostHits/I");
687 +  muonTree->Branch("muon_track_numberOfValidHits",&muon_track_numberOfValidHits,"muon_track_numberOfValidHits/I");
688 +  muonTree->Branch("muon_track_innerPosition_x",& muon_track_innerPosition_x,"muon_track_innerPosition_x/F");
689 +  muonTree->Branch("muon_track_innerPosition_y",& muon_track_innerPosition_y,"muon_track_innerPosition_y/F");
690 +  muonTree->Branch("muon_track_innerPosition_z",& muon_track_innerPosition_z,"muon_track_innerPosition_z/F");
691 +  muonTree->Branch("muon_track_outerPosition_x",& muon_track_outerPosition_x,"muon_track_outerPosition_x/F");
692 +  muonTree->Branch("muon_track_outerPosition_y",& muon_track_outerPosition_y,"muon_track_outerPosition_y/F");
693 +  muonTree->Branch("muon_track_outerPosition_z",& muon_track_outerPosition_z,"muon_track_outerPosition_z/F");
694 +
695    JetMuTree->Branch("nb_jet",&nb_jet,"nb_jet/I");
696    JetMuTree->Branch("nb_jet_eta_cut",&nb_jet_eta_cut,"nb_jet_eta_cut/I");
697    JetMuTree->Branch("nb_jet_eta_and_pt_cut",&nb_jet_eta_and_pt_cut,"nb_jet_eta_and_pt_cut/I");
1022  JetMuTree->Branch("nb_muon",&nb_muon,"nb_muon/I");
1023
1024 }
1025
1026
1027    //////////////////////////////////////////
1028    // MET & MET corrections
1029    // MET=MET-sum_p(muons)-sum_p(muons calos depositions)
698  
699 < reco::Particle::LorentzVector MuonAnalyzer::computeMET(const edm::Event& iEvent, const edm::EventSetup& iSetup, Handle<reco::CandidateCollection> MuonCands) {
1032 <  
1033 <  using namespace edm;
1034 <  using namespace reco;
1035 <  using namespace std;
1036 <
1037 <  double px_MET=0, py_MET=0, Ex_MET=0, Ey_MET=0;
1038 <  double px,py,pz,pt,Et,Ex,Ey;
1039 <  double px_muons=0;
1040 <  double py_muons=0;
1041 <  double Ex_muons=0;
1042 <  double Ey_muons=0;
1043 <  double Et_muons=0;  
1044 <  double Et_ecal;
1045 <  double Et_hcal;
1046 <  double Et_ho;
1047 <  double Et_cal;  
1048 <  double Ex_ecal;
1049 <  double Ex_hcal;
1050 <  double Ex_ho;
1051 <  double Ey_ecal;
1052 <  double Ey_hcal;
1053 <  double Ey_ho;
1054 <  double eta_cal;
1055 <  double phi_cal;
1056 <  double tg_theta_pola_ecal;
1057 <  double tg_theta_pola_hcal;
1058 <  double tg_theta_pola_ho;
1059 <  double tg_theta_ecal;
1060 <  double tg_theta_hcal;
1061 <  double tg_theta_ho;
1062 <  double E_ecal;
1063 <  double E_hcal;
1064 <  double E_ho;
1065 <  double me=0.0005;
1066 <  double sin_theta_ecal, sin_theta_hcal, sin_theta_ho, cos_theta_ecal,cos_theta_hcal,cos_theta_ho;
1067 <  double p_ecal, p_hcal,p_ho, pt_ecal,pt_hcal,pt_ho, px_ecal,px_hcal,px_ho, py_ecal,py_hcal,py_ho, pz_ecal,pz_hcal,pz_ho;
1068 <  double Ex_cal=0;
1069 <  double Ey_cal=0;    
1070 <  double px_cal=0;
1071 <  double py_cal=0;
1072 <  double Ex_kon=0;
1073 <  double Ey_kon=0;
1074 <
1075 <  reco::Particle::LorentzVector Muon_p_4v(0,0,0,0);  // sum of muons 4-vectors in (px,py,0,Et), since MET looks like that
1076 <  reco::Particle::LorentzVector Muon_p_cal_4v(0,0,0,0);
1077 <  
1078 <  Handle<CaloMETCollection> mets;
1079 <  iEvent.getByLabel("met", mets);
1080 <  //  cout << "# METs=" << mets->size() << endl;
1081 <  
1082 <  if (mets->size() != 1) {
1083 <    cout << "ALARM: # METS is not 1: !" << endl;
1084 <    return reco::Particle::LorentzVector(0.,0.,0.,0.);
1085 <  }
1086 <  
1087 <  for (CaloMETCollection::const_iterator met = mets->begin();
1088 <       met!= mets->end(); met++) {
1089 <    px_MET=met->px();
1090 <    py_MET=met->py();
1091 <    Ex_MET=met->et()*TMath::Cos(met->phi());
1092 <    Ey_MET=met->et()*TMath::Sin(met->phi());
1093 <
1094 <  }
1095 <  
1096 <  // sum of p of muons
1097 <  for (unsigned int i=0; i<MuonCands->size();i++){
1098 <    px=(*MuonCands)[i].px();
1099 <    py=(*MuonCands)[i].py();
1100 <    pz=(*MuonCands)[i].pz();
1101 <    pt=(*MuonCands)[i].pt();
1102 <    Et=(*MuonCands)[i].et();
1103 <    Ex=Et*TMath::Cos((*MuonCands)[i].phi());
1104 <    Ey=Et*TMath::Sin((*MuonCands)[i].phi());
1105 <    px_muons=px_muons+px;
1106 <    py_muons=py_muons+py;
1107 <    Ex_muons=Ex_muons+Ex;
1108 <    Ey_muons=Ey_muons+Ey;
1109 <  
1110 <  }
1111 <  Et_muons=TMath::Sqrt(Ex_muons*Ex_muons+Ey_muons*Ey_muons);
1112 <  Muon_p_4v=reco::Particle::LorentzVector(px_muons,py_muons,0,Et_muons);
1113 <  
1114 < // sum of p of muons left in calorimeters  
1115 <  for (unsigned int i=0; i<MuonCands->size();i++){
1116 <    cout<<"" << endl;
1117 <    const reco::Muon* muons=dynamic_cast<const reco::Muon *> (&(*MuonCands)[i]);
1118 <    Et_ecal=muons->getCalEnergy().emS9;  
1119 <    Et_hcal=muons->getCalEnergy().hadS9;
1120 <    Et_ho=muons->getCalEnergy().hoS9;  
1121 <    eta_cal=muons->eta();  
1122 <    phi_cal=muons->phi();  
1123 <    tg_theta_pola_ecal=TMath::Exp(-eta_cal);
1124 <    tg_theta_pola_hcal=TMath::Exp(-eta_cal);      
1125 <    tg_theta_pola_ho=TMath::Exp(-eta_cal);
1126 <    tg_theta_ecal=2*tg_theta_pola_ecal/(1-tg_theta_pola_ecal*tg_theta_pola_ecal);
1127 <    tg_theta_hcal=2*tg_theta_pola_hcal/(1-tg_theta_pola_hcal*tg_theta_pola_hcal);      
1128 <    tg_theta_ho=2*tg_theta_pola_ho/(1-tg_theta_pola_ho*tg_theta_pola_ho);
1129 <    E_ecal=TMath::Abs(Et_ecal*TMath::Sqrt(1+tg_theta_ecal*tg_theta_ecal)/tg_theta_ecal);
1130 <    E_hcal=TMath::Abs(Et_hcal*TMath::Sqrt(1+tg_theta_hcal*tg_theta_hcal)/tg_theta_hcal);
1131 <    E_ho=TMath::Abs(Et_ho*TMath::Sqrt(1+tg_theta_ho*tg_theta_ho)/tg_theta_ho);
1132 <    Ex_ecal=Et_ecal*TMath::Cos(phi_cal);
1133 <    Ex_hcal=Et_hcal*TMath::Cos(phi_cal);
1134 <    Ex_ho=Et_ho*TMath::Cos(phi_cal);
1135 <    Ey_ecal=Et_ecal*TMath::Sin(phi_cal);
1136 <    Ey_hcal=Et_hcal*TMath::Sin(phi_cal);
1137 <    Ey_ho=Et_ho*TMath::Sin(phi_cal);
1138 <    sin_theta_ecal=tg_theta_ecal/TMath::Sqrt(1+tg_theta_ecal*tg_theta_ecal);
1139 <    sin_theta_hcal=tg_theta_hcal/TMath::Sqrt(1+tg_theta_hcal*tg_theta_hcal);
1140 <    sin_theta_ho=tg_theta_ho/TMath::Sqrt(1+tg_theta_ho*tg_theta_ho);
1141 <    cos_theta_ecal=TMath::Sqrt(1-sin_theta_ecal*sin_theta_ecal);
1142 <    cos_theta_hcal=TMath::Sqrt(1-sin_theta_hcal*sin_theta_hcal);
1143 <    cos_theta_ho=TMath::Sqrt(1-sin_theta_ho*sin_theta_ho);
1144 <    if (E_ecal<me){
1145 <      p_ecal=0;
1146 <    }
1147 <    else {
1148 <      p_ecal=TMath::Sqrt(E_ecal*E_ecal-me*me);
1149 <    }
1150 <    if (E_hcal<me){
1151 <      p_hcal=0;
1152 <    }
1153 <    else {
1154 <      p_hcal=TMath::Sqrt(E_hcal*E_hcal-me*me);
1155 <    }      
1156 <    if (E_ho<me){
1157 <      p_ho=0;
1158 <    }
1159 <    else {
1160 <      p_ho=TMath::Sqrt(E_ho*E_ho-me*me);
1161 <    }
1162 <
1163 <    pz_ecal=p_ecal*cos_theta_ecal;
1164 <    pz_hcal=p_hcal*cos_theta_hcal;
1165 <    pz_ho=p_ho*cos_theta_ho;
1166 <    pt_ecal=TMath::Abs(p_ecal*sin_theta_ecal);
1167 <    
1168 <    pt_hcal=TMath::Abs(p_hcal*sin_theta_hcal);
1169 <    
1170 <    pt_ho=TMath::Abs(p_ho*sin_theta_ho);      
1171 <    
1172 <    px_ecal=pt_ecal*TMath::Cos(phi_cal);
1173 <    px_hcal=pt_hcal*TMath::Cos(phi_cal);
1174 <    px_ho=pt_ho*TMath::Cos(phi_cal);
1175 <    py_ecal=pt_ecal*TMath::Sin(phi_cal);
1176 <    py_hcal=pt_hcal*TMath::Sin(phi_cal);
1177 <    py_ho=pt_ho*TMath::Sin(phi_cal);      
1178 <
1179 <    
1180 <    Ex_cal=Ex_cal+Ex_ecal+Ex_hcal+Ex_ho;
1181 <    Ey_cal=Ey_cal+Ey_ecal+Ey_hcal+Ey_ho;
1182 <    
1183 <    px_cal=px_cal+px_ecal+px_hcal+px_ho;
1184 <    py_cal=py_cal+py_ecal+py_hcal+py_ho;
1185 <    
699 >  JetMuTree->Branch("nb_muon",&nb_muon,"nb_muon/I");
700  
701 <  }
702 <  Et_cal=TMath::Sqrt(Ex_cal*Ex_cal+Ey_cal*Ey_cal);
703 <  Muon_p_cal_4v=reco::Particle::LorentzVector(px_cal,py_cal,0, Et_cal);  
701 >  JetMuTree->Branch("weight",    &eventWeight,  "weight/F");
702 >  JetMuTree->Branch("processID", &processID, "processID/I");
703 >  JetMuTree->Branch("alpgenID", &alpgenID, "alpgenID/I");
704 >  JetMuTree->Branch("genEventScale",    &eventScale,  "genEventScale/F");
705 >  JetMuTree->Branch("RunNumber", &RunNumber, "RunNumber/I");
706 >  JetMuTree->Branch("EventID", &EventID, "EventID/I");
707  
708 <  Ex_kon=Ex_MET-Ex_muons+Ex_cal;
1192 <  Ey_kon=Ey_MET-Ey_muons+Ey_cal;
708 > }
709  
1194  reco::Particle::LorentzVector MET= reco::Particle::LorentzVector(px_MET-px_muons+px_cal,py_MET-py_muons+py_cal,0,TMath::Sqrt(Ex_kon*Ex_kon+Ey_kon*Ey_kon));  // substract p from muons and p of calo muon deposit from MET
710  
1196  return MET;
1197  
1198 }
711  
712   ////////////////////////
713   // matching
# Line 1307 | Line 819 | void MuonAnalyzer::matching(const edm::E
819    
820   }
821  
822 < //---------------------------------------------------
822 >
823   /////////////////////////////////////////////////////////////////////
824   //   made for muon fake rate
825   // method that gives the vector<MatchingInfo> matching_Infos containing (dR,i,j); i=genParticle index, j=ParticleCollection index:
# Line 1722 | Line 1234 | MuonAnalyzer::LeptonOrigin MuonAnalyzer:
1234        if ((((abs(genParticle->pdgId()))/100)%10 ==4)||(((abs(genParticle->pdgId()))/1000)%10 ==4  )) {  // mother is c
1235          return cdecay;
1236        }    
1237 +      if (abs(genParticle->pdgId()==6)) {  // mother is t
1238 +        return tdecay;
1239 +      }    
1240        return other;
1241      }
1242    }
# Line 1729 | Line 1244 | MuonAnalyzer::LeptonOrigin MuonAnalyzer:
1244    return other;
1245   }
1246  
1247 + const reco::Candidate * MuonAnalyzer::getMother_particle(const reco::Candidate* genParticle){
1248 +
1249 +  int pdg_id=genParticle->pdgId();
1250 +  //  cout << "particle id : " << pdg_id << endl;
1251 +
1252 +  while (genParticle = genParticle->mother() ) {  //izvrsava se sve dok ne dodje do nule tj. dok ne trazi majku od protona
1253 +    //    cout << "Going up: ";
1254 +    //    cout << "Mother id : " << genParticle->pdgId() << endl;
1255 +    if (abs(genParticle->pdgId())!=abs(pdg_id)) {
1256 +      //      cout<< " good mother " <<endl;
1257 +      return genParticle->mother();
1258 +    }
1259 +  }
1260 +
1261 +  //  return ;
1262 + }
1263 +
1264 +
1265 +
1266   ///////////////////
1267   int MuonAnalyzer::getMother_Id(const reco::Candidate* genParticle){
1268  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines