/[PAMELA software]/quicklook/tracker/flight/macros/FTrkCalibQLook_BASIC.cxx
ViewVC logotype

Diff of /quicklook/tracker/flight/macros/FTrkCalibQLook_BASIC.cxx

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

revision 1.1 by pam-fi, Wed May 10 10:06:54 2006 UTC revision 1.10 by pam-fi, Thu Mar 8 01:41:02 2007 UTC
# Line 2  Line 2 
2   * FTrkCalibQLook_BASIC.cxx   * FTrkCalibQLook_BASIC.cxx
3   *   *
4   * autor: D.Fedele   * autor: D.Fedele
5   * version 2.0   * version v1r11
6   * Parameters:   * Parameters:
7   *      file - the data file to analyze   *      file - the data file to analyze
8   *      fromevent - first event to analyze   *      fromevent - first event to analyze
# Line 15  Line 15 
15  #include <TLatex.h>  #include <TLatex.h>
16  #include <TCanvas.h>  #include <TCanvas.h>
17  #include <TGraph.h>  #include <TGraph.h>
18    #include <TFile.h>
19  #include <TTree.h>  #include <TTree.h>
20  #include <TStyle.h>  #include <TStyle.h>
21  #include <TString.h>  #include <TString.h>
# Line 25  Line 26 
26  #include <CalibTrk2Event.h>  #include <CalibTrk2Event.h>
27  //  //
28    
29  void stringcopy(TString& s1, const TString& s2, Int_t from=0, Int_t to=0){      typedef struct caltrk_def{
     if ( to == 0 ){  
         Int_t t2length = s2.Length();  
         s1 = "";  
         to = t2length;  
     };  
     for (Int_t i = from; i<to; i++){  
         s1.Append(s2[i],1);  
     };  
 };  
   
  typedef struct caltrk_def{  
30    Int_t good0[2];    Int_t good0[2];
31    Int_t daqmode[12];    Int_t daqmode[12];
32    Int_t dspnum[12];    Int_t dspnum[12];
# Line 64  void FTrkCalibQLook_BASIC(TString file,I Line 54  void FTrkCalibQLook_BASIC(TString file,I
54  {  {
55    //    //
56    //   obtain information about the data file and select the output dir    //   obtain information about the data file and select the output dir
57    const string filepath=file.Data();    Int_t dwpos = file.Last('/');
58    Int_t dwpos = filepath.rfind("DW_");    Int_t dwpos1 = file.Last('.');
59    Int_t dwpos1 = filepath.find(".root");    TString base,ffile ;
60    TString fpath=(filepath.c_str());    ffile=file(dwpos+1,dwpos1-(dwpos+1));
61    TString base,ffile;    if(dwpos>0) base=file(0,dwpos);
   stringcopy(base,fpath,0,dwpos);  
   stringcopy(ffile,fpath,dwpos,dwpos1);  
62    
63    TString out;    TString out;
64    if(outdir.Length()==0){    if(outdir.Length()==0){
# Line 78  void FTrkCalibQLook_BASIC(TString file,I Line 66  void FTrkCalibQLook_BASIC(TString file,I
66    }else{    }else{
67      out = outdir;      out = outdir;
68    };    };
69        if(out.Last('/')+1<out.Length()) out+="/";
70    
71    //    //
72    // inizialise the variables and open the file    // inizialise the variables and open the file
73    struct caltrk_def ctrk;    struct caltrk_def ctrk;
74    Int_t nevents=0;    Int_t nevents=0;
75    Int_t minevent = 0;    Int_t minevent = 0;
76    Int_t maxevent = 0;    Int_t maxevent = 0;
77    ULong64_t OBT[2];    ULong_t OBT[2];
78        
79    OBT[0]=0;    OBT[0]=0;
80    OBT[1]=0;    OBT[1]=0;
# Line 174  void FTrkCalibQLook_BASIC(TString file,I Line 163  void FTrkCalibQLook_BASIC(TString file,I
163      } else if (toevent > nevents) {              } else if (toevent > nevents) {        
164        maxevent = nevents;        maxevent = nevents;
165      } else {            } else {      
166        maxevent = fromevent;        maxevent = nevents;
167      };      };
168    };    };
169    
# Line 203  void FTrkCalibQLook_BASIC(TString file,I Line 192  void FTrkCalibQLook_BASIC(TString file,I
192    Int_t canvasx=900;    Int_t canvasx=900;
193    Int_t canvasy=1200;    Int_t canvasy=1200;
194    
195    Int_t ndsp =0,alarm=0;    Int_t alarm=0;
196    Float_t pedav[12][12],pedavtemp[12][12],sigav[12][12],sigavtemp[12][12];    Float_t pedav[12][12],pedavtemp[12][12],sigav[12][12],sigavtemp[12][12];
197    Int_t flpedav[12][12],flsigav[12][12];    Int_t flpedav[12][12],flsigav[12][12];
198    Float_t siglimsup[12][12],sigliminf[12][12],pedlimsup[12][12],pedliminf[12][12];    Float_t siglimsup[12][12],sigliminf[12][12],pedlimsup[12][12],pedliminf[12][12];
# Line 212  void FTrkCalibQLook_BASIC(TString file,I Line 201  void FTrkCalibQLook_BASIC(TString file,I
201    // inizialize the limits for simga and pedestall    // inizialize the limits for simga and pedestall
202    for(Int_t i=0;i<12;i++){    for(Int_t i=0;i<12;i++){
203      for(Int_t ii=0;ii<12;ii++){      for(Int_t ii=0;ii<12;ii++){
204        siglimsup[i][ii]=20.;        siglimsup[i][ii]=30.;
205        sigliminf[i][ii]=0.;        sigliminf[i][ii]=1.5;
206        pedlimsup[i][ii]=3500.;        if(!(i%2)){
207        pedliminf[i][ii]=50.;          pedlimsup[i][ii]=3700.;
208            pedliminf[i][ii]=1700.;
209          }
210          else{
211            pedlimsup[i][ii]=2200.;
212            pedliminf[i][ii]=200.;
213          }
214      }      }
215    }    }
216        
# Line 236  void FTrkCalibQLook_BASIC(TString file,I Line 231  void FTrkCalibQLook_BASIC(TString file,I
231        if(trk2->cal_flag[m]!=0) alarm+=1;        if(trk2->cal_flag[m]!=0) alarm+=1;
232      }        }  
233    }    }
234    const Int_t cnum=alarm/30 + 10;    const Int_t cnum=alarm/30 + 100;
235    Int_t flcanvas=1;    Int_t flcanvas=1;
236    Float_t spacep=1.5,space[cnum];    Float_t spacep=1.5,space[cnum];
237    TCanvas *c[cnum];    TCanvas *c[cnum];
     
