/[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 by pam-rm2, Thu Jun 15 14:00:30 2006 UTC revision 1.2 by pam-rm2, Fri Jun 23 16:06:09 2006 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=0, obt1=0;
65    Double_t scale= 1./DeltaTevtime;    Double_t scale= 1./DeltaTevtime;
66    string title, title1;    stringstream title, title1;
67    double obt;      double obt;  
68    Float_t     cut;    Float_t     cut;
69    stringstream oss, noentries;    stringstream oss, noentries;
# Line 132  void ND_QL(TString base, TString outDir, Line 132  void ND_QL(TString base, TString outDir,
132    }    }
133    
134    //------------ first and last  events ->  nbin ---------------------------------//    //------------ first and last  events ->  nbin ---------------------------------//
135    phystr->GetEntry(0);     for (Int_t i = 0; i < nevents; i++){
136    ph = eh->GetPscuHeader();      headBr->GetEntry(i);
137    firstime = ph->GetOrbitalTime();        ph = eh->GetPscuHeader();
138    phystr->GetEntry(nevents-1);      obt1 = ph->GetOrbitalTime();
139    ph = eh->GetPscuHeader();      if(obt1 <= firstime) firstime=obt1;
140    lastime = ph->GetOrbitalTime();      if(obt1 >= lastime) lastime=obt1;
141    const ULong_t nint=((lastime-firstime)/(DeltaTevtime*60000));     }
142    const ULong_t nint1=((lastime-firstime)/(DeltaT));  
143    const ULong_t nint2=lastime-firstime;    const Double_t nint=((lastime-firstime)/(DeltaTevtime*60000));
144      const Double_t nint1=((lastime-firstime)/(DeltaT));//
145      const Double_t nint2=lastime-firstime;
146    int nbin=(int)nint;    int nbin=(int)nint;
147    int nbin1=(int)nint1;    int nbin1=(int)nint1;
148    int nbin2=(int)nint2;    int nbin2=(int)nint2;
# Line 150  void ND_QL(TString base, TString outDir, Line 152  void ND_QL(TString base, TString outDir,
152    //************************** HISTOGRAMS ***************************************************//    //************************** HISTOGRAMS ***************************************************//
153    //---------------------------- First histograms -----------------------------------------//    //---------------------------- First histograms -----------------------------------------//
154    oss.str("");    oss.str("");
155    oss <<"Bottom Background Neutrons with poissionian fit (DeltaT = " << DeltaT << " ms)";    oss <<"Distribution of Bottom Background Neutrons collected in DeltaT = " << DeltaT << " ms";
156    oss1.str("");    oss1.str("");
157    oss1 <<"Upper Background Neutrons with poissionian fit (DeltaT = " << DeltaT << " ms)";    oss1 <<"Distribution of Upper Background Neutrons collected in DeltaT = " << DeltaT << " ms";
158    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);
159    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);  
160    //---------------------------- Second histograms -----------------------------------------//    //---------------------------- Second histograms -----------------------------------------//
161    title="";    title.str("");
162    title=filename+":  Bottom Background & Upper Background: Time Evolution (DT="+DeltaTevtime+" min)";    title<<filename<<":  Bottom Background & Upper Background: Time Evolution (DT="<<DeltaTevtime<<" min)";
163    title1="";    title1.str("");
164    title1=filename+". Ratio: UpperBackground / BottomBackground: Time Evolution (DT="+DeltaTevtime+" min)";    title1<<filename<<". Ratio: UpperBackground / BottomBackground: Time Evolution (DT="<<DeltaTevtime<<" min)";
165    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);
166    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);
167    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);
168    //---------------------------- Third histograms -----------------------------------------//    //---------------------------- Third histograms -----------------------------------------//
169    
170    oss.str("");    oss.str("");
# Line 206  void ND_QL(TString base, TString outDir, Line 206  void ND_QL(TString base, TString outDir,
206      yTrig=0;      yTrig=0;
207    }    }
208    
209    for (Int_t i = 0; i < nevents; i++){  
210      Int_t newBin1=(int)((h1->GetMaximum())-(h1->GetMinimum()));
211      Int_t newBin3=(int)((h3->GetMaximum())-(h3->GetMinimum()));
212      oss.str("");
213      oss <<"Distribution of Bottom Background Neutrons collected in DeltaT = " << DeltaT << " ms";
214      oss1.str("");
215      oss1 <<"Distribution of Upper Background Neutrons collected in DeltaT = " << DeltaT << " ms";
216      TH1F *h1bis = new TH1F (filename.Data(), oss.str().c_str(), newBin1, h1->GetMinimum(), h1->GetMaximum());
217      TH1F *h3bis = new TH1F (filename.Data(), oss1.str().c_str(), newBin3, h3->GetMinimum(), h3->GetMaximum());
218      for (Int_t i = 0; i < nbin1; i++){
219      h1bis->Fill(h1->GetBinContent(i));      h1bis->Fill(h1->GetBinContent(i));
220      h3bis->Fill(h3->GetBinContent(i));      h3bis->Fill(h3->GetBinContent(i));
221    }        }
222    
223    //********************************* CANVASES ************************************************//    //********************************* CANVASES ************************************************//
224    //--------------------------------- First canvas --------------------------------------------//    //--------------------------------- First canvas --------------------------------------------//
# Line 225  void ND_QL(TString base, TString outDir, Line 234  void ND_QL(TString base, TString outDir,
234    h1bis->GetXaxis()->CenterTitle();    h1bis->GetXaxis()->CenterTitle();
235    h1bis->GetYaxis()->SetTitle("Number of events");    h1bis->GetYaxis()->SetTitle("Number of events");
236    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");  
237    h1bis->Draw();    h1bis->Draw();
238    
239    histoCanv->cd(2);    histoCanv->cd(2);
# Line 243  void ND_QL(TString base, TString outDir, Line 244  void ND_QL(TString base, TString outDir,
244    h3bis->GetXaxis()->CenterTitle();    h3bis->GetXaxis()->CenterTitle();
245    h3bis->GetYaxis()->SetTitle("Number of events");    h3bis->GetYaxis()->SetTitle("Number of events");
246    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");  
247    h3bis->Draw();    h3bis->Draw();
248        
249    //---------------------------------- Second Canvas -----------------------------------------//    //---------------------------------- Second Canvas -----------------------------------------//
# Line 262  void ND_QL(TString base, TString outDir, Line 255  void ND_QL(TString base, TString outDir,
255    histo1->SetStats(kFALSE);    histo1->SetStats(kFALSE);
256    histo1->GetYaxis()->SetTitle("Number of recorded Neutrons / DT   (min^-1) ");    histo1->GetYaxis()->SetTitle("Number of recorded Neutrons / DT   (min^-1) ");
257    histo1->GetYaxis()->SetTitleSize(0.04);    histo1->GetYaxis()->SetTitleSize(0.04);
258    histo1->GetYaxis()->SetTitleOffset(0.5);    histo1->GetYaxis()->SetTitleOffset(1);
259    histo1->GetYaxis()->CenterTitle();    histo1->GetYaxis()->CenterTitle();
260    histo1->GetYaxis()->SetLabelSize(0.03);    histo1->GetYaxis()->SetLabelSize(0.03);
261    histo1->GetXaxis()->CenterTitle();    histo1->GetXaxis()->CenterTitle();
# Line 408  int main(int argc, char* argv[]){ Line 401  int main(int argc, char* argv[]){
401    TString path;    TString path;
402    TString outDir        ="./";    TString outDir        ="./";
403    TString format        ="jpg";    TString format        ="jpg";
404    ULong_t DeltaT        =1000;    ULong_t DeltaT        =1000;//era 1000
405    ULong_t DeltaTevtime  =5;    Double_t DeltaTevtime  =5;
406            
407   if (argc < 2){   if (argc < 2){
408      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 415  int main(int argc, char* argv[]){
415          printf( "\t -outDir[path]           Path where to put the output [default ./] \n");          printf( "\t -outDir[path]           Path where to put the output [default ./] \n");
416          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");
417          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");
418          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");
419          exit(1);          exit(1);
420    }    }
421    path=argv[1];    path=argv[1];
# Line 467  int main(int argc, char* argv[]){ Line 460  int main(int argc, char* argv[]){
460           exit(1);           exit(1);
461         }         }
462         else{         else{
463           DeltaTevtime = atol(argv[i]);           DeltaTevtime = atof(argv[i]);
464           continue;           continue;
465         }         }
466       }       }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.23