CMS 3D CMS Logo

Public Member Functions | Private Attributes

ExampleMuonAnalyzer Class Reference

#include <MuonAnalyzer.h>

Inheritance diagram for ExampleMuonAnalyzer:
edm::EDAnalyzer

List of all members.

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup)
virtual void beginJob ()
virtual void endJob ()
 ExampleMuonAnalyzer (const edm::ParameterSet &pset)
 Constructor.
virtual ~ExampleMuonAnalyzer ()
 Destructor.

Private Attributes

TH1F * h4MuInvMass
TH1I * hChamberMatched
TH1F * hEHcal
TH1F * hMuCaloCompatibility
TH1I * hMuIdAlgo
TH1F * hMuIso03CaloComb
TH1F * hMuIso03SumPt
TH1I * hMuonType
TH1F * hMuSegCompatibility
TH1I * hNMuons
TH1F * hPtRec
TH2F * hPtReso
TH1F * hPtSTATKDiff
std::string theMuonLabel

Detailed Description

Analyzer of the muon objects

Date:
2009/12/29 23:04:51
Revision:
1.7
Author:
R. Bellan - CERN <riccardo.bellan@cern.ch>

Analyzer of the muon objects

Date:
2009/11/06 10:06:22
Revision:
1.4
Author:
R. Bellan - CERN <riccardo.bellan@cern.ch>

Definition at line 25 of file MuonAnalyzer.h.


Constructor & Destructor Documentation

ExampleMuonAnalyzer::ExampleMuonAnalyzer ( const edm::ParameterSet pset)

Constructor.

Definition at line 31 of file MuonAnalyzer.cc.

References edm::ParameterSet::getUntrackedParameter().

                                                                {

  theMuonLabel = pset.getUntrackedParameter<string>("MuonCollection");
}
ExampleMuonAnalyzer::~ExampleMuonAnalyzer ( ) [virtual]

Destructor.

Definition at line 37 of file MuonAnalyzer.cc.

                                         {
}

Member Function Documentation

void ExampleMuonAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
) [virtual]

simple selection... Do not want to write here my super-secret Higgs analysis ;-)

Implements edm::EDAnalyzer.

Definition at line 71 of file MuonAnalyzer.cc.

