1 |
//------------------------------------------------------------------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------------------------------------------------------------------- |
2 |
// |
// |
3 |
// FEventViewer.c version 1.00 (2006-03-09) |
// FEventViewer.c version 1.03 (2006-04-04) |
4 |
// |
// |
5 |
// Shows PAMELA events - Emiliano Mocchiutti |
// Shows PAMELA events - Emiliano Mocchiutti |
6 |
// |
// |
23 |
// |
// |
24 |
// Changelog: |
// Changelog: |
25 |
// |
// |
26 |
|
// 1.02 - 1.03 (2006-04-04): Make it possible to select events with the calorimeter also when generating level1 from level0. |
27 |
|
// |
28 |
|
// 1.01 - 1.02 (2006-03-22): Read calorimeter ADC2MIP flight conversion file. Do not install FEventviewer.cxx! |
29 |
|
// |
30 |
// 1.00 - 1.01 (2006-03-09): Flight version, read unique YODA file. Many capabilities disabled at the moment (reads only LEVEL0 data). |
// 1.00 - 1.01 (2006-03-09): Flight version, read unique YODA file. Many capabilities disabled at the moment (reads only LEVEL0 data). |
31 |
// |
// |
32 |
// 0.00 - 1.00 (2006-03-09): Clone of EventViewer.c v9r01. |
// 0.00 - 1.00 (2006-03-09): Clone of EventViewer.c v9r01. |
5118 |
// OTHER SUBROUTINES ** |
// OTHER SUBROUTINES ** |
5119 |
//********************************************************************************** |
//********************************************************************************** |
5120 |
|
|
5121 |
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){ |
5122 |
struct Evento evento; |
struct Evento evento; |
5123 |
Int_t tot0 = 0; |
Int_t tot0 = 0; |
5124 |
Int_t tot1 = 0; |
Int_t tot1 = 0; |
5158 |
Int_t bgcolor = 10; |
Int_t bgcolor = 10; |
5159 |
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 *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); |
5160 |
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); |
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); |
5161 |
|
if ( upd ){ |
5162 |
|
|
5163 |
pd1->SetFillStyle(4000); |
pd1->SetFillStyle(4000); |
5164 |
pd1->SetFillColor(0); |
pd1->SetFillColor(0); |
5193 |
Yview->Fill(1.,1.,1.); |
Yview->Fill(1.,1.,1.); |
5194 |
Yview->Draw("box"); |
Yview->Draw("box"); |
5195 |
pd2->Update(); |
pd2->Update(); |
5196 |
|
}; |
5197 |
// |
// |
5198 |
// for each event check that the calibration we are using are still within calibration limits, if not call the next calibration |
// for each event check that the calibration we are using are still within calibration limits, if not call the next calibration |
5199 |
// |
// |
5315 |
// |
// |
5316 |
// 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) |
// 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) |
5317 |
// |
// |
5318 |
|
if ( upd ){ |
5319 |
xve.str(""); |
xve.str(""); |
5320 |
yve.str(""); |
yve.str(""); |
5321 |
xve << "x-view event " << n; |
xve << "x-view event " << n; |
5348 |
pd2->cd(); |
pd2->cd(); |
5349 |
Yview->Draw("box same"); |
Yview->Draw("box same"); |
5350 |
}; |
}; |
5351 |
}; |
}; |
5352 |
|
}; |
5353 |
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 ) badstrip++; |
5354 |
if ( estrip[l][m][n] > 0.7 && calib.calgood[l][m][n] == 0 ) { |
if ( estrip[l][m][n] > 0.7 && calib.calgood[l][m][n] == 0 ) { |
5355 |
qtot += estrip[l][m][n]; |
qtot += estrip[l][m][n]; |
5360 |
}; |
}; |
5361 |
}; |
}; |
5362 |
}; |
}; |
5363 |
|
if ( upd ){ |
5364 |
pd1->Update(); |
pd1->Update(); |
5365 |
pd2->Update(); |
pd2->Update(); |
5366 |
|
}; |
5367 |
var.qtot=(int)qtot; |
var.qtot=(int)qtot; |
5368 |
var.nstrip=nstrip; |
var.nstrip=nstrip; |
5369 |
} |
} |
5713 |
const char *pam_calib = pathtocalibration(); |
const char *pam_calib = pathtocalibration(); |
5714 |
stringstream calfile; |
stringstream calfile; |
5715 |
calfile.str(""); |
calfile.str(""); |
5716 |
calfile << pam_calib << "/CaloADC2MIP.root"; |
calfile << pam_calib << "/FCaloADC2MIP.dat"; |
5717 |
// |
// |
5718 |
Int_t selection = 0; |
Int_t selection = 0; |
5719 |
Bool_t firsttime = true; |
Bool_t firsttime = true; |
5813 |
Float_t mip[2][22][96]; |
Float_t mip[2][22][96]; |
5814 |
Int_t okcalo = 0; |
Int_t okcalo = 0; |
5815 |
// |
// |
|
TFile *chfile = 0; |
|
|
TTree *ctree = 0; |
|
|
CalorimeterCalibration *ccalo = 0; |
|
|
// TFile *chfile = new TFile; |
|
|
//TTree *ctree = new TTree; |
|
|
//CalorimeterCalibration *ccalo = new CalorimeterCalibration(); |
|
5816 |
Long64_t cnevents = 0ULL; |
Long64_t cnevents = 0ULL; |
5817 |
// |
// |
5818 |
var.goon = false; |
var.goon = false; |
6360 |
// |
// |
6361 |
if ( !var.refresh ){ |
if ( !var.refresh ){ |
6362 |
if ( !CALOLEV && var.CALO ){ |
if ( !CALOLEV && var.CALO ){ |
6363 |
// if ( !existfile((TString)calfile.str().c_str()) ){ |
printf(" ADC to MIP conversion file: \n %s \n",calfile.str().c_str()); |
6364 |
if ( true ){ |
FILE *f; |
6365 |
printf(" WARNING: no calorimeter calibration file! \n Using 26 as conversion factor for all strips. \n"); |
f = fopen(calfile.str().c_str(),"rb"); |
6366 |
okcalo = 0; |
if ( !f ){ |
6367 |
|
printf(" WARNING: no calorimeter ADC to MIP file! \n Using 26 as conversion factor for all strips. \n"); |
6368 |
} else { |
} else { |
|
// chfile = new TFile(calfile.str().c_str(),"READ","Calorimeter CALIBRATION data"); |
|
|
chfile = new TFile(calfile.str().c_str(),"READ"); |
|
6369 |
okcalo = 1; |
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); |
|
|
}; |
|
6370 |
}; |
}; |
6371 |
// |
// |
6372 |
if ( okcalo ) { |
for (Int_t m = 0; m < 2 ; m++ ){ |
6373 |
for (Int_t m = 0; m < 2 ; m++ ){ |
for (Int_t k = 0; k < 22; k++ ){ |
6374 |
for (Int_t k = 0; k < 22; k++ ){ |
for (Int_t l = 0; l < 96; l++ ){ |
6375 |
for (Int_t l = 0; l < 96; l++ ){ |
if ( okcalo ) { |
6376 |
if ( (ccalo->fp[1][m][k][l] > 20. && ccalo->fp[1][m][k][l] < 32.) || ccalo->mask[m][k][l] == 1. ) { |
fread(&mip[m][k][l],sizeof(mip[m][k][l]),1,f); |
6377 |
if ( ccalo->mip[m][k][l] != 0. ){ |
} else { |
6378 |
mip[m][k][l] = ccalo->mip[m][k][l]; |
mip[m][k][l] = 26. ; |
6379 |
} else { |
}; |
6380 |
mip[m][k][l] = 26. ; |
|
|
}; |
|
|
} else { |
|
|
mip[m][k][l] = 26. ; |
|
|
}; |
|
|
}; |
|
6381 |
}; |
}; |
6382 |
}; |
}; |
|
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. ; |
|
|
}; |
|
|
}; |
|
|
}; |
|
6383 |
}; |
}; |
6384 |
|
if ( okcalo ) fclose(f); |
6385 |
}; |
}; |
6386 |
}; |
}; |
6387 |
// |
// |
6483 |
isOK = 1; |
isOK = 1; |
6484 |
seldone = 1; |
seldone = 1; |
6485 |
} else { |
} else { |
6486 |
|
if ( CALOLEV == 0 ) ShowCaloL0(calcalibfile,i,calib,b,mip,otr,var,false); |
6487 |
isOK = 0; |
isOK = 0; |
6488 |
stringstream cintcom; |
stringstream cintcom; |
6489 |
cintcom.str(""); |
cintcom.str(""); |
6503 |
cintcom << "struct Levels &level = (struct Levels &)0x" << hex; |
cintcom << "struct Levels &level = (struct Levels &)0x" << hex; |
6504 |
cintcom << &level; |
cintcom << &level; |
6505 |
gROOT->ProcessLine(cintcom.str().c_str()); |
gROOT->ProcessLine(cintcom.str().c_str()); |
6506 |
isOK = gApplication->ProcessLine("filter((Int_t)a,(TTree *)otr,(TTree *)ttr,(Levels &)level);"); |
cintcom.str(""); |
6507 |
|
cintcom << "struct Variables &var = (struct Variables &)0x" << hex; |
6508 |
|
cintcom << &var; |
6509 |
|
gROOT->ProcessLine(cintcom.str().c_str()); |
6510 |
|
isOK = gApplication->ProcessLine("filter((Int_t)a,(TTree *)otr,(TTree *)ttr,(Levels &)level,(Variables &)var);"); |
6511 |
seldone = 1; |
seldone = 1; |
6512 |
printf("Scanning data: %d%c done",100*(i-minevent)/(maxevent-minevent),37); |
printf("Scanning data: %d%c done",100*(i-minevent)/(maxevent-minevent),37); |
6513 |
fflush(stdout); |
fflush(stdout); |
6711 |
// |
// |
6712 |
if ( CALOLEV == 0 ) { |
if ( CALOLEV == 0 ) { |
6713 |
if ( !thefirst ) { |
if ( !thefirst ) { |
6714 |
ShowCaloL0(calcalibfile,i,calib,b,mip,otr,var); |
ShowCaloL0(calcalibfile,i,calib,b,mip,otr,var,true); |
6715 |
} else { |
} else { |
6716 |
printf("\n\n CALORIMETER: looking for calibration data...\n"); |
printf("\n\n CALORIMETER: looking for calibration data...\n"); |
6717 |
thefirst = 0; |
thefirst = 0; |
6740 |
printf(" No calorimeter calibrations! Switching to raw mode visualitation \n Only COMPRESS and FULL mode acquisition are supported \n\n"); |
printf(" No calorimeter calibrations! Switching to raw mode visualitation \n Only COMPRESS and FULL mode acquisition are supported \n\n"); |
6741 |
CALOLEV = -1; |
CALOLEV = -1; |
6742 |
} else { |
} else { |
6743 |
ShowCaloL0(calcalibfile,i,calib,b,mip,otr,var); |
ShowCaloL0(calcalibfile,i,calib,b,mip,otr,var,true); |
6744 |
}; |
}; |
6745 |
}; |
}; |
6746 |
}; |
}; |