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

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

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

revision 1.7 by pam-fi, Thu Jun 8 17:03:57 2006 UTC revision 1.10 by pam-fi, Thu Jul 13 10:13:37 2006 UTC
# Line 1  Line 1 
1  /**  /**
2   * FTrkQLook_EXPERT   * FTrkQLook_EXPERT.cxx
3   *   *
4   * autor: D.Fedele   * autor: D.Fedele
5   * version 3.0   * version v1r06
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 19  Line 19 
19  #include <TLatex.h>  #include <TLatex.h>
20  #include <TCanvas.h>  #include <TCanvas.h>
21  #include <TGraph.h>  #include <TGraph.h>
22    #include <TFile.h>
23  #include <TTree.h>  #include <TTree.h>
24  #include <TStyle.h>  #include <TStyle.h>
25  //  //
# Line 34  Line 35 
35  //  //
36  #define MAXSTORAGE 50000  #define MAXSTORAGE 50000
37    
 void stringcopy(TString& s1, const TString& s2, Int_t from=0, Int_t to=0){      
   if ( to == 0 ){  
     Int_t t2length = s2.Length();  
     s1 = "";  
     to = t2length;  
   };  
   for (Int_t i = from; i<to; i++){  
     s1.Append(s2[i],1);  
   };  
 };  
   
   
38  void FTrkQLook_EXPERT(TString file,Int_t fromevent,Int_t toevent, TString outdir, TString outfile)  void FTrkQLook_EXPERT(TString file,Int_t fromevent,Int_t toevent, TString outdir, TString outfile)
39  {  {
40    //    //
41    //   obtain information about the data file and select the output dir    //   obtain information about the data file and select the output dir
42    const string filepath=file.Data();    Int_t dwpos = file.Last('/');
43    Int_t dwpos = filepath.rfind("/");    Int_t dwpos1 = file.Last('.');
   Int_t dwpos1 = filepath.find(".root");  
   TString fpath=(filepath.c_str());  
44    TString base,ffile ;    TString base,ffile ;
45    stringcopy(ffile,fpath,dwpos+1,dwpos1);    ffile=file(dwpos+1,dwpos1-(dwpos+1));
46    stringcopy(base,fpath,0,dwpos);    if(dwpos>0) base=file(0,dwpos);
   if(dwpos>0) base+="/";  
47    
48    TString out;    TString out;
49    if(outdir.Length()==0){    if(outdir.Length()==0){
# Line 65  void FTrkQLook_EXPERT(TString file,Int_t Line 51  void FTrkQLook_EXPERT(TString file,Int_t
51    }else{    }else{
52      out = outdir;      out = outdir;
53    }    }
54      if(out.Last('/')+1<out.Length()) out+="/";
55    
56    //    //
57    // inizialise the variables and open the file    // inizialise the variables and open the file
# Line 434  void FTrkQLook_EXPERT(TString file,Int_t Line 421  void FTrkQLook_EXPERT(TString file,Int_t
421    //    //
422    // Fill compressiontime and eventnumber graphs and DSP warnings    // Fill compressiontime and eventnumber graphs and DSP warnings
423    for(Int_t ii=0; ii<countnboot;ii++){    for(Int_t ii=0; ii<countnboot;ii++){
424      TPaveText *pt1;      TPad *pt;         //pad for histos
     TPad *pt,*pt0;         //pad for histos  
425        
     ofstream warning(out + "warning.txt",ios::out);  
   
426      //****************************************************************************************      //****************************************************************************************
427      //COMPRESSIONTIME vs. OBT Output Pages      //COMPRESSIONTIME vs. OBT Output Pages
428      //****************************************************************************************      //****************************************************************************************
# Line 464  void FTrkQLook_EXPERT(TString file,Int_t Line 448  void FTrkQLook_EXPERT(TString file,Int_t
448      //DSP EVENT NUMBER Output Pages      //DSP EVENT NUMBER Output Pages
449      //****************************************************************************************      //****************************************************************************************
450    
451      isfile<<"WARNINGS on DSP EVENT NUMBER   pag"<<ii+1;      isfile<<"DSP EVENT NUMBER vs. OBT   pag"<<ii+1;
452      EventNumCanv[ii]=new TCanvas(isfile.str().c_str(),isfile.str().c_str(),900,1200);      EventNumCanv[ii]=new TCanvas(isfile.str().c_str(),isfile.str().c_str(),900,1200);
453      EventNumCanv[ii]->SetFillColor(10);      EventNumCanv[ii]->SetFillColor(10);
454      EventNumCanv[ii]->Range(0,0,100,100);      EventNumCanv[ii]->Range(0,0,100,100);
# Line 477  void FTrkQLook_EXPERT(TString file,Int_t Line 461  void FTrkQLook_EXPERT(TString file,Int_t
461      t1->SetTextColor(1);      t1->SetTextColor(1);
462      t1->SetTextAlign(12);      t1->SetTextAlign(12);
463      t1->SetTextSize(0.02);      t1->SetTextSize(0.02);
464      t1->DrawLatex(65.,98.7,isfile.str().c_str());      t1->DrawLatex(62.,98.7,isfile.str().c_str());
465      isfile.str("");      isfile.str("");
466    
467      Float_t posy = 0.95;    // up y-coord - top pads      Float_t posy = 0.95;    // up y-coord - top pads
# Line 513  void FTrkQLook_EXPERT(TString file,Int_t Line 497  void FTrkQLook_EXPERT(TString file,Int_t
497      //      //
498      // Obtain information about the tracker data      // Obtain information about the tracker data
499      // and fill graphs and histos      // and fill graphs and histos
500      Int_t warning_dspnumber=0,al=0;  
501        Int_t al=0;
502      Float_t x[MAXSTORAGE];      Float_t x[MAXSTORAGE];
503      Float_t yc[MAXSTORAGE][12];      Float_t yc[MAXSTORAGE][12];
504      Float_t eventint[MAXSTORAGE];      Float_t eventint[MAXSTORAGE];
505        Int_t eventn[12];
506        
507      for (Int_t ev=minev; ev<maxevent; ev++){      for (Int_t ev=minev; ev<maxevent; ev++){
508        tr->GetEntry(ev);        tr->GetEntry(ev);
509        ph = eh->GetPscuHeader();        ph = eh->GetPscuHeader();
510        cod = eh->GetCounter();        cod = eh->GetCounter();
511        
512    
513        if(ev==maxevent-1) maxev=maxevent-1;        if(ev==maxevent-1) maxev=maxevent-1;
514    
515        if((ph->GetOrbitalTime()<x[ev-minev-1] && ev-minev!=0) || ev-minev==MAXSTORAGE){        if((ph->GetOrbitalTime()<x[ev-minev-1] && ev-minev!=0) || ev-minev==MAXSTORAGE){
# Line 535  void FTrkQLook_EXPERT(TString file,Int_t Line 522  void FTrkQLook_EXPERT(TString file,Int_t
522                    
523          Int_t dsp=0;          Int_t dsp=0;
524          for(Int_t i=0; i<12; i++){          for(Int_t i=0; i<12; i++){
525              if(te->DSPnumber[i]<1 || te->DSPnumber[i]>12) {
526                ALARM=1;
527                break;
528              }
529    
530            dsp=te->DSPnumber[i]-1;            dsp=te->DSPnumber[i]-1;
531            yc[(ev-minev)][dsp]= 0.051*te->compressiontime[i];            yc[(ev-minev)][dsp]= 0.051*te->compressiontime[i];
532              
533            //            //
534            // Fill Cluster Signal and Lighting of the view histos            // Fill Cluster Signal and Lighting of the view histos
535            for(Int_t j=0;j<3;j++){            for(Int_t j=0;j<3;j++){
# Line 563  void FTrkQLook_EXPERT(TString file,Int_t Line 555  void FTrkQLook_EXPERT(TString file,Int_t
555            WARNING[i]=0;            WARNING[i]=0;
556            if(te->fc[i]!=0 || te->fl1[i]!=0 || te->fl2[i]!=0 || te->fl3[i]!=0 || te->fl4[i]!=0 || te->fl5[i]!=0 || te->fl6[i]!=0){            if(te->fc[i]!=0 || te->fl1[i]!=0 || te->fl2[i]!=0 || te->fl3[i]!=0 || te->fl4[i]!=0 || te->fl5[i]!=0 || te->fl6[i]!=0){
557              ALARM = 1;      //general alarm              ALARM = 1;      //general alarm
             al=1;  
558              WARNING[i] = 1; // DSP warning              WARNING[i] = 1; // DSP warning
559            };            };
560    
561            if(te->alarm[i]!=0){ // hardware alarm            if(te->alarm[i]!=0){ // hardware alarm
562              ALARM = 1;              ALARM = 1;
             al=1;  
563            };            };
564                
565            //**************************************************************************************            //**************************************************************************************
566            // warning for internal number            // warning for internal number
567            //**************************************************************************************            //**************************************************************************************
568            if(i<=10){            if(i<=10 && te->eventn[i]!=te->eventn[i+1]) ALARM=1;
569              if(te->eventn[i]!=te->eventn[i+1]){            if((ev-minev)>=1 && eventn[i]+1!=te->eventn[i] && te->eventn[i]!=1) ALARM=1;
               warning_dspnumber++;  
               warning<< "==> WARNING!!    Check entry "<< ev<<" (DSP "<<dsp<<")" <<endl<<  
                 "eventn["<<i<<"]= "<<te->eventn[i]<<"!= eventn["<<i+1<<"]= "<< te->eventn[i+1]<<endl;  
             }  
             else  
               eventint[(ev-minev)]=te->eventn[0];  
           }  
570          }          }
571            eventint[(ev-minev)]=te->eventn[0];
572    
         if(ev<=maxevent-1){  
   
           if((ev-minev)>=1 && eventint[(ev-minev)]!=eventint[(ev-minev)-1]+1 && eventint[(ev-minev)]!=1){  
             warning_dspnumber++;  
             warning<< "==> WARNING!!    Check entry "<< ev<<endl<<  
               " DSP event num.= "<< eventint[(ev-minev)]<<  
               " is different from (previus+1) ="<<eventint[(ev-minev)-1]+1 <<"\n"<<endl;  
           }  
         }  
         
573          //********************************************************************************************          //********************************************************************************************
574          // file DSP warning          // file DSP warning
575          //********************************************************************************************          //********************************************************************************************
576    
577          if(ALARM==1) {            if(ALARM==1) {  
578              al=1;
579            alarm <<endl<< "================================================="<< endl;            alarm <<endl<< "================================================="<< endl;
580            alarm << "PSCU-Pkt N. "<< ph->GetCounter() ;            alarm << "PSCU-Pkt N. "<< ph->GetCounter() ;
581            alarm << " - OBT "<< ph->GetOrbitalTime() << " ms"<<endl;            alarm << " - OBT "<< ph->GetOrbitalTime() << " ms"<<endl;
582              alarm << "Total events "<<nevent<<endl;
583            alarm << "(ROOT-tree entry "<<ev<<" in page "<<ii+1<<" )"<<endl;            alarm << "(ROOT-tree entry "<<ev<<" in page "<<ii+1<<" )"<<endl;
584            alarm << "================================================="<< endl;            alarm << "================================================="<< endl;
585                        
586            alarm << " DSPn";            alarm << " DSPn";
587            alarm << " Event";            alarm << " Counter";
588              alarm << " previous";
589            alarm << " Words";            alarm << " Words";
590            alarm << " crc";            alarm << " crc";
591            alarm << "  FC";            alarm << "  FC";
# Line 621  void FTrkQLook_EXPERT(TString file,Int_t Line 598  void FTrkQLook_EXPERT(TString file,Int_t
598                        
599            for(Int_t i=0; i<12 ; i++){            for(Int_t i=0; i<12 ; i++){
600              alarm.width(5); alarm << te->DSPnumber[i];              alarm.width(5); alarm << te->DSPnumber[i];
601              alarm.width(6); alarm << te->eventn[i];              alarm.width(8); alarm << te->eventn[i];
602                alarm.width(8); alarm << eventn[i];
603              alarm.width(6); alarm << te->DATAlength[i];              alarm.width(6); alarm << te->DATAlength[i];
604              alarm.width(4); alarm << te->crc[i];              alarm.width(4); alarm << te->crc[i];
605              alarm.width(4); alarm << te->fc[i];              alarm.width(4); alarm << te->fc[i];
# Line 636  void FTrkQLook_EXPERT(TString file,Int_t Line 614  void FTrkQLook_EXPERT(TString file,Int_t
614              alarm    << endl;              alarm    << endl;
615            }            }
616          }          }
617            for(Int_t i=0; i<12 ; i++)
618              eventn[i]=te->eventn[i];
619        }        }
620      }      }
621      if(al==0) alarm << endl<< "Page "<<ii+1<< ": ------>  NO ALARM!!! <-------"<<endl;      if(al==0) alarm << endl<< "Page "<<ii+1<< ": ------>  NO ALARM!!! <-------"<<endl;
     if(warning_dspnumber==0) warning<<"NONE"<<endl;  
622    
623      //      //
624      // Draw the graphs      // Draw the graphs
# Line 661  void FTrkQLook_EXPERT(TString file,Int_t Line 640  void FTrkQLook_EXPERT(TString file,Int_t
640        comprtime[i][ii]->GetXaxis()->CenterTitle();        comprtime[i][ii]->GetXaxis()->CenterTitle();
641        comprtime[i][ii]->GetYaxis()->SetTitle("compressiontime (ms)");        comprtime[i][ii]->GetYaxis()->SetTitle("compressiontime (ms)");
642        comprtime[i][ii]->GetYaxis()->CenterTitle();        comprtime[i][ii]->GetYaxis()->CenterTitle();
643        comprtime[i][ii]->GetYaxis()->SetRangeUser(0,2);        comprtime[i][ii]->GetYaxis()->SetRangeUser(0,3);
644        comprtime[i][ii]->Draw("ap");        comprtime[i][ii]->Draw("ap");
645        oss1.str("");        oss1.str("");
646        CompTimeCanv[ii]->Update();        CompTimeCanv[ii]->Update();
647      }      }
648        
649      EventNumCanv[ii]->cd();      EventNumCanv[ii]->cd();
650      pt0=new TPad("pt0"," ",0.704,0.004,0.996,0.98);      pt = new TPad("pt"," ",0.02,0.01,1.,0.98,18,0,0);
     pt1 = new TPaveText(0.004,0.004,0.986,0.996);  
     pt = new TPad("pt"," ",0.004,0.004,0.7,0.98,18,0,0);  
     pt1->SetFillColor(10);  
     pt1->ReadFile(out + "warning.txt");  
     pt1->SetTextAlign(22);  
     pt1->SetTextSize(0.035);  
     pt0->SetFillColor(10);  
     pt0->SetFrameFillColor(10);  
     pt0->Draw();  
     pt0->cd();  
     pt1->Draw();  
     EventNumCanv[ii]->cd();  
651      pt->SetFillColor(10);      pt->SetFillColor(10);
652      pt->SetFrameFillColor(10);      pt->SetFrameFillColor(10);
653      pt->Draw();      pt->Draw();
654      pt->cd();      pt->cd();
655      eventnumb[ii]=new TGraph(maxev-minev,x,eventint);      eventnumb[ii]=new TGraph(maxev-minev,x,eventint);
656      eventnumb[ii]->SetTitle("");      eventnumb[ii]->SetTitle("");
657      eventnumb[ii]->GetXaxis()->SetLabelSize(0.03);      eventnumb[ii]->GetXaxis()->SetLabelSize(0.02);
658      eventnumb[ii]->GetXaxis()->SetTitleSize(0.04);      eventnumb[ii]->GetXaxis()->SetTitleSize(0.03);
659      eventnumb[ii]->GetXaxis()->SetTitle("OBT (ms)");      eventnumb[ii]->GetXaxis()->SetTitle("OBT (ms)");
660      eventnumb[ii]->GetXaxis()->CenterTitle();      eventnumb[ii]->GetXaxis()->CenterTitle();
661      eventnumb[ii]->GetXaxis()->SetTickLength(0.01);      eventnumb[ii]->GetXaxis()->SetTickLength(0.01);
662      eventnumb[ii]->GetXaxis()->SetTitleOffset(1.2);      eventnumb[ii]->GetXaxis()->SetTitleOffset(1.1);
663      eventnumb[ii]->GetYaxis()->SetLabelSize(0.03);      eventnumb[ii]->GetYaxis()->SetLabelSize(0.02);
664      eventnumb[ii]->GetYaxis()->SetTitleSize(0.04);      eventnumb[ii]->GetYaxis()->SetTitleSize(0.03);
665      eventnumb[ii]->GetYaxis()->SetTitle("DSP event-number");      eventnumb[ii]->GetYaxis()->SetTitle("DSP event-number");
666      eventnumb[ii]->GetYaxis()->CenterTitle();      eventnumb[ii]->GetYaxis()->CenterTitle();
667      eventnumb[ii]->GetYaxis()->SetTitleOffset(1.5);      eventnumb[ii]->GetYaxis()->SetTitleOffset(2.);
668      eventnumb[ii]->SetMarkerStyle(21);      eventnumb[ii]->SetMarkerStyle(21);
669      eventnumb[ii]->SetMarkerColor(kBlue);      eventnumb[ii]->SetMarkerColor(kBlue);
670      eventnumb[ii]->SetMarkerSize(0.3);      eventnumb[ii]->SetMarkerSize(0.2);
671      eventnumb[ii]->Draw("ap");      eventnumb[ii]->Draw("ap");
672      EventNumCanv[ii]->Update();      EventNumCanv[ii]->Update();
673            
   
     warning.close();  
674      minev=maxev;      minev=maxev;
675      if(maxev==maxevent-1) {      if(maxev==maxevent-1) {
676        cntpgdat=ii+1;        cntpgdat=ii+1;
677        break;        break;
678      }      }
679        
680    }    }
681    
682    
683    alarm.close();    alarm.close();
684    
685    //****************************************************************************************    //****************************************************************************************
# Line 948  void FTrkQLook_EXPERT(TString file,Int_t Line 915  void FTrkQLook_EXPERT(TString file,Int_t
915      com.str("");      com.str("");
916    }    }
917    
   command.str("");  
   command<<"rm -f "<<out<<"warning.txt";  
   system(command.str().c_str());  
     
918    gROOT->Reset();    gROOT->Reset();
919    return;    return;
920  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.23