#define trk_hists_cxx // The class definition in trk_hists.h has been generated automatically // by the ROOT utility TTree::MakeSelector(). This class is derived // from the ROOT class TSelector. For more information on the TSelector // framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual. // The following methods are defined in this file: // Begin(): called every time a loop on the tree starts, // a convenient place to create your histograms. // SlaveBegin(): called after Begin(), when on PROOF called only on the // slave servers. // Process(): called for each event, in this function you decide what // to read and fill your histograms. // SlaveTerminate: called at the end of the loop on the tree, when on PROOF // called only on the slave servers. // Terminate(): called at the end of the loop on the tree, // a convenient place to draw/fit your histograms. // // To use this file, try the following session on your Tree T: // // root> T->Process("trk_hists.C") // root> T->Process("trk_hists.C","some options") // root> T->Process("trk_hists.C+") // #include #include #include #include using namespace std; #include "trk_hists.h" #include #include void trk_hists::Begin(TTree * /*tree*/) { // The Begin() function is called at the start of the query. // When running with PROOF Begin() is only called on the client. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); } void trk_hists::SlaveBegin(TTree * /*tree*/) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). hEhit = new TH1D("hEhit","A hist", 200, 0.0, 2.0); r_vs_Ehit = new TH2D("r_vs_Ehit", "Distance from FCAL Block Center vs. E in single block", 200, 0.0, 1.0, 40, 0.0, 5.0); p_vs_Ehit = new TH2D("p_vs_Ehit", "Momentum of track vs. E in single FCAL block", 200, 0.0, 1.0, 100, 0.0, 8.0); p_vs_Ehit_center_cut = new TH2D("p_vs_Ehit_center_cut", "Momentum of track vs. E in single FCAL block cut on track projection to back being in center", 200, 0.0, 1.0, 100, 0.0, 8.0); E9_vs_p = new TH2D("E9_vs_p", "E in 9 FCAL blocks vs. Momentum of track", 80, 0.0, 4.0, 80, 0.0, 4.0); xy_back_lo = new TH2D("xy_back_lo", "XY Track projection to back of FCAL block for low energy blob", 120, -3.0, 3.0, 120, -3.0, 3.0); xy_back_hi = new TH2D("xy_back_hi", "XY Track projection to back of FCAL block for high energy blob", 120, -3.0, 3.0, 120, -3.0, 3.0); fOutput->Add(hEhit); fOutput->Add(r_vs_Ehit); fOutput->Add(p_vs_Ehit); fOutput->Add(E9_vs_p); fOutput->Add(xy_back_lo); fOutput->Add(xy_back_hi); fOutput->Add(p_vs_Ehit_center_cut); TString option = GetOption(); } Bool_t trk_hists::Process(Long64_t entry) { // The Process() function is called for each entry in the tree (or possibly // keyed object in the case of PROOF) to be processed. The entry argument // specifies which entry in the currently loaded tree is to be processed. // When processing keyed objects with PROOF, the object is already loaded // and is available via the fObject pointer. // // This function should contain the \"body\" of the analysis. It can contain // simple or elaborate selection criteria, run algorithms on the data // of the event and typically fill histograms. // // The processing can be stopped by calling Abort(). // // Use fStatus to set the return value of TTree::Process(). // // The return value is currently not used. fReader.SetEntry(entry); hEhit->Fill(t->Ehit); if(t->p>1)E9_vs_p->Fill( t->p, t->E9); if( t->ptype==9 && t->N25==1 ){ // distance to center of block double dx = t->pos_x_back - t->pos_x_block; double dy = t->pos_y_back - t->pos_y_block; r_vs_Ehit->Fill( t->Ehit, t->r_back); p_vs_Ehit->Fill( t->Ehit, t->p); if( (dx*dx + dy*dy) < 1.0) p_vs_Ehit_center_cut->Fill(t->Ehit, t->p); if(t->Ehit>=0.36 && t->Ehit<=0.50) xy_back_lo->Fill(dx , dy); if(t->Ehit>=0.58 && t->Ehit<=0.72) xy_back_hi->Fill(dx , dy); } return kTRUE; } void trk_hists::SlaveTerminate() { // The SlaveTerminate() function is called after all entries or objects // have been processed. When running with PROOF SlaveTerminate() is called // on each slave server. } void trk_hists::Terminate() { // The Terminate() function is the last function to be called during // a query. It always runs on the client, it can be used to present // the results graphically or save the results to file. TDirectory *savedir = gDirectory; TFile f("trk_hists.root", "RECREATE"); fOutput->Write(); f.Close(); savedir->cd(); TH2D *h1 = (TH2D*)fOutput->FindObject("p_vs_Ehit"); TH2D *h2 = (TH2D*)fOutput->FindObject("p_vs_Ehit_center_cut"); if( h1!=NULL && h2!=NULL ){ TCanvas *c1 = new TCanvas("c1","",1600,800); c1->Divide(2, 1); c1->cd(1); h1->Draw("colz"); c1->cd(2); h2->Draw("colz"); }else{ cout << "Couldn't find histos." << endl; } }