1 /***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Conributors are mentioned in the code where appropriate. *
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 **************************************************************************/
20 ////////////////////////////////////////////////////////////////////////
21 // This class defines the "Standard" reconstruction for the ITS //
24 ////////////////////////////////////////////////////////////////////////
25 #include "TObjArray.h"
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 "AliITSReconstructor.h"
47 #include "AliITSRecoParam.h"
48 #include "AliITSCalibrationSDD.h"
49 #include "AliITSMapSDD.h"
50 #include "AliITSDriftSpeedArraySDD.h"
51 #include "AliITSDriftSpeedSDD.h"
52 #include "AliITSCalibrationSSD.h"
53 #include "AliITSNoiseSSD.h"
54 #include "AliITSGainSSD.h"
55 #include "AliITSBadChannelsSSD.h"
56 #include "AliITSPedestalSSD.h"
57 #include "AliITSsegmentationSPD.h"
58 #include "AliITSsegmentationSDD.h"
59 #include "AliITSsegmentationSSD.h"
63 const Int_t AliITSDetTypeRec::fgkNdettypes = 3;
64 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSPD = 240;
65 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSDD = 260;
66 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSSD = 1698;
68 ClassImp(AliITSDetTypeRec)
70 //________________________________________________________________
71 AliITSDetTypeRec::AliITSDetTypeRec(): TObject(),
91 // Standard Constructor
99 fReconstruction = new TObjArray(fgkNdettypes);
100 fDigits = new TObjArray(fgkNdettypes);
101 for(Int_t i=0; i<3; i++){
102 fClusterClassName[i]=0;
104 fRecPointClassName[i]=0;
106 fSSDCalibration=new AliITSCalibrationSSD();
107 fNdtype = new Int_t[fgkNdettypes];
108 fCtype = new TObjArray(fgkNdettypes);
109 fNctype = new Int_t[fgkNdettypes];
110 fNMod = new Int_t [fgkNdettypes];
111 fNMod[0] = fgkDefaultNModulesSPD;
112 fNMod[1] = fgkDefaultNModulesSDD;
113 fNMod[2] = fgkDefaultNModulesSSD;
114 fRecPoints = new TClonesArray("AliITSRecPoint",3000);
117 for(Int_t i=0;i<fgkNdettypes;i++){
125 //______________________________________________________________________
126 AliITSDetTypeRec::AliITSDetTypeRec(const AliITSDetTypeRec & rec):TObject(rec),
128 fITSgeom(rec.fITSgeom),
129 fReconstruction(rec.fReconstruction),
130 fSegmentation(rec.fSegmentation),
131 fCalibration(rec.fCalibration),
132 fSSDCalibration(rec.fSSDCalibration),
133 fSPDDead(rec.fSPDDead),
134 fPreProcess(rec.fPreProcess),
135 fPostProcess(rec.fPostProcess),
136 fDigits(rec.fDigits),
137 fDDLMapSDD(rec.fDDLMapSDD),
138 fRespSDD(rec.fRespSDD),
139 fNdtype(rec.fNdtype),
141 fNctype(rec.fNctype),
142 fRecPoints(rec.fRecPoints),
143 fNRecPoints(rec.fNRecPoints),
144 fSelectedVertexer(rec.fSelectedVertexer),
145 fFirstcall(rec.fFirstcall)
151 //______________________________________________________________________
152 AliITSDetTypeRec& AliITSDetTypeRec::operator=(const AliITSDetTypeRec& source){
153 // Assignment operator.
154 this->~AliITSDetTypeRec();
155 new(this) AliITSDetTypeRec(source);
160 //_____________________________________________________________________
161 AliITSDetTypeRec::~AliITSDetTypeRec(){
165 fReconstruction->Delete();
166 delete fReconstruction;
170 fSegmentation->Delete();
171 delete fSegmentation;
175 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
176 AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSPD()))->GetResponse();
177 AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSSD()))->GetResponse();
178 if(rspd) delete rspd;
179 if(rssd) delete rssd;
180 fCalibration->Delete();
183 if(fRespSDD) delete fRespSDD;
184 if(fDDLMapSDD) delete fDDLMapSDD;
187 if(fSSDCalibration) delete fSSDCalibration;
189 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
195 if(fPreProcess) delete fPreProcess;
196 if(fPostProcess) delete fPostProcess;
203 fRecPoints->Delete();
216 if (fITSgeom) delete fITSgeom;
220 //___________________________________________________________________
221 void AliITSDetTypeRec::SetReconstructionModel(Int_t dettype,AliITSClusterFinder *clf){
223 //Set reconstruction model for detector type
225 if(fReconstruction==0) fReconstruction = new TObjArray(fgkNdettypes);
226 if(fReconstruction->At(dettype)!=0) delete fReconstruction->At(dettype);
227 fReconstruction->AddAt(clf,dettype);
229 //______________________________________________________________________
230 AliITSClusterFinder* AliITSDetTypeRec::GetReconstructionModel(Int_t dettype){
232 //Get reconstruction model for detector type
233 if(fReconstruction==0) {
234 Warning("GetReconstructionModel","fReconstruction is 0!");
237 return (AliITSClusterFinder*)fReconstruction->At(dettype);
240 //______________________________________________________________________
241 void AliITSDetTypeRec::SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg){
243 //Set segmentation model for detector type
245 if(fSegmentation==0) fSegmentation = new TObjArray(fgkNdettypes);
246 if(fSegmentation->At(dettype)!=0) delete fSegmentation->At(dettype);
247 fSegmentation->AddAt(seg,dettype);
250 //______________________________________________________________________
251 AliITSsegmentation* AliITSDetTypeRec::GetSegmentationModel(Int_t dettype){
253 //Get segmentation model for detector type
255 if(fSegmentation==0) {
256 Warning("GetSegmentationModel","fSegmentation is 0!");
259 return (AliITSsegmentation*)fSegmentation->At(dettype);
262 //_______________________________________________________________________
263 void AliITSDetTypeRec::SetCalibrationModel(Int_t iMod, AliITSCalibration *cal){
265 //Set calibration (response) for the module iMod of type dettype
266 if (fCalibration==0) {
267 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
268 fCalibration->SetOwner(kTRUE);
269 fCalibration->Clear();
272 if (fCalibration->At(iMod) != 0)
273 delete (AliITSCalibration*) fCalibration->At(iMod);
274 fCalibration->AddAt(cal,iMod);
277 //_______________________________________________________________________
278 void AliITSDetTypeRec::SetSPDDeadModel(Int_t iMod, AliITSCalibration *cal){
280 //Set dead pixel info for the SPD module iMod
282 fSPDDead = new TObjArray(fgkDefaultNModulesSPD);
283 fSPDDead->SetOwner(kTRUE);
287 if (fSPDDead->At(iMod) != 0)
288 delete (AliITSCalibration*) fSPDDead->At(iMod);
289 fSPDDead->AddAt(cal,iMod);
291 //_______________________________________________________________________
292 AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod){
294 //Get calibration model for module type
296 if(fCalibration==0) {
297 Warning("GetalibrationModel","fCalibration is 0!");
301 if(iMod<fgkDefaultNModulesSPD+fgkDefaultNModulesSDD){
302 return (AliITSCalibration*)fCalibration->At(iMod);
304 Int_t i=iMod-(fgkDefaultNModulesSPD+fgkDefaultNModulesSDD);
305 fSSDCalibration->SetModule(i);
306 return (AliITSCalibration*)fSSDCalibration;
310 //_______________________________________________________________________
311 AliITSCalibration* AliITSDetTypeRec::GetSPDDeadModel(Int_t iMod){
313 //Get SPD dead for module iMod
316 AliWarning("fSPDDead is 0!");
320 return (AliITSCalibration*)fSPDDead->At(iMod);
323 //______________________________________________________________________
324 void AliITSDetTypeRec::SetTreeAddressD(TTree *treeD){
325 // Set branch address for the tree of digits.
327 const char *det[4] = {"SPD","SDD","SSD","ITS"};
334 if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes);
335 for (i=0; i<fgkNdettypes; i++) {
336 digclass = GetDigitClassName(i);
337 if(!(fDigits->At(i))) {
338 fDigits->AddAt(new TClonesArray(digclass,1000),i);
342 if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]);
343 else sprintf(branchname,"%sDigits%d",det[3],i+1);
345 branch = treeD->GetBranch(branchname);
346 if (branch) branch->SetAddress(&((*fDigits)[i]));
351 //_______________________________________________________________________
352 TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree *tree, const char* name,
353 const char *classname,
354 void* address,Int_t size,
358 // Makes branch in given tree and diverts them to a separate file
364 Error("MakeBranchInTree","Making Branch %s Tree is NULL",name);
367 TBranch *branch = tree->GetBranch(name);
372 branch = tree->Branch(name,classname,address,size,splitlevel);
375 branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel);
381 //____________________________________________________________________
382 void AliITSDetTypeRec::SetDefaults(){
384 //Set defaults for segmentation and response
387 Warning("SetDefaults","null pointer to AliITSgeomGeom !");
391 AliITSsegmentation* seg;
392 if(!GetCalibration()) {AliFatal("Exit");exit(0);}
394 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
396 seg = new AliITSsegmentationSPD();
397 SetSegmentationModel(dettype,seg);
398 SetDigitClassName(dettype,"AliITSdigitSPD");
399 SetClusterClassName(dettype,"AliITSRawClusterSPD");
403 seg = new AliITSsegmentationSDD();
404 SetSegmentationModel(dettype,seg);
405 SetDigitClassName(dettype,"AliITSdigitSDD");
406 SetClusterClassName(dettype,"AliITSRawClusterSDD");
409 AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD();
410 SetSegmentationModel(dettype,seg2);
411 SetDigitClassName(dettype,"AliITSdigitSSD");
412 SetClusterClassName(dettype,"AliITSRawClusterSSD");
417 //______________________________________________________________________
418 Bool_t AliITSDetTypeRec::GetCalibration() {
419 // Get Default calibration if a storage is not defined.
422 AliITSCalibration* cal = GetCalibrationModel(0);
429 // SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
430 // Int_t run=GetRunNumber();
432 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
433 if (fCalibration==0) {
434 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
435 fCalibration->SetOwner(!cacheStatus);
436 fCalibration->Clear();
439 // dead pixel are not used for local reconstruction
440 AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy");
441 AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead");
442 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
444 // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD");
445 AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
446 AliCDBEntry *entryPedestalSSD = AliCDBManager::Instance()->Get("ITS/Calib/PedestalSSD");
447 AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
448 AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
449 // Entry for the AliITSRecoParam object
450 AliCDBEntry *entryRP = AliCDBManager::Instance()->Get("ITS/Calib/RecoParam/");
451 AliCDBEntry *entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD");
452 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD");
453 AliCDBEntry *entry2SSD = AliCDBManager::Instance()->Get("ITS/Calib/RespSSD");
454 AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD");
455 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
456 AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD");
457 AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD");
459 if(!entrySPD || !deadSPD || !entrySDD || !entryNoiseSSD || !entryGainSSD ||
460 !entryPedestalSSD || !entryBadChannelsSSD ||
461 !entry2SPD || !entry2SDD || !entry2SSD || !drSpSDD || !ddlMapSDD || !mapASDD || !mapTSDD ){
462 AliFatal("Calibration object retrieval failed! ");
466 TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
467 if(!cacheStatus)entrySPD->SetObject(NULL);
468 entrySPD->SetOwner(kTRUE);
470 TObjArray *caldeadSPD = (TObjArray *)deadSPD->GetObject();
471 if(!cacheStatus)deadSPD->SetObject(NULL);
472 deadSPD->SetOwner(kTRUE);
474 AliITSresponseSPD *pSPD = (AliITSresponseSPD*)entry2SPD->GetObject();
475 if(!cacheStatus)entry2SPD->SetObject(NULL);
476 entry2SPD->SetOwner(kTRUE);
478 TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
479 if(!cacheStatus)entrySDD->SetObject(NULL);
480 entrySDD->SetOwner(kTRUE);
482 AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
483 if(!cacheStatus)entry2SDD->SetObject(NULL);
484 entry2SDD->SetOwner(kTRUE);
486 TObjArray *drSp = (TObjArray *)drSpSDD->GetObject();
487 if(!cacheStatus)drSpSDD->SetObject(NULL);
488 drSpSDD->SetOwner(kTRUE);
490 AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
491 if(!cacheStatus)ddlMapSDD->SetObject(NULL);
492 ddlMapSDD->SetOwner(kTRUE);
494 TObjArray *mapAn = (TObjArray *)mapASDD->GetObject();
495 if(!cacheStatus)mapASDD->SetObject(NULL);
496 mapASDD->SetOwner(kTRUE);
498 TObjArray *mapT = (TObjArray *)mapTSDD->GetObject();
499 if(!cacheStatus)mapTSDD->SetObject(NULL);
500 mapTSDD->SetOwner(kTRUE);
502 AliITSNoiseSSD *noiseSSD = (AliITSNoiseSSD *)entryNoiseSSD->GetObject();
503 if(!cacheStatus)entryNoiseSSD->SetObject(NULL);
504 entryNoiseSSD->SetOwner(kTRUE);
506 AliITSPedestalSSD *pedestalSSD =
507 (AliITSPedestalSSD*)entryPedestalSSD->GetObject();
508 if(!cacheStatus)entryPedestalSSD->SetObject(NULL);
509 entryPedestalSSD->SetOwner(kTRUE);
511 AliITSGainSSD *gainSSD = (AliITSGainSSD *)entryGainSSD->GetObject();
512 if(!cacheStatus)entryGainSSD->SetObject(NULL);
513 entryGainSSD->SetOwner(kTRUE);
515 AliITSBadChannelsSSD *badchannelsSSD =
516 (AliITSBadChannelsSSD*)entryBadChannelsSSD->GetObject();
517 if(!cacheStatus)entryBadChannelsSSD->SetObject(NULL);
518 entryBadChannelsSSD->SetOwner(kTRUE);
520 AliITSresponseSSD *pSSD = (AliITSresponseSSD*)entry2SSD->GetObject();
521 if(!cacheStatus)entry2SSD->SetObject(NULL);
522 entry2SSD->SetOwner(kTRUE);
524 if(!AliITSReconstructor::GetRecoParam()){
525 if(!entryRP) AliFatal("Calibration object (RecoParam) retrieval from OCDB failed! Hint: as an alternative you can set it in your reconstruction macro ");
526 AliITSRecoParam *rp = (AliITSRecoParam*)entryRP->GetObject();
527 if(!cacheStatus)entryRP->SetObject(NULL);
528 entryRP->SetOwner(kTRUE);
529 AliITSReconstructor::SetRecoParam(rp);
532 AliWarning("AliITSRecoParam object has been already set in AliITSReconstructor. The OCDB instance will not be used\n");
536 // DB entries are deleted. In this way metadeta objects are deleted as well
541 delete entryNoiseSSD;
542 delete entryPedestalSSD;
544 delete entryBadChannelsSSD;
554 if ((!pSPD)||(!pSDD)||(!pSSD) || (!calSPD) || (!caldeadSPD) ||(!calSDD) || (!drSp) || (!ddlsdd)
555 || (!mapAn) || (!mapT) || (!noiseSSD)|| (!gainSSD)|| (!badchannelsSSD)) {
556 AliWarning("Can not get calibration from calibration database !");
560 fNMod[0] = calSPD->GetEntries();
561 fNMod[1] = calSDD->GetEntries();
562 //fNMod[2] = noiseSSD->GetEntries();
563 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
564 fNMod[0], fNMod[1], fNMod[2]));
565 AliITSCalibration* cal;
566 for (Int_t i=0; i<fNMod[0]; i++) {
567 cal = (AliITSCalibration*) calSPD->At(i);
568 cal->SetResponse((AliITSresponse*)pSPD);
569 SetCalibrationModel(i, cal);
570 cal = (AliITSCalibration*) caldeadSPD->At(i);
571 SetSPDDeadModel(i, cal);
576 for(Int_t iddl=0; iddl<AliITSDDLModuleMapSDD::GetNDDLs(); iddl++){
577 for(Int_t icar=0; icar<AliITSDDLModuleMapSDD::GetNModPerDDL();icar++){
578 Int_t iMod=fDDLMapSDD->GetModuleNumber(iddl,icar);
579 if(iMod==-1) continue;
580 Int_t i=iMod - fgkDefaultNModulesSPD;
581 cal = (AliITSCalibration*) calSDD->At(i);
584 AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0);
585 AliITSMapSDD* ma0 = (AliITSMapSDD*)mapAn->At(i0);
586 AliITSMapSDD* mt0 = (AliITSMapSDD*)mapT->At(i0);
587 AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1);
588 AliITSMapSDD* ma1 = (AliITSMapSDD*)mapAn->At(i1);
589 AliITSMapSDD* mt1 = (AliITSMapSDD*)mapT->At(i1);
590 cal->SetDriftSpeed(0,arr0);
591 cal->SetDriftSpeed(1,arr1);
596 SetCalibrationModel(iMod, cal);
600 fSSDCalibration->SetResponse((AliITSresponse*)pSSD);
601 fSSDCalibration->SetNoise(noiseSSD);
602 fSSDCalibration->SetPedestal(pedestalSSD);
603 fSSDCalibration->SetGain(gainSSD);
604 fSSDCalibration->SetBadChannels(badchannelsSSD);
605 //fSSDCalibration->FillBadChipMap();
609 for (Int_t i=0; i<fNMod[2]; i++) {
611 AliITSCalibrationSSD *calibSSD = new AliITSCalibrationSSD();
612 calibSSD->SetResponse((AliITSresponse*)pSSD);
614 AliITSNoiseSSD *noise = (AliITSNoiseSSD*) (noiseSSD->At(i));
615 calibSSD->SetNoise(noise);
616 AliITSPedestalSSD *pedestal = (AliITSPedestalSSD*) (pedestalSSD->At(i));
617 calibSSD->SetPedestal(pedestal);
618 AliITSGainSSD *gain = (AliITSGainSSD*) (gainSSD->At(i));
619 calibSSD->SetGain(gain);
620 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (badchannelsSSD->At(i));
621 calibSSD->SetBadChannels(bad);
622 calibSSD->FillBadChipMap();
624 Int_t iMod = i + fgkDefaultNModulesSPD + fgkDefaultNModulesSDD;
625 SetCalibrationModel(iMod, calibSSD);
633 //________________________________________________________________
634 void AliITSDetTypeRec::SetDefaultClusterFinders(){
636 //set defaults for standard cluster finder
639 Warning("SetDefaults","null pointer to AliITSgeom!");
643 AliITSClusterFinder *clf;
645 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
648 if(!GetReconstructionModel(dettype)){
649 TClonesArray *dig0 = DigitsAddress(0);
650 TClonesArray *rec0 = ClustersAddress(0);
651 clf = new AliITSClusterFinderSPD(this,dig0,rec0);
652 SetReconstructionModel(dettype,clf);
659 if(!GetReconstructionModel(dettype)){
660 TClonesArray *dig1 = DigitsAddress(1);
661 TClonesArray *rec1 = ClustersAddress(1);
662 clf = new AliITSClusterFinderSDD(this,dig1,rec1);
663 SetReconstructionModel(dettype,clf);
669 if(!GetReconstructionModel(dettype)){
670 TClonesArray* dig2 = DigitsAddress(2);
671 clf = new AliITSClusterFinderSSD(this,dig2);
672 SetReconstructionModel(dettype,clf);
681 //________________________________________________________________
682 void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){
684 //Set defaults for cluster finder V2
687 Warning("SetDefaults","Null pointer to AliITSgeom !");
691 AliITSClusterFinder *clf;
693 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
696 if(!GetReconstructionModel(dettype)){
697 clf = new AliITSClusterFinderV2SPD(this);
699 if(!rawdata) clf->SetDigits(DigitsAddress(0));
700 SetReconstructionModel(dettype,clf);
706 if(!GetReconstructionModel(dettype)){
707 clf = new AliITSClusterFinderV2SDD(this);
709 if(!rawdata) clf->SetDigits(DigitsAddress(1));
710 SetReconstructionModel(dettype,clf);
717 if(!GetReconstructionModel(dettype)){
718 clf = new AliITSClusterFinderV2SSD(this);
720 if(!rawdata) clf->SetDigits(DigitsAddress(2));
721 SetReconstructionModel(dettype,clf);
728 //______________________________________________________________________
729 void AliITSDetTypeRec::MakeBranch(TTree* tree, Option_t* option){
731 //Creates branches for clusters and recpoints
732 Bool_t cR = (strstr(option,"R")!=0);
733 Bool_t cRF = (strstr(option,"RF")!=0);
737 if(cR) MakeBranchR(tree);
738 if(cRF) MakeBranchRF(tree);
742 //___________________________________________________________________
743 void AliITSDetTypeRec::AddCluster(Int_t id, AliITSRawCluster *c){
745 // Adds a raw cluster to the list
746 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
749 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
752 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
755 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
759 //___________________________________________________________________
760 void AliITSDetTypeRec::ResetDigits(){
761 // Reset number of digits and the digits array for the ITS detector.
764 for(Int_t i=0;i<fgkNdettypes;i++){
768 //___________________________________________________________________
769 void AliITSDetTypeRec::ResetDigits(Int_t branch){
770 // Reset number of digits and the digits array for this branch.
772 if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear();
773 if(fNdtype) fNdtype[branch]=0;
777 //__________________________________________________________________
778 void AliITSDetTypeRec::ResetClusters(){
780 //Resets number of clusters and the cluster array
781 for(Int_t i=0;i<fgkNdettypes;i++){
786 //__________________________________________________________________
787 void AliITSDetTypeRec::ResetClusters(Int_t i){
789 //Resets number of clusters and the cluster array for this branch
791 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
792 if (fNctype) fNctype[i]=0;
794 //__________________________________________________________________
795 void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){
797 //Creates tree branches for recpoints
799 // cont char *file File name where RecPoints branch is to be written
800 // to. If blank it write the SDigits to the same
801 // file in which the Hits were found.
806 // only one branch for rec points for all detector types
807 Bool_t oFast= (strstr(opt,"Fast")!=0);
809 Char_t detname[10] = "ITS";
813 sprintf(branchname,"%sRecPointsF",detname);
815 sprintf(branchname,"%sRecPoints",detname);
818 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
820 MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99);
822 //______________________________________________________________________
823 void AliITSDetTypeRec::SetTreeAddressR(TTree *treeR){
824 // Set branch address for the Reconstructed points Trees.
826 // TTree *treeR Tree containing the RecPoints.
832 Char_t namedet[10]="ITS";
835 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
837 sprintf(branchname,"%sRecPoints",namedet);
838 branch = treeR->GetBranch(branchname);
840 branch->SetAddress(&fRecPoints);
842 sprintf(branchname,"%sRecPointsF",namedet);
843 branch = treeR->GetBranch(branchname);
845 branch->SetAddress(&fRecPoints);
850 //____________________________________________________________________
851 void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){
852 // Add a reconstructed space point to the list
854 // const AliITSRecPoint &r RecPoint class to be added to the tree
855 // of reconstructed points TreeR.
861 TClonesArray &lrecp = *fRecPoints;
862 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
865 //______________________________________________________________________
866 void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastentry,Option_t *opt, Bool_t v2){
867 // cluster finding and reconstruction of space points
868 // the condition below will disappear when the geom class will be
869 // initialized for all versions - for the moment it is only for v5 !
870 // 7 is the SDD beam test version
872 // TTree *treeD Digits tree
873 // TTree *treeR Clusters tree
874 // Int_t lastentry Offset for module when not all of the modules
876 // Option_t *opt String indicating which ITS sub-detectors should
877 // be processed. If ="All" then all of the ITS
878 // sub detectors are processed.
880 const char *all = strstr(opt,"All");
881 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
884 SetDefaultClusterFinders();
885 AliInfo("Original cluster finder has been selected\n");
888 SetDefaultClusterFindersV2();
889 AliInfo("V2 cluster finder has been selected \n");
892 AliITSClusterFinder *rec = 0;
893 Int_t id,module,first=0;
894 for(module=0;module<GetITSgeom()->GetIndexMax();module++){
895 id = GetITSgeom()->GetModuleType(module);
896 if (!all && !det[id]) continue;
897 if(det[id]) first = GetITSgeom()->GetStartDet(id);
898 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
899 TClonesArray *itsDigits = DigitsAddress(id);
901 AliFatal("The reconstruction class was not instanciated!");
902 ResetDigits(); // MvL: Not sure we neeed this when rereading anyways
904 treeD->GetEvent(lastentry+module);
906 treeD->GetEvent(lastentry+(module-first));
908 Int_t ndigits = itsDigits->GetEntriesFast();
910 rec->SetDetTypeRec(this);
911 rec->SetDigits(DigitsAddress(id));
912 // rec->SetClusters(ClustersAddress(id));
913 rec->FindRawClusters(module);
920 //______________________________________________________________________
921 void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){
922 // cluster finding and reconstruction of space points
923 // the condition below will disappear when the geom class will be
924 // initialized for all versions - for the moment it is only for v5 !
925 // 7 is the SDD beam test version
927 // AliRawReader *rawReader Pointer to the raw-data reader
928 // TTree *treeR Clusters tree
933 const char *all = strstr(opt,"All");
934 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
936 AliITSClusterFinderV2 *rec = 0;
939 TClonesArray *array=new TClonesArray("AliITSRecPoint",1000);
940 TBranch *branch = treeR->Branch("ITSRecPoints",&array);
943 TClonesArray** clusters = new TClonesArray*[GetITSgeom()->GetIndexMax()];
944 for (Int_t iModule = 0; iModule < GetITSgeom()->GetIndexMax(); iModule++) {
945 clusters[iModule] = NULL;
948 if (!all && !det[id]) continue;
949 rec = (AliITSClusterFinderV2*)GetReconstructionModel(id);
951 AliFatal("The reconstruction class was not instanciated");
952 rec->SetDetTypeRec(this);
953 rec->RawdataToClusters(rawReader,clusters);
956 TClonesArray *emptyArray=new TClonesArray("AliITSRecPoint");
957 for(Int_t iModule=0;iModule<GetITSgeom()->GetIndexMax();iModule++){
958 id = GetITSgeom()->GetModuleType(iModule);
959 if (!all && !det[id]) continue;
960 array = clusters[iModule];
962 AliDebug(1,Form("data for module %d missing!",iModule));
965 branch->SetAddress(&array);
967 nClusters+=array->GetEntriesFast();
969 if (array != emptyArray) {
977 Info("DigitsToRecPoints", "total number of found recpoints in ITS: %d\n",