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