References muon::All, muon::AllArbitrated, muon::AllStandAloneMuons, muon::AllTrackerMuons, diffTreeTool::diff, muon::GlobalMuonPromptTight, muon::isGoodMuon(), metsig::muon, patZpeak::muons, muon::segmentCompatibility(), ValidateTausOnRealMuonsData_cff::selectedMuons, muon::TM2DCompatibilityLoose, muon::TM2DCompatibilityTight, muon::TMLastStationLoose, muon::TMLastStationOptimizedLowPtLoose, muon::TMLastStationOptimizedLowPtTight, muon::TMLastStationTight, muon::TMOneStationLoose, muon::TMOneStationTight, and muon::TrackerMuonArbitrated.

                                                                                  {
  
  // Get the Muon collection
  Handle<pat::MuonCollection> muons;
  event.getByLabel(theMuonLabel, muons);

  // How many muons in the event?
  hNMuons->Fill(muons->size());

  pat::MuonCollection selectedMuons;


  // Let's look inside the muon collection.
  for (pat::MuonCollection::const_iterator muon = muons->begin();  muon != muons->end(); ++muon){

    // pT spectra of muons
    hPtRec->Fill(muon->pt());

    // what is the resolution in pt? Easy! We have the association with generated information
    //    cout<<muon->pt()<<" "<<muon->genParticle()->pt()<<endl;
    if( muon->genLepton()!=0){
      double reso = (muon->pt() - muon->genLepton()->pt())/muon->genLepton()->pt();
      hPtReso->Fill(muon->genLepton()->pt(),reso);
    }

    // What is the energy deposit in HCal?
    if(muon->isEnergyValid())
      hEHcal->Fill(muon->calEnergy().had);

    // Which type of muons in the collection?
    if(muon->isStandAloneMuon())
      if(muon->isGlobalMuon())
        if(muon->isTrackerMuon()) hMuonType->Fill(1); // STA + GLB + TM
        else hMuonType->Fill(2); // STA + GLB
      else 
        if(muon->isTrackerMuon()) hMuonType->Fill(3);  // STA + TM
        else hMuonType->Fill(5); // STA
    else
      if(muon->isTrackerMuon()) hMuonType->Fill(4); // TM

    // ...mmm I want to study the relative resolution of the STA track with respect to the Tracker track.
    // or I want to look at a track stab
    if(muon->isGlobalMuon()){
      double diff =  muon->innerTrack()->pt() - muon->standAloneMuon()->pt();
      hPtSTATKDiff->Fill(diff);
    }
    
    // Muon ID quantities
    
    // Muon in CMS are usually MIP. What is the compatibility of a muon HP using only claorimeters?
    if(muon->isCaloCompatibilityValid())
      hMuCaloCompatibility->Fill(muon->caloCompatibility());

    // The muon system can also be used just as only for ID. What is the compatibility of a muon HP using only calorimeters?
    hMuSegCompatibility->Fill(muon::segmentCompatibility(*muon));


    // How many chambers have been associated to a muon track?
    hChamberMatched->Fill(muon->numberOfChambers());
    // If you look at MuonSegmentMatcher class you will see a lot of interesting quantities to look at!
    // you can get the list of matched info using matches()


    // Muon ID selection. As described in AN-2008/098  
    if(muon::isGoodMuon(*muon, muon::All))                                // dummy options - always true
      hMuIdAlgo->Fill(0);       
    if(muon::isGoodMuon(*muon, muon::AllStandAloneMuons))                 // checks isStandAloneMuon flag
      hMuIdAlgo->Fill(1);       
    if(muon::isGoodMuon(*muon, muon::AllTrackerMuons))                    // checks isTrackerMuon flag
      hMuIdAlgo->Fill(2);          
    if(muon::isGoodMuon(*muon, muon::TrackerMuonArbitrated))              // resolve ambiguity of sharing segments
      hMuIdAlgo->Fill(3);
    if(muon::isGoodMuon(*muon, muon::AllArbitrated))                      // all muons with the tracker muon arbitrated
      hMuIdAlgo->Fill(4);            
    if(muon::isGoodMuon(*muon, muon::GlobalMuonPromptTight))              // global muons with tighter fit requirements
      hMuIdAlgo->Fill(5);    
    if(muon::isGoodMuon(*muon, muon::TMLastStationLoose))                 // penetration depth loose selector
      hMuIdAlgo->Fill(6);       
    if(muon::isGoodMuon(*muon, muon::TMLastStationTight))                 // penetration depth tight selector
      hMuIdAlgo->Fill(7);       
    if(muon::isGoodMuon(*muon, muon::TM2DCompatibilityLoose))             // likelihood based loose selector
      hMuIdAlgo->Fill(8);   
    if(muon::isGoodMuon(*muon, muon::TM2DCompatibilityTight))             // likelihood based tight selector
      hMuIdAlgo->Fill(9);   
    if(muon::isGoodMuon(*muon, muon::TMOneStationLoose))                  // require one well matched segment
      hMuIdAlgo->Fill(10);        
    if(muon::isGoodMuon(*muon, muon::TMOneStationTight))                  // require one well matched segment
      hMuIdAlgo->Fill(11);        
    if(muon::isGoodMuon(*muon, muon::TMLastStationOptimizedLowPtLoose))   // combination of TMLastStation and TMOneStation
      hMuIdAlgo->Fill(12); 
    if(muon::isGoodMuon(*muon, muon::TMLastStationOptimizedLowPtTight))   // combination of TMLastStation and TMOneStation
      hMuIdAlgo->Fill(13);  



    // Isolation variables. There are many type of isolation. You can even build your own combining the output of
    // muon->isolationR03(). E.g.: 1.2*muon->isolationR03().emEt + 0.8*muon->isolationR03().hadEt
    // *** WARNING *** it is just an EXAMPLE!
    if(muon->isIsolationValid()){
      hMuIso03CaloComb->Fill(1.2*muon->isolationR03().emEt + 0.8*muon->isolationR03().hadEt);
      hMuIso03SumPt->Fill(muon->isolationR03().sumPt);
    }

    // OK, let see if we understood everything.
    // Suppose we are searching for H->ZZ->4mu. 
    // In mean the 4 muons have/are:
    // high pt (but 1 out of 4 can be at quite low pt)
    // isolated
    // so, we can make some requirements  
    if(muon->isolationR03().sumPt< 0.2){
      if(muon->isGlobalMuon() ||
         muon::isGoodMuon(*muon, muon::TM2DCompatibilityLoose) || 
         muon::isGoodMuon(*muon, muon::TMLastStationLoose))
        selectedMuons.push_back(*muon);
    }
  }

  if(selectedMuons.size() == 4){
    reco::Candidate::LorentzVector p4CM;
    for (pat::MuonCollection::const_iterator muon = selectedMuons.begin();  muon != selectedMuons.end(); ++muon){
      p4CM = p4CM + muon->p4();
    }
    h4MuInvMass->Fill(p4CM.mass());
  }
}
void ExampleMuonAnalyzer::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 40 of file MuonAnalyzer.cc.

