#include "TCanvas.h" #include "TH1.h" #include "TF1.h" #include "TMath.h" void example(Int_t nrun1=87810, Int_t nrun2=87850) { Int_t i; // Output root file TFile *outfile = new TFile("e.root","RECREATE"); Int_t nr1=87810; Int_t nr2=90400; TH1F *h1_n0_w0 = new TH1F("h1_n0_w0","wire0 no hit precentage vs run",nr2-nr1,nr1,nr2); TH1F *h1_n0_w1 = new TH1F("h1_n0_w1","wire1 no hit precentage vs run",nr2-nr1,nr1,nr2); TH1F *h1_n0_w2 = new TH1F("h1_n0_w2","wire2 no hit precentage vs run",nr2-nr1,nr1,nr2); TH1F *h1_n0_w3 = new TH1F("h1_n0_w3","wire3 no hit precentage vs run",nr2-nr1,nr1,nr2); TH1F *h1_n1_w0 = new TH1F("h1_n1_w0","wire0 single hit precentage vs run",nr2-nr1,nr1,nr2); TH1F *h1_n1_w1 = new TH1F("h1_n1_w1","wire1 single hit precentage vs run",nr2-nr1,nr1,nr2); TH1F *h1_n1_w2 = new TH1F("h1_n1_w2","wire2 single hit precentage vs run",nr2-nr1,nr1,nr2); TH1F *h1_n1_w3 = new TH1F("h1_n1_w3","wire3 single hit precentage vs run",nr2-nr1,nr1,nr2); TH1F *h1_a_w0 = new TH1F("h1_a_w0","wire0 most probable ampliture",nr2-nr1,nr1,nr2); TH1F *h1_a_w1 = new TH1F("h1_a_w1","wire1 most probable ampliture",nr2-nr1,nr1,nr2); TH1F *h1_a_w2 = new TH1F("h1_a_w2","wire2 most probable ampliture",nr2-nr1,nr1,nr2); TH1F *h1_a_w3 = new TH1F("h1_a_w3","wire3 most probable ampliture",nr2-nr1,nr1,nr2); Long_t *id,*size,*flags,*mt; Int_t fflag; Double_t n0_w0=0; Double_t n0_w1=0; Double_t n0_w2=0; Double_t n0_w3=0; Double_t n1_w0=0; Double_t n1_w1=0; Double_t n1_w2=0; Double_t n1_w3=0; Double_t a_w0=0; Double_t a_w1=0; Double_t a_w2=0; Double_t a_w3=0; for (i=nrun1;iGetPathInfo(Form("/data/scratch/pen09/histos/his%d.root",i),id,size,flags,mt); //printf(" %d\n",fflag); if (fflag==0) { // Input ROOT file pointer TFile* file = TFile::Open(Form("his%d.root",i),"read"); TFolder *folder = (TFolder*)file.GetKey("histos")->ReadObj(); TH1F *h1_wtpc_l= (TH1F*)folder->FindObject("MTPC/h1_wtpc_l"); // 2048, 0., 8192 TH1F *h1_wtpc_r= (TH1F*)folder->FindObject("MTPC/h1_wtpc_r"); // wires 0-3 at starting at bins 0,20,40,60 TH1F *h1_npeaks= (TH1F*)folder->FindObject("MTPC/h1_npeaks"); //80, -0.5, 79.5 // signal amplitudes, wires 0,1,2,3 at 0-20000, 20000-40000, 40000-60000 and 60000-80000 TH1F *hm1_al= (TH1F*)folder->FindObject("BEAMLINE Histo Filling/hm1_al"); // TH1F *hm1_ar= (TH1F*)folder->FindObject("BEAMLINE Histo Filling/hm1_ar"); // TH1F *hm1_a= (TH1F*)folder->FindObject("BEAMLINE Histo Filling/hm1_a"); // 800,0.,80000. // Double_t w1l=h1_wtpc_l->Integral(0,8190); n0_w0=0; n0_w1=0; n0_w2=0; n0_w3=0; // zero peaks found if (h1_npeaks->Integral(0,19)>0) n0_w0=h1_npeaks->Integral(0,1)/h1_npeaks->Integral(0,19); if (h1_npeaks->Integral(20,39)>0) n0_w1=h1_npeaks->Integral(20,21)/h1_npeaks->Integral(0,19); if (h1_npeaks->Integral(40,59)>0) n0_w2=h1_npeaks->Integral(40,41)/h1_npeaks->Integral(0,19); if (h1_npeaks->Integral(60,79)>0) n0_w3=h1_npeaks->Integral(60,61)/h1_npeaks->Integral(0,19); n1_w0=0; n1_w1=0; n1_w2=0; n1_w3=0; // one peak found if (h1_npeaks->Integral(0,19)>0) n1_w0=h1_npeaks->Integral(1,2)/h1_npeaks->Integral(0,19); if (h1_npeaks->Integral(20,39)>0) n1_w1=h1_npeaks->Integral(21,22)/h1_npeaks->Integral(20,39); if (h1_npeaks->Integral(40,59)>0) n1_w2=h1_npeaks->Integral(41,42)/h1_npeaks->Integral(40,59); if (h1_npeaks->Integral(60,79)>0) n1_w3=h1_npeaks->Integral(61,62)/h1_npeaks->Integral(60,79); a_w0=0; a_w1=0; a_w2=0; a_w3=0; hm1_a->GetXaxis()->SetRange(0,180); a_w0=hm1_a->GetMaximumBin(); hm1_a->GetXaxis()->SetRange(200,380); a_w1=hm1_a->GetMaximumBin()-200; hm1_a->GetXaxis()->SetRange(400,580); a_w2=hm1_a->GetMaximumBin()-400; hm1_a->GetXaxis()->SetRange(600,780); a_w3=hm1_a->GetMaximumBin()-600; printf(" %d %.3f %.3f %.3f %.3f\n",i,n1_w0,n1_w1,n1_w2,n1_w3); h1_n0_w0->Fill((float) i+0.5,n0_w0); h1_n0_w1->Fill((float) i+0.5,n0_w1); h1_n0_w2->Fill((float) i+0.5,n0_w2); h1_n0_w3->Fill((float) i+0.5,n0_w3); h1_n1_w0->Fill((float) i+0.5,n1_w0); h1_n1_w1->Fill((float) i+0.5,n1_w1); h1_n1_w2->Fill((float) i+0.5,n1_w2); h1_n1_w3->Fill((float) i+0.5,n1_w3); h1_a_w0->Fill((float) i+0.5,a_w0); h1_a_w1->Fill((float) i+0.5,a_w1); h1_a_w2->Fill((float) i+0.5,a_w2); h1_a_w3->Fill((float) i+0.5,a_w3); delete file; delete folder; delete h1_wtpc_l; delete h1_wtpc_r; delete h1_npeaks; delete hm1_al; delete hm1_ar; delete hm1_a; } // fflag } // end for outfile->Write(); } // end example