/[PAMELA software]/quicklook/QLflightS4_ND/ND_QL.cpp
ViewVC logotype

Diff of /quicklook/QLflightS4_ND/ND_QL.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by pam-rm2, Thu Jun 15 14:00:30 2006 UTC revision 1.6 by pam-rm2, Mon Mar 12 14:32:46 2007 UTC
# Line 54  Line 54 
54    
55  using namespace std;  using namespace std;
56    
57  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
58        
59    //---------------- Variables initialization --------------------------//    //---------------- Variables initialization --------------------------//
60    Int_t    tmpSize=0;    Int_t    tmpSize=0;
61    Int_t    yTrig=0;    Int_t    yTrig=0;
62    Int_t    yUpperBackground=0;    Int_t    yUpperBackground=0;
63    Int_t    yBottomBackground=0;    Int_t    yBottomBackground=0;
64    ULong_t  lastime=0, firstime=0;    ULong_t  lastime=0, firstime=700000000;
65    Double_t scale= 1./DeltaTevtime;    Double_t scale= 1./DeltaTevtime;
66    string title, title1;    stringstream title, title1;
67    double obt;      ULong_t obt;  
   Float_t     cut;  
68    stringstream oss, noentries;    stringstream oss, noentries;
69    stringstream oss1, oss2, oss3;    stringstream oss1, oss2, oss3;
70    
# Line 132  void ND_QL(TString base, TString outDir, Line 131  void ND_QL(TString base, TString outDir,
131    }    }
132    
133    //------------ first and last  events ->  nbin ---------------------------------//    //------------ first and last  events ->  nbin ---------------------------------//
134    phystr->GetEntry(0);    headBr->GetEntry(0);
135    ph = eh->GetPscuHeader();    ph = eh->GetPscuHeader();
136    firstime = ph->GetOrbitalTime();      firstime = ph->GetOrbitalTime();
137    phystr->GetEntry(nevents-1);    
138    ph = eh->GetPscuHeader();    for (Int_t i = 0; i < nevents; i++){
139    lastime = ph->GetOrbitalTime();      headBr->GetEntry(i);
140    const ULong_t nint=((lastime-firstime)/(DeltaTevtime*60000));      ph = eh->GetPscuHeader();
141    const ULong_t nint1=((lastime-firstime)/(DeltaT));      obt=ph->GetOrbitalTime();
142    const ULong_t nint2=lastime-firstime;      if(obt<=firstime) firstime=ph->GetOrbitalTime();
143    int nbin=(int)nint;      if(obt>=lastime) lastime=ph->GetOrbitalTime();
144    int nbin1=(int)nint1;     }
   int nbin2=(int)nint2;  
   double obmin=firstime;  
   double obmax=lastime;  
