--- quicklook/QLflightS4_ND/ND_QL.cpp 2006/06/15 14:00:30 1.1 +++ quicklook/QLflightS4_ND/ND_QL.cpp 2006/06/23 16:06:09 1.2 @@ -54,16 +54,16 @@ using namespace std; -void ND_QL(TString base, TString outDir, TString format, ULong_t DeltaT, ULong_t DeltaTevtime){ // DeltaT in ms, DeltaTevtime in minute +void ND_QL(TString base, TString outDir, TString format, ULong_t DeltaT, Double_t DeltaTevtime){ // DeltaT in ms, DeltaTevtime in minute //---------------- Variables initialization --------------------------// Int_t tmpSize=0; Int_t yTrig=0; Int_t yUpperBackground=0; Int_t yBottomBackground=0; - ULong_t lastime=0, firstime=0; + ULong_t lastime=0, firstime=0, obt1=0; Double_t scale= 1./DeltaTevtime; - string title, title1; + stringstream title, title1; double obt; Float_t cut; stringstream oss, noentries; @@ -132,15 +132,17 @@ } //------------ first and last events -> nbin ---------------------------------// - phystr->GetEntry(0); - ph = eh->GetPscuHeader(); - firstime = ph->GetOrbitalTime(); - phystr->GetEntry(nevents-1); - ph = eh->GetPscuHeader(); - lastime = ph->GetOrbitalTime(); - const ULong_t nint=((lastime-firstime)/(DeltaTevtime*60000)); - const ULong_t nint1=((lastime-firstime)/(DeltaT)); - const ULong_t nint2=lastime-firstime; + for (Int_t i = 0; i < nevents; i++){ + headBr->GetEntry(i); + ph = eh->GetPscuHeader(); + obt1 = ph->GetOrbitalTime(); + if(obt1 <= firstime) firstime=obt1; + if(obt1 >= lastime) lastime=obt1; + } + + const Double_t nint=((lastime-firstime)/(DeltaTevtime*60000)); + const Double_t nint1=((lastime-firstime)/(DeltaT));// + const Double_t nint2=lastime-firstime; int nbin=(int)nint; int nbin1=(int)nint1; int nbin2=(int)nint2; @@ -150,21 +152,19 @@ //************************** HISTOGRAMS ***************************************************// //---------------------------- First histograms -----------------------------------------// oss.str(""); - oss <<"Bottom Background Neutrons with poissionian fit (DeltaT = " << DeltaT << " ms)"; + oss <<"Distribution of Bottom Background Neutrons collected in DeltaT = " << DeltaT << " ms"; oss1.str(""); - oss1 <<"Upper Background Neutrons with poissionian fit (DeltaT = " << DeltaT << " ms)"; + oss1 <<"Distribution of Upper Background Neutrons collected in DeltaT = " << DeltaT << " ms"; TH1F *h1 = new TH1F (filename.Data(), oss.str().c_str(), nbin1,obmin,obmax); TH1F *h3 = new TH1F (filename.Data(), oss1.str().c_str(), nbin1,obmin,obmax); - TH1F *h1bis = new TH1F (filename.Data(), oss.str().c_str(), 30, 0 ,30); - TH1F *h3bis = new TH1F (filename.Data(), oss1.str().c_str(), 30, 0, 30); //---------------------------- Second histograms -----------------------------------------// - title=""; - title=filename+": Bottom Background & Upper Background: Time Evolution (DT="+DeltaTevtime+" min)"; - title1=""; - title1=filename+". Ratio: UpperBackground / BottomBackground: Time Evolution (DT="+DeltaTevtime+" min)"; - TH1F *histo1= new TH1F(title.c_str(),title.c_str(),nbin,obmin,obmax); - TH1F *histo1bis= new TH1F(title1.c_str(),title1.c_str(),nbin,obmin,obmax); - TH1F *histo2= new TH1F(title.c_str(),title.c_str(),nbin,obmin,obmax); + title.str(""); + title<GetMaximum())-(h1->GetMinimum())); + Int_t newBin3=(int)((h3->GetMaximum())-(h3->GetMinimum())); + oss.str(""); + oss <<"Distribution of Bottom Background Neutrons collected in DeltaT = " << DeltaT << " ms"; + oss1.str(""); + oss1 <<"Distribution of Upper Background Neutrons collected in DeltaT = " << DeltaT << " ms"; + TH1F *h1bis = new TH1F (filename.Data(), oss.str().c_str(), newBin1, h1->GetMinimum(), h1->GetMaximum()); + TH1F *h3bis = new TH1F (filename.Data(), oss1.str().c_str(), newBin3, h3->GetMinimum(), h3->GetMaximum()); + for (Int_t i = 0; i < nbin1; i++){ h1bis->Fill(h1->GetBinContent(i)); h3bis->Fill(h3->GetBinContent(i)); - } + } //********************************* CANVASES ************************************************// //--------------------------------- First canvas --------------------------------------------// @@ -225,14 +234,6 @@ h1bis->GetXaxis()->CenterTitle(); h1bis->GetYaxis()->SetTitle("Number of events"); h1bis->GetYaxis()->CenterTitle(); - gStyle->SetOptFit(1111); - TF1 *h2 = new TF1 ("h2", "[0]*TMath::PoissonI(x, [1])" , -1., 30); - h2->SetParName(0, "NEvents"); - h2->SetParName(1, "meanFreq"); - h2->SetParameter(0, size/2); - h2->SetParameter(1, 1); - h2->SetLineColor(kRed); - h1bis->Fit("h2"); h1bis->Draw(); histoCanv->cd(2); @@ -243,14 +244,6 @@ h3bis->GetXaxis()->CenterTitle(); h3bis->GetYaxis()->SetTitle("Number of events"); h3bis->GetYaxis()->CenterTitle(); - gStyle->SetOptFit(1111); - TF1 *h4 = new TF1 ("h4", "[0]*TMath::PoissonI(x, [1])" , -1., 30); - h4->SetParName(0, "NEvents"); - h4->SetParName(1, "meanFreq"); - h4->SetParameter(0, size/2); - h4->SetParameter(1, 1); - h4->SetLineColor(kBlue); - h3bis->Fit("h4"); h3bis->Draw(); //---------------------------------- Second Canvas -----------------------------------------// @@ -262,7 +255,7 @@ histo1->SetStats(kFALSE); histo1->GetYaxis()->SetTitle("Number of recorded Neutrons / DT (min^-1) "); histo1->GetYaxis()->SetTitleSize(0.04); - histo1->GetYaxis()->SetTitleOffset(0.5); + histo1->GetYaxis()->SetTitleOffset(1); histo1->GetYaxis()->CenterTitle(); histo1->GetYaxis()->SetLabelSize(0.03); histo1->GetXaxis()->CenterTitle(); @@ -408,8 +401,8 @@ TString path; TString outDir ="./"; TString format ="jpg"; - ULong_t DeltaT =1000; - ULong_t DeltaTevtime =5; + ULong_t DeltaT =1000;//era 1000 + Double_t DeltaTevtime =5; if (argc < 2){ printf("You have to insert at least the file to analyze \n"); @@ -422,7 +415,7 @@ printf( "\t -outDir[path] Path where to put the output [default ./] \n"); printf( "\t -format[jpg|gif|ps] Format for output files [default 'jpg'] \n"); printf( "\t -DeltaT Time interval to bin histograms in ms [default = 1000ms] \n"); - printf( "\t -DeltaTevtime Time interval to control time evolution of acquired data in minute [default = 1 min.] \n"); + printf( "\t -DeltaTevtime Time interval to control time evolution of acquired data in minute [default = 5 min.] \n"); exit(1); } path=argv[1]; @@ -467,7 +460,7 @@ exit(1); } else{ - DeltaTevtime = atol(argv[i]); + DeltaTevtime = atof(argv[i]); continue; } }