--- quicklook/tracker/flight/macros/FTrkQLook_BASIC.cxx 2006/06/01 15:23:12 1.2 +++ 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,32 +25,20 @@ #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+="/"; + ffile=file(dwpos+1,dwpos1-(dwpos+1)); + if(dwpos>0) base=file(0,dwpos); TString out; if(outdir.Length()==0){ @@ -57,6 +46,7 @@ }else{ out = outdir; } + if(out.Last('/')+1Get("RunHeader"); @@ -74,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(); @@ -119,48 +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; - 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); + countnboot+=1; } - countrun+=20; - 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); @@ -173,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(""); //************************************************************************************* @@ -219,12 +215,12 @@ //*************************************************************************************** - 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 + Float_t posy = 0.95; // up y-coord - top pads + Float_t hpad = 0; // pad height + Float_t posx1=0; // left x-coord - pad column + Float_t posx0=0; // x-coord - column division + Float_t wrel = 0; // relative x size of first sub-column + Float_t marg = 0.004; // margin among pads hpad = (posy-marg*11)/6; wrel = (1-marg*4)/2; @@ -255,9 +251,6 @@ TArrow ar; ar.SetLineColor(3); - //********************************************************************************** - // Fill Graphs and Histos - //********************************************************************************** stringstream calus; TLatex *t2=new TLatex(); @@ -267,29 +260,45 @@ t2->SetTextSize(0.08); Int_t i=0; - Double_t x[30000], xb[30000]; - Double_t yyd[30000][12],yyb[30000][12]; + 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; - // printf("prova00\n"); - if((ph->GetOrbitalTime()30000){ + + if((ph->GetOrbitalTime()Get(pctp->CalibTrk1); + hfin=cod->Get(pctp->RunHeader); 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; + yyb[countbad[n]][i]=0; + xb[countbad[n]]= 0; i=te->DSPnumber[n]-1; @@ -297,57 +306,55 @@ 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; } } } } } } - - // printf("prova2\n"); - 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++){ - Double_t y[maxev-minev],yb[maxev-minev]; + Float_t y[maxev-minev],yb[maxev-minev]; for(Int_t v=0;v1000){ - 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); } @@ -357,46 +364,40 @@ 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); + 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"); - // printf("prova4\n"); 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"); } 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); @@ -404,74 +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(""); } } - // 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; + 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(""); @@ -480,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"); } @@ -492,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 "<