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