/** * FTrkQLook_BASIC.cpp * * autor: D.Fedele * version 2.0 * Parameters: * file - the data file to analyze * fromevent - first event to analyze * toevent - last event to analyze * outdir - total path of output file * outfile - extension of output file (pdf,ps,gif,jpg) * */ // #include #include #include #include #include #include #include // #include #include #include #include // 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; i0) base+="/"; TString out; if(outdir.Length()==0){ out = base; }else{ out = outdir; } // // inizialise the variables and open the file pamela::tracker::TrackerEvent *te=0; pamela::EventHeader *eh=0,*eH=0,*ceh=0; pamela::RunHeaderEvent *reh=0; pamela::PscuHeader *ph=0,*pH=0; TFile *datafile = new TFile(file); TTree *otr = (TTree*)datafile->Get("RunHeader"); otr->SetBranchAddress("Header",&eH); otr->SetBranchAddress("RunHeader",&reh); TTree *tr = (TTree*)datafile->Get("Physics"); tr->SetBranchAddress("Tracker",&te); tr->SetBranchAddress("Header",&eh); TTree *ctr = (TTree*)datafile->Get("CalibTrk1"); ctr->SetBranchAddress("Header",&ceh); Long64_t neventC = ctr->GetEntries(); Long64_t nevent = tr->GetEntries(); Long64_t neventH = otr->GetEntries(); Int_t minevent=0; Int_t maxevent=0; printf("Number of total events: %lld\nNumber of total header events: %lld\n",nevent,neventH); printf("Number of calibration events: %lld\n",neventC); if (nevent<=0){ datafile->Close(); return; } if ( fromevent > toevent && toevent>0 ){ printf("It must be fromevent < toevent \n"); return; } if ( fromevent > nevent || fromevent < 0 ) { printf("You can choose fromevent between 0 (all) and %lld \n",nevent); return; } if ( toevent > nevent || toevent < 0 ) { printf("You can choose toevent between 0 (all) and %lld \n",nevent); return; } if ( fromevent == 0 ) { minevent = 0; maxevent = nevent; } else { minevent = fromevent; if ( toevent > 0 ){ maxevent = toevent+1; } else if (toevent > nevent) { maxevent = nevent; } else { maxevent = toevent+1; } nevent=maxevent-minevent ; } // // other variables definitions stringstream oss,fromfile,isfile; const Int_t sizeH=neventH; const Int_t sizeC=neventC; Int_t count=0,trk_cal_us[sizeH],countrun=1; Double_t perc=0,xMIN=0,xMAX=0; ULong64_t HOBT[sizeH],COBT[sizeC]; for (Int_t vi=0; viGetEntry(ev); pH = eH->GetPscuHeader(); HOBT[ev]= pH->GetOrbitalTime(); trk_cal_us[ev]=reh->TRK_CALIB_USED; if((HOBT[ev]0) countrun+=1; // printf("\n%lld\t\tcountrun=%d\n",HOBT[ev],countrun); } countrun+=20; printf("\ncountrun=%d\n",countrun); // // information about calibration OBT for (Int_t ev=0; evGetEntry(ev); pH = ceh->GetPscuHeader(); COBT[ev]= pH->GetOrbitalTime(); } //**************************************************************************************** //Output figure //**************************************************************************************** gStyle->SetLabelSize(0.06,"x"); gStyle->SetLabelSize(0.06,"y"); gStyle->SetStatFontSize(0.075); gStyle->SetOptStat(10); gStyle->SetFillColor(10); gStyle->SetTitleFontSize(0.1); gStyle->SetTitleFillColor(10); gStyle->SetTitleOffset(0.8,"y"); gStyle->SetTitleOffset(0.9,"x"); gStyle->SetTitleSize(0.06,"y"); gStyle->SetTitleSize(0.055,"x"); Int_t minev=minevent,maxev=maxevent,countHOBT=0,countCOBT=0; TPad *pad[12][countrun] ; //pad for histos TGraph *dataletime[12][countrun],*dataletime1[12][countrun]; TCanvas *DataTimeCanv[countrun]; for(Int_t ii=0; iiSetFillColor(10); DataTimeCanv[ii]->Range(0,0,100,100); TLatex *t=new TLatex(); t->SetTextFont(32); t->SetTextColor(1); t->SetTextAlign(12); t->SetTextSize(0.02); t->DrawLatex(2.,98.7,fromfile.str().c_str()); TLatex *t1=new TLatex(); t1->SetTextFont(32); t1->SetTextColor(1); t1->SetTextAlign(12); t1->SetTextSize(0.02); t1->DrawLatex(70.,98.7,isfile.str().c_str()); fromfile.str(""); isfile.str(""); fromfile<<"D = Default Calibration"; isfile<<"O = OnLine Calibration"; t->SetTextColor(6); t->SetTextSize(0.018); t->DrawLatex(70.,97.,fromfile.str().c_str()); t->SetTextColor(3); t->DrawLatex(70.,96.,isfile.str().c_str()); fromfile.str(""); isfile.str(""); fromfile<<"The green arrow (if present) points out the time of the online calibration"; t->DrawLatex(10.,96.,fromfile.str().c_str()); fromfile.str(""); //************************************************************************************* //book pads and histos //*************************************************************************************** Double_t posy = 0.95; // up y-coord - top pads Double_t hpad = 0; // pad height Double_t posx1=0; // left x-coord - pad column Double_t posx0=0; // x-coord - column division Double_t wrel = 0; // relative x size of first sub-column Double_t marg = 0.004; // margin among pads hpad = (posy-marg*11)/6; wrel = (1-marg*4)/2; stringstream title; stringstream hid; for(Int_t n = 0; n<12; n++) { if ( (n+1)%2==1 ) { if(n>1) posy = posy-(marg*2+hpad); posx1 = marg; posx0 = posx1 + wrel; } else { posx1 = posx0 + 2*marg; posx0 = posx1 + wrel; } /* -----------> pad for histograms */ oss<<"pad"<SetTextFont(32); t2->SetTextColor(1); t2->SetTextAlign(13); t2->SetTextSize(0.08); Int_t i=0; Double_t x[30000], xb[30000]; Double_t yyd[30000][12],yyb[30000][12]; for (Int_t ev=minev; evGetEntry(ev); ph = eh->GetPscuHeader(); if(ev==maxevent-1) maxev=maxevent-1; // printf("prova00\n"); if((ph->GetOrbitalTime()30000){ maxev=ev; // printf("prova12\n"); break; } else{ x[(ev-minev)]= ph->GetOrbitalTime(); i=0; // printf("prova0 %d\n ",ev); for (Int_t n=0; n<12 ; n++){ perc=0; count=0; yyb[count][i]=0; xb[count]= 0; i=te->DSPnumber[n]-1; yyd[(ev-minev)][i]=te->DATAlength[n]; if(i==6){ if(yyd[(ev-minev)][i]>1500){ if(yyd[(ev-minev)][i]<3075){ yyb[count][i]= yyd[(ev-minev)][i]; xb[count]= x[(ev-minev)]; count++; } } } else{ if(yyd[(ev-minev)][i]>750){ if(yyd[(ev-minev)][i]<3075){ yyb[count][i]= yyd[(ev-minev)][i]; xb[count]= x[(ev-minev)]; count++; } } } } } } // printf("prova2\n"); if(ii==0 && COBT[0]1000){ perc=(count*100)/(maxev-minev); if(perc>10) pad[i][ii]->SetFillColor(2); else pad[i][ii]->SetFillColor(10); } else{ if(count>=100) pad[i][ii]->SetFillColor(2); else pad[i][ii]->SetFillColor(10); } oss<<"DSP "<cd(); pad[i][ii]->SetFrameFillColor(10); pad[i][ii]->Draw(); pad[i][ii]->cd(); dataletime[i][ii]= new TGraph((maxev-minev),x,y); // printf("\nentries nel graph= %d\n",maxev-minev); dataletime[i][ii]->SetTitle(oss.str().c_str()); dataletime[i][ii]->GetXaxis()->SetTitle("OBT (ms)"); dataletime[i][ii]->GetXaxis()->CenterTitle(); // dataletime[i][ii]->GetXaxis()->SetRangeUser(min,max); dataletime[i][ii]->GetXaxis()->SetRangeUser(xMIN,xMAX); dataletime[i][ii]->GetYaxis()->SetTitle("datalength (Word 13 bit)"); dataletime[i][ii]->GetYaxis()->CenterTitle(); if(i==6) dataletime[i][ii]->GetYaxis()->SetRangeUser(0,4500); else dataletime[i][ii]->GetYaxis()->SetRangeUser(0,3500); dataletime[i][ii]->SetMarkerStyle(21); if((maxev-minev)<50) dataletime[i][ii]->SetMarkerSize(0.5); else dataletime[i][ii]->SetMarkerSize(0.3); dataletime[i][ii]->SetMarkerColor(4); dataletime[i][ii]->Draw("ap"); // printf("prova4\n"); if((maxev-minev)>1000 && perc>10){ dataletime1[i][ii]= new TGraph(count,xb,yb); dataletime1[i][ii]->SetMarkerStyle(21); if((maxev-minev)<50) dataletime1[i][ii]->SetMarkerSize(0.5); else dataletime1[i][ii]->SetMarkerSize(0.3); dataletime1[i][ii]->SetMarkerColor(2); dataletime1[i][ii]->Draw("psame"); } else if((maxev-minev)<1000 && count>=100){ dataletime1[i][ii]= new TGraph(count,xb,yb); dataletime1[i][ii]->SetMarkerStyle(21); if((maxev-minev)<50) dataletime1[i][ii]->SetMarkerSize(0.5); else dataletime1[i][ii]->SetMarkerSize(0.3); dataletime1[i][ii]->SetMarkerColor(2); dataletime1[i][ii]->Draw("psame"); } li.SetLineColor(1); li.SetLineStyle(1); li.SetLineWidth(1); // if(i!=6) li.DrawLine(min,750,max,750); // else li.DrawLine(min,1500,max,1500); // li.DrawLine(min,3075,max,3075); if(i!=6) li.DrawLine(xMIN,750,xMAX,750); else li.DrawLine(xMIN,1500,xMAX,1500); li.DrawLine(xMIN,3075,xMAX,3075); li.SetLineColor(12); li.SetLineStyle(4); li.SetLineWidth(1); for(Int_t j=countHOBT;jx[maxev-minev-1]){ if(i==11) countHOBT=j; break; } else{ if( HOBT[j]>xMIN && HOBT[j]SetTextColor(6); if(i==6) t2->DrawLatex(HOBT[j],4350.,calus.str().c_str()); else t2->DrawLatex(HOBT[j],3350.,calus.str().c_str()); calus.str(""); } else{ calus<<"O"; t2->SetTextColor(3); if(i==6) t2->DrawLatex(HOBT[j],4350.,calus.str().c_str()); else t2->DrawLatex(HOBT[j],3350.,calus.str().c_str()); calus.str(""); } } } } // if(ii==0){ // if(i==6) ar.DrawArrow(COBT[0],1700.,COBT[0],2700.,0.01,"<"); // else ar.DrawArrow(COBT[0],1000.,COBT[0],2000.,0.01,"<"); // } for(Int_t j=countCOBT;jx[maxev-minev-1]){ if(i==11) countCOBT=j; break; } else{ if( COBT[j]>xMIN && COBT[j]Update(); } minev=maxev; printf("\ncountrun=%d\n",ii); if(maxev==maxevent-1) { countrun=ii+1; break; } } printf("... end of packets. \n"); //************************************************************************* // Save output Files //************************************************************************* stringstream nom1,nom2,nom3; for(Int_t fl=0;flPrint(out+nom1.str().c_str()); nom1.str(""); } if(countrun>=2){ if(!strcmp(outfile.Data(),"ps") || !strcmp(outfile.Data(),"pdf")){ nom1.str(""); nom2.str(""); nom3.str(""); nom1<Print(out+nom1.str().c_str(),"portrait"); else if(fl==countrun-1) DataTimeCanv[fl]->Print(out+nom3.str().c_str(),"portrait"); else DataTimeCanv[fl]->Print(out+nom2.str().c_str(),"portrait"); } else{ nom1.str(""); nom1<Print(out+nom1.str().c_str()); } } } if(!strcmp(outfile.Data(),"pdf") && countrun>=2){ stringstream com; com<<"ps2pdf13 "< ps file converted in pdf format!\n"); com.str(""); com<<"rm -f "< ps file removed!\n\n"); com.str(""); } datafile->Close(); gROOT->Reset(); return; }