| 1 |
campana |
1.1 |
/** |
| 2 |
|
|
* TOFScan |
| 3 |
|
|
* Author Nagni |
| 4 |
|
|
* Version 1.2 |
| 5 |
|
|
* Modified by G.De Rosa |
| 6 |
|
|
* Date 27 Apr 2006 |
| 7 |
campana |
1.3 |
* Modified by G.De Rosa |
| 8 |
|
|
* Date 03 Jul 2006 |
| 9 |
campana |
1.1 |
* |
| 10 |
|
|
* Description: |
| 11 |
|
|
* Describe the performance of the TOF. |
| 12 |
|
|
* |
| 13 |
|
|
* Parameters: |
| 14 |
|
|
* TString base - the path to the root directory for the specific Pamela unpack session |
| 15 |
|
|
* TString outDirectory - the path where to save the output image (Default = base) |
| 16 |
|
|
* TString format - the format which will be used fo rsave the produced images (Default = "gif") |
| 17 |
|
|
*/ |
| 18 |
|
|
|
| 19 |
campana |
1.3 |
#include <TROOT.h> |
| 20 |
|
|
#include <TH1.h> |
| 21 |
|
|
#include <TFile.h> |
| 22 |
|
|
#include <TObjArray.h> |
| 23 |
campana |
1.1 |
#include <TString.h> |
| 24 |
|
|
#include <TObjString.h> |
| 25 |
|
|
#include <TTree.h> |
| 26 |
|
|
#include <TBranch.h> |
| 27 |
|
|
#include <TGraph.h> |
| 28 |
|
|
#include <TStyle.h> |
| 29 |
|
|
#include <TH2S.h> |
| 30 |
|
|
#include <TPaveText.h> |
| 31 |
|
|
#include <TCanvas.h> |
| 32 |
|
|
#include <physics/tof/TofEvent.h> |
| 33 |
|
|
|
| 34 |
|
|
|
| 35 |
|
|
#include <iostream> |
| 36 |
|
|
using namespace std; |
| 37 |
|
|
|
| 38 |
|
|
void TofScan(TString base, TString outDirectory = "", TString format = ""){ |
| 39 |
|
|
|
| 40 |
|
|
std::stringstream sst; |
| 41 |
|
|
if (outDirectory == "") outDirectory = base.Data(); |
| 42 |
|
|
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
| 43 |
|
|
|
| 44 |
|
|
TFile *file =new TFile(base.Data()) ; |
| 45 |
|
|
if (!file){ |
| 46 |
|
|
printf("file not Found \n"); |
| 47 |
|
|
return; |
| 48 |
|
|
} |
| 49 |
|
|
|
| 50 |
|
|
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
| 51 |
|
|
TBranch *TofBr = PhysicsTr->GetBranch("Tof"); |
| 52 |
|
|
pamela::tof::TofEvent *tofEvent = 0; |
| 53 |
|
|
PhysicsTr->SetBranchAddress("Tof", &tofEvent); |
| 54 |
|
|
|
| 55 |
|
|
Long64_t nevents = TofBr->GetEntries(); |
| 56 |
|
|
if (nevents <= 0) { |
| 57 |
|
|
printf("nevents = %llu \n", nevents); |
| 58 |
|
|
file->Close(); |
| 59 |
|
|
return; |
| 60 |
|
|
} |
| 61 |
|
|
|
| 62 |
|
|
/* |
| 63 |
|
|
* Array to convert hdc/adc to the real Photomultiplier |
| 64 |
|
|
* The array rows definitions are: |
| 65 |
|
|
* tof[0][] = chxxA (strip or channel xxA) |
| 66 |
|
|
* tof[1][] = hbxxA (halfboard xxA) |
| 67 |
|
|
* tof[2][] = chxxB (strip or channel xxB) |
| 68 |
|
|
* tof[3][] = hbxxB (halfboard xxB) |
| 69 |
|
|
* |
| 70 |
|
|
* Each single row is a sequence of photomultipliers in this shape |
| 71 |
|
|
* - The elements from 0 to 7 correspond to S11_1->S11_8 |
| 72 |
|
|
* - The elements from 8 to 13 correspond to S12_1->S12_6 |
| 73 |
|
|
* - The elements from 14 to 15 correspond to S21_1->S21_2 |
| 74 |
|
|
* - The elements from 16 to 17 correspond to S22_1->S22_2 |
| 75 |
|
|
* - The elements from 18 to 20 correspond to S31_1->S31_3 |
| 76 |
|
|
* - The elements from 21 to 23 correspond to S32_1->S32_3 |
| 77 |
|
|
* |
| 78 |
|
|
* Example: |
| 79 |
|
|
* -------> the tdc of the S12_3B photomultiplier correspond to tdc[(tof[2][10])][(tof[3][10])] |
| 80 |
|
|
* -------> the tdc of the S31_3A photomultiplier correspond to tdc[(tof[0][20])][(tof[1][20])] |
| 81 |
|
|
*/ |
| 82 |
|
|
short tof[4][24] = { |
| 83 |
|
|
{4, 4, 4, 4, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 3, 3, 3, 3, 4}, |
| 84 |
|
|
{1, 3, 5, 7, 10, 12, 2, 4, 2, 4, 6, 8, 10, 12, 1, 5, 3, 9, 7, 9, 11, 1, 5, 9}, |
| 85 |
|
|
{2, 2, 2, 2, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 2, 1, 2, 1, 2, 2, 2, 3, 3, 4}, |
| 86 |
|
|
{6, 8, 12, 10, 8, 6, 4, 2, 12, 10, 8, 6, 4, 2, 9, 7, 11, 11, 5, 3, 1, 3, 7, 11} |
| 87 |
|
|
}; |
| 88 |
|
|
|
| 89 |
|
|
TString photoS[48] = { |
| 90 |
|
|
"S11_1A", "S11_1B", "S11_2A", "S11_2B", "S11_3A", "S11_3B", "S11_4A", "S11_4B", |
| 91 |
|
|
"S11_5A", "S11_5B", "S11_6A", "S11_6B", "S11_7A", "S11_7B", "S11_8A", "S11_8B", |
| 92 |
|
|
"S12_1A", "S12_1B", "S12_2A", "S12_2B", "S12_3A", "S12_3B", "S12_4A", "S12_4B", "S12_5A", "S12_5B", "S12_6A", "S12_6B", |
| 93 |
|
|
"S21_1A", "S21_1B", "S21_2A", "S21_2B", |
| 94 |
|
|
"S22_1A", "S22_1B", "S22_2A", "S22_2B", |
| 95 |
|
|
"S31_1A", "S31_1B", "S31_2A", "S31_2B", "S31_3A", "S31_3B", |
| 96 |
|
|
"S32_1A", "S32_1B", "S32_2A", "S32_2B", "S32_3A", "S32_3B" |
| 97 |
|
|
}; |
| 98 |
|
|
|
| 99 |
campana |
1.3 |
const Int_t nh = 48; |
| 100 |
|
|
TH1F *htdc[nh]; |
| 101 |
|
|
TH1F *hadc[nh]; |
| 102 |
|
|
|
| 103 |
|
|
TObjArray *hhtdc = new TObjArray(nh); |
| 104 |
|
|
TObjArray *hhadc = new TObjArray(nh); |
| 105 |
|
|
char tdcname[48]=""; |
| 106 |
|
|
char adcname[48]=""; |
| 107 |
|
|
|
| 108 |
campana |
1.1 |
int j = 0; |
| 109 |
|
|
int k = 0; |
| 110 |
|
|
int z = 0; |
| 111 |
|
|
int ch = 0; |
| 112 |
|
|
int hb = 0; |
| 113 |
campana |
1.3 |
int ind =0; |
| 114 |
|
|
|
| 115 |
|
|
|
| 116 |
|
|
for (int i=0; i < nevents; i++){ |
| 117 |
|
|
|
| 118 |
campana |
1.1 |
TofBr->GetEntry(i); |
| 119 |
campana |
1.3 |
|
| 120 |
campana |
1.1 |
k = 0; |
| 121 |
|
|
while (k < 24){ |
| 122 |
|
|
j = 0; |
| 123 |
|
|
while (j < 2){ |
| 124 |
|
|
ch = tof[2*j][k] - 1; |
| 125 |
|
|
hb = tof[2*j + 1][k] - 1; |
| 126 |
campana |
1.3 |
ind = 2*k + j; |
| 127 |
|
|
|
| 128 |
|
|
if(i==0){ |
| 129 |
|
|
sprintf(tdcname,"TDChist%4.4d",ind); |
| 130 |
|
|
sprintf(adcname,"ADChist%4.4d",ind); |
| 131 |
|
|
|
| 132 |
|
|
htdc[ind] = new TH1F(tdcname,tdcname,409,0,4096); |
| 133 |
|
|
hadc[ind] = new TH1F(adcname,adcname,409,0,4096); |
| 134 |
|
|
|
| 135 |
|
|
hhtdc->Add(htdc[ind]); |
| 136 |
|
|
hhadc->Add(hadc[ind]); |
| 137 |
|
|
} |
| 138 |
|
|
|
| 139 |
|
|
htdc[ind]->Fill(tofEvent->tdc[ch][hb]); |
| 140 |
|
|
hadc[ind]->Fill(tofEvent->adc[ch][hb]); |
| 141 |
|
|
|
| 142 |
campana |
1.1 |
j++; |
| 143 |
|
|
} |
| 144 |
|
|
k++; |
| 145 |
|
|
} |
| 146 |
|
|
} |
| 147 |
|
|
|
| 148 |
|
|
float *X = new float[48]; |
| 149 |
|
|
float *means = new float[48]; |
| 150 |
|
|
float *entries = new float[48]; |
| 151 |
|
|
int *entriestdc = new int[48]; |
| 152 |
|
|
int *entriesadc = new int[48]; |
| 153 |
campana |
1.3 |
|
| 154 |
campana |
1.1 |
const char *saveas = format; |
| 155 |
|
|
|
| 156 |
campana |
1.3 |
int i=0; |
| 157 |
campana |
1.1 |
|
| 158 |
|
|
gStyle->SetStatW(0.4); |
| 159 |
|
|
gStyle->SetStatH(0.4); |
| 160 |
|
|
gStyle->SetOptStat("nmri"); |
| 161 |
|
|
gStyle->SetTitleH(0.10); |
| 162 |
|
|
gStyle->SetTitleW(0.96); |
| 163 |
|
|
|
| 164 |
|
|
TCanvas *SCanvas = new TCanvas("SCanvas","SCanvas", 1280, 1024); |
| 165 |
|
|
SCanvas->Divide(4,2); |
| 166 |
campana |
1.3 |
|
| 167 |
campana |
1.1 |
j = 0; |
| 168 |
|
|
while (j < 12){ |
| 169 |
|
|
k = 0; |
| 170 |
|
|
z = 0; |
| 171 |
|
|
if (gROOT->IsBatch()) { |
| 172 |
|
|
SCanvas = new TCanvas("SCanvas","SCanvas", 1280, 1024); |
| 173 |
|
|
SCanvas->Divide(4,2); |
| 174 |
|
|
} else { |
| 175 |
|
|
if (j > 0) SCanvas->DrawClone(); |
| 176 |
|
|
} |
| 177 |
|
|
|
| 178 |
|
|
|
| 179 |
|
|
while(k < 4){ |
| 180 |
|
|
if (k > 1) z = 2; |
| 181 |
|
|
i = j*4 + k; |
| 182 |
|
|
X[i] = i; |
| 183 |
|
|
|
| 184 |
|
|
SCanvas->cd(k+3+z); |
| 185 |
campana |
1.3 |
htdc[i] = (TH1F*)hhtdc->At(i); |
| 186 |
|
|
entriestdc[i] = (Int_t)htdc[i]->Integral(); |
| 187 |
campana |
1.1 |
sst.str(""); |
| 188 |
|
|
sst << "TDC - " << photoS[i].Data() << " (Nev < 4096 = " << entriestdc[i] << ")"; |
| 189 |
campana |
1.3 |
htdc[i]->SetTitle(sst.str().c_str()); |
| 190 |
|
|
htdc[i]->SetTitleSize(10); |
| 191 |
|
|
htdc[i]->SetAxisRange(690,1510); |
| 192 |
|
|
htdc[i]->DrawCopy(); |
| 193 |
|
|
htdc[i]->ComputeIntegral(); |
| 194 |
|
|
entries[i] = htdc[i]->Integral(); |
| 195 |
campana |
1.1 |
|
| 196 |
|
|
SCanvas->cd(k+1+z); |
| 197 |
campana |
1.3 |
hadc[i] = (TH1F*)hhadc->At(i); |
| 198 |
|
|
entriesadc[i] = (Int_t)hadc[i]->Integral(); |
| 199 |
campana |
1.1 |
sst.str(""); |
| 200 |
|
|
sst << "ADC - " << photoS[i].Data() << " (Nev < 4096 = " << entriesadc[i] << ")"; |
| 201 |
campana |
1.3 |
hadc[i]->SetTitle(sst.str().c_str()); |
| 202 |
|
|
hadc[i]->SetAxisRange(-10,710); |
| 203 |
|
|
hadc[i]->DrawCopy(); |
| 204 |
|
|
means[i] = hadc[i]->GetMean(); |
| 205 |
campana |
1.1 |
|
| 206 |
|
|
k++; |
| 207 |
|
|
} |
| 208 |
campana |
1.3 |
|
| 209 |
|
|
|
| 210 |
campana |
1.1 |
if ( !strcmp(saveas,"ps") ) { |
| 211 |
|
|
sst.str(""); |
| 212 |
|
|
sst << outDirectory.Data() << filename.Data() << "TOFScan.ps("; |
| 213 |
|
|
SCanvas->Print(sst.str().c_str()); |
| 214 |
|
|
} else { |
| 215 |
|
|
sst.str(""); |
| 216 |
|
|
sst << outDirectory.Data() << filename.Data() << "TOFScan" << j+1 << "." << saveas; |
| 217 |
|
|
SCanvas->SaveAs(sst.str().c_str()); |
| 218 |
|
|
|
| 219 |
|
|
} |
| 220 |
|
|
j++; |
| 221 |
|
|
} |
| 222 |
campana |
1.3 |
|
| 223 |
campana |
1.1 |
if (gROOT->IsBatch()) SCanvas->Close(); |
| 224 |
|
|
|
| 225 |
|
|
/* |
| 226 |
|
|
* This Canvas will represent a summary of the performances for TOF TDC/ADC channels |
| 227 |
|
|
*/ |
| 228 |
|
|
TCanvas *performanceCanvas = new TCanvas("performanceCanvas","performanceCanvas", 1280, 1024); |
| 229 |
|
|
performanceCanvas->Divide(1,2); |
| 230 |
|
|
|
| 231 |
|
|
gStyle->SetTitleW(.9); |
| 232 |
|
|
|
| 233 |
|
|
performanceCanvas->cd(1); |
| 234 |
|
|
TGraph *adcMeans = new TGraph(48, X, means); |
| 235 |
|
|
sst.str(""); |
| 236 |
|
|
sst << "ADCMean" << " - Data in " << base.Data() << " - Nevents in the run = " << nevents; |
| 237 |
|
|
adcMeans->SetTitle(sst.str().c_str()); |
| 238 |
campana |
1.2 |
adcMeans->SetFillColor(35); |
| 239 |
campana |
1.1 |
adcMeans->GetXaxis()->SetTitle("Photomultipliers"); |
| 240 |
|
|
adcMeans->GetXaxis()->CenterTitle(); |
| 241 |
|
|
adcMeans->GetXaxis()->SetLimits(-0.5, 47.5); |
| 242 |
|
|
adcMeans->GetYaxis()->SetTitle("ADCMean"); |
| 243 |
|
|
adcMeans->GetYaxis()->CenterTitle(); |
| 244 |
|
|
adcMeans->Draw("AB"); |
| 245 |
|
|
|
| 246 |
|
|
performanceCanvas->cd(2); |
| 247 |
|
|
TGraph *tdcEntries = new TGraph(48, X, entries); |
| 248 |
|
|
sst.str(""); |
| 249 |
|
|
sst << "TDCEntries" << " - Data in " << base.Data() << " - Nevents in the run = " << nevents; |
| 250 |
|
|
tdcEntries->SetTitle(sst.str().c_str()); |
| 251 |
campana |
1.2 |
tdcEntries->SetFillColor(35); |
| 252 |
campana |
1.1 |
tdcEntries->GetXaxis()->SetTitle("Photomultipliers"); |
| 253 |
|
|
tdcEntries->GetXaxis()->CenterTitle(); |
| 254 |
|
|
tdcEntries->GetXaxis()->SetLimits(-0.5, 47.5); |
| 255 |
|
|
tdcEntries->GetYaxis()->SetTitle("TDCIntegral"); |
| 256 |
|
|
tdcEntries->GetYaxis()->CenterTitle(); |
| 257 |
|
|
tdcEntries->Draw("AB"); |
| 258 |
|
|
|
| 259 |
|
|
//------print the ps |
| 260 |
|
|
|
| 261 |
|
|
if ( !strcmp(saveas,"ps") ) { |
| 262 |
|
|
sst.str(""); |
| 263 |
|
|
sst << outDirectory.Data() << filename.Data() << "TOFScan.ps)"; |
| 264 |
|
|
performanceCanvas->Print(sst.str().c_str()); |
| 265 |
|
|
|
| 266 |
|
|
} else { |
| 267 |
|
|
sst.str(""); |
| 268 |
|
|
sst << outDirectory.Data() << filename.Data() << "TOFScan13." << saveas; |
| 269 |
|
|
performanceCanvas->SaveAs(sst.str().c_str()); |
| 270 |
|
|
} |
| 271 |
|
|
if (gROOT->IsBatch()) { |
| 272 |
|
|
SCanvas->Close(); |
| 273 |
|
|
performanceCanvas->Close(); |
| 274 |
|
|
} |
| 275 |
|
|
|
| 276 |
|
|
} |
| 277 |
|
|
|
| 278 |
|
|
int main(int argc, char* argv[]){ |
| 279 |
|
|
TString path; |
| 280 |
|
|
TString outDir ="./"; |
| 281 |
|
|
TString format ="ps"; |
| 282 |
|
|
|
| 283 |
|
|
if (argc < 2){ |
| 284 |
|
|
printf("You have to insert at least the file to analyze \n"); |
| 285 |
|
|
printf("Try '--help' for more information. \n"); |
| 286 |
|
|
exit(1); |
| 287 |
|
|
} |
| 288 |
|
|
|
| 289 |
|
|
if (!strcmp(argv[1], "--help")){ |
| 290 |
|
|
printf( "Usage: TofScan FILE [OPTION] \n"); |
| 291 |
|
|
printf( "\t --help Print this help and exit \n"); |
| 292 |
|
|
printf( "\t -outDir[path] Path where to put the output [default ./] \n"); |
| 293 |
|
|
printf( "\t -format[ps] Format for output files [default 'ps'] \n"); |
| 294 |
|
|
exit(1); |
| 295 |
|
|
} |
| 296 |
|
|
|
| 297 |
|
|
|
| 298 |
|
|
path=argv[1]; |
| 299 |
|
|
|
| 300 |
|
|
for (int i = 2; i < argc; i++){ |
| 301 |
|
|
|
| 302 |
|
|
if (!strcmp(argv[i], "-outDir")){ |
| 303 |
|
|
if (++i >= argc){ |
| 304 |
|
|
printf( "-outDir needs arguments. \n"); |
| 305 |
|
|
printf( "Try '--help' for more information. \n"); |
| 306 |
|
|
exit(1); |
| 307 |
|
|
} |
| 308 |
|
|
else{ |
| 309 |
|
|
outDir = argv[i]; |
| 310 |
|
|
continue; |
| 311 |
|
|
} |
| 312 |
|
|
} |
| 313 |
|
|
|
| 314 |
|
|
|
| 315 |
|
|
|
| 316 |
|
|
if (!strcmp(argv[i], "-format")){ |
| 317 |
|
|
if (++i >= argc){ |
| 318 |
|
|
printf( "-format needs arguments. \n"); |
| 319 |
|
|
printf( "Try '--help' for more information. \n"); |
| 320 |
|
|
exit(1); |
| 321 |
|
|
} |
| 322 |
|
|
else{ |
| 323 |
|
|
format = argv[i]; |
| 324 |
|
|
continue; |
| 325 |
|
|
} |
| 326 |
|
|
} |
| 327 |
|
|
} |
| 328 |
|
|
|
| 329 |
|
|
TofScan(argv[1], outDir, format); |
| 330 |
|
|
|
| 331 |
|
|
} |