145    
146       const ULong_t nint=((lastime-firstime)/(DeltaTevtime*60000));
147       const ULong_t nint1=((lastime-firstime)/(DeltaT));//
148       const ULong_t nint2=lastime-firstime;
149       int nbin=(int)nint;
150       int nbin1=(int)nint1;
151       int nbin2=(int)nint2;
152       if(nbin2 >= 37000000) nbin2=37000000;
153       Double_t obmin=firstime;
154       Double_t obmax=lastime;
155      
156    //************************** HISTOGRAMS ***************************************************//    //************************** HISTOGRAMS ***************************************************//
157    //---------------------------- First histograms -----------------------------------------//    //---------------------------- First histograms -----------------------------------------//
158    oss.str("");    oss.str("");
159    oss <<"Bottom Background Neutrons with poissionian fit (DeltaT = " << DeltaT << " ms)";    oss <<"Distribution of Bottom Background Neutrons collected in DeltaT = " << DeltaT << " ms";
160    oss1.str("");    oss1.str("");
161    oss1 <<"Upper Background Neutrons with poissionian fit (DeltaT = " << DeltaT << " ms)";    oss1 <<"Distribution of Upper Background Neutrons collected in DeltaT = " << DeltaT << " ms";
162    TH1F *h1 = new TH1F (filename.Data(), oss.str().c_str(), nbin1,obmin,obmax);    TH1F *h1 = new TH1F (filename.Data(), oss.str().c_str(), nbin1,obmin,obmax);
163    TH1F *h3 = new TH1F (filename.Data(), oss1.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);  
164    //---------------------------- Second histograms -----------------------------------------//    //---------------------------- Second histograms -----------------------------------------//
165    title="";    title.str("");
166    title=filename+":  Bottom Background & Upper Background: Time Evolution (DT="+DeltaTevtime+" min)";    title<<filename<<":  Bottom Background & Upper Background: Time Evolution (DT="<<DeltaTevtime<<" min)";
167    title1="";    title1.str("");
168    title1=filename+". Ratio: UpperBackground / BottomBackground: Time Evolution (DT="+DeltaTevtime+" min)";    title1<<filename<<". Ratio: UpperBackground / BottomBackground: Time Evolution (DT="<<DeltaTevtime<<" min)";
169    TH1F *histo1= new TH1F(title.c_str(),title.c_str(),nbin,obmin,obmax);    TH1F *histo1= new TH1F(title.str().c_str(),title.str().c_str(),nbin,obmin,obmax);
170    TH1F *histo1bis= new TH1F(title1.c_str(),title1.c_str(),nbin,obmin,obmax);    TH1F *histo1bis= new TH1F(title1.str().c_str(),title1.str().c_str(),nbin,obmin,obmax);
171    TH1F *histo2= new TH1F(title.c_str(),title.c_str(),nbin,obmin,obmax);    TH1F *histo2= new TH1F(title.str().c_str(),title.str().c_str(),nbin,obmin,obmax);
172    
173    //---------------------------- Third histograms -----------------------------------------//    //---------------------------- Third histograms -----------------------------------------//
174    
175    oss.str("");    oss.str("");
# Line 192  void ND_QL(TString base, TString outDir, Line 197  void ND_QL(TString base, TString outDir,
197        yUpperBackground  = yUpperBackground  + (int)nr->upperBack;        yUpperBackground  = yUpperBackground  + (int)nr->upperBack;
198        yBottomBackground = yBottomBackground + (int)nr->bottomBack;        yBottomBackground = yBottomBackground + (int)nr->bottomBack;
199      }      }
200      histo1->Fill(ph->GetOrbitalTime(), yUpperBackground);      obt=ph->GetOrbitalTime();
201      histo1bis->Fill(ph->GetOrbitalTime(), yUpperBackground);      histo1->Fill(obt, yUpperBackground);
202      histo2->Fill(ph->GetOrbitalTime(), yBottomBackground);      histo1bis->Fill(obt, yUpperBackground);
203      h1->Fill(ph->GetOrbitalTime(), yBottomBackground);      histo2->Fill(obt, yBottomBackground);
204      h3->Fill(ph->GetOrbitalTime(), yUpperBackground);      h1->Fill(obt, yBottomBackground);
205      Trig->Fill(ph->GetOrbitalTime(), yTrig);      h3->Fill(obt, yUpperBackground);
206      Trigger->Fill(ph->GetOrbitalTime(), yTrig);  
207        Trig->Fill(obt, yTrig);
208        Trigger->Fill(obt, yTrig);
209      if(yTrig >=10)          if(yTrig >=10)    
210        Triggercut->Fill(ph->GetOrbitalTime(), yTrig);        Triggercut->Fill(obt, yTrig);
211      yUpperBackground=0;      yUpperBackground=0;
212      yBottomBackground=0;      yBottomBackground=0;
213      yTrig=0;      yTrig=0;
214    }    }
215    
216    for (Int_t i = 0; i < nevents; i++){  
217      Int_t newBin1=(int)((h1->GetMaximum())-(h1->GetMinimum()));
218      Int_t newBin3=(int)((h3->GetMaximum())-(h3->GetMinimum()));
219      oss.str("");
220      oss <<"Distribution of Bottom Background Neutrons collected in DeltaT = " << DeltaT << " ms";
221      oss1.str("");
222      oss1 <<"Distribution of Upper Background Neutrons collected in DeltaT = " << DeltaT << " ms";
223      TH1F *h1bis = new TH1F (filename.Data(), oss.str().c_str(), newBin1, h1->GetMinimum(), h1->GetMaximum());
224      TH1F *h3bis = new TH1F (filename.Data(), oss1.str().c_str(), newBin3, h3->GetMinimum(), h3->GetMaximum());
225      for (Int_t i = 0; i < nbin1; i++){
226      h1bis->Fill(h1->GetBinContent(i));      h1bis->Fill(h1->GetBinContent(i));
227      h3bis->Fill(h3->GetBinContent(i));      h3bis->Fill(h3->GetBinContent(i));
228    }        }
229    
230    //********************************* CANVASES ************************************************//    //********************************* CANVASES ************************************************//
231    //--------------------------------- First canvas --------------------------------------------//    //--------------------------------- First canvas --------------------------------------------//
# Line 218  void ND_QL(TString base, TString outDir, Line 234  void ND_QL(TString base, TString outDir,
234    histoCanv->Divide(1,2);    histoCanv->Divide(1,2);
235    
236    histoCanv->cd(1);    histoCanv->cd(1);
237      gPad->SetLogy();
238    h1bis->SetLineColor(kRed);    h1bis->SetLineColor(kRed);
239    h1bis->SetFillStyle(3004);    h1bis->SetFillStyle(3004);
240    h1bis->SetFillColor(kRed);    h1bis->SetFillColor(kRed);
# Line 225  void ND_QL(TString base, TString outDir, Line 242  void ND_QL(TString base, TString outDir,
242    h1bis->GetXaxis()->CenterTitle();    h1bis->GetXaxis()->CenterTitle();
243    h1bis->GetYaxis()->SetTitle("Number of events");    h1bis->GetYaxis()->SetTitle("Number of events");
244    h1bis->GetYaxis()->CenterTitle();    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");  
245    h1bis->Draw();    h1bis->Draw();
246    
247    histoCanv->cd(2);    histoCanv->cd(2);
248      gPad->SetLogy();
249    h3bis->SetLineColor(kBlue);    h3bis->SetLineColor(kBlue);
250    h3bis->SetFillStyle(3004);    h3bis->SetFillStyle(3004);
251    h3bis->SetFillColor(kBlue);    h3bis->SetFillColor(kBlue);
# Line 243  void ND_QL(TString base, TString outDir, Line 253  void ND_QL(TString base, TString outDir,
253    h3bis->GetXaxis()->CenterTitle();    h3bis->GetXaxis()->CenterTitle();
254    h3bis->GetYaxis()->SetTitle("Number of events");    h3bis->GetYaxis()->SetTitle("Number of events");
255    h3bis->GetYaxis()->CenterTitle();    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");  
256    h3bis->Draw();    h3bis->Draw();
257        
258    //---------------------------------- Second Canvas -----------------------------------------//    //---------------------------------- Second Canvas -----------------------------------------//
# Line 262  void ND_QL(TString base, TString outDir, Line 264  void ND_QL(TString base, TString outDir,
264    histo1->SetStats(kFALSE);    histo1->SetStats(kFALSE);
265    histo1->GetYaxis()->SetTitle("Number of recorded Neutrons / DT   (min^-1) ");    histo1->GetYaxis()->SetTitle("Number of recorded Neutrons / DT   (min^-1) ");
266    histo1->GetYaxis()->SetTitleSize(0.04);    histo1->GetYaxis()->SetTitleSize(0.04);
267    histo1->GetYaxis()->SetTitleOffset(0.5);    histo1->GetYaxis()->SetTitleOffset(1);
268    histo1->GetYaxis()->CenterTitle();    histo1->GetYaxis()->CenterTitle();
269    histo1->GetYaxis()->SetLabelSize(0.03);    histo1->GetYaxis()->SetLabelSize(0.03);
270    histo1->GetXaxis()->CenterTitle();    histo1->GetXaxis()->CenterTitle();
# Line 270  void ND_QL(TString base, TString outDir, Line 272  void ND_QL(TString base, TString outDir,
272    histo1->GetXaxis()->SetTitleOffset(1);    histo1->GetXaxis()->SetTitleOffset(1);
273    histo1->GetXaxis()->SetLabelSize(0.03);    histo1->GetXaxis()->SetLabelSize(0.03);
274    histo1->GetXaxis()->SetTitle("OBT   (ms)");    histo1->GetXaxis()->SetTitle("OBT   (ms)");
275    histo1->SetMarkerSize(.5);    histo1->SetMarkerSize(.3);
276    histo1->SetMarkerStyle(21);    histo1->SetMarkerStyle(21);
277    histo1->SetMarkerColor(3);    histo1->SetMarkerColor(3);
278    histo1->Scale(scale);    histo1->Scale(scale);
# Line 278  void ND_QL(TString base, TString outDir, Line 280  void ND_QL(TString base, TString outDir,
280    histo1->Draw("9p0");    histo1->Draw("9p0");
281    
282    histo2->SetStats(kFALSE);    histo2->SetStats(kFALSE);
283    histo2->SetMarkerSize(.5);    histo2->SetMarkerSize(.3);
284    histo2->SetMarkerStyle(21);    histo2->SetMarkerStyle(21);
285    histo2->SetMarkerColor(2);    histo2->SetMarkerColor(2);
286    histo2->Scale(scale);    histo2->Scale(scale);
# Line 291  void ND_QL(TString base, TString outDir, Line 293  void ND_QL(TString base, TString outDir,
293    leg->Draw();    leg->Draw();
294    
295    finalCanv->cd(2);    finalCanv->cd(2);
296    histo1bis->SetMarkerSize(.5);    histo1bis->SetMarkerSize(.3);
297    histo1bis->SetStats(kFALSE);    histo1bis->SetStats(kFALSE);
298    histo1bis->SetMarkerStyle(21);    histo1bis->SetMarkerStyle(21);
299    histo1bis->SetMarkerColor(4);    histo1bis->SetMarkerColor(4);
# Line 331  void ND_QL(TString base, TString outDir, Line 333  void ND_QL(TString base, TString outDir,
333    triggerCanv->cd(1);    triggerCanv->cd(1);
334    Trig->SetStats(kFALSE);    Trig->SetStats(kFALSE);
335    Trig->SetMarkerStyle(21);    Trig->SetMarkerStyle(21);
336    Trig->SetMarkerSize(.7);    Trig->SetMarkerSize(.4);
337    Trig->SetMarkerColor(2);    Trig->SetMarkerColor(2);
338    Trig->GetXaxis()->SetTitle("OBT (ms)");    Trig->GetXaxis()->SetTitle("OBT (ms)");
339    Trig->GetXaxis()->CenterTitle();    Trig->GetXaxis()->CenterTitle();
# Line 347  void ND_QL(TString base, TString outDir, Line 349  void ND_QL(TString base, TString outDir,
349    triggerCanv->cd(2);    triggerCanv->cd(2);
350    Trigger->SetStats(kFALSE);    Trigger->SetStats(kFALSE);
351    Trigger->SetMarkerStyle(21);    Trigger->SetMarkerStyle(21);
352    Trigger->SetMarkerSize(.7);    Trigger->SetMarkerSize(.4);
353    Trigger->SetMarkerColor(4);    Trigger->SetMarkerColor(4);
354    Trigger->GetYaxis()->SetTitle("Number of Neutrons");    Trigger->GetYaxis()->SetTitle("Number of Neutrons");
355    Trigger->GetYaxis()->SetTitleSize(0.06);    Trigger->GetYaxis()->SetTitleSize(0.06);
# Line 364  void ND_QL(TString base, TString outDir, Line 366  void ND_QL(TString base, TString outDir,
366    triggerCanv->cd(3);    triggerCanv->cd(3);
367    Triggercut->SetStats(kFALSE);    Triggercut->SetStats(kFALSE);
368    Triggercut->SetMarkerStyle(21);    Triggercut->SetMarkerStyle(21);
369    Triggercut->SetMarkerSize(.7);    Triggercut->SetMarkerSize(.4);
370    Triggercut->SetMarkerColor(4);    Triggercut->SetMarkerColor(4);
371    Triggercut->GetYaxis()->SetTitle("Number of Neutrons");    Triggercut->GetYaxis()->SetTitle("Number of Neutrons");
372    Triggercut->GetYaxis()->SetTitleSize(0.06);    Triggercut->GetYaxis()->SetTitleSize(0.06);
# Line 408  int main(int argc, char* argv[]){ Line 410  int main(int argc, char* argv[]){
410    TString path;    TString path;
411    TString outDir        ="./";    TString outDir        ="./";
412    TString format        ="jpg";    TString format        ="jpg";
413    ULong_t DeltaT        =1000;    ULong_t DeltaT        =1000;//era 1000
414    ULong_t DeltaTevtime  =5;    Double_t DeltaTevtime  =1;
415            
416   if (argc < 2){   if (argc < 2){
417      printf("You have to insert at least the file to analyze \n");      printf("You have to insert at least the file to analyze \n");
# Line 422  int main(int argc, char* argv[]){ Line 424  int main(int argc, char* argv[]){
424          printf( "\t -outDir[path]           Path where to put the output [default ./] \n");          printf( "\t -outDir[path]           Path where to put the output [default ./] \n");
425          printf( "\t -format[jpg|gif|ps]     Format for output files [default 'jpg'] \n");          printf( "\t -format[jpg|gif|ps]     Format for output files [default 'jpg'] \n");
426          printf( "\t -DeltaT                 Time interval to bin histograms in ms [default = 1000ms] \n");          printf( "\t -DeltaT                 Time interval to bin histograms in ms [default = 1000ms] \n");
427          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");
428          exit(1);          exit(1);
429    }    }
430    path=argv[1];    path=argv[1];
# Line 467  int main(int argc, char* argv[]){ Line 469  int main(int argc, char* argv[]){
469           exit(1);           exit(1);
470         }         }
471         else{         else{
472           DeltaTevtime = atol(argv[i]);           DeltaTevtime = atof(argv[i]);
473           continue;           continue;
474         }         }
475       }       }
# Line 476  int main(int argc, char* argv[]){ Line 478  int main(int argc, char* argv[]){
478     ND_QL(argv[1], outDir, format, DeltaT, DeltaTevtime);     ND_QL(argv[1], outDir, format, DeltaT, DeltaTevtime);
479  }  }
480    
   

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.23