Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:03

0001 {
0002    gStyle->SetPalette(1,0);
0003    TFile f("/afs/cern.ch/user/d/dmytro/scratch0/muons.root");
0004    TTree* tree = (TTree*)f.Get("Events");
0005    TString name = "edges";
0006 
0007    TCanvas* c1 = new TCanvas(name,name,600,900);
0008    c1->Divide(2,4);
0009    TH1F* hRecoXCSC = new TH1F(name+"_CSC_recoX",name+"_CSC_recoX",110,-100,10);
0010    TH1F* hTrueXCSC = new TH1F(name+"_CSC_trueX",name+"_CSC_trueX",110,-100,10);
0011    TH1F* hRecoYCSC = new TH1F(name+"_CSC_recoY",name+"_CSC_recoY",110,-100,10);
0012    TH1F* hTrueYCSC = new TH1F(name+"_CSC_trueY",name+"_CSC_trueY",110,-100,10);
0013    TH1F* hRecoXDT = new TH1F(name+"_DT_recoX",name+"_DT_recoX",110,-210,10);
0014    TH1F* hTrueXDT = new TH1F(name+"_DT_trueX",name+"_DT_trueX",110,-210,10);
0015    TH1F* hRecoYDT = new TH1F(name+"_DT_recoY",name+"_DT_recoY",140,-270,10);
0016    TH1F* hTrueYDT = new TH1F(name+"_DT_trueY",name+"_DT_trueY",140,-270,10);
0017 
0018    // create and connect muon collection branch 
0019 
0020    tree->SetBranchStatus("*",0);
0021    tree->SetBranchStatus("recoMuons_test_muons_TEST.obj*",1);
0022    std::vector<reco::Muon> muons;
0023    
0024    TString branchName = tree->GetAlias("muons");
0025    tree->SetBranchAddress(branchName,&muons);
0026 
0027    for ( unsigned int index = 0; index < tree->GetEntries(); ++index ) {
0028       tree->GetEntry(index);
0029       tree->SetBranchAddress(branchName,&muons);
0030       if (index%1000==0) std::cout << "Event " << index << " has " << muons.size() << " muons" << std::endl;
0031       for(unsigned int i=0; i<muons.size(); i++)
0032     {
0033        const std::vector<reco::MuonChamberMatch>& matches = muons[i].matches();
0034        if ( matches.empty() || matches.front().segmentMatches.empty() ) continue;
0035        
0036        bool fillReco = false;
0037        bool fillTrue = false;
0038        // std::cout << "#segments: " << matches.front().segmentMatches.front().x << std::endl;
0039        // std::cout << "#segments: " << muons.front().matches().front().segmentMatches.size() << std::endl;
0040        for ( unsigned int j = 0; j <  matches.front().segmentMatches.size(); j++)
0041          {
0042         // std::cout << "\txErr: " << matches.front().segmentMatches[j].xErr << std::endl;
0043         if (matches.front().segmentMatches[j].xErr < -100)
0044           fillTrue = true;
0045         else
0046           fillReco = true;
0047          }
0048        
0049        if (fillReco) {
0050           if ( matches.front().id.subdetId() == 2 ) { //CSC
0051          hRecoXCSC->Fill(matches.front().edgeX);
0052          hRecoYCSC->Fill(matches.front().edgeY);
0053          //  std::cout << matches.front().edgeX << std::endl;
0054           }else{
0055          hRecoXDT->Fill(matches.front().edgeX);
0056          hRecoYDT->Fill(matches.front().edgeY);
0057           }
0058        }
0059        
0060        if (fillTrue) {
0061           if ( matches.front().id.subdetId() == 2 ) { //CSC
0062          hTrueXCSC->Fill(matches.front().edgeX);
0063          hTrueYCSC->Fill(matches.front().edgeY);
0064          //  std::cout << matches.front().edgeX << std::endl;
0065           }else{
0066          hTrueXDT->Fill(matches.front().edgeX);
0067          hTrueYDT->Fill(matches.front().edgeY);
0068           }
0069        }
0070     }
0071    }
0072    
0073    c1->cd(1);
0074    hRecoXDT->Draw();
0075    c1->cd(2);
0076    hRecoYDT->Draw();
0077    c1->cd(3);
0078    hTrueXDT->Draw();
0079    c1->cd(4);
0080    hTrueYDT->Draw();
0081    c1->cd(5);
0082    hRecoXCSC->Draw();
0083    c1->cd(6);
0084    hRecoYCSC->Draw();
0085    c1->cd(7);
0086    hTrueXCSC->Draw();
0087    c1->cd(8);
0088    hTrueYCSC->Draw();
0089    
0090    //return c1;
0091 }