#define E_total_hist_cxx // 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("E_total_hist.C") // root> T->Process("E_total_hist.C","some options") // root> T->Process("E_total_hist.C+") // #include "E_total_hist.h" #include #include #include #include #include #include #include #include "TChain.h" #include "TRandom1.h" // read in the calib file to add properly calibrated random number to energy //ifstream myReadFile; //myReadFile("calib.dat"); // declare the variables int i, Temp_TAC; int TAC_low=0; int TAC_high=100000; ULong64_t n, Temp_0_ch, Temp_1_ch, Temp_2_ch, Temp_3_ch=0; ULong64_t Temp_4_ch, Temp_5_ch, Temp_6_ch, Temp_7_ch, Temp_8_ch, Temp_9_ch=0; Double_t etotalT1, etotalT2, etotalT3, etotalT4=0; Double_t etotal_ymin, etotal_ymax, E_T1, E_T3, rand1=0; Double_t Temp_D1, Temp_D2, Temp_D3, Temp_D4, Temp_D5=0; Double_t Temp_D6, Temp_D7, Temp_D8, Temp_D9, Temp_D0=0; // declare the root structures TRandom *random1=new TRandom; TH1D *E_total_T1, *E_total_T2, *E_total_T3, *E_total_T4=NULL; TH2D *DEE98, *DEE765, *DEE75, *DEE65, *DEE43, *DEE210, *DEE20, *DEE10=NULL; TH2D *E_v_theta_9, *E_v_theta_8, *E_v_theta_7, *E_v_theta_6, *E_v_theta_5=NULL; TH2D *E_v_theta_4, *E_v_theta_3, *E_v_theta_2, *E_v_theta_1, *E_v_theta_0=NULL; // arrays to hold the angles for the detectors double QQQ5_angle[32]={18.1441, 17.93065, 17.70615, 17.47065, 17.224, 16.96615, 16.697, 16.41655, 16.12465, 15.82125, 15.5062, 15.17945, 14.84095, 14.49055, 14.1282, 13.7539, 13.36745, 12.9688, 12.5579, 12.13475, 11.69915, 11.25105, 10.7905, 10.31735, 9.83161, 9.33324, 8.82218, 8.298415, 7.761945, 7.21277, 6.65089, 6.07634}; double QQQ3_angle[16]={12.2215, 12.9241, 13.62275, 14.3173, 15.0076, 15.69345, 16.3747, 17.05125, 17.72295, 18.38965, 19.0512, 19.7075, 20.3585, 21.00405, 21.64405, 22.27845}; void E_total_hist::Begin(TTree * /*tree*/) { TString option = GetOption(); E_total_T1=new TH1D("E_total_T1","Total energy telescope 1", 1000,0,20000); E_total_T2=new TH1D("E_total_T2","Total energy telescope 2", 1000,0,20000); E_total_T3=new TH1D("E_total_T3","Total energy telescope 3", 1000,0,20000); E_total_T4=new TH1D("E_total_T4","Total energy telescope 4", 1000,0,20000); DEE98=new TH2D("DEET4","#Delta E vs E T4 Front",10000,0,20000,10000,0,20000); DEE765=new TH2D("DEET3","#Delta E vs E T3 Front",20000,0,40000,10000,0,20000); DEE43=new TH2D("DEET2","#Delta E vs E T2 Front",10000,0,20000,10000,0,20000); DEE210=new TH2D("DEET1","#Delta E vs E T1 Front",20000,0,40000,10000,0,20000); E_v_theta_9=new TH2D("E_v_theta_9", "Energy vs #theta D9",16, 0, 16, 10000,0,20000); E_v_theta_8=new TH2D("E_v_theta_8", "Energy vs #theta D8",16, 0, 16, 10000,0,20000); E_v_theta_7=new TH2D("E_v_theta_7", "Energy vs #theta D7",31,0,31, 10000,0,20000); E_v_theta_6=new TH2D("E_v_theta_6", "Energy vs #theta D6",31,0,31, 10000,0,20000); E_v_theta_5=new TH2D("E_v_theta_5", "Energy vs #theta D5",31,0,31, 10000,0,20000); E_v_theta_4=new TH2D("E_v_theta_4", "Energy vs #theta D4",16, 0, 16, 10000,0,20000); E_v_theta_3=new TH2D("E_v_theta_3", "Energy vs #theta D3",16, 0, 16, 10000,0,20000); E_v_theta_2=new TH2D("E_v_theta_2", "Energy vs #theta D2",31,0,31, 10000,0,20000); E_v_theta_1=new TH2D("E_v_theta_1", "Energy vs #theta D1",31,0,31, 10000,0,20000); E_v_theta_0=new TH2D("E_v_theta_0", "Energy vs #theta D0",31,0,31, 10500,-1000,20000); } void E_total_hist::SlaveBegin(TTree * /*tree*/) { TString option = GetOption();} Bool_t E_total_hist::Process(Long64_t entry) { fReader.SetEntry(entry); Temp_TAC=0; Temp_D1=0; Temp_D2=0; Temp_D3=0; Temp_D4=0; Temp_D5=0; Temp_D6=0; Temp_D7=0; Temp_D8=0; Temp_D9=0; Temp_D0=0; Temp_1_ch=0; Temp_2_ch=0; Temp_3_ch=0; Temp_4_ch=0; Temp_5_ch=0; Temp_6_ch=0; Temp_7_ch=0; Temp_8_ch=0; Temp_9_ch=0; Temp_0_ch=0; etotalT1=0; etotalT2=0; etotalT3=0; etotalT4=0; if(*size !=0){ for(i=0;i<*size;i++){ n=detid[i]; if(energy[i]>100 && energy[i]<20000){ //detid is not 0 indexed! Det#=detid-1 if(n== 1){ rand1=random1->Rndm(); Temp_D0+=energy[i]+rand1*1.48; Temp_0_ch=detch[i]; } if(n== 2){ rand1=random1->Rndm(); Temp_D1+=energy[i]+rand1*1.48; Temp_1_ch=detch[i]; } if(n== 3){ rand1=random1->Rndm(); Temp_D2+=energy[i]+rand1*1.48; Temp_2_ch=detch[i]; } if(n== 4){ rand1=random1->Rndm(); Temp_D3+=energy[i]+rand1*1.48; Temp_3_ch=detch[i]; } if(n== 5){ rand1=random1->Rndm(); Temp_D4+=energy[i]+rand1*1.48; Temp_4_ch=detch[i]; } if(n== 6){ rand1=random1->Rndm(); Temp_D5+=energy[i]+rand1*1.48; Temp_5_ch=detch[i]; } if(n== 7){ rand1=random1->Rndm(); Temp_D6+=energy[i]+rand1*1.48; Temp_6_ch=detch[i]; } if(n== 8){ rand1=random1->Rndm(); Temp_D7+=energy[i]+rand1*1.48; Temp_7_ch=detch[i]; } if(n== 9){ rand1=random1->Rndm(); Temp_D8+=energy[i]+rand1*1.48; Temp_8_ch=detch[i]; } if(n== 10){ rand1=random1->Rndm(); Temp_D9+=energy[i]+rand1*1.48; Temp_9_ch=detch[i]; } if(n== 25){ Temp_TAC=value[i]; } } } // TAC CONTROL if(Temp_TAC>TAC_low && Temp_TACFill(etotalT1); } if(Temp_D3 != 0 || Temp_D4!= 0){ etotalT2+=Temp_D3+Temp_D4; E_total_T2->Fill(etotalT2); } if(Temp_D5 != 0 || Temp_D6 != 0 || Temp_D7 != 0){ etotalT3+=Temp_D5+Temp_D6+Temp_D7; E_total_T3->Fill(etotalT3); } if(Temp_D8 != 0 || Temp_D9 != 0){ etotalT4+=Temp_D8+Temp_D9; E_total_T4->Fill(etotalT4); } // sum the energies of the second and third detectors of the 3 layer telescope // and fill DE E histograms if(Temp_D0 != 0 || Temp_D1 != 0){ E_T1=Temp_D0+Temp_D1; } if(Temp_D5 != 0 || Temp_D6 != 0){ E_T3=Temp_D5+Temp_D6; } if(Temp_D8 !=0 && Temp_D9 !=0){ DEE98->Fill(Temp_D8, Temp_D9); } if(E_T3 !=0 && Temp_D7 !=0){ DEE765->Fill(E_T3, Temp_D7); } if(Temp_D3 !=0 && Temp_D4 !=0){ DEE43->Fill(Temp_D3, Temp_D4); } if(E_T1 !=0 && Temp_D2 !=0){ DEE210->Fill(E_T1, Temp_D2); } } if(Temp_D0 !=0){ cout<< "D0= " << Temp_D0 << "\n"; } if(Temp_D1 !=0){ cout<< "D1= " << Temp_D1 << "\n"; } if(Temp_D2 !=0){ cout<< "D2= " << Temp_D2 << "\n"; } if(Temp_D3 !=0){ cout<< "D3= " << Temp_D3 << "\n"; } if(Temp_D4 !=0){ cout<< "D4= " << Temp_D4 << "\n"; } if(Temp_D5 !=0){ cout<< "D5= " << Temp_D5 << "\n"; } if(Temp_D6 !=0){ cout<< "D6= " << Temp_D6 << "\n"; } if(Temp_D7 !=0){ cout<< "D7= " << Temp_D7 << "\n"; } if(Temp_D8 !=0){ cout<< "D8= " << Temp_D8 << "\n"; } if(Temp_D9 !=0){ cout<< "D9= " << Temp_D9 << "\n"; } //fill E v theta histograms if(Temp_D9 !=0){ E_v_theta_9->Fill(Temp_9_ch, Temp_D9); } if(Temp_D8 !=0){ E_v_theta_8->Fill(Temp_8_ch, Temp_D8); } if(Temp_D7 !=0){ E_v_theta_7->Fill(Temp_7_ch, Temp_D7); } if(Temp_D6 !=0){ E_v_theta_6->Fill(Temp_6_ch, Temp_D6); } if(Temp_D5 !=0){ E_v_theta_5->Fill(Temp_5_ch, Temp_D5); } if(Temp_D4 !=0){ E_v_theta_4->Fill(Temp_4_ch, Temp_D4); } if(Temp_D3 !=0){ E_v_theta_3->Fill(Temp_3_ch, Temp_D3); } if(Temp_D2 !=0){ E_v_theta_2->Fill(Temp_2_ch, Temp_D2); } if(Temp_D1 !=0){ E_v_theta_1->Fill(Temp_1_ch, Temp_D1); } if(Temp_D0 !=0){ E_v_theta_0->Fill(Temp_0_ch, Temp_D0); } } return kTRUE; } void E_total_hist::SlaveTerminate(){} void E_total_hist::Terminate() { TCanvas *Canvas_1 = new TCanvas("E_total","E_total",10,10,1000,700); // change the color scheme on "colz" UInt_t Number = 6; Double_t Red[6] = {0.00, 0.22 ,0.0667, 0.1961, 0.04392, 0.094118}; Double_t Green[6] = {0.00, 0.01, 0.0510, 0.06235, 0.8118, 0.94901}; Double_t Blue[6] = {0.00, 0.27, 0.4314, 0.6431, 0.4902, 0.79607}; //Double_t Length[Number] = {0.0, .166667, .333333, .5, .66667, .833333, 1.00}; //Double_t Length[Number] = {0.0, 0.05, .2, .35, .4, .7, 1.0}; //Double_t Length[Number] = {0.000, .125, .250, .375, .5, .625, .75, .875, 1.00}; Double_t Length[6] = {0, .25, .5, .75, .9, 1.00}; Int_t nb=200; TColor::CreateGradientColorTable(Number,Length,Red,Green,Blue,nb); //Print E_totals E_total_T1->SetMinimum(0); E_total_T1->SetMaximum(30); E_total_T1->Draw(); Canvas_1->Print("E_total_T1.jpg","jpg"); Canvas_1->Print("E_total_T1.root","root"); E_total_T2->SetMinimum(0); E_total_T2->SetMaximum(30); E_total_T2->Draw(); Canvas_1->Print("E_total_T2.jpg","jpg"); Canvas_1->Print("E_total_T2.root","root"); E_total_T3->SetMinimum(0); E_total_T3->SetMaximum(30); E_total_T3->Draw(); Canvas_1->Print("E_total_T3.jpg","jpg"); Canvas_1->Print("E_total_T3.root","root"); E_total_T4->SetMinimum(0); E_total_T4->SetMaximum(30); E_total_T4->Draw(); Canvas_1->Print("E_total_T4.jpg","jpg"); Canvas_1->Print("E_total_T4.root","root"); //Print DE_E's DEE98->SetMarkerStyle(4); DEE98->Draw(); Canvas_1->Print("DEET4.jpg","jpg"); //Canvas_1->Print("DEET4.root","root"); DEE765->SetMarkerStyle(4); DEE765->Draw(); Canvas_1->Print("DEET3.jpg","jpg"); //Canvas_1->Print("DEET3.root","root"); DEE43->SetMarkerStyle(4); DEE43->Draw(); Canvas_1->Print("DEET2.jpg","jpg"); //Canvas_1->Print("DEET2.root","root"); DEE210->SetMarkerStyle(4); DEE210->Draw(); Canvas_1->Print("DEET1.jpg","jpg"); //Print E v E_v_theta_9->SetMarkerStyle(4); E_v_theta_9->Draw("colz"); Canvas_1->Print("E_v_theta_D9.jpg","jpg"); //Canvas_1->Print("E_v_theta_D9.root","root"); E_v_theta_8->SetMarkerStyle(4); E_v_theta_8->Draw("colz"); Canvas_1->Print("E_v_theta_D8.jpg","jpg"); //Canvas_1->Print("E_v_theta_D8.root","root"); E_v_theta_7->SetMarkerStyle(4); E_v_theta_7->Draw("colz"); Canvas_1->Print("E_v_theta_D7.jpg","jpg"); //Canvas_1->Print("E_v_theta_D7.root","root"); E_v_theta_6->SetMarkerStyle(4); E_v_theta_6->Draw("colz"); Canvas_1->Print("E_v_theta_D6.jpg","jpg"); //Canvas_1->Print("E_v_theta_D6.root","root"); E_v_theta_5->SetMarkerStyle(4); E_v_theta_5->Draw("colz"); Canvas_1->Print("E_v_theta_D5.jpg","jpg"); //Canvas_1->Print("E_v_theta_D5.root","root"); E_v_theta_4->SetMarkerStyle(4); E_v_theta_4->Draw("colz"); Canvas_1->Print("E_v_theta_D4.jpg","jpg"); //Canvas_1->Print("E_v_theta_D4.root","root"); E_v_theta_3->SetMarkerStyle(4); E_v_theta_3->Draw("colz"); Canvas_1->Print("E_v_theta_D3.jpg","jpg"); //Canvas_1->Print("E_v_theta_D3.root","root"); E_v_theta_2->SetMarkerStyle(4); E_v_theta_2->Draw("colz"); Canvas_1->Print("E_v_theta_D2.jpg","jpg"); //Canvas_1->Print("E_v_theta_D2.root","root"); E_v_theta_1->SetMarkerStyle(4); E_v_theta_1->Draw("colz"); Canvas_1->Print("E_v_theta_D1.jpg","jpg"); //Canvas_1->Print("E_v_theta_D1.root","root"); E_v_theta_0->SetMarkerStyle(4); E_v_theta_0->Draw("colz"); Canvas_1->Print("E_v_theta_D0.jpg","jpg"); //Canvas_1->Print("E_v_theta_D0.root","root"); } //not in use //for debug /* if(Temp_D0 !=0){ cout<< "D0= " << Temp_D0 << "\n"; } if(Temp_D1 !=0){ cout<< "D1= " << Temp_D1 << "\n"; } if(Temp_D2 !=0){ cout<< "D2= " << Temp_D2 << "\n"; } if(Temp_D3 !=0){ cout<< "D3= " << Temp_D3 << "\n"; } if(Temp_D4 !=0){ cout<< "D4= " << Temp_D4 << "\n"; } if(Temp_D5 !=0){ cout<< "D5= " << Temp_D5 << "\n"; } if(Temp_D6 !=0){ cout<< "D6= " << Temp_D6 << "\n"; } if(Temp_D7 !=0){ cout<< "D7= " << Temp_D7 << "\n"; } if(Temp_D8 !=0){ cout<< "D8= " << Temp_D8 << "\n"; } if(Temp_D9 !=0){ cout<< "D9= " << Temp_D9 << "\n"; } */