/[PAMELA software]/quicklook/QLflightTmtc_Header/HeaderScan.cpp
ViewVC logotype

Diff of /quicklook/QLflightTmtc_Header/HeaderScan.cpp

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

revision 1.9 by pam-rm2, Fri Sep 8 08:26:47 2006 UTC revision 1.13 by pam-rm2, Thu Mar 8 09:53:44 2007 UTC
# Line 59  Line 59 
59  *  *
60  * Description: changed the scale in the second and third graph of the first canvas; added a pad of text in the second canvas  * Description: changed the scale in the second and third graph of the first canvas; added a pad of text in the second canvas
61  *  *
62    * Version 1.9
63    * Date 7 March 2007 - Malvezzi
64    *
65    * Description: to read correctly the OBT changed the type of time variables from signed to unsigned
66    *
67  */  */
68    
69    
# Line 70  Line 75 
75  #include "TMultiGraph.h"  #include "TMultiGraph.h"
76  #include <sstream>  #include <sstream>
77  #include <iostream>  #include <iostream>
78    #include <stdio.h>
79    #include <string.h>
80  #include "TString.h"  #include "TString.h"
81  #include "TStyle.h"  #include "TStyle.h"
82  #include "TFile.h"  #include "TFile.h"
# Line 106  void HeaderScan(TString base, TString ou Line 113  void HeaderScan(TString base, TString ou
113    TTree *PhysicsTr = (TTree*)file->Get("Physics");    TTree *PhysicsTr = (TTree*)file->Get("Physics");
114    TBranch *headBr = PhysicsTr->GetBranch("Header");    TBranch *headBr = PhysicsTr->GetBranch("Header");
115    
116    pamela::EventHeader  *eh   = 0;    pamela::EventHeader  *eh   = new pamela::EventHeader;
117    pamela::PscuHeader   *ph   = 0;    pamela::PscuHeader   *ph   = new pamela::PscuHeader;
118    
119    PhysicsTr->SetBranchAddress("Header", &eh);    PhysicsTr->SetBranchAddress("Header", &eh);
120    nevents = PhysicsTr->GetEntries();    nevents = PhysicsTr->GetEntries();
121    const Int_t size = nevents;    const Int_t size = nevents;
122      
123    TTree *RunHeadTr = (TTree*)file->Get("RunHeader");  ///run header tree    TTree *RunHeadTr = (TTree*)file->Get("RunHeader");  ///run header tree
124    pamela::EventHeader *eH=0;    pamela::EventHeader *eH= new pamela::EventHeader;
125    pamela::RunHeaderEvent *reh=0;    pamela::RunHeaderEvent *reh=new pamela::RunHeaderEvent;
126        
127    RunHeadTr->SetBranchAddress("Header",&eH);    RunHeadTr->SetBranchAddress("Header",&eH);
128    RunHeadTr->SetBranchAddress("RunHeader",&reh);    RunHeadTr->SetBranchAddress("RunHeader",&reh);
129    runnevents = RunHeadTr->GetEntries();    runnevents = RunHeadTr->GetEntries();
130    
131    TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString();    TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString();
132    filename = ((TObjString*)filename.Tokenize('.')->First())->GetString();    filename = ((TObjString*)filename.Tokenize('.')->First())->GetString();
133    
# Line 177  void HeaderScan(TString base, TString ou Line 184  void HeaderScan(TString base, TString ou
184    //------------------- fill vectors and histogram -----------------------------//    //------------------- fill vectors and histogram -----------------------------//
185    Double_t *PscuCounter = new Double_t[size];    Double_t *PscuCounter = new Double_t[size];
186    Double_t *PacketLenght = new Double_t[size];    Double_t *PacketLenght = new Double_t[size];
187    Double_t *OBTime = new Double_t[size];    ULong_t utile=0;
188      double *OBTime = new Double_t[size];
189    Double_t *Eventsperminute= new Double_t[nbin];    Double_t *Eventsperminute= new Double_t[nbin];
190    Double_t *Minute= new Double_t[nbin];    Double_t *Minute= new Double_t[nbin];
191    Int_t max=0;    Int_t max=0;
# Line 187  void HeaderScan(TString base, TString ou Line 195  void HeaderScan(TString base, TString ou
195      h1->Fill(ph->GetOrbitalTime());      h1->Fill(ph->GetOrbitalTime());
196      PscuCounter[k]= ph->GetCounter();      PscuCounter[k]= ph->GetCounter();
197      PacketLenght[k]=ph->GetPacketLenght();      PacketLenght[k]=ph->GetPacketLenght();
198      OBTime[k]=ph->GetOrbitalTime();      utile= ph->GetOrbitalTime();
199        OBTime[k]=utile;
200    }      }  
201    int l=0;    int l=0;
202    while(l<nbin){    while(l<nbin){
# Line 203  void HeaderScan(TString base, TString ou Line 212  void HeaderScan(TString base, TString ou
212    TMultiGraph *packeCounter = new TMultiGraph();    TMultiGraph *packeCounter = new TMultiGraph();
213    
214    oss1.str("");    oss1.str("");
215    oss1 << filename.Data() <<": Physics Packet per minute.  Start time = " << obmin << ", End time = "<< obmax <<" ms";    oss1 << "Physics Packet per minute.  Start time = " << obmin << ", End time = "<< obmax <<" ms";
216    TGraph *rate1= new TGraph(nbin, (const Double_t*)Minute, (const Double_t*)Eventsperminute);    TGraph *rate1= new TGraph(nbin, (const Double_t*)Minute, (const Double_t*)Eventsperminute);
217    rate1->SetMarkerColor(kBlack);    rate1->SetMarkerColor(kBlack);
218    rate1->SetMarkerSize(.1);    rate1->SetMarkerSize(.1);
219    rate1->SetMarkerStyle(21);    rate1->SetMarkerStyle(21);
220    rate->Add(rate1);    rate->Add(rate1);
221    
222    TGraph *packetLength1= new TGraph(nevents, (const Double_t*)OBTime, (const Double_t*)PacketLenght);    TGraph *packetLength1= new TGraph(nevents, (const double*)OBTime, (const double*)PacketLenght);
223    oss2.str("");    oss2.str("");
224    oss2 << filename.Data() <<": Lenght of Physic packets";    oss2 <<"Lenght of Physic packets";
225    packetLength1->SetMarkerColor(2);    packetLength1->SetMarkerColor(2);
226    packetLength1->SetMarkerSize(.5);    packetLength1->SetMarkerSize(.3);
227    packetLength1->SetMarkerStyle(21);    packetLength1->SetMarkerStyle(21);
228    packetLength->Add(packetLength1);    packetLength->Add(packetLength1);
229    
230    TGraph *packeCounter1= new TGraph(nevents, (const Double_t*)OBTime, (const Double_t*)PscuCounter);    TGraph *packeCounter1= new TGraph(nevents, (const Double_t*)OBTime, (const Double_t*)PscuCounter);
231    oss3.str("");    oss3.str("");
232    oss3 << filename.Data() <<": Physics Counter vs. OBT";    oss3 <<"Physics Counter vs. OBT";
233    packeCounter1->SetMarkerColor(4);    packeCounter1->SetMarkerColor(4);
234    packeCounter1->SetMarkerSize(.2);    packeCounter1->SetMarkerSize(.2);
235    packeCounter1->SetMarkerStyle(21);    packeCounter1->SetMarkerStyle(21);
# Line 228  void HeaderScan(TString base, TString ou Line 237  void HeaderScan(TString base, TString ou
237    
238    //------------ Create and Draw Canvas ---------------------//    //------------ Create and Draw Canvas ---------------------//
239    TCanvas *finalCanv = new TCanvas("Header", base, 1200, 1600);    TCanvas *finalCanv = new TCanvas("Header", base, 1200, 1600);
240    finalCanv->Divide(1,5);    finalCanv->Divide(1,6);
241    finalCanv->SetFillColor(10);    finalCanv->SetFillColor(10);
242    
243    TPad *all2= new TPad ("","", 0, 0, 1, 1);    TPad *all2= new TPad ("","", 0, 0, 1, 1);
# Line 241  void HeaderScan(TString base, TString ou Line 250  void HeaderScan(TString base, TString ou
250    all->SetFillColor(10);    all->SetFillColor(10);
251    TPad *all1= new TPad ("","", 0, 0, 1, 1);    TPad *all1= new TPad ("","", 0, 0, 1, 1);
252    all1->SetFillColor(10);    all1->SetFillColor(10);
   TPad *pad = new TPad("pad","pad", .80,.45,.90,.75);  
   pad->SetFillColor(10);  
253    
254    TLine li;    TLine li;
255    li.SetLineStyle(4);    li.SetLineStyle(4);
# Line 278  void HeaderScan(TString base, TString ou Line 285  void HeaderScan(TString base, TString ou
285      }        }  
286    }    }
287        
288      RunHeadTr->GetEntry(0);
289      ph = eH->GetPscuHeader();
290      ULong_t TimeSync = reh->LAST_TIME_SYNC_INFO;
291      ULong_t ObtSync = reh->OBT_TIME_SYNC;
292      //cout<<"TimeSync "<<reh->LAST_TIME_SYNC_INFO<<"\n";
293      //cout<<"ObtSync "<<reh->OBT_TIME_SYNC<<"\n";
294    
295    finalCanv->cd(1);    finalCanv->cd(1);
296    stringstream ws1, ws2;    stringstream ws1, ws2;
297    ws1.str("");    ws1.str("");
# Line 364  void HeaderScan(TString base, TString ou Line 378  void HeaderScan(TString base, TString ou
378    Int_t numkey;    Int_t numkey;
379    TObject *key = new TObject;    TObject *key = new TObject;
380    const char *name;    const char *name;
381      char *SoftInfo="SoftInfo";
382    TTree* tr = new TTree;    TTree* tr = new TTree;
383    Long64_t nevntskey=0;    Long64_t nevntskey=0;
384    list = file->GetListOfKeys();    list = file->GetListOfKeys();
385    numkey = file->GetNkeys();    numkey = file->GetNkeys();
386    Double_t salto;    ULong_t salto;
387    for (Int_t m=0; m<numkey; m++){    for (Int_t m=0; m<numkey; m++){
388      key = list->At(m);      key = list->At(m);
389      name=(char *)(key->GetName());      name=(char *)(key->GetName());
390        if(strcmp(name,SoftInfo)==0)continue;
391      tr = (TTree*)file->Get(name);      tr = (TTree*)file->Get(name);
392      if (tr->IsZombie()) continue;      if (tr->IsZombie()) continue;
393    
394      tr->SetBranchAddress("Header", &eh);      tr->SetBranchAddress("Header", &eh);
395      TBranch *Br = tr->GetBranch("Header");      TBranch *Br = tr->GetBranch("Header");
396      nevntskey = tr->GetEntries();      nevntskey = tr->GetEntries();
   
397      if(nevntskey !=0){      if(nevntskey !=0){
398        Int_t size1=nevntskey;        Int_t size1=nevntskey;
399        Double_t *PscuCounter1 = new Double_t[size1];        Double_t *PscuCounter1 = new Double_t[size1];
# Line 390  void HeaderScan(TString base, TString ou Line 406  void HeaderScan(TString base, TString ou
406          ph = eh->GetPscuHeader();            ph = eh->GetPscuHeader();  
407          PscuCounter1[n]= ph->GetCounter();          PscuCounter1[n]= ph->GetCounter();
408          FileOffset1[n]=ph->GetFileOffset();          FileOffset1[n]=ph->GetFileOffset();
409          tempo1[n]=ph->GetOrbitalTime();          utile=ph->GetOrbitalTime();
410            tempo1[n]=utile;
411          if((m==0) && (n==0)){          if((m==0) && (n==0)){
412            primotempo=ph->GetOrbitalTime();            primotempo=ph->GetOrbitalTime();
413            salto=ph->GetOrbitalTime();            salto=ph->GetOrbitalTime();
# Line 406  void HeaderScan(TString base, TString ou Line 423  void HeaderScan(TString base, TString ou
423          }          }
424          n++;          n++;
425        }        }
426    
427        TGraph *graph3= new TGraph(nevntskey, (const Double_t*)FileOffset1, (const Double_t*)PscuCounter1);        TGraph *graph3= new TGraph(nevntskey, (const Double_t*)FileOffset1, (const Double_t*)PscuCounter1);
428        graph3->SetMarkerColor(3);        graph3->SetMarkerColor(3);
429        graph3->SetMarkerSize(.2);        graph3->SetMarkerSize(.2);
# Line 431  void HeaderScan(TString base, TString ou Line 449  void HeaderScan(TString base, TString ou
449     all1->cd();     all1->cd();
450    
451     oss1.str("");     oss1.str("");
452     oss1 << filename.Data() <<": PscuCounter vs FileOffset.";     oss1 <<"PscuCounter vs FileOffset.";
453     mg1->Draw("AP");     mg1->Draw("AP");
454     mg1->GetXaxis()->SetTitle("File Offset");     mg1->GetXaxis()->SetTitle("File Offset");
455     mg1->GetXaxis()->CenterTitle();     mg1->GetXaxis()->CenterTitle();
# Line 456  void HeaderScan(TString base, TString ou Line 474  void HeaderScan(TString base, TString ou
474     finalCanv->cd(5);     finalCanv->cd(5);
475     all->Draw();     all->Draw();
476     all->cd();     all->cd();
     
477     oss3.str("");     oss3.str("");
478     oss3 << filename.Data() <<" OBT vs FileOffset. First packet at "<<primotempo <<" ms, last packet at "<<ultimotempo<<" ms.";     oss3 << "OBT vs FileOffset";
479     mg2->Draw("AP");     mg2->Draw("AP");
480     mg2->GetXaxis()->SetTitle("File Offset");     mg2->GetXaxis()->SetTitle("File Offset");
481     mg2->GetXaxis()->CenterTitle();     mg2->GetXaxis()->CenterTitle();
# Line 469  void HeaderScan(TString base, TString ou Line 486  void HeaderScan(TString base, TString ou
486     mg2->GetYaxis()->SetTitleSize(0.06);     mg2->GetYaxis()->SetTitleSize(0.06);
487     mg2->GetYaxis()->SetLabelSize(0.05);     mg2->GetYaxis()->SetLabelSize(0.05);
488     mg2->GetYaxis()->SetTitleOffset(0.6);     mg2->GetYaxis()->SetTitleOffset(0.6);
    pad->Draw();  
    pad->cd();  
    stringa.str("");  
    stringa << "jump at: "<<salto<<" ms \n";  
    if(salto != primotempo) lat->DrawLatex(0.08, 0.8,stringa.str().c_str());  
489    
490     finalCanv->cd(5);     finalCanv->cd(5);
491     TPaveText *pt4=0;     TPaveText *pt4=0;
492     pt4 = new TPaveText (.38 ,.91,.92,1);     pt4 = new TPaveText (.70,.91,.90,1);
493     pt4->AddText(oss3.str().c_str());     pt4->AddText(oss3.str().c_str());
494     pt4->SetTextColor(kBlue);     pt4->SetTextColor(kBlue);
495     pt4->SetFillColor(10);     pt4->SetFillColor(10);
496     pt4->SetBorderSize(0);     pt4->SetBorderSize(0);
497     pt4->Draw();     pt4->Draw();
498    
499       finalCanv->cd(6);
500       ULong_t primotempoABS=TimeSync+((primotempo/1000)-ObtSync);
501       ULong_t obmaxABS=TimeSync+((lastime/1000)-ObtSync);
502       ULong_t saltoABS=TimeSync+((salto/1000)-ObtSync);
503       ULong_t ultimotempoABS=TimeSync+((ultimotempo/1000)-ObtSync);
504    
505       TPaveText *pt5=0;
506       pt5 = new TPaveText (0,0,1,1);
507       stringa.str("");
508       stringa << "  Filename:   "<<filename.Data()<<"\n";
509       TText *t1=pt5->AddText(0.25,0.95,stringa.str().c_str());
510       t1->SetTextSize(0.1);
511       stringa.str("");
512       stringa << "  OBT (ms)            ABS TIME (s)";
513       TText *t2=pt5->AddText(0.32,0.75,stringa.str().c_str());
514       t2->SetTextSize(0.07);
515       stringa.str("");
516       stringa << "New data start at:   "<<primotempo<<"         "<<primotempoABS;
517       TText *t3=pt5->AddText(0.25,0.60,stringa.str().c_str());
518       t3->SetTextSize(0.08);
519       stringa.str("");
520       stringa << "New data end at:     "<<lastime<<"         "<<obmaxABS;
521       TText *t4=pt5->AddText(0.25,0.50,stringa.str().c_str());
522       t4->SetTextSize(0.08);
523       if(primotempo!=salto || lastime!=ultimotempo){
524         stringa.str("");
525         stringa << "Old data start at:   "<<salto<<"        "<<saltoABS;
526         TText *t5=pt5->AddText(0.65,0.60,stringa.str().c_str());
527         t5->SetTextSize(0.08);
528         stringa.str("");
529         stringa << "Old data end at:     "<<ultimotempo<<"        "<<ultimotempoABS;
530         TText *t6=pt5->AddText(0.65,0.50,stringa.str().c_str());
531         t6->SetTextSize(0.08);
532         stringa.str("");
533         stringa << "  OBT (ms)          ABS TIME (s)";
534         TText *t2=pt5->AddText(0.72,0.75,stringa.str().c_str());
535         t2->SetTextSize(0.07);
536       }
537       pt5->SetTextColor(kBlack);
538       pt5->SetFillColor(10);
539       pt5->SetBorderSize(0);
540       pt5->Draw();
541    
542     finalCanv->Update();     finalCanv->Update();
543    
544     oss1.str("");     oss1.str("");

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.23