--- eventviewer/flight/macros/FEventViewer.cxx 2006/03/20 10:36:48 1.1.1.1 +++ eventviewer/flight/macros/FEventViewer.cxx 2006/04/04 14:04:08 1.3 @@ -1,6 +1,6 @@ //------------------------------------------------------------------------------------------------------------------------------------------------------- // -// FEventViewer.c version 1.00 (2006-03-09) +// FEventViewer.c version 1.03 (2006-04-04) // // Shows PAMELA events - Emiliano Mocchiutti // @@ -23,6 +23,10 @@ // // Changelog: // +// 1.02 - 1.03 (2006-04-04): Make it possible to select events with the calorimeter also when generating level1 from level0. +// +// 1.01 - 1.02 (2006-03-22): Read calorimeter ADC2MIP flight conversion file. Do not install FEventviewer.cxx! +// // 1.00 - 1.01 (2006-03-09): Flight version, read unique YODA file. Many capabilities disabled at the moment (reads only LEVEL0 data). // // 0.00 - 1.00 (2006-03-09): Clone of EventViewer.c v9r01. @@ -5114,7 +5118,7 @@ // OTHER SUBROUTINES ** //********************************************************************************** -void ShowCaloL0(TString filename, Int_t i, Calib & calib, Int_t b[4], Float_t mip[2][22][96], TTree *otr, Variables & var){ +void ShowCaloL0(TString filename, Int_t i, Calib & calib, Int_t b[4], Float_t mip[2][22][96], TTree *otr, Variables & var, Bool_t upd){ struct Evento evento; Int_t tot0 = 0; Int_t tot1 = 0; @@ -5154,6 +5158,7 @@ Int_t bgcolor = 10; TPad *pd1 = new TPad("calox","This is pad1",var.xxvc-0.154*var.sfx,var.yxvc-0.3645*var.sfy,var.xxvc+0.154*var.sfx,var.yxvc-0.1200*var.sfy,bgcolor); TPad *pd2 = new TPad("caloy","This is pad2",var.xyvc-0.154*var.sfx,var.yyvc-0.3645*var.sfy,var.xyvc+0.154*var.sfx,var.yyvc-0.1200*var.sfy,bgcolor); + if ( upd ){ pd1->SetFillStyle(4000); pd1->SetFillColor(0); @@ -5188,6 +5193,7 @@ Yview->Fill(1.,1.,1.); Yview->Draw("box"); pd2->Update(); + }; // // for each event check that the calibration we are using are still within calibration limits, if not call the next calibration // @@ -5309,6 +5315,7 @@ // // OK, now in estrip we have the energy deposit in MIP of all the strips for this event (at the end of loops of course) // + if ( upd ){ xve.str(""); yve.str(""); xve << "x-view event " << n; @@ -5341,7 +5348,8 @@ pd2->cd(); Yview->Draw("box same"); }; - }; + }; + }; if ( estrip[l][m][n] > 0.7 && calib.calgood[l][m][n] != 0 ) badstrip++; if ( estrip[l][m][n] > 0.7 && calib.calgood[l][m][n] == 0 ) { qtot += estrip[l][m][n]; @@ -5352,8 +5360,10 @@ }; }; }; + if ( upd ){ pd1->Update(); pd2->Update(); + }; var.qtot=(int)qtot; var.nstrip=nstrip; } @@ -5703,7 +5713,7 @@ const char *pam_calib = pathtocalibration(); stringstream calfile; calfile.str(""); - calfile << pam_calib << "/CaloADC2MIP.root"; + calfile << pam_calib << "/FCaloADC2MIP.dat"; // Int_t selection = 0; Bool_t firsttime = true; @@ -5803,12 +5813,6 @@ Float_t mip[2][22][96]; Int_t okcalo = 0; // - TFile *chfile = 0; - TTree *ctree = 0; - CalorimeterCalibration *ccalo = 0; - // TFile *chfile = new TFile; - //TTree *ctree = new TTree; - //CalorimeterCalibration *ccalo = new CalorimeterCalibration(); Long64_t cnevents = 0ULL; // var.goon = false; @@ -6356,52 +6360,28 @@ // if ( !var.refresh ){ if ( !CALOLEV && var.CALO ){ - // if ( !existfile((TString)calfile.str().c_str()) ){ - if ( true ){ - printf(" WARNING: no calorimeter calibration file! \n Using 26 as conversion factor for all strips. \n"); - okcalo = 0; + printf(" ADC to MIP conversion file: \n %s \n",calfile.str().c_str()); + FILE *f; + f = fopen(calfile.str().c_str(),"rb"); + if ( !f ){ + printf(" WARNING: no calorimeter ADC to MIP file! \n Using 26 as conversion factor for all strips. \n"); } else { - // chfile = new TFile(calfile.str().c_str(),"READ","Calorimeter CALIBRATION data"); - chfile = new TFile(calfile.str().c_str(),"READ"); okcalo = 1; - ctree = (TTree*)chfile->Get("CaloADC"); - if ( !ctree ){ - okcalo = 0; - chfile->Close(); - } else { - ctree->SetBranchAddress("Event", &ccalo); - // - cnevents = ctree->GetEntries(); - ctree->GetEntry(cnevents-1); - }; }; // - if ( okcalo ) { - for (Int_t m = 0; m < 2 ; m++ ){ - for (Int_t k = 0; k < 22; k++ ){ - for (Int_t l = 0; l < 96; l++ ){ - if ( (ccalo->fp[1][m][k][l] > 20. && ccalo->fp[1][m][k][l] < 32.) || ccalo->mask[m][k][l] == 1. ) { - if ( ccalo->mip[m][k][l] != 0. ){ - mip[m][k][l] = ccalo->mip[m][k][l]; - } else { - mip[m][k][l] = 26. ; - }; - } else { - mip[m][k][l] = 26. ; - }; - }; + for (Int_t m = 0; m < 2 ; m++ ){ + for (Int_t k = 0; k < 22; k++ ){ + for (Int_t l = 0; l < 96; l++ ){ + if ( okcalo ) { + fread(&mip[m][k][l],sizeof(mip[m][k][l]),1,f); + } else { + mip[m][k][l] = 26. ; + }; + }; }; - chfile->Close(); - } else { - for (Int_t m = 0; m < 2 ; m++ ){ - for (Int_t k = 0; k < 22; k++ ){ - for (Int_t l = 0; l < 96; l++ ){ - mip[m][k][l] = 26. ; - }; - }; - }; }; + if ( okcalo ) fclose(f); }; }; // @@ -6503,6 +6483,7 @@ isOK = 1; seldone = 1; } else { + if ( CALOLEV == 0 ) ShowCaloL0(calcalibfile,i,calib,b,mip,otr,var,false); isOK = 0; stringstream cintcom; cintcom.str(""); @@ -6522,7 +6503,11 @@ cintcom << "struct Levels &level = (struct Levels &)0x" << hex; cintcom << &level; gROOT->ProcessLine(cintcom.str().c_str()); - isOK = gApplication->ProcessLine("filter((Int_t)a,(TTree *)otr,(TTree *)ttr,(Levels &)level);"); + cintcom.str(""); + cintcom << "struct Variables &var = (struct Variables &)0x" << hex; + cintcom << &var; + gROOT->ProcessLine(cintcom.str().c_str()); + isOK = gApplication->ProcessLine("filter((Int_t)a,(TTree *)otr,(TTree *)ttr,(Levels &)level,(Variables &)var);"); seldone = 1; printf("Scanning data: %d%c done",100*(i-minevent)/(maxevent-minevent),37); fflush(stdout); @@ -6726,7 +6711,7 @@ // if ( CALOLEV == 0 ) { if ( !thefirst ) { - ShowCaloL0(calcalibfile,i,calib,b,mip,otr,var); + ShowCaloL0(calcalibfile,i,calib,b,mip,otr,var,true); } else { printf("\n\n CALORIMETER: looking for calibration data...\n"); thefirst = 0; @@ -6755,7 +6740,7 @@ printf(" No calorimeter calibrations! Switching to raw mode visualitation \n Only COMPRESS and FULL mode acquisition are supported \n\n"); CALOLEV = -1; } else { - ShowCaloL0(calcalibfile,i,calib,b,mip,otr,var); + ShowCaloL0(calcalibfile,i,calib,b,mip,otr,var,true); }; }; };