/** * 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 // 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; iGet("RunHeader"); otr->SetBranchAddress("Header",&eH); otr->SetBranchAddress("RunHeader",&reh); TTree *tr = (TTree*)datafile->Get("Physics"); tr->SetBranchAddress("Tracker",&te); tr->SetBranchAddress("Header",&eh); 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); 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 size=nevent; Int_t dsp=0,count=0,trk_cal_us[50]; Double_t perc; Double_t yd[size*12], x[size+1]; Double_t yyd[size+1],yyb[size], xb[size]; ULong64_t HOBT[50]; TGraph *dataletime,*dataletime1; for (Int_t i=0; i<50;i++){ HOBT[i]=0; trk_cal_us[i]=0; } //*************************************************************************************** // LOOP on each event //*************************************************************************************** // // information about trk_calib_used for (Int_t ev=0; evGetEntry(ev); pH = eH->GetPscuHeader(); HOBT[ev]= pH->GetOrbitalTime(); trk_cal_us[ev]=reh->TRK_CALIB_USED; } // // information about datalength x[0]=(Double_t)HOBT[0]; for (Int_t ev=minevent; evGetEntry(ev); ph = eh->GetPscuHeader(); x[(ev-minevent)+1]= ph->GetOrbitalTime(); dsp=0; for(Int_t i=0; i<12; i++){ dsp=te->DSPnumber[i]-1; yd[(ev-minevent)*12+dsp]= te->DATAlength[i]; } }; datafile->Close(); //**************************************************************************************** //Output figure //**************************************************************************************** TCanvas *DataTimeCanv=new TCanvas("Tracker_Detector_Report_","",900,1200); DataTimeCanv->SetFillColor(10); DataTimeCanv->Range(0,0,100,100); fromfile<<"FTrkQLook_BASIC File: "<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(""); //************************************************************************************* //book pads and histos //*************************************************************************************** gStyle->SetLabelSize(0.06,"x"); gStyle->SetLabelSize(0.06,"y"); gStyle->SetStatFontSize(0.075); gStyle->SetOptStat(1110); gStyle->SetFillColor(10); gStyle->SetTitleFontSize(0.1); gStyle->SetTitleOffset(0.8,"y"); gStyle->SetTitleOffset(0.9,"x"); gStyle->SetTitleSize(0.06,"y"); gStyle->SetTitleSize(0.055,"x"); TPad *pad[12]; //pad for 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 */ pad[n] = new TPad("pad"," ",posx1,posy-hpad,posx0,posy,18,0,0); }; TLine li; li.SetLineColor(1); li.SetLineStyle(1); li.SetLineWidth(1); //********************************************************************************** // Fill Graphs and Histos //********************************************************************************** stringstream calus; TLatex *t2=new TLatex(); t2->SetTextFont(32); t2->SetTextColor(1); t2->SetTextAlign(13); t2->SetTextSize(0.08); for (Int_t i=0; i<12 ; i++){ perc=0; count=0; yyd[0]=-10000.; for (Int_t ev=minevent; ev1500){ if(yyd[(ev-minevent)+1]<3075){ yyb[count]= yyd[(ev-minevent)+1]; xb[count]= x[(ev-minevent)+1]; count++; } } } else{ if(yyd[(ev-minevent)+1]>750){ if(yyd[(ev-minevent)+1]<3075){ yyb[count]= yyd[(ev-minevent)+1]; xb[count]= x[(ev-minevent)+1]; count++; } } } } if((maxevent-minevent)>100) perc=(count*100)/(maxevent-minevent); else perc=(count*10)/(maxevent-minevent); Double_t min,max; if((maxevent-minevent)<100){ min=x[0]; max=x[size]*1.0001; } else{ min=x[0]; max=x[size-1]*1.0005; } oss<<"DSP "<cd(); if(perc>1) pad[i]->SetFillColor(2); else pad[i]->SetFillColor(10); pad[i]->SetFrameFillColor(10); pad[i]->Draw(); pad[i]->cd(); dataletime= new TGraph((maxevent-minevent)+1,x,yyd); dataletime->SetTitle(oss.str().c_str()); dataletime->GetXaxis()->SetTitle("OBT (ms)"); dataletime->GetXaxis()->CenterTitle(); dataletime->GetXaxis()->SetRangeUser(min,max); dataletime->GetYaxis()->SetTitle("datalength (Word 13 bit)"); dataletime->GetYaxis()->CenterTitle(); dataletime->GetYaxis()->SetRangeUser(0,3500); dataletime->SetMarkerStyle(21); if((maxevent-minevent)<50) dataletime->SetMarkerSize(0.5); else dataletime->SetMarkerSize(0.3); dataletime->SetMarkerColor(1); dataletime->Draw("ap"); if(perc>1){ dataletime1= new TGraph(count,xb,yyb); dataletime1->SetMarkerStyle(21); if((maxevent-minevent)<50) dataletime1->SetMarkerSize(0.5); else dataletime1->SetMarkerSize(0.3); dataletime1->SetMarkerColor(2); dataletime1->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); for(Int_t j=0;jSetTextColor(6); t2->DrawLatex(HOBT[j],3350.,calus.str().c_str()); calus.str(""); } else{ calus<SetTextColor(3); t2->DrawLatex(HOBT[j],3350.,calus.str().c_str()); calus.str(""); } } oss.str(""); }; DataTimeCanv->Update(); printf("... end of packets. \n"); //************************************************************************* // Save output Files //************************************************************************* stringstream out1; out1<Print(out+out1.str().c_str()); out1.str(""); gROOT->Reset(); return; }