Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:20:36

0001 {
0002    gROOT->SetStyle("Plain");
0003    gStyle->SetPalette(1);
0004    gStyle->SetOptStat(1111111);
0005    gSystem->Load("libRecoMuonMuonIdentification");
0006    
0007    f = TFile::Open("dcap://cmsdca3.fnal.gov:24143/pnfs/fnal.gov/usr/cms/WAX/11/store/mc/2007/11/7/RelVal-RelValSingleMuMinusPt10-1194439351/0000/1ACAFBB9-4A8D-DC11-A8EE-001617C3B73A.root");
0008    TTree* tree = (TTree*)f->Get("Events");
0009    TCanvas* c1 = new TCanvas("muons","muons",800,800);
0010    c1->Divide(3,3);
0011    TH1F* h1 = new TH1F("h1","global muon",100,0,100);
0012    TH1F* h2 = new TH1F("h2","tracker muon",100,0,100);
0013    TH1F* h3 = new TH1F("h3","tracker muon + Loose ID",100,0,100);
0014    TH1F* h4 = new TH1F("h4","tracker muon + Tight ID",100,0,100);
0015    TH2F* h5 = new TH2F("h5","segment vs calo compatibility",120,-0.1,1.1,120,-0.1,1.1);
0016    TH1F* h6 = new TH1F("h6","tracker muon + Loose compatibility ID",100,0.,100.);
0017    TH1F* h7 = new TH1F("h7","tracker muon + Tight compatibility ID",100,0.,100.);
0018    
0019    // create and connect muon collection branch 
0020    tree->SetBranchStatus("*",0);
0021    tree->SetBranchStatus("recoMuons*",1);
0022    std::vector<reco::Muon> muons;
0023    std::vector<reco::Muon> trackerMuons;
0024    
0025    int TMLastStationLoose = 0;
0026    int TMLastStationTight = 1;
0027    int TM2DCompatibilityLoose      = 2;
0028    int TM2DCompatibilityTight      = 3;
0029 
0030 
0031    TString branchName = tree->GetAlias("muons");
0032    tree->SetBranchAddress(branchName,&muons);
0033 
0034    for ( unsigned int index = 0; index < tree->GetEntries(); ++index ) {
0035       tree->GetEntry(index);
0036       tree->SetBranchAddress(branchName,&muons);
0037       if (index%1000==0) std::cout << "Event " << index << std::endl;
0038       for(unsigned int i=0; i<muons.size(); i++) 
0039     {
0040        if ( muons[i].isGlobalMuon() ) h1->Fill(muons[i].pt());
0041        if ( muons[i].isTrackerMuon() ) {
0042           h2->Fill(muons[i].pt());
0043           if (muon::isGoodMuon(muons[i],TMLastStationLoose)) h3->Fill(muons[i].pt());
0044           if (muon::isGoodMuon(muons[i],TMLastStationTight)) h4->Fill(muons[i].pt());
0045           h5->Fill(muon::getSegmentCompatibility(muons[i]),muon::getCaloCompatibility(muons[i]));
0046           if (muon::isGoodMuon(muons[i],TM2DCompatibilityLoose)) h6->Fill(muons[i].pt());
0047           if (muon::isGoodMuon(muons[i],TM2DCompatibilityTight)) h7->Fill(muons[i].pt());
0048        }
0049     }
0050    }
0051    
0052    c1->cd(1);
0053    h1->Draw();
0054    c1->cd(2);
0055    h2->Draw();
0056    c1->cd(3);
0057    h3->Draw();
0058    c1->cd(4);
0059    h4->Draw();
0060    c1->cd(5);
0061    h5->Draw();
0062    c1->cd(6);
0063    h6->Draw();
0064    c1->cd(7);
0065    h7->Draw();
0066 }