void drawBranches(std::string inFile) { TFile *_file0 = TFile::Open(inFile.c_str(), "read"); TTree* nt = (TTree*)_file0->Get("reco_tree"); InitRecoTree(nt); std::cout << " nt->GetEntries() = " << nt->GetEntries() << std::endl; // define histos TProfile** p_Tot_amp = new TProfile[5]; TProfile** p_amp_Tot = new TProfile[5]; TProfile** p_charge_Amp = new TProfile[5]; // TProfile** p_Tcf_amp = new TProfile[5]; // TProfile** p_Tcf_Tot = new TProfile[5]; TH2F** h2_Tot_amp = new TH2F[5]; TH2F** h2_amp_Tot = new TH2F[5]; TH2F** h2_charge_amp = new TH2F[5]; TH1F** h_amp = new TH1F[5]; // soglie float Tcharge[5] = {126., 93., 90., 145., 89.}; for(int iCh=0; iCh<5; ++iCh){ p_Tot_amp[iCh] = new TProfile(Form("p_Tot_amp_%d",iCh), "", 2000, 0., 4000.); p_amp_Tot[iCh] = new TProfile(Form("p_amp_Tot_%d",iCh), "", 1000, 0., 1000.); p_charge_Amp[iCh] = new TProfile(Form("p_charge_Amp_%d", iCh), "", 2000, 0., 4000.); // p_Tcf_amp[iCh] = new TProfile(Form("p_Tcf_amp_%d",iCh), "", 300, 0., 300.); // p_Tcf_Tot[iCh] = new TProfile(Form("p_Tcf_Tof_%d",iCh), "", 300, 0., 300.); h2_Tot_amp[iCh] = new TH2F(Form("h2_Tot_amp_%d", iCh), "", 2000, 0., 4000., 1000, 0., 1000.); h2_amp_Tot[iCh] = new TH2F(Form("h2_amp_Tot_%d", iCh), "", 1000, 0., 1000., 2000, 0., 4000.); h2_charge_amp[iCh] = new TH2F(Form("h2_charge_amp_%d",iCh), "", 2000, 0., 4000., 10000, 0., 10000.); h_amp[iCh] = new TH1F(Form("h_amp_%d",iCh), "", 2000, 0., 4000.); } std::cout << " start loop over Entries " << std::endl; for(int iEntry=0; iEntry<nt->GetEntries(); ++iEntry){ nt->GetEntry(iEntry); for(int iCh=0; iCh<5; ++iCh){ // if(tdcX > -8 && tdcX < 0 && tdcY >-2 && tdcY < 6 && charge[iCh] > Tcharge[iCh]){ // std::cout << " amp_max[iCh] = " << amp_max[iCh] << std::endl; // std::cout << " time_OT[iCh] = " << time_OT[iCh] << std::endl; // std::cout << " charge[iCh] = " << charge[iCh] << std::endl; p_Tot_amp[iCh]->Fill(amp_max[iCh], time_OT[iCh]); p_amp_Tot[iCh]->Fill(time_OT[iCh], amp_max[iCh]); p_charge_Amp[iCh]->Fill(amp_max[iCh], charge[iCh]); h2_Tot_amp[iCh]->Fill(amp_max[iCh], time_OT[iCh]); h2_amp_Tot[iCh]->Fill(time_OT[iCh], amp_max[iCh]); h2_charge_amp[iCh]->Fill(amp_max[iCh], charge[iCh]); h_amp[iCh]->Fill(amp_max[iCh]); /* p_Tot_amp[iCh]->Fill(amp_max_corr[iCh], time_OT[iCh]); p_amp_Tot[iCh]->Fill(time_OT[iCh], amp_max_corr[iCh]); p_charge_Amp[iCh]->Fill(amp_max_corr[iCh], charge_corr[iCh]); h2_Tot_amp[iCh]->Fill(amp_max_corr[iCh], time_OT[iCh]); h_amp[iCh]->Fill(amp_max_corr[iCh]); h2_charge_amp[iCh]->Fill(amp_max_corr[iCh], charge_corr[iCh]); p_Tcf_amp[iCh]->Fill(amp_max[iCh], time_CF[iCh]); p_Tcf_Tot[iCh]->Fill(time_OT[iCh], time_CF[iCh]); */ // } } } std::cout << " stop loop over Entries " << std::endl; // DRAW TCanvas** c_pro_TvA = new TCanvas*[5]; TCanvas** c_pro_AvT = new TCanvas*[5]; TCanvas** c_pro_CvA = new TCanvas*[5]; TCanvas** c_h2_TvA = new TCanvas*[5]; TCanvas** c_h2_AvT = new TCanvas*[5]; TCanvas** c_h2_CvA = new TCanvas*[5]; TCanvas** c_h1_A = new TCanvas*[5]; for(int iCh=0; iCh<5; ++iCh){ // c_pro_CvA[iCh] = new TCanvas(); // c_pro_CvA[iCh]->cd(); // p_charge_Amp[iCh]->GetXaxis()->SetTitle(Form("amp ch%d", iCh)); // p_charge_Amp[iCh]->GetYaxis()->SetTitle("charge"); // p_charge_Amp[iCh]->Draw(""); // c_h2_CvA[iCh] = new TCanvas(); // c_h2_CvA[iCh]->cd(); // h2_charge_amp[iCh]->GetXaxis()->SetTitle(Form("amp ch%d", iCh)); // h2_charge_amp[iCh]->GetYaxis()->SetTitle(Form("charge ", iCh)); // h2_charge_amp[iCh]->Draw("colz"); c_h2_TvA[iCh] = new TCanvas(); c_h2_TvA[iCh]->cd(); h2_Tot_amp[iCh]->GetXaxis()->SetTitle(Form("amp ch%d", iCh)); h2_Tot_amp[iCh]->GetYaxis()->SetTitle("time_OT"); h2_Tot_amp[iCh]->Draw("colz"); c_h2_AvT[iCh] = new TCanvas(); c_h2_AvT[iCh]->cd(); h2_amp_Tot[iCh]->GetXaxis()->SetTitle(Form("time_OT ch%d", iCh)); h2_amp_Tot[iCh]->GetYaxis()->SetTitle("amp"); h2_amp_Tot[iCh]->Draw("hist"); // c_pTcf1[iCh] = new TCanvas(); // c_pTcf1[iCh]->cd(); // p_Tcf_Tot[iCh]->GetXaxis()->SetTitle(Form("time_OT ch%d", iCh)); // p_Tcf_Tot[iCh]->GetYaxis()->SetTitle("Tcf"); // p_Tcf_Tot[iCh]->Draw("hist"); // c_pTcf2[iCh] = new TCanvas(); // c_pTcf2[iCh]->cd(); // p_Tcf_amp[iCh]->GetXaxis()->SetTitle(Form("time_OT ch%d", iCh)); // p_Tcf_amp[iCh]->GetYaxis()->SetTitle("amp"); // p_Tcf_amp[iCh]->Draw("hist"); // c_h1_A[iCh] = new TCanvas(); // c_h1_A[iCh]->cd(); // h_amp[iCh]->GetXaxis()->SetTitle(Form("amp ch%d", iCh)); // h_amp[iCh]->Draw("hist"); /* c_h2C[iCh] = new TCanvas(); c_h2C[iCh]->cd(); c_h2C[iCh] = new TCanvas(); c_h2C[iCh]->cd(); h2_charge_amp[iCh]->GetXaxis()->SetTitle(Form("amp ch%d", iCh)); h2_charge_amp[iCh]->GetYaxis()->SetTitle("charge"); h2_charge_amp[iCh]->Draw("colz"); */ } TFile outF("drawBranches.root", "recreate"); outF.cd(); for(int iCh=0; iCh<5; ++iCh) { // p_charge_Amp[iCh]->Write(); // p_Tcf_amp[iCh]->Write(); // p_Tcf_Tot[iCh]->Write(); p_Tot_amp[iCh]->Write(); p_amp_Tot[iCh]->Write(); p_charge_Amp[iCh]->Write(); h2_Tot_amp[iCh]->Write(); h2_amp_Tot[iCh]->Write(); h2_charge_amp[iCh]->Write(); h_amp[iCh]->Write(); } outF.Close(); // return; }
int main (int argc, char** argv) { std::cout<<"--------> DUMPER: READ RECO DATA AND PRODUCE PROFILE PLOTS <--------"<<std::endl; //--------Read Options-------------------------------- std::string inputFileList(argv[1]); std::string outputLabel = argv[2]; int entriesMax = atoi(argv[3]); std::cout << "--------------------------------" << std::endl; std::cout << "inputFileList: " << argv[1] << std::endl; std::cout << "outputLabel: " << argv[2] << std::endl; std::cout << "entriesMax: " << argv[3] << std::endl; std::cout << "--------------------------------" << std::endl; //-------start to read the input file list-------- TChain* treeReco = new TChain("ntu"); RecoTreeVars recoTV; InitRecoTree(treeReco,recoTV); FillChain(treeReco,inputFileList); //---------output histograms---------------- TFile* outputFile = TFile::Open(Form("plots/plots_studyProfiles_%s.root",outputLabel.c_str()),"RECREATE"); TH2F* h2_beamPosition_TDC = new TH2F("h2_beamPosition_TDC","",100,-240,-140.,100,-146,-46.); TH2F* h2_beamPosition_hodo11 = new TH2F("h2_beamPosition_hodo11","",160,-210.,-130.,160,-155.,-75.); TH2F* h2_beamPosition_hodo22 = new TH2F("h2_beamPosition_hodo22","",160,-210.,-130.,160,-155.,-75.); TH2F* h2_beamPosition_hodo12 = new TH2F("h2_beamPosition_hodo12","",160,-210.,-130.,160,-155.,-75.); TH2F* h2_beamPosition_hodo21 = new TH2F("h2_beamPosition_hodo21","",160,-210.,-130.,160,-155.,-75.); std::map<int,TProfile*> p_cellProfileX_TDC; std::map<int,TProfile*> p_cellProfileX_hodo12; std::map<int,TProfile*> p_cellProfileY_TDC; std::map<int,TProfile*> p_cellProfileY_hodo12; std::map<int,TH1F*> h_cell_charge; for(int iCh = 0; iCh < 32; ++iCh) { p_cellProfileX_TDC[iCh] = new TProfile(Form("p_cell%02dProfileX_TDC",iCh),"", 100,-240.,-140.); p_cellProfileX_hodo12[iCh] = new TProfile(Form("p_cell%02dProfileX_hodo12",iCh),"",160,-210.,-130.); p_cellProfileY_TDC[iCh] = new TProfile(Form("p_cell%02dProfileY_TDC",iCh),"", 100,-146., -46.); p_cellProfileY_hodo12[iCh] = new TProfile(Form("p_cell%02dProfileY_hodo12",iCh),"",160,-155., -75.); h_cell_charge[iCh] = new TH1F(Form("h_cell%02d_charge",iCh),"",100000,0., 10000000.); } TH1F* h_total_charge = new TH1F("h_total_charge","",100000,0., 10000000.); TProfile2D* p2_cellPosition_TDC = new TProfile2D("p2_cellPosition_TDC", "",100,-240.,-140.,100,-152.,-52.); TProfile2D* p2_cellPosition_hodo12 = new TProfile2D("p2_cellPosition_hodo12","",160,-210.,-130.,160,-155.,-75.); //-----Data loop-------------------------------------------------------- int nEntries = treeReco -> GetEntries(); if( entriesMax < 0 ) entriesMax = nEntries; for(int iEntry = 0; iEntry < entriesMax; ++iEntry) { if( iEntry%1 == 0 ) std::cout << ">>> reading entry: " << iEntry << " / " << nEntries << "\r" << std::flush; //---Read the entry ClearRecoTreeVars(recoTV); treeReco->GetEntry(iEntry); //---Reconstruct beam position float beamX_TDC = -recoTV.tableX + recoTV.tdcX; float beamY_TDC = -recoTV.tableY + recoTV.tdcY; float hodoX1 = GetHodoWire(recoTV.nHodoX1,recoTV.hodoX1); float hodoY1 = GetHodoWire(recoTV.nHodoY1,recoTV.hodoY1); float hodoX2 = GetHodoWire(recoTV.nHodoX2,recoTV.hodoX2); float hodoY2 = GetHodoWire(recoTV.nHodoY2,recoTV.hodoY2); float beamX_hodo1 = hodoX1 >= 0 ? -recoTV.tableX + 0.5*hodoX1 : -999; float beamY_hodo1 = hodoY1 >= 0 ? -recoTV.tableY - 0.5*hodoY1 : -999; float beamX_hodo2 = hodoX2 >= 0 ? -recoTV.tableX + 0.5*hodoX2 : -999; float beamY_hodo2 = hodoY2 >= 0 ? -recoTV.tableY - 0.5*hodoY2 : -999; //---Fill histograms h2_beamPosition_TDC -> Fill(beamX_TDC,beamY_TDC); if( beamX_hodo1 != -999 && beamY_hodo1 != -999 ) h2_beamPosition_hodo11 -> Fill(beamX_hodo1,beamY_hodo1); if( beamX_hodo2 != -999 && beamY_hodo2 != -999 ) h2_beamPosition_hodo22 -> Fill(beamX_hodo2,beamY_hodo2); if( beamX_hodo1 != -999 && beamY_hodo2 != -999 ) h2_beamPosition_hodo12 -> Fill(beamX_hodo1,beamY_hodo2); if( beamX_hodo2 != -999 && beamY_hodo1 != -999 ) h2_beamPosition_hodo21 -> Fill(beamX_hodo2,beamY_hodo1); float total_charge = 0.; for(int iCh = 0; iCh < 32; ++iCh) { if( recoTV.amp_DQM[iCh] > 500 ) p2_cellPosition_TDC -> Fill(beamX_TDC, beamY_TDC, 32*(iCh%2)+pow(-1,iCh)*iCh); if( recoTV.amp_DQM[iCh] > 500 ) p2_cellPosition_hodo12 -> Fill(beamX_hodo1,beamY_hodo2,32*(iCh%2)+pow(-1,iCh)*iCh); if( recoTV.amp_DQM[iCh] > 0. && recoTV.amp_DQM[iCh] < 999999. ) { p_cellProfileX_TDC[iCh] -> Fill(beamX_TDC, recoTV.amp_DQM[iCh]); p_cellProfileX_hodo12[iCh] -> Fill(beamX_hodo1,recoTV.amp_DQM[iCh]); p_cellProfileY_TDC[iCh] -> Fill(beamY_TDC, recoTV.amp_DQM[iCh]); p_cellProfileY_hodo12[iCh] -> Fill(beamY_hodo2,recoTV.amp_DQM[iCh]); h_cell_charge[iCh] -> Fill(recoTV.charge_DQM[iCh]); if(iCh==12 || iCh==13 || iCh==18 || iCh==19) total_charge += recoTV.charge_DQM[iCh]; } } if( (fabs(beamX_hodo1+180.) < 5.) && (fabs(beamY_hodo2+117.) < 5.) ) h_total_charge -> Fill(total_charge); } std::cout << std::endl; // //-----close everything----------------------------------------------------- outputFile -> Write(); outputFile -> Close(); //---------Done----------------------------------------------------------------- }