--- quicklook/QLflightS4_ND/S4_QL.cpp 2006/06/15 14:00:30 1.1 +++ quicklook/QLflightS4_ND/S4_QL.cpp 2006/09/25 08:42:56 1.5 @@ -28,6 +28,9 @@ * in a pad * * for a large namber of events is not possible to have vectors, so all graphs have been converted in histograms +* +* Version 2.0 - September 2006 +* Fixed bugs: changed the number of bin in the "rate" histograms and the size of the string vector trcss *******/ @@ -59,7 +62,7 @@ using namespace std; void S4_QL(TString base, TString outDir, TString format, ULong_t DeltaT){ //DeltaT in minute - + //------ Variables initialization ---------/ Int_t tmpSize; ULong_t mintime, maxtime; @@ -74,11 +77,12 @@ TString str; TString trcsstot[31]; TString trcsstot2; - TString trcss[100]=""; + TString trgconf[31]={"TOF1","TOF2","TOF3","TOF4","TOF5","TOF6","TOF7","S4","CALO","CALO-S4","TOF1-S4","TOF2-S4","TOF3-S4","TOF4-S4","TOF5-S4","TOF6-S4","TOF7-S4","TOF1-CALO","TOF2-CALO","TOF3-CALO","TOF4-CALO","TOF5-CALO","TOF6-CALO","TOF7-CALO","TOF1-CALO-S4","TOF2-CALO-S4","TOF3-CALO-S4","TOF4-CALO-S4","TOF5-CALO-S4","TOF6-CALO-S4","TOF7-CALO-S4",}; stringstream oss, oss1, oss2, oss3, s4soglia, buffer, conftrig, noentries; ULong_t lastime, firstime; Int_t vardumpentries = 0; + Int_t channels = 4096; char S4_TRH[10]; char S4_TRH2[10]; Int_t trigconf = 0; @@ -88,7 +92,6 @@ double obmax=0.; double obt; double s4rate; - int nbin=0; //------to open headerfile, s4file, Trigfile and vardumpfile---------------------------/ TFile *file =new TFile(base.Data()) ; if (!file){ @@ -98,13 +101,13 @@ TTree *VarDumpTr = (TTree*)file->Get("VarDump"); TTree *PhysicsTr = (TTree*)file->Get("Physics"); - + TBranch *S4Br = PhysicsTr->GetBranch("S4"); TBranch *TriggerBr = PhysicsTr->GetBranch("Trigger"); TBranch *headBr = PhysicsTr->GetBranch("Header"); TBranch *VarDumpBr = VarDumpTr->GetBranch("VarDump"); TBranch *headVarDumpBr = VarDumpTr->GetBranch("Header"); - + pamela::S4::S4Event *s4e = 0; pamela::EventHeader *eh = 0; pamela::PscuHeader *ph = 0; @@ -117,14 +120,13 @@ PhysicsTr->SetBranchAddress("Trigger", &trige); VarDumpTr->SetBranchAddress("VarDump", &vde); - nevents = headBr->GetEntries(); - const Int_t sizetot = nevents; + nevents = S4Br->GetEntries(); //----------- If nevents < = 0 ---------------------------------/ if (nevents<=0) { printf("nevents = %i \n", nevents); printf(" \n"); - + TCanvas *canvas4 = new TCanvas("No entries", "No entries ", 400, 200); canvas4->SetFillColor(10); canvas4->cd(); @@ -139,7 +141,7 @@ noentries.str(""); noentries<< "No entries for this files"; l->DrawLatex(0.05, 0.5, noentries.str().c_str()); - + if (outDir == "./") { oss.str(""); oss << filename.Data() << "_S4_QL." << format.Data(); @@ -147,24 +149,17 @@ oss.str(""); oss << outDir.Data() << filename.Data() << "_S4_QL." << format.Data(); } - + canvas4->Update(); canvas4->SaveAs(oss.str().c_str()); - + return; } - - for (Int_t i = 0; i < nevents; i++){ - headBr->GetEntry(i); - S4Br->GetEntry(i); - TriggerBr->GetEntry(i); - if (s4e->unpackError == 1 || s4e->S4_DATA==0) continue; - //-------to set max adc value------------------------------------------// - if (i==0){ - adcmax=s4e->S4_DATA; - } - //-------to set trigger configuration---------------------------------// - if ((s4e->S4_DATA)> adcmax) adcmax=(s4e->S4_DATA); + const Int_t ev = nevents; + TString trcss[ev]; + //-------to set trigger configuration---------------------------------// + for (Int_t ll = 0; ll < nevents; ll++){ + TriggerBr->GetEntry(ll); trigconf = trige->trigconf; trc = 0; if ( trigconf & (1<<0) ) trc = "TOF1"; @@ -179,15 +174,15 @@ if ( trigconf & (1<<3) ) { if (trc==0) trc= "TOF4"; else trc = Form("%s-TOF4",trc); - } + } if ( trigconf & (1<<4) ) { if (trc==0) trc= "TOF5"; else trc = Form("%s-TOF5",trc); - } + } if ( trigconf & (1<<5) ) { if (trc==0) trc= "TOF6"; else trc = Form("%s-TOF6",trc); - } + } if ( trigconf & (1<<6) ) { if (trc==0) trc= "TOF7"; else trc = Form("%s-TOF7",trc); @@ -196,25 +191,28 @@ if (trc==0) trc= "S4"; else trc = Form("%s-S4",trc); } - if ( trigconf & (1<<8) ) { - if (trc==0) trc= "CALO"; - else trc = Form("%s-CALO",trc); - } - if ( trigconf & (1<<9) ) { - if (trc==0) trc= "CALIB_ON"; - else trc = Form("%s-CALIB_ON",trc); - } - trcs = ""; - trcs = trc; - if (i==0){ - trcss[0]=trcs; - j=j+1; - } - if (trcs!=trcss[j-1] && i>0){ - trcss[j]=trcs; - j=j+1; - } + if ( trigconf & (1<<8) ) { + if (trc==0) trc= "CALO"; + else trc = Form("%s-CALO",trc); + } + if ( trigconf & (1<<9) ) { + if (trc==0) trc= "CALIB_ON"; + else trc = Form("%s-CALIB_ON",trc); + } + trcs = ""; + trcs = trc; + if (ll==0){ + trcss[0]=trcs; + j=j+1; + } + if (trcs!=trcss[j-1] && ll>0){ + trcss[j]=trcs; + j=j+1; + } + //cout<GetEntries(); if(vardumpentries==0){ @@ -250,19 +249,26 @@ } sprintf(S4_TRH, "%d" , S4_TRHmip); } - } + } //********************** First Histogram ************************************// - TH1F *h1 = new TH1F("All events", "S4 distribution for file: "+filename, adcmax, 10, adcmax+(adcmax/10)); - TH1F *h2 = new TH1F("S4 Triggered events", "S4 distribution for file: "+filename, adcmax, 10, adcmax+(adcmax/10)); + TH1F *h1 = new TH1F("All events", "S4 distribution for file: "+filename, channels, 1, channels); + TH1F *h2 = new TH1F("S4 Triggered events", "S4 distribution for file: "+filename, channels, 1, channels); //********************** Second Histogram ************************************// headBr->GetEntry(0); ph = eh->GetPscuHeader(); firstime = ph->GetOrbitalTime(); - headBr->GetEntry(nevents-1); - ph = eh->GetPscuHeader(); - lastime = ph->GetOrbitalTime(); + + int iii =0; + while(iii < nevents){ + headBr->GetEntry(iii); + ph = eh->GetPscuHeader(); + if((ph->GetOrbitalTime()) <= firstime) firstime=ph->GetOrbitalTime(); + if((ph->GetOrbitalTime()) >= lastime) lastime=ph->GetOrbitalTime(); + iii++; + } + obmin=firstime; obmax=lastime; const ULong_t nint=(((lastime-firstime)/(DeltaT*60000))); @@ -274,15 +280,15 @@ TH1F *S4time = new TH1F("Mean signal from S4-triggered events", filename+": Mean signal from S4 (only s4 triggered events)", size, obmin, obmax); //********************** Third Histogram ************************************// - nbin=sizetot; title=""; title=filename+": S4 rate from Trigger Packet"; - const ULong_t nint3=(lastime-firstime); - const Int_t size3 = (Int_t)((nint3)/3); - - TH1F *rate= new TH1F(title.c_str(), title.c_str(), nint3, obmin, obmax); - TH1F *rateline= new TH1F(filename+": smoothed S4 rate", filename+": smoothed S4 rate", size3, obmin, obmax); + const ULong_t nint2=(lastime-firstime)/10000; + const Int_t size2 = (Int_t)((nint2+1)); // one bin every 10 second + const ULong_t nint3=(lastime-firstime)/1000; + const Int_t size3 = (Int_t)((nint3+1)); // one bin every 1 second + TH1F *rate= new TH1F(title.c_str(), title.c_str(), size2, obmin, obmax); + TH1F *rateline= new TH1F(filename+". S4 rate from Trigger Packet: mean value over 100 events", filename+". S4 rate from Trigger Packet: mean value over 100 events", size3, obmin, obmax); //------------------------------------------------------------------------------------------------------------------ //------- fill histograms ---------// @@ -292,25 +298,32 @@ headBr->GetEntry(i); S4Br->GetEntry(i); ph = eh->GetPscuHeader(); - obt = ph->GetOrbitalTime(); if (s4e->unpackError == 1 && (s4e->S4_DATA)==0) continue; s4rate= trige->s4calcount[0]; - rate->Fill(obt, s4rate); + rate->Fill(ph->GetOrbitalTime(), s4rate); h1->Fill(s4e->S4_DATA); - Allev->Fill(obt,s4e->S4_DATA); - Alltime->Fill(obt); - if((i==n) && (s4rate >0)){ - rateline->Fill(obt,s4rate); - n=n+5; - } - if ((trige->patterntrig[0] == 0) && (trige->patterntrig[2] == 0) && (trige->patterntrig[3] == 0) && (trige->patterntrig[4] == 0) && (trige->patterntrig[5] == 0)){ + Allev->Fill(ph->GetOrbitalTime(),s4e->S4_DATA); + Alltime->Fill(ph->GetOrbitalTime()); + if ((trige->patterntrig[0] == 0)&&(trige->patterntrig[1] != 0)&&(trige->patterntrig[2] == 0)&&(trige->patterntrig[3] == 0)&&(trige->patterntrig[4] == 0)&&(trige->patterntrig[5] == 0)){ h2->Fill(s4e->S4_DATA); - S4ev->Fill(obt,s4e->S4_DATA); - S4time->Fill(obt); + S4ev->Fill(ph->GetOrbitalTime(),s4e->S4_DATA); + S4time->Fill(ph->GetOrbitalTime()); p=p+1; } } - + Int_t kk=0; + while (kk < nevents){ + obt=0; + s4rate=0; + for(Int_t jj=kk; jj< (kk+100); jj++){ + TriggerBr->GetEntry(jj); + headBr->GetEntry(jj); + obt = obt+(ph->GetOrbitalTime()); + s4rate= s4rate+(trige->s4calcount[0]); + } + rateline->Fill((obt/100),(s4rate/100)); + kk=kk+100; + } //****************************** Canvases *******************************// //------------------- First Canvas --------------------------------// @@ -450,7 +463,7 @@ Allev->GetXaxis()->CenterTitle(); Allev->GetYaxis()->SetTitle("Mean signal ( ADC )"); Allev->GetYaxis()->CenterTitle(); - Allev->SetMinimum(20); + //Allev->SetMinimum(20); Allev->Divide(Alltime); Allev->Draw("p"); pad3->Draw();