]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ITS/AliITSDetTypeRec.cxx
Undo previous commit of this file
[u/mrichter/AliRoot.git] / ITS / AliITSDetTypeRec.cxx
... / ...
CommitLineData
1/***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Conributors 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
16/*
17 $Id$
18*/
19
20////////////////////////////////////////////////////////////////////////
21// This class defines the "Standard" reconstruction for the ITS //
22// detector. //
23// //
24////////////////////////////////////////////////////////////////////////
25#include "TObjArray.h"
26#include "TTree.h"
27
28#include "AliCDBManager.h"
29#include "AliCDBStorage.h"
30#include "AliCDBEntry.h"
31#include "AliITSClusterFinder.h"
32#include "AliITSClusterFinderV2.h"
33#include "AliITSClusterFinderV2SPD.h"
34#include "AliITSClusterFinderV2SDD.h"
35#include "AliITSClusterFinderV2SSD.h"
36#include "AliITSClusterFinderSPD.h"
37#include "AliITSClusterFinderSDD.h"
38#include "AliITSClusterFinderSSD.h"
39#include "AliITSDetTypeRec.h"
40#include "AliITSgeom.h"
41#include "AliITSRawCluster.h"
42#include "AliITSRawClusterSPD.h"
43#include "AliITSRawClusterSDD.h"
44#include "AliITSRawClusterSSD.h"
45#include "AliITSRecPoint.h"
46#include "AliITSCalibrationSPD.h"
47#include "AliITSCalibrationSDD.h"
48#include "AliITSMapSDD.h"
49#include "AliITSDriftSpeedArraySDD.h"
50#include "AliITSCalibrationSSD.h"
51#include "AliITSNoiseSSD.h"
52#include "AliITSGainSSD.h"
53#include "AliITSBadChannelsSSD.h"
54#include "AliITSPedestalSSD.h"
55#include "AliITSsegmentationSPD.h"
56#include "AliITSsegmentationSDD.h"
57#include "AliITSsegmentationSSD.h"
58#include "AliLog.h"
59
60
61const Int_t AliITSDetTypeRec::fgkNdettypes = 3;
62const Int_t AliITSDetTypeRec::fgkDefaultNModulesSPD = 240;
63const Int_t AliITSDetTypeRec::fgkDefaultNModulesSDD = 260;
64const Int_t AliITSDetTypeRec::fgkDefaultNModulesSSD = 1698;
65
66ClassImp(AliITSDetTypeRec)
67
68//________________________________________________________________
69AliITSDetTypeRec::AliITSDetTypeRec(): TObject(),
70fNMod(0),
71fITSgeom(0),
72fReconstruction(0),
73fSegmentation(0),
74fCalibration(0),
75fPreProcess(0),
76fPostProcess(0),
77fDigits(0),
78fDDLMapSDD(0),
79fNdtype(0),
80fCtype(0),
81fNctype(0),
82fRecPoints(0),
83fNRecPoints(0),
84fSelectedVertexer(),
85fFirstcall(kTRUE){
86 // Standard Constructor
87 // Inputs:
88 // none.
89 // Outputs:
90 // none.
91 // Return:
92 //
93
94 fReconstruction = new TObjArray(fgkNdettypes);
95 fDigits = new TObjArray(fgkNdettypes);
96 for(Int_t i=0; i<3; i++){
97 fClusterClassName[i]=0;
98 fDigClassName[i]=0;
99 fRecPointClassName[i]=0;
100 }
101 fDDLMapSDD=new AliITSDDLModuleMapSDD();
102 fNdtype = new Int_t[fgkNdettypes];
103 fCtype = new TObjArray(fgkNdettypes);
104 fNctype = new Int_t[fgkNdettypes];
105 fNMod = new Int_t [fgkNdettypes];
106 fNMod[0] = fgkDefaultNModulesSPD;
107 fNMod[1] = fgkDefaultNModulesSDD;
108 fNMod[2] = fgkDefaultNModulesSSD;
109 fRecPoints = new TClonesArray("AliITSRecPoint",3000);
110 fNRecPoints = 0;
111
112 for(Int_t i=0;i<fgkNdettypes;i++){
113 fNdtype[i]=0;
114 fNctype[i]=0;
115 }
116
117 SelectVertexer(" ");
118}
119
120//______________________________________________________________________
121AliITSDetTypeRec::AliITSDetTypeRec(const AliITSDetTypeRec & rec):TObject(rec),
122fNMod(rec.fNMod),
123fITSgeom(rec.fITSgeom),
124fReconstruction(rec.fReconstruction),
125fSegmentation(rec.fSegmentation),
126fCalibration(rec.fCalibration),
127fPreProcess(rec.fPreProcess),
128fPostProcess(rec.fPostProcess),
129fDigits(rec.fDigits),
130fDDLMapSDD(rec.fDDLMapSDD),
131fNdtype(rec.fNdtype),
132fCtype(rec.fCtype),
133fNctype(rec.fNctype),
134fRecPoints(rec.fRecPoints),
135fNRecPoints(rec.fNRecPoints),
136fSelectedVertexer(rec.fSelectedVertexer),
137fFirstcall(rec.fFirstcall)
138{
139
140 // Copy constructor.
141
142}
143//______________________________________________________________________
144AliITSDetTypeRec& AliITSDetTypeRec::operator=(const AliITSDetTypeRec& source){
145 // Assignment operator.
146 this->~AliITSDetTypeRec();
147 new(this) AliITSDetTypeRec(source);
148 return *this;
149
150}
151
152//_____________________________________________________________________
153AliITSDetTypeRec::~AliITSDetTypeRec(){
154 //Destructor
155
156 if(fReconstruction){
157 fReconstruction->Delete();
158 delete fReconstruction;
159 fReconstruction = 0;
160 }
161 if(fSegmentation){
162 fSegmentation->Delete();
163 delete fSegmentation;
164 fSegmentation = 0;
165 }
166 if(fCalibration){
167 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
168 AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSPD()))->GetResponse();
169 AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSDD()))->GetResponse();
170 AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSSD()))->GetResponse();
171 if(rspd) delete rspd;
172 if(rsdd) delete rsdd;
173 if(rssd) delete rssd;
174 fCalibration->Delete();
175 delete fCalibration;
176 fCalibration = 0;
177 }
178 }
179 if(fPreProcess) delete fPreProcess;
180 if(fPostProcess) delete fPostProcess;
181 if(fDDLMapSDD) delete fDDLMapSDD;
182 if(fDigits){
183 fDigits->Delete();
184 delete fDigits;
185 fDigits=0;
186 }
187 if(fRecPoints){
188 fRecPoints->Delete();
189 delete fRecPoints;
190 fRecPoints=0;
191 }
192 if(fCtype) {
193 fCtype->Delete();
194 delete fCtype;
195 fCtype = 0;
196 }
197 delete [] fNctype;
198 delete [] fNdtype;
199 delete [] fNMod;
200
201 if (fITSgeom) delete fITSgeom;
202
203}
204
205//___________________________________________________________________
206void AliITSDetTypeRec::SetReconstructionModel(Int_t dettype,AliITSClusterFinder *clf){
207
208 //Set reconstruction model for detector type
209
210 if(fReconstruction==0) fReconstruction = new TObjArray(fgkNdettypes);
211 if(fReconstruction->At(dettype)!=0) delete fReconstruction->At(dettype);
212 fReconstruction->AddAt(clf,dettype);
213}
214//______________________________________________________________________
215AliITSClusterFinder* AliITSDetTypeRec::GetReconstructionModel(Int_t dettype){
216
217 //Get reconstruction model for detector type
218 if(fReconstruction==0) {
219 Warning("GetReconstructionModel","fReconstruction is 0!");
220 return 0;
221 }
222 return (AliITSClusterFinder*)fReconstruction->At(dettype);
223}
224
225//______________________________________________________________________
226void AliITSDetTypeRec::SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg){
227
228 //Set segmentation model for detector type
229
230 if(fSegmentation==0) fSegmentation = new TObjArray(fgkNdettypes);
231 if(fSegmentation->At(dettype)!=0) delete fSegmentation->At(dettype);
232 fSegmentation->AddAt(seg,dettype);
233
234}
235//______________________________________________________________________
236AliITSsegmentation* AliITSDetTypeRec::GetSegmentationModel(Int_t dettype){
237
238 //Get segmentation model for detector type
239
240 if(fSegmentation==0) {
241 Warning("GetSegmentationModel","fSegmentation is 0!");
242 return 0;
243 }
244 return (AliITSsegmentation*)fSegmentation->At(dettype);
245
246}
247//_______________________________________________________________________
248void AliITSDetTypeRec::SetCalibrationModel(Int_t iMod, AliITSCalibration *cal){
249
250 //Set calibration (response) for the module iMod of type dettype
251 if (fCalibration==0) {
252 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
253 fCalibration->SetOwner(kTRUE);
254 fCalibration->Clear();
255 }
256
257 if (fCalibration->At(iMod) != 0)
258 delete (AliITSCalibration*) fCalibration->At(iMod);
259 fCalibration->AddAt(cal,iMod);
260
261}
262//_______________________________________________________________________
263AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod){
264
265 //Get calibration model for module type
266
267 if(fCalibration==0) {
268 Warning("GetalibrationModel","fCalibration is 0!");
269 return 0;
270 }
271
272 return (AliITSCalibration*)fCalibration->At(iMod);
273}
274
275//______________________________________________________________________
276void AliITSDetTypeRec::SetTreeAddressD(TTree *treeD){
277 // Set branch address for the tree of digits.
278
279 const char *det[4] = {"SPD","SDD","SSD","ITS"};
280 TBranch *branch;
281 Char_t* digclass;
282 Int_t i;
283 char branchname[30];
284
285 if(!treeD) return;
286 if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes);
287 for (i=0; i<fgkNdettypes; i++) {
288 digclass = GetDigitClassName(i);
289 if(!(fDigits->At(i))) {
290 fDigits->AddAt(new TClonesArray(digclass,1000),i);
291 }else{
292 ResetDigits(i);
293 }
294 if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]);
295 else sprintf(branchname,"%sDigits%d",det[3],i+1);
296 if (fDigits) {
297 branch = treeD->GetBranch(branchname);
298 if (branch) branch->SetAddress(&((*fDigits)[i]));
299 }
300 }
301}
302
303//_______________________________________________________________________
304TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree *tree, const char* name,
305 const char *classname,
306 void* address,Int_t size,
307 Int_t splitlevel)
308{
309//
310// Makes branch in given tree and diverts them to a separate file
311//
312//
313//
314
315 if (tree == 0x0) {
316 Error("MakeBranchInTree","Making Branch %s Tree is NULL",name);
317 return 0x0;
318 }
319 TBranch *branch = tree->GetBranch(name);
320 if (branch) {
321 return branch;
322 }
323 if (classname){
324 branch = tree->Branch(name,classname,address,size,splitlevel);
325 }
326 else {
327 branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel);
328 }
329
330 return branch;
331}
332
333//____________________________________________________________________
334void AliITSDetTypeRec::SetDefaults(){
335
336 //Set defaults for segmentation and response
337
338 if(!GetITSgeom()){
339 Warning("SetDefaults","null pointer to AliITSgeomGeom !");
340 return;
341 }
342
343 AliITSsegmentation* seg;
344 if(!GetCalibration()) {AliFatal("Exit");exit(0);}
345
346 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
347 if(dettype==0){
348 seg = new AliITSsegmentationSPD();
349 SetSegmentationModel(dettype,seg);
350 SetDigitClassName(dettype,"AliITSdigitSPD");
351 SetClusterClassName(dettype,"AliITSRawClusterSPD");
352
353 }
354 if(dettype==1){
355 AliITSCalibrationSDD* res=(AliITSCalibrationSDD*) GetCalibrationModel(GetITSgeom()->GetStartSDD());
356 seg = new AliITSsegmentationSDD();
357 SetSegmentationModel(dettype,seg);
358 const char *kopt = ((AliITSresponseSDD*)res->GetResponse())->ZeroSuppOption();
359 if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D"))) SetDigitClassName(dettype,"AliITSdigit");
360 else SetDigitClassName(dettype,"AliITSdigitSDD");
361 SetClusterClassName(dettype,"AliITSRawClusterSDD");
362
363 }
364 if(dettype==2){
365 AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD();
366 seg2->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
367 seg2->SetAnglesLay5(0.0075,0.0275); // strip angels rad P and N side.
368 seg2->SetAnglesLay6(0.0275,0.0075); // strip angels rad P and N side.
369 SetSegmentationModel(dettype,seg2);
370 SetDigitClassName(dettype,"AliITSdigitSSD");
371 SetClusterClassName(dettype,"AliITSRawClusterSSD");
372 }
373 }
374
375}
376//______________________________________________________________________
377Bool_t AliITSDetTypeRec::GetCalibration() {
378 // Get Default calibration if a storage is not defined.
379
380 if(!fFirstcall){
381 AliITSCalibration* cal = GetCalibrationModel(0);
382 if(cal)return kTRUE;
383 }
384 else {
385 fFirstcall = kFALSE;
386 }
387
388 // SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
389 // Int_t run=GetRunNumber();
390
391 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
392 if (fCalibration==0) {
393 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
394 fCalibration->SetOwner(!cacheStatus);
395 fCalibration->Clear();
396 }
397
398 AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead");
399 AliCDBEntry *entrySPDn = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy");
400 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
401
402 // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD");
403 AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
404 AliCDBEntry *entryPedestalSSD = AliCDBManager::Instance()->Get("ITS/Calib/PedestalSSD");
405 AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
406 AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
407
408 AliCDBEntry *entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD");
409 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD");
410 AliCDBEntry *entry2SSD = AliCDBManager::Instance()->Get("ITS/Calib/RespSSD");
411 AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD");
412 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
413 AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD");
414 AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD");
415
416 if(!entrySPD || !entrySPDn || !entrySDD || !entryNoiseSSD || !entryGainSSD ||
417 !entryPedestalSSD || !entryBadChannelsSSD ||
418 !entry2SPD || !entry2SDD || !entry2SSD || !drSpSDD || !ddlMapSDD || !mapASDD || !mapTSDD){
419 AliFatal("Calibration object retrieval failed! ");
420 return kFALSE;
421 }
422
423 TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
424 if(!cacheStatus)entrySPD->SetObject(NULL);
425 entrySPD->SetOwner(kTRUE);
426
427 TObjArray *calSPDn = (TObjArray *)entrySPDn->GetObject();
428 if(!cacheStatus)entrySPDn->SetObject(NULL);
429 entrySPDn->SetOwner(kTRUE);
430
431 AliITSresponseSPD *pSPD = (AliITSresponseSPD*)entry2SPD->GetObject();
432 if(!cacheStatus)entry2SPD->SetObject(NULL);
433 entry2SPD->SetOwner(kTRUE);
434
435 TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
436 if(!cacheStatus)entrySDD->SetObject(NULL);
437 entrySDD->SetOwner(kTRUE);
438
439 AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
440 if(!cacheStatus)entry2SDD->SetObject(NULL);
441 entry2SDD->SetOwner(kTRUE);
442
443 TObjArray *drSp = (TObjArray *)drSpSDD->GetObject();
444 if(!cacheStatus)drSpSDD->SetObject(NULL);
445 drSpSDD->SetOwner(kTRUE);
446
447 AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
448 if(!cacheStatus)ddlMapSDD->SetObject(NULL);
449 ddlMapSDD->SetOwner(kTRUE);
450
451 TObjArray *mapAn = (TObjArray *)mapASDD->GetObject();
452 if(!cacheStatus)mapASDD->SetObject(NULL);
453 mapASDD->SetOwner(kTRUE);
454
455 TObjArray *mapT = (TObjArray *)mapTSDD->GetObject();
456 if(!cacheStatus)mapTSDD->SetObject(NULL);
457 mapTSDD->SetOwner(kTRUE);
458
459 TObjArray *noiseSSD = (TObjArray *)entryNoiseSSD->GetObject();
460 if(!cacheStatus)entryNoiseSSD->SetObject(NULL);
461 entryNoiseSSD->SetOwner(kTRUE);
462
463 TObjArray *pedestalSSD = (TObjArray *)entryPedestalSSD->GetObject();
464 if(!cacheStatus)entryPedestalSSD->SetObject(NULL);
465 entryPedestalSSD->SetOwner(kTRUE);
466
467 TObjArray *gainSSD = (TObjArray *)entryGainSSD->GetObject();
468 if(!cacheStatus)entryGainSSD->SetObject(NULL);
469 entryGainSSD->SetOwner(kTRUE);
470
471 TObjArray *badchannelsSSD = (TObjArray *)entryBadChannelsSSD->GetObject();
472 if(!cacheStatus)entryBadChannelsSSD->SetObject(NULL);
473 entryBadChannelsSSD->SetOwner(kTRUE);
474
475 AliITSresponseSSD *pSSD = (AliITSresponseSSD*)entry2SSD->GetObject();
476 if(!cacheStatus)entry2SSD->SetObject(NULL);
477 entry2SSD->SetOwner(kTRUE);
478
479 // DB entries are deleted. In this way metadeta objects are deleted as well
480 if(!cacheStatus){
481 delete entrySPD;
482 delete entrySPDn;
483 delete entrySDD;
484 delete entryNoiseSSD;
485 delete entryPedestalSSD;
486 delete entryGainSSD;
487 delete entryBadChannelsSSD;
488 delete entry2SPD;
489 delete entry2SDD;
490 delete entry2SSD;
491 delete mapASDD;
492 delete mapTSDD;
493 delete drSpSDD;
494 delete ddlMapSDD;
495 }
496
497 if ((!pSPD)||(!pSDD)||(!pSSD) || (!calSPD) || !(calSPDn) || (!calSDD) || (!drSp) || (!ddlsdd)
498 || (!mapAn) || (!mapT) || (!noiseSSD)|| (!gainSSD)|| (!badchannelsSSD)) {
499 AliWarning("Can not get calibration from calibration database !");
500 return kFALSE;
501 }
502
503 fNMod[0] = calSPD->GetEntries();
504 if(fNMod[0] != calSPDn->GetEntries())AliFatal(Form("Different number of calibration objects in SPD dead (%d ) and SPD noisy (%d)\n",fNMod[0],calSPDn->GetEntries()));
505 fNMod[1] = calSDD->GetEntries();
506 fNMod[2] = noiseSSD->GetEntries();
507 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
508 fNMod[0], fNMod[1], fNMod[2]));
509 AliITSCalibrationSPD* calD;
510 AliITSCalibrationSPD* calN;
511 for (Int_t i=0; i<fNMod[0]; i++) {
512 calD = (AliITSCalibrationSPD*) calSPD->At(i);
513 printf("SPD module %d - Number of dead pixels %d \n",i,calD->GetNrBad());
514 calN = (AliITSCalibrationSPD*) calSPDn->At(i);
515 printf("SPD module %d - Number of noisy pixels %d \n",i,calN->GetNrBad());
516 for(Int_t ii=0; ii<calN->GetNrBad();ii++){
517 calD->AddBad(calN->GetBadColAt(ii),calN->GetBadRowAt(ii));
518 }
519 calD->SetResponse((AliITSresponse*)pSPD);
520 SetCalibrationModel(i, calD);
521 printf("SPD module %d - Number of bad pixels %d \n",i,calD->GetNrBad());
522 }
523 calSPDn->Delete();
524 delete calSPDn;
525 calSPDn = NULL;
526 AliITSCalibration* cal;
527 for (Int_t i=0; i<fNMod[1]; i++) {
528 cal = (AliITSCalibration*) calSDD->At(i);
529 cal->SetResponse((AliITSresponse*)pSDD);
530 Int_t i0=2*i;
531 Int_t i1=1+2*i;
532 AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0);
533 AliITSMapSDD* ma0 = (AliITSMapSDD*)mapAn->At(i0);
534 AliITSMapSDD* mt0 = (AliITSMapSDD*)mapT->At(i0);
535 AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1);
536 AliITSMapSDD* ma1 = (AliITSMapSDD*)mapAn->At(i1);
537 AliITSMapSDD* mt1 = (AliITSMapSDD*)mapT->At(i1);
538 cal->SetDriftSpeed(0,arr0);
539 cal->SetDriftSpeed(1,arr1);
540 cal->SetMapA(0,ma0);
541 cal->SetMapA(1,ma1);
542 cal->SetMapT(0,mt0);
543 cal->SetMapT(1,mt1);
544 fDDLMapSDD->SetDDLMap(ddlsdd);
545 Int_t iMod = i + fNMod[0];
546 SetCalibrationModel(iMod, cal);
547 }
548 for (Int_t i=0; i<fNMod[2]; i++) {
549
550 AliITSCalibrationSSD *calibSSD = new AliITSCalibrationSSD();
551 calibSSD->SetResponse((AliITSresponse*)pSSD);
552
553 AliITSNoiseSSD *noise = (AliITSNoiseSSD*) (noiseSSD->At(i));
554 calibSSD->SetNoise(noise);
555 AliITSPedestalSSD *pedestal = (AliITSPedestalSSD*) (pedestalSSD->At(i));
556 calibSSD->SetPedestal(pedestal);
557 AliITSGainSSD *gain = (AliITSGainSSD*) (gainSSD->At(i));
558 calibSSD->SetGain(gain);
559 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (badchannelsSSD->At(i));
560 calibSSD->SetBadChannels(bad);
561
562 Int_t iMod = i + fNMod[0] + fNMod[1];
563 SetCalibrationModel(iMod, calibSSD);
564 }
565
566 return kTRUE;
567}
568
569
570//________________________________________________________________
571void AliITSDetTypeRec::SetDefaultClusterFinders(){
572
573 //set defaults for standard cluster finder
574
575 if(!GetITSgeom()){
576 Warning("SetDefaults","null pointer to AliITSgeom!");
577 return;
578 }
579
580 AliITSClusterFinder *clf;
581
582 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
583 //SPD
584 if(dettype==0){
585 if(!GetReconstructionModel(dettype)){
586 TClonesArray *dig0 = DigitsAddress(0);
587 TClonesArray *rec0 = ClustersAddress(0);
588 clf = new AliITSClusterFinderSPD(this,dig0,rec0);
589 SetReconstructionModel(dettype,clf);
590
591 }
592 }
593
594 //SDD
595 if(dettype==1){
596 if(!GetReconstructionModel(dettype)){
597 TClonesArray *dig1 = DigitsAddress(1);
598 TClonesArray *rec1 = ClustersAddress(1);
599 clf = new AliITSClusterFinderSDD(this,dig1,rec1);
600 SetReconstructionModel(dettype,clf);
601 }
602
603 }
604 //SSD
605 if(dettype==2){
606 if(!GetReconstructionModel(dettype)){
607 TClonesArray* dig2 = DigitsAddress(2);
608 clf = new AliITSClusterFinderSSD(this,dig2);
609 SetReconstructionModel(dettype,clf);
610 }
611 }
612
613 }
614
615
616}
617
618//________________________________________________________________
619void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){
620
621 //Set defaults for cluster finder V2
622
623 if(!GetITSgeom()){
624 Warning("SetDefaults","Null pointer to AliITSgeom !");
625 return;
626 }
627
628 AliITSClusterFinder *clf;
629
630 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
631 //SPD
632 if(dettype==0){
633 if(!GetReconstructionModel(dettype)){
634 clf = new AliITSClusterFinderV2SPD(this);
635 clf->InitGeometry();
636 if(!rawdata) clf->SetDigits(DigitsAddress(0));
637 SetReconstructionModel(dettype,clf);
638
639 }
640 }
641 //SDD
642 if(dettype==1){
643 if(!GetReconstructionModel(dettype)){
644 clf = new AliITSClusterFinderV2SDD(this);
645 clf->InitGeometry();
646 if(!rawdata) clf->SetDigits(DigitsAddress(1));
647 SetReconstructionModel(dettype,clf);
648 }
649
650 }
651
652 //SSD
653 if(dettype==2){
654 if(!GetReconstructionModel(dettype)){
655 clf = new AliITSClusterFinderV2SSD(this);
656 clf->InitGeometry();
657 if(!rawdata) clf->SetDigits(DigitsAddress(2));
658 SetReconstructionModel(dettype,clf);
659 }
660 }
661
662 }
663
664}
665//______________________________________________________________________
666void AliITSDetTypeRec::MakeBranch(TTree* tree, Option_t* option){
667
668 //Creates branches for clusters and recpoints
669 Bool_t cR = (strstr(option,"R")!=0);
670 Bool_t cRF = (strstr(option,"RF")!=0);
671
672 if(cRF)cR = kFALSE;
673
674 if(cR) MakeBranchR(tree);
675 if(cRF) MakeBranchRF(tree);
676
677}
678
679//___________________________________________________________________
680void AliITSDetTypeRec::AddCluster(Int_t id, AliITSRawCluster *c){
681
682 // Adds a raw cluster to the list
683 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
684 switch(id){
685 case 0:
686 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
687 break;
688 case 1:
689 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
690 break;
691 case 2:
692 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
693 break;
694 }
695}
696//___________________________________________________________________
697void AliITSDetTypeRec::ResetDigits(){
698 // Reset number of digits and the digits array for the ITS detector.
699
700 if(!fDigits) return;
701 for(Int_t i=0;i<fgkNdettypes;i++){
702 ResetDigits(i);
703 }
704}
705//___________________________________________________________________
706void AliITSDetTypeRec::ResetDigits(Int_t branch){
707 // Reset number of digits and the digits array for this branch.
708
709 if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear();
710 if(fNdtype) fNdtype[branch]=0;
711
712}
713
714//__________________________________________________________________
715void AliITSDetTypeRec::ResetClusters(){
716
717 //Resets number of clusters and the cluster array
718 for(Int_t i=0;i<fgkNdettypes;i++){
719 ResetClusters(i);
720 }
721}
722
723//__________________________________________________________________
724void AliITSDetTypeRec::ResetClusters(Int_t i){
725
726 //Resets number of clusters and the cluster array for this branch
727
728 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
729 if (fNctype) fNctype[i]=0;
730}
731//__________________________________________________________________
732void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){
733
734 //Creates tree branches for recpoints
735 // Inputs:
736 // cont char *file File name where RecPoints branch is to be written
737 // to. If blank it write the SDigits to the same
738 // file in which the Hits were found.
739
740 Int_t buffsz = 4000;
741 char branchname[30];
742
743 // only one branch for rec points for all detector types
744 Bool_t oFast= (strstr(opt,"Fast")!=0);
745
746 Char_t detname[10] = "ITS";
747
748
749 if(oFast){
750 sprintf(branchname,"%sRecPointsF",detname);
751 } else {
752 sprintf(branchname,"%sRecPoints",detname);
753 }
754
755 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
756 if (treeR)
757 MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99);
758}
759//______________________________________________________________________
760void AliITSDetTypeRec::SetTreeAddressR(TTree *treeR){
761 // Set branch address for the Reconstructed points Trees.
762 // Inputs:
763 // TTree *treeR Tree containing the RecPoints.
764 // Outputs:
765 // none.
766 // Return:
767
768 char branchname[30];
769 Char_t namedet[10]="ITS";
770
771 if(!treeR) return;
772 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
773 TBranch *branch;
774 sprintf(branchname,"%sRecPoints",namedet);
775 branch = treeR->GetBranch(branchname);
776 if (branch) {
777 branch->SetAddress(&fRecPoints);
778 }else {
779 sprintf(branchname,"%sRecPointsF",namedet);
780 branch = treeR->GetBranch(branchname);
781 if (branch) {
782 branch->SetAddress(&fRecPoints);
783 }
784
785 }
786}
787//____________________________________________________________________
788void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){
789 // Add a reconstructed space point to the list
790 // Inputs:
791 // const AliITSRecPoint &r RecPoint class to be added to the tree
792 // of reconstructed points TreeR.
793 // Outputs:
794 // none.
795 // Return:
796 // none.
797
798 TClonesArray &lrecp = *fRecPoints;
799 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
800}
801
802//______________________________________________________________________
803void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastentry,Option_t *opt, Bool_t v2){
804 // cluster finding and reconstruction of space points
805 // the condition below will disappear when the geom class will be
806 // initialized for all versions - for the moment it is only for v5 !
807 // 7 is the SDD beam test version
808 // Inputs:
809 // TTree *treeD Digits tree
810 // TTree *treeR Clusters tree
811 // Int_t lastentry Offset for module when not all of the modules
812 // are processed.
813 // Option_t *opt String indicating which ITS sub-detectors should
814 // be processed. If ="All" then all of the ITS
815 // sub detectors are processed.
816
817 const char *all = strstr(opt,"All");
818 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
819 strstr(opt,"SSD")};
820 if(!v2) {
821 SetDefaultClusterFinders();
822 AliInfo("Original cluster finder has been selected\n");
823 }
824 else {
825 SetDefaultClusterFindersV2();
826 AliInfo("V2 cluster finder has been selected \n");
827 }
828
829 AliITSClusterFinder *rec = 0;
830 Int_t id,module,first=0;
831 for(module=0;module<GetITSgeom()->GetIndexMax();module++){
832 id = GetITSgeom()->GetModuleType(module);
833 if (!all && !det[id]) continue;
834 if(det[id]) first = GetITSgeom()->GetStartDet(id);
835 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
836 TClonesArray *itsDigits = DigitsAddress(id);
837 if (!rec)
838 AliFatal("The reconstruction class was not instanciated!");
839 ResetDigits(); // MvL: Not sure we neeed this when rereading anyways
840 if (all) {
841 treeD->GetEvent(lastentry+module);
842 }else {
843 treeD->GetEvent(lastentry+(module-first));
844 }
845 Int_t ndigits = itsDigits->GetEntriesFast();
846 if(ndigits>0){
847 rec->SetDetTypeRec(this);
848 rec->SetDigits(DigitsAddress(id));
849 // rec->SetClusters(ClustersAddress(id));
850 rec->FindRawClusters(module);
851 } // end if
852 treeR->Fill();
853 ResetRecPoints();
854 ResetClusters();
855 }
856}
857//______________________________________________________________________
858void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){
859 // cluster finding and reconstruction of space points
860 // the condition below will disappear when the geom class will be
861 // initialized for all versions - for the moment it is only for v5 !
862 // 7 is the SDD beam test version
863 // Inputs:
864 // AliRawReader *rawReader Pointer to the raw-data reader
865 // TTree *treeR Clusters tree
866 // Outputs:
867 // none.
868 // Return:
869 // none.
870 const char *all = strstr(opt,"All");
871 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
872 strstr(opt,"SSD")};
873 AliITSClusterFinderV2 *rec = 0;
874 Int_t id=0;
875
876 TClonesArray *array=new TClonesArray("AliITSRecPoint",1000);
877 TBranch *branch = treeR->Branch("ITSRecPoints",&array);
878 delete array;
879
880 TClonesArray** clusters = new TClonesArray*[GetITSgeom()->GetIndexMax()];
881 for (Int_t iModule = 0; iModule < GetITSgeom()->GetIndexMax(); iModule++) {
882 clusters[iModule] = NULL;
883 }
884 for(id=0;id<3;id++){
885 if (!all && !det[id]) continue;
886 rec = (AliITSClusterFinderV2*)GetReconstructionModel(id);
887 if (!rec)
888 AliFatal("The reconstruction class was not instanciated");
889 rec->SetDetTypeRec(this);
890 rec->RawdataToClusters(rawReader,clusters);
891 }
892 Int_t nClusters =0;
893 TClonesArray *emptyArray=new TClonesArray("AliITSRecPoint");
894 for(Int_t iModule=0;iModule<GetITSgeom()->GetIndexMax();iModule++){
895 id = GetITSgeom()->GetModuleType(iModule);
896 if (!all && !det[id]) continue;
897 array = clusters[iModule];
898 if(!array){
899 AliDebug(1,Form("data for module %d missing!",iModule));
900 array = emptyArray;
901 }
902 branch->SetAddress(&array);
903 treeR->Fill();
904 nClusters+=array->GetEntriesFast();
905
906 if (array != emptyArray) {
907 array->Delete();
908 delete array;
909 }
910 }
911 delete emptyArray;
912
913 delete[] clusters;
914 Info("DigitsToRecPoints", "total number of found recpoints in ITS: %d\n",
915 nClusters);
916
917}
918
919