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

Diff of /quicklook/QLflightS4_ND/S4_QL.cpp

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

revision 1.3 by pam-rm2, Wed Jul 12 09:06:35 2006 UTC revision 1.5 by pam-rm2, Mon Sep 25 08:42:56 2006 UTC
# Line 28  Line 28 
28  *             in a pad  *             in a pad
29  *  *
30  *             for a large namber of events is not possible to have vectors, so all graphs have been converted in histograms  *             for a large namber of events is not possible to have vectors, so all graphs have been converted in histograms
31    *
32    * Version 2.0 - September 2006
33    * Fixed bugs: changed the number of bin in the "rate" histograms and the size of the string vector trcss
34  *******/  *******/
35    
36    
# Line 59  Line 62 
62  using namespace std;  using namespace std;
63    
64  void S4_QL(TString base, TString outDir, TString format, ULong_t DeltaT){  //DeltaT in minute  void S4_QL(TString base, TString outDir, TString format, ULong_t DeltaT){  //DeltaT in minute
65      
66    //------ Variables initialization ---------/    //------ Variables initialization ---------/
67    Int_t tmpSize;    Int_t tmpSize;
68    ULong_t mintime, maxtime;    ULong_t mintime, maxtime;
# Line 74  void S4_QL(TString base, TString outDir, Line 77  void S4_QL(TString base, TString outDir,
77    TString str;    TString str;
78    TString trcsstot[31];    TString trcsstot[31];
79    TString trcsstot2;    TString trcsstot2;
80    TString trcss[100]="";    
81    TString trgconf[31]={"TOF1","TOF2","TOF3","TOF4","TOF5","TOF6","TOF7","S4","CALO","CALO-S4","TOF1-S4","TOF2-S4","TOF3-S4","TOF4-S4","TOF5-S4","TOF6-S4","TOF7-S4","TOF1-CALO","TOF2-CALO","TOF3-CALO","TOF4-CALO","TOF5-CALO","TOF6-CALO","TOF7-CALO","TOF1-CALO-S4","TOF2-CALO-S4","TOF3-CALO-S4","TOF4-CALO-S4","TOF5-CALO-S4","TOF6-CALO-S4","TOF7-CALO-S4",};    TString trgconf[31]={"TOF1","TOF2","TOF3","TOF4","TOF5","TOF6","TOF7","S4","CALO","CALO-S4","TOF1-S4","TOF2-S4","TOF3-S4","TOF4-S4","TOF5-S4","TOF6-S4","TOF7-S4","TOF1-CALO","TOF2-CALO","TOF3-CALO","TOF4-CALO","TOF5-CALO","TOF6-CALO","TOF7-CALO","TOF1-CALO-S4","TOF2-CALO-S4","TOF3-CALO-S4","TOF4-CALO-S4","TOF5-CALO-S4","TOF6-CALO-S4","TOF7-CALO-S4",};
82    stringstream oss, oss1, oss2, oss3, s4soglia, buffer, conftrig, noentries;    stringstream oss, oss1, oss2, oss3, s4soglia, buffer, conftrig, noentries;
83    ULong_t lastime, firstime;    ULong_t lastime, firstime;
84    Int_t vardumpentries = 0;    Int_t vardumpentries = 0;
85      Int_t channels = 4096;
86    char S4_TRH[10];    char S4_TRH[10];
87    char S4_TRH2[10];    char S4_TRH2[10];
88    Int_t trigconf = 0;    Int_t trigconf = 0;
# Line 88  void S4_QL(TString base, TString outDir, Line 92  void S4_QL(TString base, TString outDir,
92    double obmax=0.;    double obmax=0.;
93    double obt;    double obt;
94    double s4rate;    double s4rate;
   int nbin=0;  
95    //------to open headerfile, s4file, Trigfile and vardumpfile---------------------------/    //------to open headerfile, s4file, Trigfile and vardumpfile---------------------------/
96    TFile  *file  =new TFile(base.Data()) ;    TFile  *file  =new TFile(base.Data()) ;
97    if (!file){    if (!file){
# Line 98  void S4_QL(TString base, TString outDir, Line 101  void S4_QL(TString base, TString outDir,
101        
102    TTree *VarDumpTr = (TTree*)file->Get("VarDump");    TTree *VarDumpTr = (TTree*)file->Get("VarDump");
103    TTree *PhysicsTr = (TTree*)file->Get("Physics");    TTree *PhysicsTr = (TTree*)file->Get("Physics");
104      
105    TBranch *S4Br = PhysicsTr->GetBranch("S4");    TBranch *S4Br = PhysicsTr->GetBranch("S4");
106    TBranch *TriggerBr = PhysicsTr->GetBranch("Trigger");    TBranch *TriggerBr = PhysicsTr->GetBranch("Trigger");
107    TBranch *headBr = PhysicsTr->GetBranch("Header");    TBranch *headBr = PhysicsTr->GetBranch("Header");
108    TBranch *VarDumpBr = VarDumpTr->GetBranch("VarDump");    TBranch *VarDumpBr = VarDumpTr->GetBranch("VarDump");
109    TBranch *headVarDumpBr = VarDumpTr->GetBranch("Header");    TBranch *headVarDumpBr = VarDumpTr->GetBranch("Header");
110      
111    pamela::S4::S4Event  *s4e  = 0;    pamela::S4::S4Event  *s4e  = 0;
112    pamela::EventHeader  *eh   = 0;    pamela::EventHeader  *eh   = 0;
113    pamela::PscuHeader   *ph   = 0;    pamela::PscuHeader   *ph   = 0;
# Line 117  void S4_QL(TString base, TString outDir, Line 120  void S4_QL(TString base, TString outDir,
120    PhysicsTr->SetBranchAddress("Trigger", &trige);    PhysicsTr->SetBranchAddress("Trigger", &trige);
121    VarDumpTr->SetBranchAddress("VarDump", &vde);    VarDumpTr->SetBranchAddress("VarDump", &vde);
122    
123    nevents = headBr->GetEntries();    nevents = S4Br->GetEntries();
   const Int_t sizetot = nevents;  
124    
125    //----------- If nevents < = 0 ---------------------------------/    //----------- If nevents < = 0 ---------------------------------/
126    if (nevents<=0) {    if (nevents<=0) {
127      printf("nevents = %i \n", nevents);      printf("nevents = %i \n", nevents);
128      printf(" \n");      printf(" \n");
129        
130      TCanvas *canvas4 = new TCanvas("No entries", "No entries ", 400, 200);      TCanvas *canvas4 = new TCanvas("No entries", "No entries ", 400, 200);
131      canvas4->SetFillColor(10);      canvas4->SetFillColor(10);
132      canvas4->cd();      canvas4->cd();
# Line 139  void S4_QL(TString base, TString outDir, Line 141  void S4_QL(TString base, TString outDir,
141      noentries.str("");      noentries.str("");
142      noentries<< "No entries for this files";      noentries<< "No entries for this files";
143      l->DrawLatex(0.05, 0.5, noentries.str().c_str());      l->DrawLatex(0.05, 0.5, noentries.str().c_str());
144        
145      if (outDir == "./") {      if (outDir == "./") {
146        oss.str("");        oss.str("");
147        oss << filename.Data() << "_S4_QL." << format.Data();        oss << filename.Data() << "_S4_QL." << format.Data();
# Line 147  void S4_QL(TString base, TString outDir, Line 149  void S4_QL(TString base, TString outDir,
149        oss.str("");        oss.str("");
150        oss << outDir.Data() << filename.Data() << "_S4_QL." << format.Data();        oss << outDir.Data() << filename.Data() << "_S4_QL." << format.Data();
151      }      }
152          
153      canvas4->Update();      canvas4->Update();
154      canvas4->SaveAs(oss.str().c_str());      canvas4->SaveAs(oss.str().c_str());
155        
156      return;      return;
157    }    }
158      const Int_t ev = nevents;
159    for (Int_t i = 0; i < nevents; i++){    TString trcss[ev];
160      headBr->GetEntry(i);    //-------to set trigger configuration---------------------------------//
161      S4Br->GetEntry(i);    for (Int_t ll = 0; ll < nevents; ll++){
162      TriggerBr->GetEntry(i);      TriggerBr->GetEntry(ll);
     if (s4e->unpackError == 1 || s4e->S4_DATA==0)  continue;        
     //-------to set max adc value------------------------------------------//  
     if (i==0){  
       adcmax=s4e->S4_DATA;  
     }  
     //-------to set trigger configuration---------------------------------//  
     if ((s4e->S4_DATA)> adcmax) adcmax=(s4e->S4_DATA);  
163      trigconf = trige->trigconf;      trigconf = trige->trigconf;
164      trc = 0;      trc = 0;
165      if ( trigconf & (1<<0) ) trc = "TOF1";      if ( trigconf & (1<<0) ) trc = "TOF1";
# Line 179  void S4_QL(TString base, TString outDir, Line 174  void S4_QL(TString base, TString outDir,
174      if ( trigconf & (1<<3) ) {      if ( trigconf & (1<<3) ) {
175        if (trc==0) trc= "TOF4";        if (trc==0) trc= "TOF4";
176        else trc = Form("%s-TOF4",trc);        else trc = Form("%s-TOF4",trc);
177      }      }  
178      if ( trigconf & (1<<4) ) {      if ( trigconf & (1<<4) ) {
179        if (trc==0) trc= "TOF5";        if (trc==0) trc= "TOF5";
180        else trc = Form("%s-TOF5",trc);        else trc = Form("%s-TOF5",trc);
181      }      }  
182      if ( trigconf & (1<<5) ) {      if ( trigconf & (1<<5) ) {
183        if (trc==0) trc= "TOF6";        if (trc==0) trc= "TOF6";
184        else trc = Form("%s-TOF6",trc);        else trc = Form("%s-TOF6",trc);
185      }      }
186      if ( trigconf & (1<<6) ) {      if ( trigconf & (1<<6) ) {
187        if (trc==0) trc= "TOF7";        if (trc==0) trc= "TOF7";
188        else trc = Form("%s-TOF7",trc);        else trc = Form("%s-TOF7",trc);
# Line 196  void S4_QL(TString base, TString outDir, Line 191  void S4_QL(TString base, TString outDir,
191        if (trc==0) trc= "S4";        if (trc==0) trc= "S4";
192        else trc = Form("%s-S4",trc);        else trc = Form("%s-S4",trc);
193      }      }
194      if ( trigconf & (1<<8) ) {     if ( trigconf & (1<<8) ) {
195        if (trc==0) trc= "CALO";       if (trc==0) trc= "CALO";
196        else trc = Form("%s-CALO",trc);       else trc = Form("%s-CALO",trc);
197      }     }
198      if ( trigconf & (1<<9) ) {     if ( trigconf & (1<<9) ) {
199        if (trc==0) trc= "CALIB_ON";       if (trc==0) trc= "CALIB_ON";
200        else trc = Form("%s-CALIB_ON",trc);       else trc = Form("%s-CALIB_ON",trc);
201      }     }  
202      trcs = "";     trcs = "";
203      trcs = trc;     trcs = trc;
204      if (i==0){     if (ll==0){
205        trcss[0]=trcs;       trcss[0]=trcs;
206        j=j+1;       j=j+1;
207      }     }
208      if (trcs!=trcss[j-1] && i>0){     if (trcs!=trcss[j-1] && ll>0){
209        trcss[j]=trcs;       trcss[j]=trcs;
210        j=j+1;       j=j+1;
211      }     }
212       //cout<<i<<"\n";
213       //cout<<nevents<<"\n\n";
214    }    }
215      //--------------------------//
216    for(Int_t k=0; k<31; k++){    for(Int_t k=0; k<31; k++){
217      for(Int_t p=0; p<j ; p++){      for(Int_t p=0; p<j ; p++){
218        if(trgconf[k]==trcss[p]){        if(trgconf[k]==trcss[p]){
# Line 226  void S4_QL(TString base, TString outDir, Line 224  void S4_QL(TString base, TString outDir,
224      if(trcsstot[k]!= "")      if(trcsstot[k]!= "")
225        trcsstot2=trcsstot2+"/"+ trcsstot[k];        trcsstot2=trcsstot2+"/"+ trcsstot[k];
226    }    }
227      
228    //---------to search S4 threshold and convert it into char (hexadecimal value)--------//    //---------to search S4 threshold and convert it into char (hexadecimal value)--------//
229    vardumpentries =  VarDumpBr->GetEntries();    vardumpentries =  VarDumpBr->GetEntries();
230    if(vardumpentries==0){    if(vardumpentries==0){
# Line 250  void S4_QL(TString base, TString outDir, Line 249  void S4_QL(TString base, TString outDir,
249        }        }
250        sprintf(S4_TRH, "%d" , S4_TRHmip);        sprintf(S4_TRH, "%d" , S4_TRHmip);
251      }      }
252    }      }
253    
254    //********************** First Histogram ************************************//    //********************** First Histogram ************************************//
255    TH1F *h1 = new TH1F("All events", "S4 distribution for file: "+filename, adcmax, 10, adcmax+(adcmax/10));    TH1F *h1 = new TH1F("All events", "S4 distribution for file: "+filename, channels, 1, channels);
256    TH1F *h2 = new TH1F("S4 Triggered events", "S4 distribution for file: "+filename, adcmax, 10, adcmax+(adcmax/10));    TH1F *h2 = new TH1F("S4 Triggered events", "S4 distribution for file: "+filename, channels, 1, channels);
257    
258    //********************** Second Histogram ************************************//    //********************** Second Histogram ************************************//
259    headBr->GetEntry(0);    headBr->GetEntry(0);
260    ph = eh->GetPscuHeader();    ph = eh->GetPscuHeader();
261    firstime = ph->GetOrbitalTime();    firstime = ph->GetOrbitalTime();
262    
263    for (Int_t i = 0; i < nevents; i++){    int iii =0;
264      headBr->GetEntry(i);    while(iii < nevents){
265        headBr->GetEntry(iii);
266      ph = eh->GetPscuHeader();      ph = eh->GetPscuHeader();
267      if((ph->GetOrbitalTime()) <= firstime) firstime=ph->GetOrbitalTime();      if((ph->GetOrbitalTime()) <= firstime) firstime=ph->GetOrbitalTime();
268      if((ph->GetOrbitalTime()) >= lastime) lastime=ph->GetOrbitalTime();      if((ph->GetOrbitalTime()) >= lastime) lastime=ph->GetOrbitalTime();
269        iii++;
270    }    }
271      
272    obmin=firstime;    obmin=firstime;
273    obmax=lastime;      obmax=lastime;  
274    const ULong_t nint=(((lastime-firstime)/(DeltaT*60000)));    const ULong_t nint=(((lastime-firstime)/(DeltaT*60000)));
# Line 278  void S4_QL(TString base, TString outDir, Line 280  void S4_QL(TString base, TString outDir,
280    TH1F *S4time = new TH1F("Mean signal from S4-triggered events", filename+": Mean signal from S4 (only s4 triggered events)", size, obmin, obmax);      TH1F *S4time = new TH1F("Mean signal from S4-triggered events", filename+": Mean signal from S4 (only s4 triggered events)", size, obmin, obmax);  
281    
282    //********************** Third Histogram ************************************//    //********************** Third Histogram ************************************//
   nbin=sizetot;  
283    title="";    title="";
284    title=filename+": S4 rate from Trigger Packet";    title=filename+": S4 rate from Trigger Packet";
285    
286    const ULong_t nint3=(lastime-firstime);    const ULong_t nint2=(lastime-firstime)/10000;
287    const Int_t size3 = (Int_t)((nint3)/100);    const Int_t size2 = (Int_t)((nint2+1)); // one bin every 10 second
288      const ULong_t nint3=(lastime-firstime)/1000;
289    TH1F *rate= new TH1F(title.c_str(), title.c_str(), nint3, obmin, obmax);    const Int_t size3 = (Int_t)((nint3+1)); // one bin every 1 second
290      TH1F *rate= new TH1F(title.c_str(), title.c_str(), size2, obmin, obmax);
291    TH1F *rateline= new TH1F(filename+". S4 rate from Trigger Packet: mean value over 100 events", filename+". S4 rate from Trigger Packet: mean value over 100 events", size3, obmin, obmax);    TH1F *rateline= new TH1F(filename+". S4 rate from Trigger Packet: mean value over 100 events", filename+". S4 rate from Trigger Packet: mean value over 100 events", size3, obmin, obmax);
292    
293    //------------------------------------------------------------------------------------------------------------------    //------------------------------------------------------------------------------------------------------------------
# Line 296  void S4_QL(TString base, TString outDir, Line 298  void S4_QL(TString base, TString outDir,
298      headBr->GetEntry(i);      headBr->GetEntry(i);
299      S4Br->GetEntry(i);      S4Br->GetEntry(i);
300      ph = eh->GetPscuHeader();      ph = eh->GetPscuHeader();
     obt = ph->GetOrbitalTime();    
301      if (s4e->unpackError == 1 && (s4e->S4_DATA)==0)  continue;        if (s4e->unpackError == 1 && (s4e->S4_DATA)==0)  continue;  
302      s4rate= trige->s4calcount[0];      s4rate= trige->s4calcount[0];
303      rate->Fill(obt, s4rate);      rate->Fill(ph->GetOrbitalTime(), s4rate);
304      h1->Fill(s4e->S4_DATA);        h1->Fill(s4e->S4_DATA);  
305      Allev->Fill(obt,s4e->S4_DATA);      Allev->Fill(ph->GetOrbitalTime(),s4e->S4_DATA);
306      Alltime->Fill(obt);      Alltime->Fill(ph->GetOrbitalTime());
307      if ((trige->patterntrig[0] == 0) && (trige->patterntrig[1] != 0) &&(trige->patterntrig[2] == 0) && (trige->patterntrig[3] == 0) && (trige->patterntrig[4] == 0) && (trige->patterntrig[5] == 0)){      if ((trige->patterntrig[0] == 0)&&(trige->patterntrig[1] != 0)&&(trige->patterntrig[2] == 0)&&(trige->patterntrig[3] == 0)&&(trige->patterntrig[4] == 0)&&(trige->patterntrig[5] == 0)){
308        h2->Fill(s4e->S4_DATA);        h2->Fill(s4e->S4_DATA);
309        S4ev->Fill(obt,s4e->S4_DATA);        S4ev->Fill(ph->GetOrbitalTime(),s4e->S4_DATA);
310        S4time->Fill(obt);        S4time->Fill(ph->GetOrbitalTime());
311        p=p+1;        p=p+1;
312      }      }
313    }    }
# Line 462  void S4_QL(TString base, TString outDir, Line 463  void S4_QL(TString base, TString outDir,
463    Allev->GetXaxis()->CenterTitle();    Allev->GetXaxis()->CenterTitle();
464    Allev->GetYaxis()->SetTitle("Mean signal ( ADC )");    Allev->GetYaxis()->SetTitle("Mean signal ( ADC )");
465    Allev->GetYaxis()->CenterTitle();    Allev->GetYaxis()->CenterTitle();
466    Allev->SetMinimum(20);    //Allev->SetMinimum(20);
467    Allev->Divide(Alltime);    Allev->Divide(Alltime);
468    Allev->Draw("p");    Allev->Draw("p");
469    pad3->Draw();    pad3->Draw();

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.23