]>
Commit | Line | Data |
---|---|---|
ed228cbc | 1 | /*************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
01709453 | 16 | //-----------------------------------------------------// |
17 | // // | |
18 | // Date : August 05 2003 // | |
19 | // This reads the file PMD.digits.root(TreeD), // | |
20 | // calls the Clustering algorithm and stores the // | |
21 | // clustering output in PMD.RecPoints.root(TreeR) // | |
22 | // // | |
23 | //-----------------------------------------------------// | |
24 | ||
25 | #include <Riostream.h> | |
01709453 | 26 | #include <TTree.h> |
01709453 | 27 | #include <TObjArray.h> |
28 | #include <TClonesArray.h> | |
01709453 | 29 | |
7e9508a7 | 30 | #include "AliLog.h" |
01709453 | 31 | #include "AliRunLoader.h" |
32 | #include "AliLoader.h" | |
5f55af10 | 33 | #include "AliRawReader.h" |
01709453 | 34 | |
35 | #include "AliPMDdigit.h" | |
36 | #include "AliPMDClusterFinder.h" | |
37 | #include "AliPMDClustering.h" | |
5c5cadd5 | 38 | #include "AliPMDClusteringV1.h" |
01709453 | 39 | #include "AliPMDcluster.h" |
96377d57 | 40 | #include "AliPMDrecpoint1.h" |
5c5cadd5 | 41 | #include "AliPMDrechit.h" |
5f55af10 | 42 | #include "AliPMDRawStream.h" |
09a06455 | 43 | #include "AliPMDCalibData.h" |
35535af7 | 44 | #include "AliPMDPedestal.h" |
df42ab21 | 45 | #include "AliPMDddldata.h" |
09a06455 | 46 | |
2332574a | 47 | #include "AliDAQ.h" |
09a06455 | 48 | #include "AliCDBManager.h" |
49 | #include "AliCDBEntry.h" | |
01709453 | 50 | |
7e9508a7 | 51 | |
52 | ||
01709453 | 53 | ClassImp(AliPMDClusterFinder) |
b208c6a3 | 54 | |
7e9508a7 | 55 | AliPMDClusterFinder::AliPMDClusterFinder(): |
56 | fRunLoader(0), | |
57 | fPMDLoader(0), | |
35535af7 | 58 | fCalibGain(GetCalibGain()), |
59 | fCalibPed(GetCalibPed()), | |
7e9508a7 | 60 | fTreeD(0), |
61 | fTreeR(0), | |
62 | fDigits(new TClonesArray("AliPMDdigit", 1000)), | |
63 | fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)), | |
5c5cadd5 | 64 | fRechits(new TClonesArray("AliPMDrechit", 1000)), |
7e9508a7 | 65 | fNpoint(0), |
5c5cadd5 | 66 | fNhit(0), |
a48edddd | 67 | fDetNo(0), |
7e9508a7 | 68 | fEcut(0.) |
69 | { | |
70 | // | |
71 | // Constructor | |
72 | // | |
73 | } | |
74 | // ------------------------------------------------------------------------- // | |
dfaeee5f | 75 | AliPMDClusterFinder::AliPMDClusterFinder(AliRunLoader* runLoader): |
76 | fRunLoader(runLoader), | |
77 | fPMDLoader(runLoader->GetLoader("PMDLoader")), | |
35535af7 | 78 | fCalibGain(GetCalibGain()), |
79 | fCalibPed(GetCalibPed()), | |
1758e4fe | 80 | fTreeD(0), |
81 | fTreeR(0), | |
ebd83c56 | 82 | fDigits(new TClonesArray("AliPMDdigit", 1000)), |
1758e4fe | 83 | fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)), |
5c5cadd5 | 84 | fRechits(new TClonesArray("AliPMDrechit", 1000)), |
1758e4fe | 85 | fNpoint(0), |
5c5cadd5 | 86 | fNhit(0), |
a48edddd | 87 | fDetNo(0), |
1758e4fe | 88 | fEcut(0.) |
01709453 | 89 | { |
b208c6a3 | 90 | // |
dfaeee5f | 91 | // Constructor |
b208c6a3 | 92 | // |
a48edddd | 93 | } |
94 | // ------------------------------------------------------------------------- // | |
2332574a | 95 | AliPMDClusterFinder::AliPMDClusterFinder(const AliPMDClusterFinder & finder): |
96 | TObject(finder), | |
97 | fRunLoader(0), | |
98 | fPMDLoader(0), | |
35535af7 | 99 | fCalibGain(GetCalibGain()), |
100 | fCalibPed(GetCalibPed()), | |
2332574a | 101 | fTreeD(0), |
102 | fTreeR(0), | |
103 | fDigits(NULL), | |
104 | fRecpoints(NULL), | |
105 | fRechits(NULL), | |
106 | fNpoint(0), | |
107 | fNhit(0), | |
108 | fDetNo(0), | |
109 | fEcut(0.) | |
a48edddd | 110 | { |
111 | // copy constructor | |
112 | AliError("Copy constructor not allowed"); | |
113 | } | |
114 | // ------------------------------------------------------------------------- // | |
115 | AliPMDClusterFinder &AliPMDClusterFinder::operator=(const AliPMDClusterFinder & /*finder*/) | |
116 | { | |
117 | // assignment op | |
118 | AliError("Assignment Operator not allowed"); | |
119 | return *this; | |
01709453 | 120 | } |
1758e4fe | 121 | // ------------------------------------------------------------------------- // |
01709453 | 122 | AliPMDClusterFinder::~AliPMDClusterFinder() |
123 | { | |
b208c6a3 | 124 | // Destructor |
ebd83c56 | 125 | if (fDigits) |
126 | { | |
722ccc67 | 127 | fDigits->Clear(); |
ebd83c56 | 128 | } |
1758e4fe | 129 | if (fRecpoints) |
130 | { | |
722ccc67 | 131 | fRecpoints->Clear(); |
1758e4fe | 132 | } |
5c5cadd5 | 133 | if (fRechits) |
134 | { | |
722ccc67 | 135 | fRechits->Clear(); |
5c5cadd5 | 136 | } |
01709453 | 137 | } |
1758e4fe | 138 | // ------------------------------------------------------------------------- // |
b208c6a3 | 139 | |
01709453 | 140 | void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt) |
141 | { | |
b208c6a3 | 142 | // Converts digits to recpoints after running clustering |
143 | // algorithm on CPV plane and PREshower plane | |
144 | // | |
2332574a | 145 | |
ed228cbc | 146 | Int_t det = 0,smn = 0; |
01709453 | 147 | Int_t xpos,ypos; |
148 | Float_t adc; | |
1758e4fe | 149 | Int_t ismn; |
01709453 | 150 | Int_t idet; |
5c5cadd5 | 151 | Float_t clusdata[6]; |
ed228cbc | 152 | |
153 | TObjArray *pmdcont = new TObjArray(); | |
5c5cadd5 | 154 | AliPMDClustering *pmdclust = new AliPMDClusteringV1(); |
7e9508a7 | 155 | |
ed228cbc | 156 | pmdclust->SetEdepCut(fEcut); |
01709453 | 157 | |
158 | fRunLoader->GetEvent(ievt); | |
7e9508a7 | 159 | |
01b56f5c | 160 | |
b208c6a3 | 161 | fTreeD = fPMDLoader->TreeD(); |
162 | if (fTreeD == 0x0) | |
01709453 | 163 | { |
7e9508a7 | 164 | AliFatal("AliPMDClusterFinder: Can not get TreeD"); |
165 | ||
01709453 | 166 | } |
167 | AliPMDdigit *pmddigit; | |
b208c6a3 | 168 | TBranch *branch = fTreeD->GetBranch("PMDDigit"); |
01709453 | 169 | branch->SetAddress(&fDigits); |
170 | ||
171 | ResetRecpoint(); | |
01b56f5c | 172 | |
b208c6a3 | 173 | fTreeR = fPMDLoader->TreeR(); |
174 | if (fTreeR == 0x0) | |
01709453 | 175 | { |
b208c6a3 | 176 | fPMDLoader->MakeTree("R"); |
177 | fTreeR = fPMDLoader->TreeR(); | |
01709453 | 178 | } |
179 | ||
180 | Int_t bufsize = 16000; | |
5c5cadd5 | 181 | TBranch * branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize); |
182 | TBranch * branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize); | |
01709453 | 183 | |
b208c6a3 | 184 | Int_t nmodules = (Int_t) fTreeD->GetEntries(); |
01b56f5c | 185 | |
01709453 | 186 | for (Int_t imodule = 0; imodule < nmodules; imodule++) |
187 | { | |
ed228cbc | 188 | ResetCellADC(); |
b208c6a3 | 189 | fTreeD->GetEntry(imodule); |
01709453 | 190 | Int_t nentries = fDigits->GetLast(); |
191 | for (Int_t ient = 0; ient < nentries+1; ient++) | |
192 | { | |
193 | pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient); | |
194 | ||
195 | det = pmddigit->GetDetector(); | |
196 | smn = pmddigit->GetSMNumber(); | |
5e6a9312 | 197 | xpos = pmddigit->GetRow(); |
198 | ypos = pmddigit->GetColumn(); | |
01709453 | 199 | adc = pmddigit->GetADC(); |
09a06455 | 200 | |
201 | // CALIBRATION | |
35535af7 | 202 | Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos); |
2332574a | 203 | // printf("adc = %d gain = %f\n",adc,gain); |
09a06455 | 204 | |
205 | adc = adc*gain; | |
206 | ||
ed228cbc | 207 | //Int_t trno = pmddigit->GetTrackNumber(); |
ed228cbc | 208 | fCellADC[xpos][ypos] = (Double_t) adc; |
01709453 | 209 | } |
01709453 | 210 | |
ed228cbc | 211 | idet = det; |
1758e4fe | 212 | ismn = smn; |
8616b098 | 213 | pmdclust->DoClust(idet,ismn,fCellADC,pmdcont); |
ed228cbc | 214 | |
215 | Int_t nentries1 = pmdcont->GetEntries(); | |
7e9508a7 | 216 | |
217 | AliDebug(1,Form("Total number of clusters/module = %d",nentries1)); | |
218 | ||
ed228cbc | 219 | for (Int_t ient1 = 0; ient1 < nentries1; ient1++) |
01709453 | 220 | { |
ebd83c56 | 221 | AliPMDcluster *pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1); |
1758e4fe | 222 | idet = pmdcl->GetDetector(); |
223 | ismn = pmdcl->GetSMN(); | |
224 | clusdata[0] = pmdcl->GetClusX(); | |
225 | clusdata[1] = pmdcl->GetClusY(); | |
226 | clusdata[2] = pmdcl->GetClusADC(); | |
227 | clusdata[3] = pmdcl->GetClusCells(); | |
5c5cadd5 | 228 | clusdata[4] = pmdcl->GetClusSigmaX(); |
229 | clusdata[5] = pmdcl->GetClusSigmaY(); | |
01b56f5c | 230 | |
1758e4fe | 231 | AddRecPoint(idet,ismn,clusdata); |
5c5cadd5 | 232 | |
5c5cadd5 | 233 | Int_t ncell = (Int_t) clusdata[3]; |
234 | for(Int_t ihit = 0; ihit < ncell; ihit++) | |
235 | { | |
236 | Int_t celldataX = pmdcl->GetClusCellX(ihit); | |
237 | Int_t celldataY = pmdcl->GetClusCellY(ihit); | |
238 | AddRecHit(celldataX, celldataY); | |
239 | } | |
240 | branch2->Fill(); | |
241 | ResetRechit(); | |
ed228cbc | 242 | } |
26e08752 | 243 | pmdcont->Delete(); |
ed228cbc | 244 | |
5c5cadd5 | 245 | branch1->Fill(); |
ed228cbc | 246 | ResetRecpoint(); |
247 | ||
248 | } // modules | |
249 | ||
01709453 | 250 | ResetCellADC(); |
e1287360 | 251 | fPMDLoader = fRunLoader->GetLoader("PMDLoader"); |
b208c6a3 | 252 | fPMDLoader->WriteRecPoints("OVERWRITE"); |
01709453 | 253 | |
254 | // delete the pointers | |
255 | delete pmdclust; | |
256 | delete pmdcont; | |
257 | ||
7e9508a7 | 258 | } |
259 | // ------------------------------------------------------------------------- // | |
260 | ||
8fbad6d3 | 261 | void AliPMDClusterFinder::Digits2RecPoints(TTree *digitsTree, |
262 | TTree *clustersTree) | |
263 | { | |
264 | // Converts digits to recpoints after running clustering | |
265 | // algorithm on CPV plane and PREshower plane | |
266 | // | |
267 | ||
268 | Int_t det = 0,smn = 0; | |
269 | Int_t xpos,ypos; | |
270 | Float_t adc; | |
271 | Int_t ismn; | |
272 | Int_t idet; | |
273 | Float_t clusdata[6]; | |
274 | ||
275 | TObjArray *pmdcont = new TObjArray(); | |
276 | AliPMDClustering *pmdclust = new AliPMDClusteringV1(); | |
277 | ||
278 | pmdclust->SetEdepCut(fEcut); | |
279 | ||
8fbad6d3 | 280 | AliPMDdigit *pmddigit; |
281 | TBranch *branch = digitsTree->GetBranch("PMDDigit"); | |
282 | branch->SetAddress(&fDigits); | |
283 | ||
284 | ResetRecpoint(); | |
285 | ||
8fbad6d3 | 286 | Int_t bufsize = 16000; |
287 | TBranch * branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize); | |
288 | TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize); | |
289 | ||
290 | Int_t nmodules = (Int_t) digitsTree->GetEntries(); | |
291 | ||
292 | for (Int_t imodule = 0; imodule < nmodules; imodule++) | |
293 | { | |
294 | ResetCellADC(); | |
295 | digitsTree->GetEntry(imodule); | |
296 | Int_t nentries = fDigits->GetLast(); | |
297 | for (Int_t ient = 0; ient < nentries+1; ient++) | |
298 | { | |
299 | pmddigit = (AliPMDdigit*)fDigits->UncheckedAt(ient); | |
300 | ||
301 | det = pmddigit->GetDetector(); | |
302 | smn = pmddigit->GetSMNumber(); | |
303 | xpos = pmddigit->GetRow(); | |
304 | ypos = pmddigit->GetColumn(); | |
305 | adc = pmddigit->GetADC(); | |
35535af7 | 306 | |
307 | // Pedestal Subtraction | |
308 | Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,xpos,ypos); | |
309 | Int_t pedrms1 = (Int_t) pedmeanrms%1000; | |
310 | Float_t pedrms = (Float_t)pedrms1/10.; | |
311 | Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0; | |
312 | //printf("%f %f\n",pedmean, pedrms); | |
313 | ||
314 | Float_t adc1 = adc - (pedmean + 3.0*pedrms); | |
315 | ||
8fbad6d3 | 316 | // CALIBRATION |
35535af7 | 317 | Float_t gain = fCalibGain->GetGainFact(det,smn,xpos,ypos); |
8fbad6d3 | 318 | // printf("adc = %d gain = %f\n",adc,gain); |
35535af7 | 319 | |
320 | adc = adc1*gain; | |
8fbad6d3 | 321 | |
322 | //Int_t trno = pmddigit->GetTrackNumber(); | |
323 | fCellADC[xpos][ypos] = (Double_t) adc; | |
324 | } | |
325 | ||
326 | idet = det; | |
327 | ismn = smn; | |
328 | pmdclust->DoClust(idet,ismn,fCellADC,pmdcont); | |
329 | ||
330 | Int_t nentries1 = pmdcont->GetEntries(); | |
331 | ||
332 | AliDebug(1,Form("Total number of clusters/module = %d",nentries1)); | |
333 | ||
334 | for (Int_t ient1 = 0; ient1 < nentries1; ient1++) | |
335 | { | |
336 | AliPMDcluster *pmdcl = (AliPMDcluster*)pmdcont->UncheckedAt(ient1); | |
337 | idet = pmdcl->GetDetector(); | |
338 | ismn = pmdcl->GetSMN(); | |
339 | clusdata[0] = pmdcl->GetClusX(); | |
340 | clusdata[1] = pmdcl->GetClusY(); | |
341 | clusdata[2] = pmdcl->GetClusADC(); | |
342 | clusdata[3] = pmdcl->GetClusCells(); | |
343 | clusdata[4] = pmdcl->GetClusSigmaX(); | |
344 | clusdata[5] = pmdcl->GetClusSigmaY(); | |
345 | ||
346 | AddRecPoint(idet,ismn,clusdata); | |
347 | ||
348 | Int_t ncell = (Int_t) clusdata[3]; | |
349 | for(Int_t ihit = 0; ihit < ncell; ihit++) | |
350 | { | |
351 | Int_t celldataX = pmdcl->GetClusCellX(ihit); | |
352 | Int_t celldataY = pmdcl->GetClusCellY(ihit); | |
353 | AddRecHit(celldataX, celldataY); | |
354 | } | |
355 | branch2->Fill(); | |
356 | ResetRechit(); | |
357 | } | |
26e08752 | 358 | pmdcont->Delete(); |
8fbad6d3 | 359 | |
360 | branch1->Fill(); | |
361 | ResetRecpoint(); | |
362 | ||
363 | } // modules | |
364 | ||
365 | ResetCellADC(); | |
8fbad6d3 | 366 | |
367 | // delete the pointers | |
368 | delete pmdclust; | |
369 | delete pmdcont; | |
370 | ||
371 | } | |
372 | // ------------------------------------------------------------------------- // | |
373 | ||
7e9508a7 | 374 | void AliPMDClusterFinder::Digits2RecPoints(AliRawReader *rawReader, |
375 | TTree *clustersTree) | |
376 | { | |
377 | // Converts RAW data to recpoints after running clustering | |
378 | // algorithm on CPV and PREshower plane | |
379 | // | |
2332574a | 380 | // This method is called at the time of reconstruction |
381 | ||
7e9508a7 | 382 | |
5c5cadd5 | 383 | Float_t clusdata[6]; |
df42ab21 | 384 | TObjArray pmdddlcont; |
7e9508a7 | 385 | |
386 | TObjArray *pmdcont = new TObjArray(); | |
5c5cadd5 | 387 | AliPMDClustering *pmdclust = new AliPMDClusteringV1(); |
7e9508a7 | 388 | |
389 | pmdclust->SetEdepCut(fEcut); | |
390 | ||
391 | ResetRecpoint(); | |
392 | ||
393 | Int_t bufsize = 16000; | |
5c5cadd5 | 394 | TBranch *branch1 = clustersTree->Branch("PMDRecpoint", &fRecpoints, bufsize); |
395 | ||
396 | TBranch * branch2 = clustersTree->Branch("PMDRechit", &fRechits, bufsize); | |
7e9508a7 | 397 | |
7e9508a7 | 398 | const Int_t kRow = 48; |
399 | const Int_t kCol = 96; | |
400 | ||
401 | Int_t idet = 0; | |
402 | Int_t iSMN = 0; | |
2332574a | 403 | |
722ccc67 | 404 | Int_t indexDDL = -1; |
405 | AliPMDRawStream pmdinput(rawReader); | |
8fbad6d3 | 406 | |
722ccc67 | 407 | while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0) |
408 | { | |
7e9508a7 | 409 | if (indexDDL < 4) |
410 | { | |
411 | iSMN = 6; | |
412 | } | |
413 | else if (indexDDL >= 4) | |
414 | { | |
415 | iSMN = 12; | |
416 | } | |
417 | Int_t ***precpvADC; | |
418 | precpvADC = new int **[iSMN]; | |
419 | for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow]; | |
420 | for (Int_t i=0; i<iSMN;i++) | |
421 | { | |
422 | for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol]; | |
423 | } | |
424 | for (Int_t i = 0; i < iSMN; i++) | |
425 | { | |
426 | for (Int_t j = 0; j < kRow; j++) | |
427 | { | |
428 | for (Int_t k = 0; k < kCol; k++) | |
429 | { | |
430 | precpvADC[i][j][k] = 0; | |
431 | } | |
432 | } | |
433 | } | |
434 | ResetCellADC(); | |
2332574a | 435 | |
df42ab21 | 436 | Int_t indexsmn = 0; |
437 | Int_t ientries = pmdddlcont.GetEntries(); | |
438 | for (Int_t ient = 0; ient < ientries; ient++) | |
7e9508a7 | 439 | { |
df42ab21 | 440 | AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient); |
7e9508a7 | 441 | |
df42ab21 | 442 | Int_t det = pmdddl->GetDetector(); |
443 | Int_t smn = pmdddl->GetSMN(); | |
444 | //Int_t mcm = pmdddl->GetMCM(); | |
445 | //Int_t chno = pmdddl->GetChannel(); | |
446 | Int_t row = pmdddl->GetRow(); | |
447 | Int_t col = pmdddl->GetColumn(); | |
448 | Int_t sig = pmdddl->GetSignal(); | |
09a06455 | 449 | |
35535af7 | 450 | // Pedestal Subtraction |
451 | Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col); | |
452 | Int_t pedrms1 = (Int_t) pedmeanrms%1000; | |
453 | Float_t pedrms = (Float_t)pedrms1/10.; | |
454 | Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0; | |
455 | ||
456 | //printf("%f %f\n",pedmean, pedrms); | |
457 | ||
458 | // Float_t sig1 = (Float_t) sig; | |
459 | Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms); | |
460 | ||
09a06455 | 461 | // CALIBRATION |
35535af7 | 462 | Float_t gain = fCalibGain->GetGainFact(det,smn,row,col); |
df42ab21 | 463 | //printf("sig = %d gain = %f\n",sig,gain); |
09a06455 | 464 | sig = (Int_t) (sig1*gain); |
7e9508a7 | 465 | |
466 | if (indexDDL < 4) | |
467 | { | |
468 | if (det != 0) | |
469 | AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *", | |
470 | indexDDL, det)); | |
471 | indexsmn = smn - indexDDL * 6; | |
472 | } | |
473 | else if (indexDDL == 4) | |
474 | { | |
475 | if (det != 1) | |
476 | AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *", | |
477 | indexDDL, det)); | |
478 | if (smn < 6) | |
479 | { | |
480 | indexsmn = smn; | |
481 | } | |
df42ab21 | 482 | else if (smn >= 18 && smn < 24) |
7e9508a7 | 483 | { |
df42ab21 | 484 | indexsmn = smn - 12; |
7e9508a7 | 485 | } |
486 | } | |
487 | else if (indexDDL == 5) | |
488 | { | |
489 | if (det != 1) | |
490 | AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *", | |
491 | indexDDL, det)); | |
492 | if (smn >= 6 && smn < 12) | |
493 | { | |
494 | indexsmn = smn - 6; | |
495 | } | |
df42ab21 | 496 | else if (smn >= 12 && smn < 18) |
7e9508a7 | 497 | { |
df42ab21 | 498 | indexsmn = smn - 6; |
7e9508a7 | 499 | } |
500 | } | |
501 | precpvADC[indexsmn][row][col] = sig; | |
df42ab21 | 502 | } |
503 | ||
26e08752 | 504 | //pmdddlcont.Clear(); |
505 | pmdddlcont.Delete(); | |
7e9508a7 | 506 | |
507 | Int_t ismn = 0; | |
78fc1b96 | 508 | for (indexsmn = 0; indexsmn < iSMN; indexsmn++) |
7e9508a7 | 509 | { |
510 | ResetCellADC(); | |
511 | for (Int_t irow = 0; irow < kRow; irow++) | |
512 | { | |
513 | for (Int_t icol = 0; icol < kCol; icol++) | |
514 | { | |
515 | fCellADC[irow][icol] = | |
516 | (Double_t) precpvADC[indexsmn][irow][icol]; | |
517 | } // row | |
518 | } // col | |
df42ab21 | 519 | |
7e9508a7 | 520 | if (indexDDL < 4) |
521 | { | |
522 | ismn = indexsmn + indexDDL * 6; | |
523 | idet = 0; | |
524 | } | |
525 | else if (indexDDL == 4) | |
526 | { | |
527 | if (indexsmn < 6) | |
528 | { | |
529 | ismn = indexsmn; | |
530 | } | |
531 | else if (indexsmn >= 6 && indexsmn < 12) | |
532 | { | |
df42ab21 | 533 | ismn = indexsmn + 12; |
7e9508a7 | 534 | } |
535 | idet = 1; | |
536 | } | |
537 | else if (indexDDL == 5) | |
538 | { | |
539 | if (indexsmn < 6) | |
540 | { | |
541 | ismn = indexsmn + 6; | |
542 | } | |
543 | else if (indexsmn >= 6 && indexsmn < 12) | |
544 | { | |
df42ab21 | 545 | ismn = indexsmn + 6; |
7e9508a7 | 546 | } |
547 | idet = 1; | |
548 | } | |
549 | ||
7e9508a7 | 550 | pmdclust->DoClust(idet,ismn,fCellADC,pmdcont); |
551 | Int_t nentries1 = pmdcont->GetEntries(); | |
552 | ||
553 | AliDebug(1,Form("Total number of clusters/module = %d",nentries1)); | |
554 | ||
555 | for (Int_t ient1 = 0; ient1 < nentries1; ient1++) | |
556 | { | |
557 | AliPMDcluster *pmdcl = | |
558 | (AliPMDcluster*)pmdcont->UncheckedAt(ient1); | |
559 | idet = pmdcl->GetDetector(); | |
560 | ismn = pmdcl->GetSMN(); | |
561 | clusdata[0] = pmdcl->GetClusX(); | |
562 | clusdata[1] = pmdcl->GetClusY(); | |
563 | clusdata[2] = pmdcl->GetClusADC(); | |
564 | clusdata[3] = pmdcl->GetClusCells(); | |
5c5cadd5 | 565 | clusdata[4] = pmdcl->GetClusSigmaX(); |
566 | clusdata[5] = pmdcl->GetClusSigmaY(); | |
7e9508a7 | 567 | |
568 | AddRecPoint(idet,ismn,clusdata); | |
09a06455 | 569 | |
5c5cadd5 | 570 | Int_t ncell = (Int_t) clusdata[3]; |
571 | for(Int_t ihit = 0; ihit < ncell; ihit++) | |
572 | { | |
573 | Int_t celldataX = pmdcl->GetClusCellX(ihit); | |
574 | Int_t celldataY = pmdcl->GetClusCellY(ihit); | |
575 | AddRecHit(celldataX, celldataY); | |
576 | } | |
577 | branch2->Fill(); | |
578 | ResetRechit(); | |
579 | ||
7e9508a7 | 580 | } |
26e08752 | 581 | pmdcont->Delete(); |
7e9508a7 | 582 | |
5c5cadd5 | 583 | branch1->Fill(); |
7e9508a7 | 584 | ResetRecpoint(); |
585 | ||
586 | ||
587 | } // smn | |
588 | ||
589 | for (Int_t i=0; i<iSMN; i++) | |
590 | { | |
591 | for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j]; | |
592 | } | |
593 | for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i]; | |
594 | delete precpvADC; | |
722ccc67 | 595 | |
7e9508a7 | 596 | } // DDL Loop |
597 | ||
598 | ResetCellADC(); | |
599 | ||
600 | // delete the pointers | |
601 | delete pmdclust; | |
602 | delete pmdcont; | |
603 | ||
01709453 | 604 | } |
1758e4fe | 605 | // ------------------------------------------------------------------------- // |
5f55af10 | 606 | |
607 | void AliPMDClusterFinder::Digits2RecPoints(Int_t ievt, AliRawReader *rawReader) | |
608 | { | |
01b56f5c | 609 | // Converts RAW data to recpoints after running clustering |
610 | // algorithm on CPV and PREshower plane | |
5f55af10 | 611 | // |
612 | ||
5c5cadd5 | 613 | Float_t clusdata[6]; |
df42ab21 | 614 | TObjArray pmdddlcont; |
5f55af10 | 615 | TObjArray *pmdcont = new TObjArray(); |
5c5cadd5 | 616 | |
617 | AliPMDClustering *pmdclust = new AliPMDClusteringV1(); | |
7e9508a7 | 618 | |
5f55af10 | 619 | pmdclust->SetEdepCut(fEcut); |
620 | ||
621 | fRunLoader->GetEvent(ievt); | |
622 | ||
623 | ResetRecpoint(); | |
01b56f5c | 624 | |
5f55af10 | 625 | fTreeR = fPMDLoader->TreeR(); |
626 | if (fTreeR == 0x0) | |
627 | { | |
628 | fPMDLoader->MakeTree("R"); | |
629 | fTreeR = fPMDLoader->TreeR(); | |
630 | } | |
5f55af10 | 631 | Int_t bufsize = 16000; |
5c5cadd5 | 632 | TBranch *branch1 = fTreeR->Branch("PMDRecpoint", &fRecpoints, bufsize); |
633 | TBranch *branch2 = fTreeR->Branch("PMDRechit", &fRechits, bufsize); | |
01b56f5c | 634 | |
5f55af10 | 635 | const Int_t kRow = 48; |
636 | const Int_t kCol = 96; | |
5f55af10 | 637 | |
01b56f5c | 638 | Int_t idet = 0; |
639 | Int_t iSMN = 0; | |
722ccc67 | 640 | |
641 | AliPMDRawStream pmdinput(rawReader); | |
642 | Int_t indexDDL = -1; | |
643 | ||
644 | while ((indexDDL = pmdinput.DdlData(&pmdddlcont)) >=0) { | |
645 | ||
01b56f5c | 646 | if (indexDDL < 4) |
5f55af10 | 647 | { |
01b56f5c | 648 | iSMN = 6; |
5f55af10 | 649 | } |
01b56f5c | 650 | else if (indexDDL >= 4) |
5f55af10 | 651 | { |
01b56f5c | 652 | iSMN = 12; |
5f55af10 | 653 | } |
01b56f5c | 654 | Int_t ***precpvADC; |
655 | precpvADC = new int **[iSMN]; | |
656 | for (Int_t i=0; i<iSMN; i++) precpvADC[i] = new int *[kRow]; | |
657 | for (Int_t i=0; i<iSMN;i++) | |
5f55af10 | 658 | { |
01b56f5c | 659 | for (Int_t j=0; j<kRow; j++) precpvADC[i][j] = new int [kCol]; |
5f55af10 | 660 | } |
01b56f5c | 661 | for (Int_t i = 0; i < iSMN; i++) |
662 | { | |
663 | for (Int_t j = 0; j < kRow; j++) | |
664 | { | |
665 | for (Int_t k = 0; k < kCol; k++) | |
666 | { | |
667 | precpvADC[i][j][k] = 0; | |
668 | } | |
669 | } | |
670 | } | |
671 | ResetCellADC(); | |
2332574a | 672 | |
df42ab21 | 673 | |
674 | Int_t indexsmn = 0; | |
675 | Int_t ientries = pmdddlcont.GetEntries(); | |
676 | for (Int_t ient = 0; ient < ientries; ient++) | |
01b56f5c | 677 | { |
df42ab21 | 678 | AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont.UncheckedAt(ient); |
679 | ||
680 | Int_t det = pmdddl->GetDetector(); | |
681 | Int_t smn = pmdddl->GetSMN(); | |
682 | //Int_t mcm = pmdddl->GetMCM(); | |
683 | //Int_t chno = pmdddl->GetChannel(); | |
684 | Int_t row = pmdddl->GetRow(); | |
685 | Int_t col = pmdddl->GetColumn(); | |
686 | Int_t sig = pmdddl->GetSignal(); | |
09a06455 | 687 | |
35535af7 | 688 | // Pedestal Subtraction |
689 | Int_t pedmeanrms = fCalibPed->GetPedMeanRms(det,smn,row,col); | |
690 | Int_t pedrms1 = (Int_t) pedmeanrms%1000; | |
691 | Float_t pedrms = (Float_t)pedrms1/10.; | |
692 | Float_t pedmean = (Float_t) (pedmeanrms - pedrms1)/1000.0; | |
693 | ||
694 | //printf("%f %f\n",pedmean, pedrms); | |
695 | ||
696 | //Float_t sig1 = (Float_t) sig; | |
697 | Float_t sig1 = (Float_t) sig - (pedmean + 3.0*pedrms); | |
09a06455 | 698 | // CALIBRATION |
35535af7 | 699 | Float_t gain = fCalibGain->GetGainFact(det,smn,row,col); |
2332574a | 700 | |
df42ab21 | 701 | //printf("sig = %d gain = %f\n",sig,gain); |
09a06455 | 702 | sig = (Int_t) (sig1*gain); |
df42ab21 | 703 | |
5f55af10 | 704 | |
01b56f5c | 705 | if (indexDDL < 4) |
706 | { | |
707 | if (det != 0) | |
7e9508a7 | 708 | AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *", |
709 | indexDDL, det)); | |
01b56f5c | 710 | indexsmn = smn - indexDDL * 6; |
711 | } | |
712 | else if (indexDDL == 4) | |
713 | { | |
714 | if (det != 1) | |
7e9508a7 | 715 | AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *", |
716 | indexDDL, det)); | |
01b56f5c | 717 | if (smn < 6) |
718 | { | |
719 | indexsmn = smn; | |
720 | } | |
df42ab21 | 721 | else if (smn >= 18 && smn < 24) |
01b56f5c | 722 | { |
df42ab21 | 723 | indexsmn = smn - 12; |
01b56f5c | 724 | } |
725 | } | |
726 | else if (indexDDL == 5) | |
727 | { | |
728 | if (det != 1) | |
7e9508a7 | 729 | AliError(Form("*DDL %d and Detector NUMBER %d NOT MATCHING *", |
730 | indexDDL, det)); | |
01b56f5c | 731 | if (smn >= 6 && smn < 12) |
732 | { | |
733 | indexsmn = smn - 6; | |
734 | } | |
df42ab21 | 735 | else if (smn >= 12 && smn < 18) |
01b56f5c | 736 | { |
df42ab21 | 737 | indexsmn = smn - 6; |
01b56f5c | 738 | } |
739 | } | |
740 | precpvADC[indexsmn][row][col] = sig; | |
df42ab21 | 741 | |
742 | } | |
743 | ||
26e08752 | 744 | pmdddlcont.Delete(); |
01b56f5c | 745 | |
746 | Int_t ismn = 0; | |
78fc1b96 | 747 | for (indexsmn = 0; indexsmn < iSMN; indexsmn++) |
5f55af10 | 748 | { |
01b56f5c | 749 | ResetCellADC(); |
5f55af10 | 750 | for (Int_t irow = 0; irow < kRow; irow++) |
751 | { | |
752 | for (Int_t icol = 0; icol < kCol; icol++) | |
753 | { | |
01b56f5c | 754 | fCellADC[irow][icol] = |
755 | (Double_t) precpvADC[indexsmn][irow][icol]; | |
5f55af10 | 756 | } // row |
757 | } // col | |
df42ab21 | 758 | |
759 | ||
01b56f5c | 760 | if (indexDDL < 4) |
761 | { | |
762 | ismn = indexsmn + indexDDL * 6; | |
763 | idet = 0; | |
764 | } | |
765 | else if (indexDDL == 4) | |
766 | { | |
767 | if (indexsmn < 6) | |
768 | { | |
769 | ismn = indexsmn; | |
770 | } | |
771 | else if (indexsmn >= 6 && indexsmn < 12) | |
772 | { | |
df42ab21 | 773 | ismn = indexsmn + 12; |
01b56f5c | 774 | } |
775 | idet = 1; | |
776 | } | |
777 | else if (indexDDL == 5) | |
778 | { | |
779 | if (indexsmn < 6) | |
780 | { | |
781 | ismn = indexsmn + 6; | |
782 | } | |
783 | else if (indexsmn >= 6 && indexsmn < 12) | |
784 | { | |
df42ab21 | 785 | ismn = indexsmn + 6; |
01b56f5c | 786 | } |
787 | idet = 1; | |
788 | } | |
789 | ||
5f55af10 | 790 | pmdclust->DoClust(idet,ismn,fCellADC,pmdcont); |
791 | Int_t nentries1 = pmdcont->GetEntries(); | |
7e9508a7 | 792 | |
793 | AliDebug(1,Form("Total number of clusters/module = %d",nentries1)); | |
794 | ||
5f55af10 | 795 | for (Int_t ient1 = 0; ient1 < nentries1; ient1++) |
796 | { | |
797 | AliPMDcluster *pmdcl = | |
798 | (AliPMDcluster*)pmdcont->UncheckedAt(ient1); | |
799 | idet = pmdcl->GetDetector(); | |
800 | ismn = pmdcl->GetSMN(); | |
801 | clusdata[0] = pmdcl->GetClusX(); | |
802 | clusdata[1] = pmdcl->GetClusY(); | |
803 | clusdata[2] = pmdcl->GetClusADC(); | |
804 | clusdata[3] = pmdcl->GetClusCells(); | |
5c5cadd5 | 805 | clusdata[4] = pmdcl->GetClusSigmaX(); |
806 | clusdata[5] = pmdcl->GetClusSigmaY(); | |
01b56f5c | 807 | |
5f55af10 | 808 | AddRecPoint(idet,ismn,clusdata); |
5c5cadd5 | 809 | |
5c5cadd5 | 810 | Int_t ncell = (Int_t) clusdata[3]; |
811 | for(Int_t ihit = 0; ihit < ncell; ihit++) | |
812 | { | |
813 | Int_t celldataX = pmdcl->GetClusCellX(ihit); | |
814 | Int_t celldataY = pmdcl->GetClusCellY(ihit); | |
815 | AddRecHit(celldataX, celldataY); | |
816 | } | |
817 | branch2->Fill(); | |
818 | ResetRechit(); | |
819 | ||
5f55af10 | 820 | } |
26e08752 | 821 | pmdcont->Delete(); |
5f55af10 | 822 | |
5c5cadd5 | 823 | branch1->Fill(); |
5f55af10 | 824 | ResetRecpoint(); |
01b56f5c | 825 | |
826 | ||
5f55af10 | 827 | } // smn |
5f55af10 | 828 | |
01b56f5c | 829 | for (Int_t i=0; i<iSMN; i++) |
830 | { | |
831 | for (Int_t j=0; j<kRow; j++) delete [] precpvADC[i][j]; | |
832 | } | |
833 | for (Int_t i=0; i<iSMN; i++) delete [] precpvADC[i]; | |
834 | delete precpvADC; | |
835 | } // DDL Loop | |
836 | ||
5f55af10 | 837 | ResetCellADC(); |
01b56f5c | 838 | |
5f55af10 | 839 | fPMDLoader = fRunLoader->GetLoader("PMDLoader"); |
840 | fPMDLoader->WriteRecPoints("OVERWRITE"); | |
841 | ||
842 | // delete the pointers | |
843 | delete pmdclust; | |
844 | delete pmdcont; | |
845 | ||
5f55af10 | 846 | } |
847 | // ------------------------------------------------------------------------- // | |
ed228cbc | 848 | void AliPMDClusterFinder::SetCellEdepCut(Float_t ecut) |
849 | { | |
850 | fEcut = ecut; | |
851 | } | |
1758e4fe | 852 | // ------------------------------------------------------------------------- // |
1758e4fe | 853 | void AliPMDClusterFinder::AddRecPoint(Int_t idet,Int_t ismn,Float_t *clusdata) |
01709453 | 854 | { |
b208c6a3 | 855 | // Add Reconstructed points |
856 | // | |
01709453 | 857 | TClonesArray &lrecpoints = *fRecpoints; |
ed228cbc | 858 | AliPMDrecpoint1 *newrecpoint; |
1758e4fe | 859 | newrecpoint = new AliPMDrecpoint1(idet, ismn, clusdata); |
ed228cbc | 860 | new(lrecpoints[fNpoint++]) AliPMDrecpoint1(newrecpoint); |
01709453 | 861 | delete newrecpoint; |
862 | } | |
1758e4fe | 863 | // ------------------------------------------------------------------------- // |
5c5cadd5 | 864 | void AliPMDClusterFinder::AddRecHit(Int_t celldataX,Int_t celldataY) |
865 | { | |
866 | // Add associated cell hits to the Reconstructed points | |
867 | // | |
868 | TClonesArray &lrechits = *fRechits; | |
869 | AliPMDrechit *newrechit; | |
870 | newrechit = new AliPMDrechit(celldataX, celldataY); | |
871 | new(lrechits[fNhit++]) AliPMDrechit(newrechit); | |
872 | delete newrechit; | |
873 | } | |
874 | // ------------------------------------------------------------------------- // | |
01709453 | 875 | void AliPMDClusterFinder::ResetCellADC() |
876 | { | |
b208c6a3 | 877 | // Reset the individual cell ADC value to zero |
878 | // | |
5e6a9312 | 879 | for(Int_t irow = 0; irow < fgkRow; irow++) |
01709453 | 880 | { |
5e6a9312 | 881 | for(Int_t icol = 0; icol < fgkCol; icol++) |
01709453 | 882 | { |
ed228cbc | 883 | fCellADC[irow][icol] = 0.; |
01709453 | 884 | } |
885 | } | |
886 | } | |
1758e4fe | 887 | // ------------------------------------------------------------------------- // |
01709453 | 888 | |
889 | void AliPMDClusterFinder::ResetRecpoint() | |
890 | { | |
b208c6a3 | 891 | // Clear the list of reconstructed points |
01709453 | 892 | fNpoint = 0; |
893 | if (fRecpoints) fRecpoints->Clear(); | |
894 | } | |
1758e4fe | 895 | // ------------------------------------------------------------------------- // |
5c5cadd5 | 896 | void AliPMDClusterFinder::ResetRechit() |
897 | { | |
898 | // Clear the list of reconstructed points | |
899 | fNhit = 0; | |
900 | if (fRechits) fRechits->Clear(); | |
901 | } | |
902 | // ------------------------------------------------------------------------- // | |
55601d47 | 903 | void AliPMDClusterFinder::Load() |
904 | { | |
ebd83c56 | 905 | // Load all the *.root files |
55601d47 | 906 | // |
907 | fPMDLoader->LoadDigits("READ"); | |
908 | fPMDLoader->LoadRecPoints("recreate"); | |
909 | } | |
910 | // ------------------------------------------------------------------------- // | |
01b56f5c | 911 | void AliPMDClusterFinder::LoadClusters() |
912 | { | |
913 | // Load all the *.root files | |
914 | // | |
915 | fPMDLoader->LoadRecPoints("recreate"); | |
916 | } | |
917 | // ------------------------------------------------------------------------- // | |
ebd83c56 | 918 | void AliPMDClusterFinder::UnLoad() |
01709453 | 919 | { |
b208c6a3 | 920 | // Unload all the *.root files |
921 | // | |
ebd83c56 | 922 | fPMDLoader->UnloadDigits(); |
923 | fPMDLoader->UnloadRecPoints(); | |
01709453 | 924 | } |
1758e4fe | 925 | // ------------------------------------------------------------------------- // |
01b56f5c | 926 | void AliPMDClusterFinder::UnLoadClusters() |
927 | { | |
928 | // Unload all the *.root files | |
929 | // | |
930 | fPMDLoader->UnloadRecPoints(); | |
931 | } | |
932 | // ------------------------------------------------------------------------- // | |
09a06455 | 933 | |
35535af7 | 934 | AliPMDCalibData* AliPMDClusterFinder::GetCalibGain() const |
09a06455 | 935 | { |
936 | // The run number will be centralized in AliCDBManager, | |
937 | // you don't need to set it here! | |
938 | // Added by ZA | |
35535af7 | 939 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Gain"); |
09a06455 | 940 | |
0dd3d6f9 | 941 | if(!entry) AliFatal("Calibration object retrieval failed! "); |
09a06455 | 942 | |
943 | AliPMDCalibData *calibdata=0; | |
944 | if (entry) calibdata = (AliPMDCalibData*) entry->GetObject(); | |
945 | ||
0dd3d6f9 | 946 | if (!calibdata) AliFatal("No calibration data from calibration database !"); |
09a06455 | 947 | |
948 | return calibdata; | |
949 | } | |
35535af7 | 950 | |
951 | // ------------------------------------------------------------------------- // | |
952 | ||
953 | AliPMDPedestal* AliPMDClusterFinder::GetCalibPed() const | |
954 | { | |
955 | // The run number will be centralized in AliCDBManager, | |
956 | // you don't need to set it here! | |
957 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("PMD/Calib/Ped"); | |
958 | ||
959 | if(!entry) AliFatal("Pedestal object retrieval failed!"); | |
960 | ||
961 | AliPMDPedestal *pedestal = 0; | |
962 | if (entry) pedestal = (AliPMDPedestal*) entry->GetObject(); | |
963 | ||
964 | if (!pedestal) AliFatal("No pedestal data from pedestal database !"); | |
965 | ||
966 | return pedestal; | |
967 | } |