--- quicklook/tracker/flight/macros/FTrkQLook_BASIC.cxx 2006/06/05 14:23:29 1.5 +++ quicklook/tracker/flight/macros/FTrkQLook_BASIC.cxx 2006/07/13 10:13:37 1.10 @@ -1,8 +1,8 @@ /** - * FTrkQLook_BASIC.cpp + * FTrkQLook_BASIC.cxx * * autor: D.Fedele - * version 2.0 + * version v1r06 * Parameters: * file - the data file to analyze * fromevent - first event to analyze @@ -17,6 +17,7 @@ #include #include #include +#include #include #include // @@ -24,33 +25,20 @@ #include #include #include +#include +#include // #define MAXSTORAGE 50000 -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+="/"; + ffile=file(dwpos+1,dwpos1-(dwpos+1)); + if(dwpos>0) base=file(0,dwpos); TString out; if(outdir.Length()==0){ @@ -58,6 +46,7 @@ }else{ out = outdir; } + if(out.Last('/')+1Get("RunHeader"); @@ -75,7 +67,6 @@ tr->SetBranchAddress("Header",&eh); TTree *ctr = (TTree*)datafile->Get("CalibTrk1"); ctr->SetBranchAddress("Header",&ceh); - Long64_t neventC = ctr->GetEntries(); Long64_t nevent = tr->GetEntries(); @@ -120,49 +111,43 @@ // // 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; - Float_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); + countnboot+=1; } - countrun+=(Int_t)nevent/30000; - // printf("\ncountrun=%d\n",countrun); + countnboot+=2*(Int_t)nevent/MAXSTORAGE; + // printf("\ncountnboot=%d\n",countnboot); // // information about calibration OBT + Int_t COBT[neventC]; + for (Int_t vi=0; viGetEntry(ev); pH = ceh->GetPscuHeader(); COBT[ev]= pH->GetOrbitalTime(); } - //**************************************************************************************** - //Output figure - //**************************************************************************************** + // + // Style options gStyle->SetLabelSize(0.06,"x"); gStyle->SetLabelSize(0.06,"y"); gStyle->SetStatFontSize(0.075); @@ -175,12 +160,21 @@ gStyle->SetTitleSize(0.06,"y"); gStyle->SetTitleSize(0.055,"x"); + //*************************************************************************************** + // LOOP on each event + //*************************************************************************************** + + if (fromevent!=0) + printf("\n Scan of events from %i to %i ... \n",minevent,maxevent-1); + else + printf("\n Scan of events from %i to %i ... \n",minevent+1,maxevent); + - 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; iiDrawLatex(10.,96.,fromfile.str().c_str()); + t->DrawLatex(7.,96.,fromfile.str().c_str()); fromfile.str(""); //************************************************************************************* @@ -257,9 +251,6 @@ TArrow ar; ar.SetLineColor(3); - //********************************************************************************** - // Fill Graphs and Histos - //********************************************************************************** stringstream calus; TLatex *t2=new TLatex(); @@ -271,24 +262,43 @@ Int_t i=0; Float_t x[MAXSTORAGE], xb[MAXSTORAGE]; Float_t yyd[MAXSTORAGE][12],yyb[MAXSTORAGE][12]; + Int_t countbad[12]; + Float_t perc=0,xMIN=0.,xMAX=0.; + for (Int_t n=0; n<12 ; n++) + countbad[n]=0; + + // + // obtain values of the datalenght for (Int_t ev=minev; evGetEntry(ev); ph = eh->GetPscuHeader(); - + cod = eh->GetCounter(); + + if(ev==minev){ + if(cod->Get(pctp->CalibTrk1)>0) cin=cod->Get(pctp->CalibTrk1)-1; + else cin=cod->Get(pctp->CalibTrk1); + if(cin==cfin-1) cin+=1; + + if(cod->Get(pctp->RunHeader)>0) hin=cod->Get(pctp->RunHeader)-1; + else hin=cod->Get(pctp->RunHeader); + if(hin==hfin-1) hin+=1; + } + if(ev==maxevent-1) maxev=maxevent-1; - if((ph->GetOrbitalTime()GetOrbitalTime()Get(pctp->CalibTrk1); + hfin=cod->Get(pctp->RunHeader); x[(ev-minev)]= ph->GetOrbitalTime(); i=0; for (Int_t n=0; n<12 ; n++){ - perc=0; - count=0; - yyb[count][i]=0; - xb[count]= 0; + yyb[countbad[n]][i]=0; + xb[countbad[n]]= 0; i=te->DSPnumber[n]-1; @@ -296,40 +306,35 @@ 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++; + yyb[countbad[i]][i]= yyd[(ev-minev)][i]; + xb[countbad[i]]= x[(ev-minev)]; + countbad[i]+=1; } } } 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++; + yyb[countbad[i]][i]= yyd[(ev-minev)][i]; + xb[countbad[i]]= x[(ev-minev)]; + countbad[i]+=1; } } } } } } - - if(ii==0 && COBT[0]1000000) xMIN=x[0]-(x[maxev-minev-1]-x[0])/10; + if(xMAX<1000000 || xMIN<0) xMIN=0.; + + // + // Draw Histos for (Int_t i=0; i<12 ; i++){ Float_t y[maxev-minev],yb[maxev-minev]; @@ -338,13 +343,18 @@ yb[v]=yyb[v][i]; } + if(xMAX<1000000){ + x[maxev-minev-1]=0.; + y[maxev-minev-1]=0.; + } + if((maxev-minev)>1000){ - perc=(count*100)/(maxev-minev); + perc=(countbad[i]*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); + if(countbad[i]>=100) pad[i][ii]->SetFillColor(2); else pad[i][ii]->SetFillColor(10); } @@ -361,27 +371,27 @@ 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); + else dataletime[i][ii]->GetYaxis()->SetRangeUser(0,4000); dataletime[i][ii]->SetMarkerStyle(21); if((maxev-minev)<50) dataletime[i][ii]->SetMarkerSize(0.5); - else dataletime[i][ii]->SetMarkerSize(0.3); + else dataletime[i][ii]->SetMarkerSize(0.1); dataletime[i][ii]->SetMarkerColor(4); dataletime[i][ii]->Draw("ap"); if((maxev-minev)>1000 && perc>10){ - dataletime1[i][ii]= new TGraph(count,xb,yb); + dataletime1[i][ii]= new TGraph(countbad[i],xb,yb); dataletime1[i][ii]->SetMarkerStyle(21); if((maxev-minev)<50) dataletime1[i][ii]->SetMarkerSize(0.5); - else dataletime1[i][ii]->SetMarkerSize(0.3); + else dataletime1[i][ii]->SetMarkerSize(0.1); 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); + else if((maxev-minev)<1000 && countbad[i]>=100){ + dataletime1[i][ii]= new TGraph(countbad[i],xb,yb); dataletime1[i][ii]->SetMarkerStyle(21); if((maxev-minev)<50) dataletime1[i][ii]->SetMarkerSize(0.5); - else dataletime1[i][ii]->SetMarkerSize(0.3); + else dataletime1[i][ii]->SetMarkerSize(0.1); dataletime1[i][ii]->SetMarkerColor(2); dataletime1[i][ii]->Draw("psame"); } @@ -395,70 +405,54 @@ li.SetLineColor(12); li.SetLineStyle(4); li.SetLineWidth(1); - for(Int_t j=countHOBT;jx[maxev-minev-1]){ - if(i==11) countHOBT=j; - break; - } + for(Int_t j=hin;jSetTextColor(6); + if(i==6) t2->DrawLatex(HOBT[j],4350.,calus.str().c_str()); + else t2->DrawLatex(HOBT[j],3850.,calus.str().c_str()); + calus.str(""); + } 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(""); - } - } + calus<<"O"; + t2->SetTextColor(3); + if(i==6) t2->DrawLatex(HOBT[j],4350.,calus.str().c_str()); + else t2->DrawLatex(HOBT[j],3850.,calus.str().c_str()); + calus.str(""); } } - 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; + countnboot=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(countnboot>=2){ if(!strcmp(outfile.Data(),"ps") || !strcmp(outfile.Data(),"pdf")){ nom1.str(""); nom2.str(""); @@ -467,7 +461,7 @@ nom2<Print(out+nom1.str().c_str(),"portrait"); - else if(fl==countrun-1) DataTimeCanv[fl]->Print(out+nom3.str().c_str(),"portrait"); + else if(fl==countnboot-1) DataTimeCanv[fl]->Print(out+nom3.str().c_str(),"portrait"); else DataTimeCanv[fl]->Print(out+nom2.str().c_str(),"portrait"); } @@ -479,7 +473,9 @@ } } - if(!strcmp(outfile.Data(),"pdf") && countrun>=2){ + // + // Convert ps to pdf if required + if(!strcmp(outfile.Data(),"pdf") && countnboot>=2){ stringstream com; com<<"ps2pdf13 "<