Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:00

0001 {
0002   // book histograms
0003   TFile histofile("track_hists.root","RECREATE");
0004   TH1F* h_chisqtr = new TH1F("chisqtr","Track chisq",100,0.,10.);
0005   TH1F* h_pttr = new TH1F("pttr","Track pT (GeV)",100,8.0,12.0);
0006   TH1F* h_nhittr = new TH1F("nhittr","Number of Hits",31,-0.5,30.5);
0007 
0008   TTree *tree = (TTree*)file.Get("Events");
0009 
0010   std::vector<reco::Track> trackCollection;
0011 
0012   TBranch *branch = tree->GetBranch("recoTracks_generalTracks__RECO.obj");
0013   branch->SetAddress(&trackCollection);
0014 
0015   for ( unsigned int index = 0; index < tree->GetEntries(); ++index ) {
0016     std::cout << "Event: " << index << std::endl;
0017     branch->GetEntry(index);
0018     for ( unsigned int bindex = 0; bindex < trackCollection.size(); ++bindex ) {
0019       reco::Track* track = (reco::Track*)trackCollection[bindex];
0020       h_chisqtr->Fill(track->normalizedChi2());
0021       double pT = sqrt(track->px()*track->px()+track->py()*track->py());
0022       h_pttr->Fill(pT);
0023 
0024       h_nhittr->Fill(track->found());
0025     }
0026   }
0027   
0028   // save histograms
0029   histofile.Write();
0030   histofile.Close();
0031 }