--- quicklook/anticounter/src/AcQLOOK.cpp 2006/07/07 12:56:18 1.2 +++ quicklook/anticounter/src/AcQLOOK.cpp 2006/07/10 14:39:32 1.3 @@ -13,22 +13,25 @@ #include #include #include +#include #include #define DEBUG 0 -#define VERSION 1.4 +#define VERSION 1.5 #define INTERVAL 100 +#define FORMAT "png" using namespace std; +UInt_t found; Int_t minevent,maxevent; UShort_t ACheader[2]; TString *cardname = new TString[2]; TString *detector = new TString[16]; -int AcQLOOKbasic(TString base,int fromevent=0, int toevent=0, TString outDir = "./", TString format = "jpg"){ +int AcQLOOKbasic(TString base,int fromevent=0, int toevent=0, TString outDir = "./", TString format = FORMAT){ ofstream outputFile; stringstream oss; @@ -47,9 +50,60 @@ //Takes the tree of the header file TTree *tr = (TTree*)rootFile->Get("Physics"); + tr->SetBranchStatus("*",0,&found); //disable all branches + + tr->SetBranchStatus("header*",1,&found); + // printf("header: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("status*",1,&found); + // printf("status: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("hitmap*",1,&found); + // printf("hitmap: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("regist*",1,&found); + // printf("regist: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("shift*",1,&found); + // printf("shift: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("counters*",1,&found); + // printf("counters: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("coinc*",1,&found); + // printf("coinc: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("trigg*",1,&found); + // printf("trigg: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("clock*",1,&found); + // printf("clock: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("temp*",1,&found); + // printf("temp: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("DAC*",1,&found); + // printf("DAC: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("CRC*",1,&found); + // printf("CRC: enabled %i branches \n",found); + + found = 0; + tr->SetBranchStatus("Pscu*",1,&found); + // printf("enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("Anticounter*",1,&found); + // printf("Ac enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("Header*",1,&found); + // printf("head enabled %i branches \n",found); + tr->SetBranchAddress("Anticounter", &ace); tr->SetBranchAddress("Header", &eh); + + + Int_t nevents = tr->GetEntries(); //check that the selected range of events is ok @@ -253,7 +307,12 @@ } //end AcBasic -int AcQLOOKpro(TString base,int fromevent=0, int toevent=0, TString outDir = "./", TString format = "jpg"){ +int AcQLOOKpro(TString base,int fromevent=0, int toevent=0, TString outDir = "./", TString format = FORMAT){ + + //Float_t startTime,stopTime; + //Float_t time1,time2,time3,time4; + + //startTime = clock(); ofstream outputFile; stringstream oss; @@ -271,7 +330,55 @@ //Takes the tree of the header file TTree *tr = (TTree*)rootFile->Get("Physics"); + + tr->SetBranchStatus("*",0,&found); //disable all branches + tr->SetBranchStatus("header*",1,&found); + // printf("header: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("status*",1,&found); + // printf("status: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("hitmap*",1,&found); + // printf("hitmap: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("regist*",1,&found); + // printf("regist: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("shift*",1,&found); + // printf("shift: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("counters*",1,&found); + // printf("counters: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("coinc*",1,&found); + // printf("coinc: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("trigg*",1,&found); + // printf("trigg: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("clock*",1,&found); + // printf("clock: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("temp*",1,&found); + // printf("temp: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("DAC*",1,&found); + // printf("DAC: enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("CRC*",1,&found); + // printf("CRC: enabled %i branches \n",found); + found = 0; + + tr->SetBranchStatus("Pscu*",1,&found); + // printf("enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("Anticounter*",1,&found); + // printf("Ac enabled %i branches \n",found); + found = 0; + tr->SetBranchStatus("Header*",1,&found); + // printf("head enabled %i branches \n",found); + tr->SetBranchAddress("Anticounter", &ace); tr->SetBranchAddress("Header", &eh); @@ -321,7 +428,6 @@ Int_t paramEvents; Int_t minevent,maxevent; char *figsave = " "; - Int_t ch_cnt; UShort_t ACheader[2]; ACheader[0]=0xAC11; ACheader[1]=0xAC22; @@ -433,17 +539,19 @@ } } - TH1D *status_h = new TH1D("Status","Status",10,0.,10.); + TH1D *status_h = new TH1D("Status","Status",12,0.,12.); status_h->GetXaxis()->SetBinLabel(1,"CRC event M"); status_h->GetXaxis()->SetBinLabel(2,"Headers M"); status_h->GetXaxis()->SetBinLabel(3,"CRC M"); status_h->GetXaxis()->SetBinLabel(4,"Dsp M"); - status_h->GetXaxis()->SetBinLabel(5,"Reg M"); - status_h->GetXaxis()->SetBinLabel(6,"CRC event E"); - status_h->GetXaxis()->SetBinLabel(7,"Headers E"); - status_h->GetXaxis()->SetBinLabel(8,"CRC E"); - status_h->GetXaxis()->SetBinLabel(9,"Dsp E"); - status_h->GetXaxis()->SetBinLabel(10,"Reg E"); + status_h->GetXaxis()->SetBinLabel(5,"Temp M"); + status_h->GetXaxis()->SetBinLabel(6,"Reg M"); + status_h->GetXaxis()->SetBinLabel(7,"CRC event E"); + status_h->GetXaxis()->SetBinLabel(8,"Headers E"); + status_h->GetXaxis()->SetBinLabel(9,"CRC E"); + status_h->GetXaxis()->SetBinLabel(10,"Dsp E"); + status_h->GetXaxis()->SetBinLabel(11,"Temp E"); + status_h->GetXaxis()->SetBinLabel(12,"Reg E"); status_h->GetYaxis()->SetTitle("# of Errors"); status_h->SetMinimum(0); @@ -483,7 +591,11 @@ /********************* MAIN LOOP **********************/ - //UShort_t tshift[16]; + //time1 = clock(); + //printf("Init time: %f\n",(Double_t) (time1 - startTime) / (Double_t) CLOCKS_PER_SEC); + + //iterators used in the loop + Int_t card, ch, bin; for (Int_t i = minevent; i < maxevent; i++){ @@ -495,28 +607,11 @@ hitsCARD=hitsCAT=hitsCAS=0; - /* - for(Int_t ii=0;ii<16;ii++) - tshift[ii]=0; - for(Int_t ii=0;ii<16;ii++) - { - for(Int_t jj=0;jj<16;jj++) - { - if(ace->shift[0][jj] & (1<Fill(kk,tshift[ii] & 0x1<CRCcheck[card]); + //printf("Hitmap: %hx\n\n",ace->hitmap[card]); if(ace->CRCcheck[card]==1) { //clock @@ -531,45 +626,45 @@ time_between_trigg_h[card]->Fill( 0.000000025*ac_clock_diff[card] ); //counters, singlesrate & shift reg content - for(Int_t ch=0;ch<16;ch++){ - counter_old[card][ch] = counter_new[card][ch]; - counter_new[card][ch] = ace->counters[card][ch]; - if(counter_new[card][ch] - counter_old[card][ch] < 0.) - counter_diff[card][ch] = 0xFFFF + counter_new[card][ch] - counter_old[card][ch]; - else - counter_diff[card][ch] = counter_new[card][ch] - counter_old[card][ch]; - - singles_gr[card][ch][paramEvent] += (Double_t)counter_diff[card][ch]; - - - for(Int_t bin = 0; bin < 16; bin++){ - shiftreg_h[card][bin]->Fill(ch,ace->shift[card][ch] & 0x1<hitmap[card] & (0x1< 0 ){ - hitmap_h[card]->Fill(ch_cnt,1.); - if(ch_cnt==0 || ch_cnt==4 || ch_cnt==8 || ch_cnt==12) + counter_old[card][ch] = counter_new[card][ch]; + counter_new[card][ch] = ace->counters[card][ch]; + if(counter_new[card][ch] - counter_old[card][ch] < 0.) + counter_diff[card][ch] = 0xFFFF + counter_new[card][ch] - counter_old[card][ch]; + else + counter_diff[card][ch] = counter_new[card][ch] - counter_old[card][ch]; + + singles_gr[card][ch][paramEvent] += (Double_t)counter_diff[card][ch]; + + for(bin = 0; bin < 16; bin++){ + shiftreg_h[card][bin]->Fill(ch,ace->shift[card][ch] & 0x1<hitmap[card] & (0x1< 0 ){ + hitmap_h[card]->Fill(ch,1.); + if(ch==0 || ch==4 || ch==8 || ch==12) hitsCARD++; - else if(ch_cnt==1 || ch_cnt==5 || ch_cnt==9 || ch_cnt==13) + else if(ch==1 || ch==5 || ch==9 || ch==13) hitsCAT++; - else if(ch_cnt==2 || ch_cnt==6 || ch_cnt==10 || ch_cnt==14) + else if(ch==2 || ch==6 || ch==10 || ch==14) hitsCAS++; } + } - + //Status if((ace->header[card][0] != 0xACAC) || (ace->header[card][1] != ACheader[card])) - status_h->Fill(1.+5.*card,1.); + status_h->Fill(1.+6.*card,1.); if((ace->status[card] & 0x8000) < 0x8000) //crc - status_h->Fill(2.+5.*card,1.); - if((ace->status[card] & 0x4000) < 0x4000) //dsp - status_h->Fill(3.+5.*card,1.); + status_h->Fill(2.+6.*card,1.); + if((ace->status[card] & 0x6000) < 0x6000) //dsp + status_h->Fill(3.+6.*card,1.); + if((ace->status[card] & 0x0E00) < 0x0E00) //temp + status_h->Fill(4.+6.*card,1.); if((ace->status[card] & 0x01FF) < 0x01FF) //reg - status_h->Fill(4.+5*card,1.); + status_h->Fill(4.+6*card,1.); //temperature (left on cards) temp_gr[card][0][paramEvent] += ( ((ace->temp[card][0] & 0x00FF))*2.8 - 273. )/(Float_t)INTERVAL; @@ -578,9 +673,8 @@ temp_gr[card][3][paramEvent] += ( ((ace->temp[card][1] & 0xFF00)/256)*2.8 - 273. )/(Float_t)INTERVAL; }//if(crc check) - /******************************************************/ else - status_h->Fill(5.*card,1.); //event crc + status_h->Fill(6.*card,1.); //event crc }//for(card) nmbhitpmtCARD_h->Fill(hitsCARD); @@ -588,12 +682,11 @@ nmbhitpmtCAT_h->Fill(hitsCAT); - if(interval_cnt==(Int_t)((Float_t)INTERVAL/2.)) - event_obt[paramEvent] = ph->GetOrbitalTime(); - if(interval_cnt==INTERVAL) { - for(Int_t card=0;card<2;card++) + event_obt[paramEvent] = ph->GetOrbitalTime(); + + for(card=0;card<2;card++) { ac_clock100_old[card] = ac_clock100_new[card]; ac_clock100_new[card] = (ace->clock[card][1])*0xFFFF + ace->clock[card][0]; @@ -604,20 +697,18 @@ trigger_gr[card][paramEvent] = (Float_t)INTERVAL/(0.000000025*ac_clock100_diff[card]); - for(Int_t ch=0;ch<16;ch++) + for(ch=0;ch<16;ch++) singles_gr[card][ch][paramEvent] = singles_gr[card][ch][paramEvent]/(Double_t)(0.000000025*ac_clock100_diff[card]); }//for(card) interval_cnt=0; paramEvent++; }//if(interval_cnt)) - /* - for(card=0;card<2;card++) - for(Int_t ch=0;ch<16;ch++) - for(Int_t bin=0;bin<16;bin++) - shiftreg_h[card][ch]->Fill(bin,vec[card][bin][ch]); - */ + } //for(events) + + //time2 = clock(); + //printf("Loop time: %f\n",(Double_t) (time2 - time1) / (Double_t) CLOCKS_PER_SEC); /****************************** PLOTTING ***************************/ @@ -646,12 +737,15 @@ pd4->Draw(); pd4->cd(); - char *namn2 = "Anticounter Quicklook"; char namn3[30]; - sprintf(namn3,"Version %.1f",VERSION); + char namn4[40]; + sprintf(namn3,"Anticounter Quicklook v%.1f",VERSION); + sprintf(namn4,"File: %s",fileName.Data()); + t->SetTextSize(0.1); + t->DrawLatex(5,90,namn3); t->SetTextSize(0.1); - t->DrawLatex(20,60,namn2); - t->DrawLatex(20,40,namn3); + t->DrawLatex(20,50,namn4); + t->SetTextSize(0.02); pd3->cd(); @@ -697,19 +791,24 @@ temperatureACTEL_E_g->SetMarkerColor(2); temperatureLEFT_E_g->SetMarkerColor(3); temperatureDSP_E_g->SetMarkerColor(4); + temperatureRIGHT_E_g->SetLineColor(1); + temperatureACTEL_E_g->SetLineColor(2); + temperatureLEFT_E_g->SetLineColor(3); + temperatureDSP_E_g->SetLineColor(4); + temperatureRIGHT_E_g->SetMaximum(50.); temperatureRIGHT_E_g->SetMinimum(0.); - temperatureRIGHT_E_g->Draw("AP"); - temperatureACTEL_E_g->Draw("PSAME"); - temperatureLEFT_E_g->Draw("PSAME"); - temperatureDSP_E_g->Draw("PSAME"); + temperatureRIGHT_E_g->Draw("AL"); + temperatureACTEL_E_g->Draw("LSAME"); + temperatureLEFT_E_g->Draw("LSAME"); + temperatureDSP_E_g->Draw("LSAME"); TLegend *legTempE = new TLegend(0.72,0.63,0.86,0.8); - legTempE->AddEntry(temperatureRIGHT_E_g,"Right","P"); - legTempE->AddEntry(temperatureACTEL_E_g,"Actel","P"); - legTempE->AddEntry(temperatureLEFT_E_g,"Left","P"); - legTempE->AddEntry(temperatureDSP_E_g,"Dsp","P"); + legTempE->AddEntry(temperatureRIGHT_E_g,"Right","L"); + legTempE->AddEntry(temperatureACTEL_E_g,"Actel","L"); + legTempE->AddEntry(temperatureLEFT_E_g,"Left","L"); + legTempE->AddEntry(temperatureDSP_E_g,"Dsp","L"); legTempE->Draw(); /************************/ @@ -748,8 +847,10 @@ triggM_gr->GetYaxis()->SetTitle("f [Hz]"); triggM_gr->SetMarkerColor(1); triggE_gr->SetMarkerColor(2); - triggM_gr->Draw("AP"); - triggE_gr->Draw("PSAME"); + triggM_gr->SetLineColor(1); + triggE_gr->SetLineColor(2); + triggM_gr->Draw("AL"); + triggE_gr->Draw("LSAME"); pd23->cd(); gPad->SetLogy(1); @@ -973,6 +1074,11 @@ delete hitmap_h[0]; delete hitmap_h[1]; + //stopTime = clock(); + //printf("Draw time: %f\n\n",(Double_t) (stopTime - time2) / (Double_t) CLOCKS_PER_SEC); + //printf("Exc time: %f\n",(Double_t) (stopTime-startTime) / (Double_t) CLOCKS_PER_SEC); + + return 1; } @@ -980,7 +1086,7 @@ int main(int argc, char* argv[]){ TString outDir = "."; - TString format = "jpg"; + TString format = FORMAT; int from = 0; int to = 0; int mode = 0;