238    //    //
239    //  create output canvas      //  create output canvas  
240    for(Int_t i=0;i<cnum;i++){    for(Int_t i=0;i<cnum;i++){
# Line 251  void FTrkCalibQLook_BASIC(TString file,I Line 245  void FTrkCalibQLook_BASIC(TString file,I
245      rep<<"FTrkCalibQLook_BASIC_pag"<<i+1;      rep<<"FTrkCalibQLook_BASIC_pag"<<i+1;
246      c[i]=new TCanvas(tit.str().c_str(),rep.str().c_str(),canvasx,canvasy);      c[i]=new TCanvas(tit.str().c_str(),rep.str().c_str(),canvasx,canvasy);
247      c[i]->Range(0,0,100,100);      c[i]->Range(0,0,100,100);
248        c[i]->SetFillColor(10);
249      tzz->DrawLatex(1,98.5,fromfile.str().c_str());      tzz->DrawLatex(1,98.5,fromfile.str().c_str());
250      rep.str("");      rep.str("");
251      rep<<"CALIBRATION REPORT pag"<<i+1;      rep<<"CALIBRATION REPORT pag"<<i+1;
# Line 277  void FTrkCalibQLook_BASIC(TString file,I Line 272  void FTrkCalibQLook_BASIC(TString file,I
272      for (Int_t m = 0; m < 6; m++){      for (Int_t m = 0; m < 6; m++){
273        ph1 = eh1->GetPscuHeader();        ph1 = eh1->GetPscuHeader();
274        OBT[0]= ph1->GetOrbitalTime();        OBT[0]= ph1->GetOrbitalTime();
275        ctrk.daqmode[trk1->DSPnumber[m]-1]=trk1->DAQmode[m];        if(trk1->DSPnumber[m]>0){
276        ctrk.dspnum[trk1->DSPnumber[m]-1]=trk1->DSPnumber[m];          if(trk1->DSPnumber[m]<13){
277        ctrk.calibnum[trk1->DSPnumber[m]-1]=trk1->calibnumber[m];            ctrk.daqmode[trk1->DSPnumber[m]-1]=trk1->DAQmode[m];
278        ctrk.ncalev[trk1->DSPnumber[m]-1]=trk1->ncalib_event[m];            ctrk.dspnum[trk1->DSPnumber[m]-1]=trk1->DSPnumber[m];
279        ctrk.ped1[trk1->DSPnumber[m]-1]=trk1->ped_l1[m];            ctrk.calibnum[trk1->DSPnumber[m]-1]=trk1->calibnumber[m];
280        ctrk.ped2[trk1->DSPnumber[m]-1]=trk1->ped_l2[m];            ctrk.ncalev[trk1->DSPnumber[m]-1]=trk1->ncalib_event[m];
281        ctrk.ped3[trk1->DSPnumber[m]-1]=trk1->ped_l3[m];            ctrk.ped1[trk1->DSPnumber[m]-1]=trk1->ped_l1[m];
282        ctrk.sig1[trk1->DSPnumber[m]-1]=trk1->sig_l1[m];            ctrk.ped2[trk1->DSPnumber[m]-1]=trk1->ped_l2[m];
283        ctrk.sig2[trk1->DSPnumber[m]-1]=trk1->sig_l2[m];            ctrk.ped3[trk1->DSPnumber[m]-1]=trk1->ped_l3[m];
284        ctrk.sig3[trk1->DSPnumber[m]-1]=trk1->sig_l3[m];            ctrk.sig1[trk1->DSPnumber[m]-1]=trk1->sig_l1[m];
285        ctrk.nbad1[trk1->DSPnumber[m]-1]=trk1->nbad_l1[m];            ctrk.sig2[trk1->DSPnumber[m]-1]=trk1->sig_l2[m];
286        ctrk.nbad2[trk1->DSPnumber[m]-1]=trk1->nbad_l2[m];            ctrk.sig3[trk1->DSPnumber[m]-1]=trk1->sig_l3[m];
287        ctrk.nbad3[trk1->DSPnumber[m]-1]=trk1->nbad_l3[m];            ctrk.nbad1[trk1->DSPnumber[m]-1]=trk1->nbad_l1[m];
288        ctrk.calfl[trk1->DSPnumber[m]-1]=trk1->cal_flag[m];            ctrk.nbad2[trk1->DSPnumber[m]-1]=trk1->nbad_l2[m];
289        ctrk.crc_c[trk1->DSPnumber[m]-1][0]=trk1->crc_cal[m][0];            ctrk.nbad3[trk1->DSPnumber[m]-1]=trk1->nbad_l3[m];
290        ctrk.crc_c[trk1->DSPnumber[m]-1][1]=trk1->crc_cal[m][1];            ctrk.calfl[trk1->DSPnumber[m]-1]=trk1->cal_flag[m];
291        ctrk.crc_c[trk1->DSPnumber[m]-1][2]=trk1->crc_cal[m][2];            ctrk.crc_c[trk1->DSPnumber[m]-1][0]=trk1->crc_cal[m][0];
292        ctrk.crc_hc[trk1->DSPnumber[m]-1]=trk1->crc_hcal[m];            ctrk.crc_c[trk1->DSPnumber[m]-1][1]=trk1->crc_cal[m][1];
293        for (Int_t j = 0; j < 3072; j++){            ctrk.crc_c[trk1->DSPnumber[m]-1][2]=trk1->crc_cal[m][2];
294          ctrk.dspped[trk1->DSPnumber[m]-1][j]=trk1->DSPped_par[m][j];            ctrk.crc_hc[trk1->DSPnumber[m]-1]=trk1->crc_hcal[m];
295          ctrk.dspsig[trk1->DSPnumber[m]-1][j]=trk1->DSPsig_par[m][j];            for (Int_t j = 0; j < 3072; j++){
296          ctrk.dspbad[trk1->DSPnumber[m]-1][j]=trk1->DSPbad_par[m][j];              ctrk.dspped[trk1->DSPnumber[m]-1][j]=trk1->DSPped_par[m][j];
297                ctrk.dspsig[trk1->DSPnumber[m]-1][j]=trk1->DSPsig_par[m][j];
298                ctrk.dspbad[trk1->DSPnumber[m]-1][j]=trk1->DSPbad_par[m][j];
299              }
300            }
301        }        }
302        ph2 = eh2->GetPscuHeader();        ph2 = eh2->GetPscuHeader();
303        OBT[1]= ph2->GetOrbitalTime();        OBT[1]= ph2->GetOrbitalTime();
304        ctrk.daqmode[trk2->DSPnumber[m]-1]=trk2->DAQmode[m];        if(trk2->DSPnumber[m]>0){
305        ctrk.dspnum[trk2->DSPnumber[m]-1]=trk2->DSPnumber[m];          if(trk2->DSPnumber[m]<13){
306        ctrk.calibnum[trk2->DSPnumber[m]-1]=trk2->calibnumber[m];            ctrk.daqmode[trk2->DSPnumber[m]-1]=trk2->DAQmode[m];
307        ctrk.ncalev[trk2->DSPnumber[m]-1]=trk2->ncalib_event[m];            ctrk.dspnum[trk2->DSPnumber[m]-1]=trk2->DSPnumber[m];
308        ctrk.ped1[trk2->DSPnumber[m]-1]=trk2->ped_l1[m];            ctrk.calibnum[trk2->DSPnumber[m]-1]=trk2->calibnumber[m];
309        ctrk.ped2[trk2->DSPnumber[m]-1]=trk2->ped_l2[m];            ctrk.ncalev[trk2->DSPnumber[m]-1]=trk2->ncalib_event[m];
310        ctrk.ped3[trk2->DSPnumber[m]-1]=trk2->ped_l3[m];            ctrk.ped1[trk2->DSPnumber[m]-1]=trk2->ped_l1[m];
311        ctrk.sig1[trk2->DSPnumber[m]-1]=trk2->sig_l1[m];            ctrk.ped2[trk2->DSPnumber[m]-1]=trk2->ped_l2[m];
312        ctrk.sig2[trk2->DSPnumber[m]-1]=trk2->sig_l2[m];            ctrk.ped3[trk2->DSPnumber[m]-1]=trk2->ped_l3[m];
313        ctrk.sig3[trk2->DSPnumber[m]-1]=trk2->sig_l3[m];            ctrk.sig1[trk2->DSPnumber[m]-1]=trk2->sig_l1[m];
314        ctrk.nbad1[trk2->DSPnumber[m]-1]=trk2->nbad_l1[m];            ctrk.sig2[trk2->DSPnumber[m]-1]=trk2->sig_l2[m];
315        ctrk.nbad2[trk2->DSPnumber[m]-1]=trk2->nbad_l2[m];            ctrk.sig3[trk2->DSPnumber[m]-1]=trk2->sig_l3[m];
316        ctrk.nbad3[trk2->DSPnumber[m]-1]=trk2->nbad_l3[m];            ctrk.nbad1[trk2->DSPnumber[m]-1]=trk2->nbad_l1[m];
317        ctrk.calfl[trk2->DSPnumber[m]-1]=trk2->cal_flag[m];            ctrk.nbad2[trk2->DSPnumber[m]-1]=trk2->nbad_l2[m];
318        ctrk.crc_c[trk1->DSPnumber[m]-1][0]=trk2->crc_cal[m][0];            ctrk.nbad3[trk2->DSPnumber[m]-1]=trk2->nbad_l3[m];
319        ctrk.crc_c[trk1->DSPnumber[m]-1][1]=trk2->crc_cal[m][1];            ctrk.calfl[trk2->DSPnumber[m]-1]=trk2->cal_flag[m];
320        ctrk.crc_c[trk1->DSPnumber[m]-1][2]=trk2->crc_cal[m][2];            ctrk.crc_c[trk1->DSPnumber[m]-1][0]=trk2->crc_cal[m][0];
321        ctrk.crc_hc[trk1->DSPnumber[m]-1]=trk2->crc_hcal[m];            ctrk.crc_c[trk1->DSPnumber[m]-1][1]=trk2->crc_cal[m][1];
322        for (Int_t j = 0; j < 3072; j++){            ctrk.crc_c[trk1->DSPnumber[m]-1][2]=trk2->crc_cal[m][2];
323          ctrk.dspped[trk2->DSPnumber[m]-1][j]=trk2->DSPped_par[m][j];            ctrk.crc_hc[trk1->DSPnumber[m]-1]=trk2->crc_hcal[m];
324          ctrk.dspsig[trk2->DSPnumber[m]-1][j]=trk2->DSPsig_par[m][j];            for (Int_t j = 0; j < 3072; j++){
325          ctrk.dspbad[trk2->DSPnumber[m]-1][j]=trk2->DSPbad_par[m][j];              ctrk.dspped[trk2->DSPnumber[m]-1][j]=trk2->DSPped_par[m][j];
326                ctrk.dspsig[trk2->DSPnumber[m]-1][j]=trk2->DSPsig_par[m][j];
327                ctrk.dspbad[trk2->DSPnumber[m]-1][j]=trk2->DSPbad_par[m][j];
328              }
329            }
330        }        }
331      }        }  
332    
# Line 338  void FTrkCalibQLook_BASIC(TString file,I Line 341  void FTrkCalibQLook_BASIC(TString file,I
341        }        }
342      }      }
343            
344      Int_t nn,ok=0;      Int_t nn=0,ok=0;
345            
346      //      //
347      // write warning if it occur            // write warning if it occur      
348      for(Int_t n = 0; n<12; n++){      for(Int_t n = 0; n<12; n++){
349                
350        ndsp = ctrk.dspnum[n];        if(ctrk.dspnum[n]==0)
351        nn = ndsp-1;          continue;
352          nn = ctrk.dspnum[n]-1;
353    
354        for(Int_t iii=0;iii<3;iii++){        for(Int_t iii=0;iii<3;iii++){
355          if(ctrk.crc_c[nn][iii]!=0){          if(ctrk.crc_c[nn][iii]!=0){
# Line 412  void FTrkCalibQLook_BASIC(TString file,I Line 416  void FTrkCalibQLook_BASIC(TString file,I
416          space[wc]-=spacep;          space[wc]-=spacep;
417        }        }
418    
419        if(ctrk.good0[0]==1 && ctrk.good0[1]==1){        //      if(ctrk.good0[0]==1 && ctrk.good0[1]==1){
420          //          //
421          // evaluate the mean value of the sigma and pedestal          // evaluate the mean value of the sigma and pedestal
422          for(Int_t j = 0; j < 3072; j++){          for(Int_t j = 0; j < 3072; j++){
# Line 427  void FTrkCalibQLook_BASIC(TString file,I Line 431  void FTrkCalibQLook_BASIC(TString file,I
431            if(pedav[nn][ii]>pedlimsup[nn][ii] || pedav[nn][ii]<pedliminf[nn][ii]) flpedav[nn][ii]=1;              if(pedav[nn][ii]>pedlimsup[nn][ii] || pedav[nn][ii]<pedliminf[nn][ii]) flpedav[nn][ii]=1;  
432            if(sigav[nn][ii]>siglimsup[nn][ii] || sigav[nn][ii]<sigliminf[nn][ii]) flsigav[nn][ii]=1;            if(sigav[nn][ii]>siglimsup[nn][ii] || sigav[nn][ii]<sigliminf[nn][ii]) flsigav[nn][ii]=1;
433    
434            if(flpedav[nn][ii]==1){            if((nn==1 && ii==11)||(nn==6 && ii==2)||(nn==6 && ii==4)||(nn==6 && ii==5)||(nn==6 && ii==6)||(nn==6 && ii==10)||(nn==11 && ii==3))
435              ok=1;              continue;
436              if(space[wc]<=3){            else{
437                wc+=1;              if(flpedav[nn][ii]==1){
438                flcanvas+=1;                ok=1;
439                  if(space[wc]<=3){
440                    wc+=1;
441                    flcanvas+=1;
442                  }
443                  c[wc]->cd();
444                  tzz->SetTextFont(40);
445                  tzz->SetTextSize(0.02);
446                  tzz->SetTextAlign(13);
447                  tzz->SetTextColor(50);
448                  rep<<"********************************************************************************************************************************";
449                  tzz->DrawLatex(2,space[wc],rep.str().c_str());
450                  rep.str("");
451                  space[wc]-=spacep;
452                  rep<<"WARNING >>> CALIBRATION pkt "<<i+1<<" -->CalibTrk"<<(nn+1)%2+1<<" at OBT: "<<OBT[(nn+1)%2]<<"-->DSP "<<nn+1<<" -VA1 "<<2*ii+1<<"-"<<2*ii+2<<" --> <PED>= "<<pedav[nn][ii];
453                  tzz->DrawLatex(2,space[wc],rep.str().c_str());
454                  rep.str("");
455                  space[wc]-=spacep;
456              }              }
457              c[wc]->cd();                
458              tzz->SetTextFont(40);              if(flsigav[nn][ii]==1){
459              tzz->SetTextSize(0.02);                ok=1;
460              tzz->SetTextAlign(13);                if(space[wc]<=3){
461              tzz->SetTextColor(50);                  wc+=1;
462              rep<<"********************************************************************************************************************************";                  flcanvas+=1;
463              tzz->DrawLatex(2,space[wc],rep.str().c_str());                }
464              rep.str("");                c[wc]->cd();
465              space[wc]-=spacep;                tzz->SetTextFont(40);
466              rep<<"WARNING >>> CALIBRATION pkt "<<i+1<<" -->CalibTrk"<<(nn+1)%2+1<<" at OBT: "<<OBT[(nn+1)%2]<<"-->DSP "<<nn+1<<" -VA1 "<<2*ii+1<<"-"<<2*ii+2<<" --> <PED>= "<<pedav[nn][ii];                tzz->SetTextSize(0.02);
467              tzz->DrawLatex(2,space[wc],rep.str().c_str());                tzz->SetTextAlign(13);
468              rep.str("");                tzz->SetTextColor(50);
469              space[wc]-=spacep;                rep<<"********************************************************************************************************************************";
470            }                tzz->DrawLatex(2,space[wc],rep.str().c_str());
471                  rep.str("");
472            if(flsigav[nn][ii]==1){                space[wc]-=spacep;
473              ok=1;                rep<<"WARNING >>> CALIBRATION pkt "<<i+1<<" -->CalibTrk"<<(nn+1)%2+1<<" at OBT: "<<OBT[(nn+1)%2]<<"-->DSP "<<nn+1<<" -VA1 "<<2*ii+1<<"-"<<2*ii+2<<" --> <SIG>= "<<sigav[nn][ii];
474              if(space[wc]<=3){                tzz->DrawLatex(2,space[wc],rep.str().c_str());
475                wc+=1;                rep.str("");
476                flcanvas+=1;                space[wc]-=spacep;
477              }              }
             c[wc]->cd();  
             tzz->SetTextFont(40);  
             tzz->SetTextSize(0.02);  
             tzz->SetTextAlign(13);  
             tzz->SetTextColor(50);  
             rep<<"********************************************************************************************************************************";  
             tzz->DrawLatex(2,space[wc],rep.str().c_str());  
             rep.str("");  
             space[wc]-=spacep;  
             rep<<"WARNING >>> CALIBRATION pkt "<<i+1<<" -->CalibTrk"<<(nn+1)%2+1<<" at OBT: "<<OBT[(nn+1)%2]<<"-->DSP "<<nn+1<<" -VA1 "<<2*ii+1<<"-"<<2*ii+2<<" --> <SIG>= "<<sigav[nn][ii];  
             tzz->DrawLatex(2,space[wc],rep.str().c_str());  
             rep.str("");  
             space[wc]-=spacep;  
478            }            }
479          }          }
480        }          //      }
481      }      }
482            if(ok==0){
483      if(ok==0 && ctrk.good0[0]==1 && ctrk.good0[1]==1){    //    if(ok==0 && ctrk.good0[0]==1 && ctrk.good0[1]==1){
484        if(space[wc]<=10){        if(space[wc]<=10){
485          wc+=1;          wc+=1;
486          flcanvas+=1;          flcanvas+=1;

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

  ViewVC Help
Powered by ViewVC 1.1.23