forked from alisw/AliRoot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAliTOFanalyzeSDigitsV2.C
202 lines (164 loc) · 5.32 KB
/
AliTOFanalyzeSDigitsV2.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
Int_t AliTOFanalyzeSDigitsV2(Int_t ndump=0, Int_t iEvNum=-1, Int_t nEvent=0)
{
/////////////////////////////////////////////////////////////////////////
//
// Analyzes the TOF sdigits and fills QA-histograms
// iEvNum=-1 and nEvent=0 means all events in the file
//
// root[0] .L AliTOFanalyzeSDigitsV2.C
// root[1] AliTOFanalyzeSDigitsV2()
//
// If you want analyze only the sdigits in the 2th event
// (existing int the header file), see in the following:
//
// root[0] .L AliTOFanalyzeSDigitsV2.C
// root[1] AliTOFanalyzeSDigitsV2(0,2,1)
//
// Updated to the new I/O by: A. De Caro, C. Zampolli
//
// Report problems to: decaro@sa.infn.it
//
/////////////////////////////////////////////////////////////////////////
Int_t rc = 0;
// adc and tdc
TH1F *htdc = new TH1F("htdc","TDC [bin]",5000,0.,150000.);
TH1F *hadc = new TH1F("hadc","ADC [bin]",100,0., 3000.);
// TOF sdigit volumes
TH1F *hsector = new TH1F("hsector","Sector",18,0.,18.);
TH1F *hplate = new TH1F("hplate","Plate ", 5,0., 5.);
TH1F *hstrip = new TH1F("hstrip","Strip ",20,0.,20.);
TH1F *hpadz = new TH1F("hpadz","Pad along z ",2,0.,2.);
TH1F *hpadx = new TH1F("hpadx","Pad along x",48,0.,48.);
// ADC-TDC correlation
TH2F *h2tdcVSadc = new TH2F("h2tdcVSadc","TDC [bin] VS ADC [bin]",500,0.,150000.,100,0.,3000.);
// Dynamically link some shared libs
if (gClassTable->GetID("AliRun") < 0) {
gROOT->LoadMacro("loadlibs.C");
loadlibs();
}
if (gAlice)
{
delete AliRunLoader::Instance();
delete gAlice;
gAlice = 0x0;
}
AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");
if (!rl)
{
cerr<<"Can't load RunLoader from file"<<"!\n";
rc = 1;
return rc;
}
rl->LoadgAlice();
gAlice = rl->GetAliRun();
if (!gAlice)
{
cerr << "<AliTOFanalyzeSDigits> AliRun object not found on file\n ";
rc = 2;
return rc;
}
rl->LoadHeader();
AliLoader *tofl = rl->GetLoader("TOFLoader");
AliTOF *tof = (AliTOF *) rl->GetAliRun()->GetDetector("TOF");
if (tof==0x0 || tofl==0x0)
{
cerr << "<AliTOFanalyzeSDigits> no TOF detector found" << endl;
rc = 3;
return rc;
}
cout << "First " << ndump << " SDigits found in TOF TreeS branch have: \n";
Int_t upperLimit;
Int_t bottomLimit;
if (iEvNum<0) bottomLimit=0;
else bottomLimit = iEvNum;
if (nEvent == 0) upperLimit = (Int_t)(rl->GetNumberOfEvents());
else upperLimit = nEvent+bottomLimit;
AliTOFSDigit *tofsdigit;
for (Int_t ievent = bottomLimit; ievent < upperLimit; ievent++) {
rl->GetEvent(ievent);
printf ("Processing event %d \n", ievent);
// Get the pointer SDigit tree
tofl->LoadSDigits("read");
TTree *TS=tofl->TreeS();
tof->SetTreeAddress();
if(!TS)
{
cout << "<AliTOFanalyzeSDigits> No TreeS found \n";
rc = 4;
return rc;
}
TClonesArray * TOFsdigits = new TClonesArray("AliTOFSDigit",1000);
//TOFsdigits = tof->SDigits();
tof->SDigits();
TOFsdigits = TS->GetBranch("TOF")->SetAddress(&TOFsdigits);
Int_t nEntries = TS->GetEntries();
for (Int_t iEntry = 0; iEntry < nEntries; iEntry ++)
{
tof->ResetDigits();
TS->GetEvent(iEntry);
Int_t ndig = TOFsdigits->GetEntriesFast();
cout << "<AliTOFanalyzeSDigits> found " << ndig
<< " TOF sdigits for event " << ievent << endl;
for (Int_t k=0; k<ndig; k++) {
tofsdigit = (AliTOFSDigit*) TOFsdigits->UncheckedAt(k);
Float_t firstTDC = tofsdigit->GetTdc(0);
Float_t firstADC = tofsdigit->GetAdc(0);
htdc->Fill(firstTDC);
hadc->Fill(firstADC);
// TOF sdigit volumes
Int_t sector = tofsdigit->GetSector(); // range [0-17]
Int_t plate = tofsdigit->GetPlate(); // range [0- 4]
Int_t strip = tofsdigit->GetStrip(); // range [0-19]
Int_t padz = tofsdigit->GetPadz(); // range [0- 1]
Int_t padx = tofsdigit->GetPadx(); // range [0-47]
// it is QA, then I perform QA!
Bool_t isSDigitBad = (sector<0 || sector>17 || plate<0 || plate >4 || padz<0 || padz>1 || padx<0 || padx>47);
if (isSDigitBad) {
cout << "<AliTOFanalyzeSDigits> strange sdigit found \n";
rc = 4;
return rc;
}
if(k<ndump){
cout << k << "-th | Sector " << sector << " | Plate " << plate << " | Strip " << strip << " | PadZ " << padz << " | PadX " << padx << endl;
cout << k << "-th | ADC " << firstADC << " [bin] | TDC " << firstTDC << " [bin] \n";
cout << "---------------------------------------------------- \n";
}
// filling sdigit volume histos
hsector->Fill(sector);
hplate->Fill(plate);
hstrip->Fill(strip);
hpadx->Fill(padx);
hpadz->Fill(padz);
h2tdcVSadc->Fill(firstTDC,firstADC);
}
}
tofl->UnloadSDigits();
} // end loop on events
rl->UnloadHeader();
rl->UnloadgAlice();
TFile *fout = new TFile("TOF_sdigitsQA.root","RECREATE");
htdc->Write();
hadc->Write();
h2tdcVSadc->Write();
hsector->Write();
hplate->Write();
hstrip->Write();
hpadz->Write();
hpadx->Write();
fout->Close();
delete htdc;
delete hadc;
delete h2tdcVSadc;
delete hsector;
delete hplate;
delete hstrip;
delete hpadz;
delete hpadx;
if (gAlice)
{
delete AliRunLoader::Instance();
delete gAlice;
gAlice = 0x0;
}
return rc;
}