References fileService.

                                  {

  // Book histograms
  edm::Service<TFileService> fileService;
  hPtRec  = fileService->make<TH1F>("pT","p_{T}^{rec}",250,0,120);
  hPtReso = fileService->make<TH2F>("pT_Reso","(p_{T}^{rec}-p_{T}^{sim})/p_{T}^{sim}",250,0,120,100,-0.2,0.2);
  hNMuons = fileService->make<TH1I>("NMuons","Number of muons per event",20,0,20);
  
  hEHcal = fileService->make<TH1F>("EHCal","Energy deposit in HCAL",100,0,10);

  // ID
  hMuonType = fileService->make<TH1I>("MuonType", "Type of Muons", 5, 1, 6);
  hPtSTATKDiff = fileService->make<TH1F>("DiffPt_STA_TK","p^{TK}_{T}-p^{STA}_T",200,-50,50);
  hMuCaloCompatibility = fileService->make<TH1F>("CaloCompatibility","Muon HP using Calorimeters only",100,0,1);
  hMuSegCompatibility = fileService->make<TH1F>("SegmentCompatibility","Muon HP using segments only",100,0,1);
  hChamberMatched = fileService->make<TH1I>("NumMatchedChamber", "Number of matched chambers", 7, 0, 7);
  hMuIdAlgo = fileService->make<TH1I>("MuonIDSelectors", "Results of muon id selectors", 13, 0, 13);

  // Isolation
  hMuIso03SumPt = fileService->make<TH1F>("MuIso03SumPt","Isolation #Delta(R)=0.3: SumPt",200,0,10);
  hMuIso03CaloComb = fileService->make<TH1F>("MuIso03CaloComb","Isolation #Delta(R)=0.3: 1.2*ECAL+0.8HCAL",200,0,10);

  // 4Mu invariant mass
  h4MuInvMass = fileService->make<TH1F>("InvMass4MuSystem","Invariant mass of the 4 muons system",200,0,500);

}
void ExampleMuonAnalyzer::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 67 of file MuonAnalyzer.cc.

                                {
}

Member Data Documentation

Definition at line 63 of file MuonAnalyzer.h.

Definition at line 56 of file MuonAnalyzer.h.

TH1F* ExampleMuonAnalyzer::hEHcal [private]

Definition at line 48 of file MuonAnalyzer.h.

Definition at line 54 of file MuonAnalyzer.h.

Definition at line 57 of file MuonAnalyzer.h.

Definition at line 61 of file MuonAnalyzer.h.

Definition at line 60 of file MuonAnalyzer.h.

Definition at line 50 of file MuonAnalyzer.h.

Definition at line 55 of file MuonAnalyzer.h.

Definition at line 45 of file MuonAnalyzer.h.

TH1F* ExampleMuonAnalyzer::hPtRec [private]

Definition at line 46 of file MuonAnalyzer.h.

Definition at line 47 of file MuonAnalyzer.h.

Definition at line 51 of file MuonAnalyzer.h.

std::string ExampleMuonAnalyzer::theMuonLabel [private]

Definition at line 42 of file MuonAnalyzer.h.