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(),
89 // Standard Constructor
97 fReconstruction = new TObjArray(fgkNdettypes);
98 fDigits = new TObjArray(fgkNdettypes);
99 for(Int_t i=0; i<3; i++){
100 fClusterClassName[i]=0;
102 fRecPointClassName[i]=0;
104 fDDLMapSDD=new AliITSDDLModuleMapSDD();
105 fNdtype = new Int_t[fgkNdettypes];
106 fCtype = new TObjArray(fgkNdettypes);
107 fNctype = new Int_t[fgkNdettypes];
108 fNMod = new Int_t [fgkNdettypes];
109 fNMod[0] = fgkDefaultNModulesSPD;
110 fNMod[1] = fgkDefaultNModulesSDD;
111 fNMod[2] = fgkDefaultNModulesSSD;
112 fRecPoints = new TClonesArray("AliITSRecPoint",3000);
115 for(Int_t i=0;i<fgkNdettypes;i++){
123 //______________________________________________________________________
124 AliITSDetTypeRec::AliITSDetTypeRec(const AliITSDetTypeRec & rec):TObject(rec),
126 fITSgeom(rec.fITSgeom),
127 fReconstruction(rec.fReconstruction),
128 fSegmentation(rec.fSegmentation),
129 fCalibration(rec.fCalibration),
130 fSPDDead(rec.fSPDDead),
131 fPreProcess(rec.fPreProcess),
132 fPostProcess(rec.fPostProcess),
133 fDigits(rec.fDigits),
134 fDDLMapSDD(rec.fDDLMapSDD),
135 fNdtype(rec.fNdtype),
137 fNctype(rec.fNctype),
138 fRecPoints(rec.fRecPoints),
139 fNRecPoints(rec.fNRecPoints),
140 fSelectedVertexer(rec.fSelectedVertexer),
141 fFirstcall(rec.fFirstcall)
147 //______________________________________________________________________
148 AliITSDetTypeRec& AliITSDetTypeRec::operator=(const AliITSDetTypeRec& source){
149 // Assignment operator.
150 this->~AliITSDetTypeRec();
151 new(this) AliITSDetTypeRec(source);
156 //_____________________________________________________________________
157 AliITSDetTypeRec::~AliITSDetTypeRec(){
161 fReconstruction->Delete();
162 delete fReconstruction;
166 fSegmentation->Delete();
167 delete fSegmentation;
171 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
172 AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSPD()))->GetResponse();
173 AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSDD()))->GetResponse();
174 AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSSD()))->GetResponse();
175 if(rspd) delete rspd;
176 if(rsdd) delete rsdd;
177 if(rssd) delete rssd;
178 fCalibration->Delete();
184 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
190 if(fPreProcess) delete fPreProcess;
191 if(fPostProcess) delete fPostProcess;
192 if(fDDLMapSDD) delete fDDLMapSDD;
199 fRecPoints->Delete();
212 if (fITSgeom) delete fITSgeom;
216 //___________________________________________________________________
217 void AliITSDetTypeRec::SetReconstructionModel(Int_t dettype,AliITSClusterFinder *clf){
219 //Set reconstruction model for detector type
221 if(fReconstruction==0) fReconstruction = new TObjArray(fgkNdettypes);
222 if(fReconstruction->At(dettype)!=0) delete fReconstruction->At(dettype);
223 fReconstruction->AddAt(clf,dettype);
225 //______________________________________________________________________
226 AliITSClusterFinder* AliITSDetTypeRec::GetReconstructionModel(Int_t dettype){
228 //Get reconstruction model for detector type
229 if(fReconstruction==0) {
230 Warning("GetReconstructionModel","fReconstruction is 0!");
233 return (AliITSClusterFinder*)fReconstruction->At(dettype);
236 //______________________________________________________________________
237 void AliITSDetTypeRec::SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg){
239 //Set segmentation model for detector type
241 if(fSegmentation==0) fSegmentation = new TObjArray(fgkNdettypes);
242 if(fSegmentation->At(dettype)!=0) delete fSegmentation->At(dettype);
243 fSegmentation->AddAt(seg,dettype);
246 //______________________________________________________________________
247 AliITSsegmentation* AliITSDetTypeRec::GetSegmentationModel(Int_t dettype){
249 //Get segmentation model for detector type
251 if(fSegmentation==0) {
252 Warning("GetSegmentationModel","fSegmentation is 0!");
255 return (AliITSsegmentation*)fSegmentation->At(dettype);
258 //_______________________________________________________________________
259 void AliITSDetTypeRec::SetCalibrationModel(Int_t iMod, AliITSCalibration *cal){
261 //Set calibration (response) for the module iMod of type dettype
262 if (fCalibration==0) {
263 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
264 fCalibration->SetOwner(kTRUE);
265 fCalibration->Clear();
268 if (fCalibration->At(iMod) != 0)
269 delete (AliITSCalibration*) fCalibration->At(iMod);
270 fCalibration->AddAt(cal,iMod);
273 //_______________________________________________________________________
274 void AliITSDetTypeRec::SetSPDDeadModel(Int_t iMod, AliITSCalibration *cal){
276 //Set dead pixel info for the SPD module iMod
278 fSPDDead = new TObjArray(fgkDefaultNModulesSPD);
279 fSPDDead->SetOwner(kTRUE);
283 if (fSPDDead->At(iMod) != 0)
284 delete (AliITSCalibration*) fSPDDead->At(iMod);
285 fSPDDead->AddAt(cal,iMod);
287 //_______________________________________________________________________
288 AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod){
290 //Get calibration model for module type
292 if(fCalibration==0) {
293 Warning("GetalibrationModel","fCalibration is 0!");
297 return (AliITSCalibration*)fCalibration->At(iMod);
299 //_______________________________________________________________________
300 AliITSCalibration* AliITSDetTypeRec::GetSPDDeadModel(Int_t iMod){
302 //Get SPD dead for module iMod
305 AliWarning("fSPDDead is 0!");
309 return (AliITSCalibration*)fSPDDead->At(iMod);
312 //______________________________________________________________________
313 void AliITSDetTypeRec::SetTreeAddressD(TTree *treeD){
314 // Set branch address for the tree of digits.
316 const char *det[4] = {"SPD","SDD","SSD","ITS"};
323 if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes);
324 for (i=0; i<fgkNdettypes; i++) {
325 digclass = GetDigitClassName(i);
326 if(!(fDigits->At(i))) {
327 fDigits->AddAt(new TClonesArray(digclass,1000),i);
331 if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]);
332 else sprintf(branchname,"%sDigits%d",det[3],i+1);
334 branch = treeD->GetBranch(branchname);
335 if (branch) branch->SetAddress(&((*fDigits)[i]));
340 //_______________________________________________________________________
341 TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree *tree, const char* name,
342 const char *classname,
343 void* address,Int_t size,
347 // Makes branch in given tree and diverts them to a separate file
353 Error("MakeBranchInTree","Making Branch %s Tree is NULL",name);
356 TBranch *branch = tree->GetBranch(name);
361 branch = tree->Branch(name,classname,address,size,splitlevel);
364 branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel);
370 //____________________________________________________________________
371 void AliITSDetTypeRec::SetDefaults(){
373 //Set defaults for segmentation and response
376 Warning("SetDefaults","null pointer to AliITSgeomGeom !");
380 AliITSsegmentation* seg;
381 if(!GetCalibration()) {AliFatal("Exit");exit(0);}
383 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
385 seg = new AliITSsegmentationSPD();
386 SetSegmentationModel(dettype,seg);
387 SetDigitClassName(dettype,"AliITSdigitSPD");
388 SetClusterClassName(dettype,"AliITSRawClusterSPD");
392 seg = new AliITSsegmentationSDD();
393 SetSegmentationModel(dettype,seg);
394 SetDigitClassName(dettype,"AliITSdigitSDD");
395 SetClusterClassName(dettype,"AliITSRawClusterSDD");
398 AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD();
399 SetSegmentationModel(dettype,seg2);
400 SetDigitClassName(dettype,"AliITSdigitSSD");
401 SetClusterClassName(dettype,"AliITSRawClusterSSD");
406 //______________________________________________________________________
407 Bool_t AliITSDetTypeRec::GetCalibration() {
408 // Get Default calibration if a storage is not defined.
411 AliITSCalibration* cal = GetCalibrationModel(0);
418 // SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
419 // Int_t run=GetRunNumber();
421 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
422 if (fCalibration==0) {
423 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
424 fCalibration->SetOwner(!cacheStatus);
425 fCalibration->Clear();
428 // dead pixel are not used for local reconstruction
429 AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy");
430 AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead");
431 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
433 // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD");
434 AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
435 AliCDBEntry *entryPedestalSSD = AliCDBManager::Instance()->Get("ITS/Calib/PedestalSSD");
436 AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
437 AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
438 // Entry for the AliITSRecoParam object
439 AliCDBEntry *entryRP = AliCDBManager::Instance()->Get("ITS/Calib/RecoParam/");
440 AliCDBEntry *entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD");
441 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD");
442 AliCDBEntry *entry2SSD = AliCDBManager::Instance()->Get("ITS/Calib/RespSSD");
443 AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD");
444 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
445 AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD");
446 AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD");
448 if(!entrySPD || !deadSPD || !entrySDD || !entryNoiseSSD || !entryGainSSD ||
449 !entryPedestalSSD || !entryBadChannelsSSD ||
450 !entry2SPD || !entry2SDD || !entry2SSD || !drSpSDD || !ddlMapSDD || !mapASDD || !mapTSDD ){
451 AliFatal("Calibration object retrieval failed! ");
455 TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
456 if(!cacheStatus)entrySPD->SetObject(NULL);
457 entrySPD->SetOwner(kTRUE);
459 TObjArray *caldeadSPD = (TObjArray *)deadSPD->GetObject();
460 if(!cacheStatus)deadSPD->SetObject(NULL);
461 deadSPD->SetOwner(kTRUE);
463 AliITSresponseSPD *pSPD = (AliITSresponseSPD*)entry2SPD->GetObject();
464 if(!cacheStatus)entry2SPD->SetObject(NULL);
465 entry2SPD->SetOwner(kTRUE);
467 TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
468 if(!cacheStatus)entrySDD->SetObject(NULL);
469 entrySDD->SetOwner(kTRUE);
471 AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
472 if(!cacheStatus)entry2SDD->SetObject(NULL);
473 entry2SDD->SetOwner(kTRUE);
475 TObjArray *drSp = (TObjArray *)drSpSDD->GetObject();
476 if(!cacheStatus)drSpSDD->SetObject(NULL);
477 drSpSDD->SetOwner(kTRUE);
479 AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
480 if(!cacheStatus)ddlMapSDD->SetObject(NULL);
481 ddlMapSDD->SetOwner(kTRUE);
483 TObjArray *mapAn = (TObjArray *)mapASDD->GetObject();
484 if(!cacheStatus)mapASDD->SetObject(NULL);
485 mapASDD->SetOwner(kTRUE);
487 TObjArray *mapT = (TObjArray *)mapTSDD->GetObject();
488 if(!cacheStatus)mapTSDD->SetObject(NULL);
489 mapTSDD->SetOwner(kTRUE);
491 TObjArray *noiseSSD = (TObjArray *)entryNoiseSSD->GetObject();
492 if(!cacheStatus)entryNoiseSSD->SetObject(NULL);
493 entryNoiseSSD->SetOwner(kTRUE);
495 TObjArray *pedestalSSD = (TObjArray *)entryPedestalSSD->GetObject();
496 if(!cacheStatus)entryPedestalSSD->SetObject(NULL);
497 entryPedestalSSD->SetOwner(kTRUE);
499 TObjArray *gainSSD = (TObjArray *)entryGainSSD->GetObject();
500 if(!cacheStatus)entryGainSSD->SetObject(NULL);
501 entryGainSSD->SetOwner(kTRUE);
503 TObjArray *badchannelsSSD = (TObjArray *)entryBadChannelsSSD->GetObject();
504 if(!cacheStatus)entryBadChannelsSSD->SetObject(NULL);
505 entryBadChannelsSSD->SetOwner(kTRUE);
507 AliITSresponseSSD *pSSD = (AliITSresponseSSD*)entry2SSD->GetObject();
508 if(!cacheStatus)entry2SSD->SetObject(NULL);
509 entry2SSD->SetOwner(kTRUE);
511 if(!AliITSReconstructor::GetRecoParam()){
512 if(!entryRP) AliFatal("Calibration object (RecoParam) retrieval from OCDB failed! Hint: as an alternative you can set it in your reconstruction macro ");
513 AliITSRecoParam *rp = (AliITSRecoParam*)entryRP->GetObject();
514 if(!cacheStatus)entryRP->SetObject(NULL);
515 entryRP->SetOwner(kTRUE);
516 AliITSReconstructor::SetRecoParam(rp);
519 AliWarning("AliITSRecoParam object has been already set in AliITSReconstructor. The OCDB instance will not be used\n");
523 // DB entries are deleted. In this way metadeta objects are deleted as well
528 delete entryNoiseSSD;
529 delete entryPedestalSSD;
531 delete entryBadChannelsSSD;
541 if ((!pSPD)||(!pSDD)||(!pSSD) || (!calSPD) || (!caldeadSPD) ||(!calSDD) || (!drSp) || (!ddlsdd)
542 || (!mapAn) || (!mapT) || (!noiseSSD)|| (!gainSSD)|| (!badchannelsSSD)) {
543 AliWarning("Can not get calibration from calibration database !");
547 fNMod[0] = calSPD->GetEntries();
548 fNMod[1] = calSDD->GetEntries();
549 fNMod[2] = noiseSSD->GetEntries();
550 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
551 fNMod[0], fNMod[1], fNMod[2]));
552 AliITSCalibration* cal;
553 for (Int_t i=0; i<fNMod[0]; i++) {
554 cal = (AliITSCalibration*) calSPD->At(i);
555 cal->SetResponse((AliITSresponse*)pSPD);
556 SetCalibrationModel(i, cal);
557 cal = (AliITSCalibration*) caldeadSPD->At(i);
558 SetSPDDeadModel(i, cal);
561 fDDLMapSDD->SetDDLMap(ddlsdd);
562 for(Int_t iddl=0; iddl<AliITSDDLModuleMapSDD::GetNDDLs(); iddl++){
563 for(Int_t icar=0; icar<AliITSDDLModuleMapSDD::GetNModPerDDL();icar++){
564 Int_t iMod=fDDLMapSDD->GetModuleNumber(iddl,icar);
565 if(iMod==-1) continue;
566 Int_t i=iMod - fgkDefaultNModulesSPD;
567 cal = (AliITSCalibration*) calSDD->At(i);
568 cal->SetResponse((AliITSresponse*)pSDD);
571 AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0);
572 AliITSMapSDD* ma0 = (AliITSMapSDD*)mapAn->At(i0);
573 AliITSMapSDD* mt0 = (AliITSMapSDD*)mapT->At(i0);
574 AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1);
575 AliITSMapSDD* ma1 = (AliITSMapSDD*)mapAn->At(i1);
576 AliITSMapSDD* mt1 = (AliITSMapSDD*)mapT->At(i1);
577 cal->SetDriftSpeed(0,arr0);
578 cal->SetDriftSpeed(1,arr1);
583 SetCalibrationModel(iMod, cal);
586 for (Int_t i=0; i<fNMod[2]; i++) {
588 AliITSCalibrationSSD *calibSSD = new AliITSCalibrationSSD();
589 calibSSD->SetResponse((AliITSresponse*)pSSD);
591 AliITSNoiseSSD *noise = (AliITSNoiseSSD*) (noiseSSD->At(i));
592 calibSSD->SetNoise(noise);
593 AliITSPedestalSSD *pedestal = (AliITSPedestalSSD*) (pedestalSSD->At(i));
594 calibSSD->SetPedestal(pedestal);
595 AliITSGainSSD *gain = (AliITSGainSSD*) (gainSSD->At(i));
596 calibSSD->SetGain(gain);
597 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (badchannelsSSD->At(i));
598 calibSSD->SetBadChannels(bad);
599 calibSSD->FillBadChipMap();
601 Int_t iMod = i + fgkDefaultNModulesSPD + fgkDefaultNModulesSDD;
602 SetCalibrationModel(iMod, calibSSD);
609 //________________________________________________________________
610 void AliITSDetTypeRec::SetDefaultClusterFinders(){
612 //set defaults for standard cluster finder
615 Warning("SetDefaults","null pointer to AliITSgeom!");
619 AliITSClusterFinder *clf;
621 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
624 if(!GetReconstructionModel(dettype)){
625 TClonesArray *dig0 = DigitsAddress(0);
626 TClonesArray *rec0 = ClustersAddress(0);
627 clf = new AliITSClusterFinderSPD(this,dig0,rec0);
628 SetReconstructionModel(dettype,clf);
635 if(!GetReconstructionModel(dettype)){
636 TClonesArray *dig1 = DigitsAddress(1);
637 TClonesArray *rec1 = ClustersAddress(1);
638 clf = new AliITSClusterFinderSDD(this,dig1,rec1);
639 SetReconstructionModel(dettype,clf);
645 if(!GetReconstructionModel(dettype)){
646 TClonesArray* dig2 = DigitsAddress(2);
647 clf = new AliITSClusterFinderSSD(this,dig2);
648 SetReconstructionModel(dettype,clf);
657 //________________________________________________________________
658 void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){
660 //Set defaults for cluster finder V2
663 Warning("SetDefaults","Null pointer to AliITSgeom !");
667 AliITSClusterFinder *clf;
669 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
672 if(!GetReconstructionModel(dettype)){
673 clf = new AliITSClusterFinderV2SPD(this);
675 if(!rawdata) clf->SetDigits(DigitsAddress(0));
676 SetReconstructionModel(dettype,clf);
682 if(!GetReconstructionModel(dettype)){
683 clf = new AliITSClusterFinderV2SDD(this);
685 if(!rawdata) clf->SetDigits(DigitsAddress(1));
686 SetReconstructionModel(dettype,clf);
693 if(!GetReconstructionModel(dettype)){
694 clf = new AliITSClusterFinderV2SSD(this);
696 if(!rawdata) clf->SetDigits(DigitsAddress(2));
697 SetReconstructionModel(dettype,clf);
704 //______________________________________________________________________
705 void AliITSDetTypeRec::MakeBranch(TTree* tree, Option_t* option){
707 //Creates branches for clusters and recpoints
708 Bool_t cR = (strstr(option,"R")!=0);
709 Bool_t cRF = (strstr(option,"RF")!=0);
713 if(cR) MakeBranchR(tree);
714 if(cRF) MakeBranchRF(tree);
718 //___________________________________________________________________
719 void AliITSDetTypeRec::AddCluster(Int_t id, AliITSRawCluster *c){
721 // Adds a raw cluster to the list
722 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
725 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
728 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
731 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
735 //___________________________________________________________________
736 void AliITSDetTypeRec::ResetDigits(){
737 // Reset number of digits and the digits array for the ITS detector.
740 for(Int_t i=0;i<fgkNdettypes;i++){
744 //___________________________________________________________________
745 void AliITSDetTypeRec::ResetDigits(Int_t branch){
746 // Reset number of digits and the digits array for this branch.
748 if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear();
749 if(fNdtype) fNdtype[branch]=0;
753 //__________________________________________________________________
754 void AliITSDetTypeRec::ResetClusters(){
756 //Resets number of clusters and the cluster array
757 for(Int_t i=0;i<fgkNdettypes;i++){
762 //__________________________________________________________________
763 void AliITSDetTypeRec::ResetClusters(Int_t i){
765 //Resets number of clusters and the cluster array for this branch
767 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
768 if (fNctype) fNctype[i]=0;
770 //__________________________________________________________________
771 void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){
773 //Creates tree branches for recpoints
775 // cont char *file File name where RecPoints branch is to be written
776 // to. If blank it write the SDigits to the same
777 // file in which the Hits were found.
782 // only one branch for rec points for all detector types
783 Bool_t oFast= (strstr(opt,"Fast")!=0);
785 Char_t detname[10] = "ITS";
789 sprintf(branchname,"%sRecPointsF",detname);
791 sprintf(branchname,"%sRecPoints",detname);
794 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
796 MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99);
798 //______________________________________________________________________
799 void AliITSDetTypeRec::SetTreeAddressR(TTree *treeR){
800 // Set branch address for the Reconstructed points Trees.
802 // TTree *treeR Tree containing the RecPoints.
808 Char_t namedet[10]="ITS";
811 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
813 sprintf(branchname,"%sRecPoints",namedet);
814 branch = treeR->GetBranch(branchname);
816 branch->SetAddress(&fRecPoints);
818 sprintf(branchname,"%sRecPointsF",namedet);
819 branch = treeR->GetBranch(branchname);
821 branch->SetAddress(&fRecPoints);
826 //____________________________________________________________________
827 void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){
828 // Add a reconstructed space point to the list
830 // const AliITSRecPoint &r RecPoint class to be added to the tree
831 // of reconstructed points TreeR.
837 TClonesArray &lrecp = *fRecPoints;
838 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
841 //______________________________________________________________________
842 void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastentry,Option_t *opt, Bool_t v2){
843 // cluster finding and reconstruction of space points
844 // the condition below will disappear when the geom class will be
845 // initialized for all versions - for the moment it is only for v5 !
846 // 7 is the SDD beam test version
848 // TTree *treeD Digits tree
849 // TTree *treeR Clusters tree
850 // Int_t lastentry Offset for module when not all of the modules
852 // Option_t *opt String indicating which ITS sub-detectors should
853 // be processed. If ="All" then all of the ITS
854 // sub detectors are processed.
856 const char *all = strstr(opt,"All");
857 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
860 SetDefaultClusterFinders();
861 AliInfo("Original cluster finder has been selected\n");
864 SetDefaultClusterFindersV2();
865 AliInfo("V2 cluster finder has been selected \n");
868 AliITSClusterFinder *rec = 0;
869 Int_t id,module,first=0;
870 for(module=0;module<GetITSgeom()->GetIndexMax();module++){
871 id = GetITSgeom()->GetModuleType(module);
872 if (!all && !det[id]) continue;
873 if(det[id]) first = GetITSgeom()->GetStartDet(id);
874 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
875 TClonesArray *itsDigits = DigitsAddress(id);
877 AliFatal("The reconstruction class was not instanciated!");
878 ResetDigits(); // MvL: Not sure we neeed this when rereading anyways
880 treeD->GetEvent(lastentry+module);
882 treeD->GetEvent(lastentry+(module-first));
884 Int_t ndigits = itsDigits->GetEntriesFast();
886 rec->SetDetTypeRec(this);
887 rec->SetDigits(DigitsAddress(id));
888 // rec->SetClusters(ClustersAddress(id));
889 rec->FindRawClusters(module);
896 //______________________________________________________________________
897 void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){
898 // cluster finding and reconstruction of space points
899 // the condition below will disappear when the geom class will be
900 // initialized for all versions - for the moment it is only for v5 !
901 // 7 is the SDD beam test version
903 // AliRawReader *rawReader Pointer to the raw-data reader
904 // TTree *treeR Clusters tree
909 const char *all = strstr(opt,"All");
910 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
912 AliITSClusterFinderV2 *rec = 0;
915 TClonesArray *array=new TClonesArray("AliITSRecPoint",1000);
916 TBranch *branch = treeR->Branch("ITSRecPoints",&array);
919 TClonesArray** clusters = new TClonesArray*[GetITSgeom()->GetIndexMax()];
920 for (Int_t iModule = 0; iModule < GetITSgeom()->GetIndexMax(); iModule++) {
921 clusters[iModule] = NULL;
924 if (!all && !det[id]) continue;
925 rec = (AliITSClusterFinderV2*)GetReconstructionModel(id);
927 AliFatal("The reconstruction class was not instanciated");
928 rec->SetDetTypeRec(this);
929 rec->RawdataToClusters(rawReader,clusters);
932 TClonesArray *emptyArray=new TClonesArray("AliITSRecPoint");
933 for(Int_t iModule=0;iModule<GetITSgeom()->GetIndexMax();iModule++){
934 id = GetITSgeom()->GetModuleType(iModule);
935 if (!all && !det[id]) continue;
936 array = clusters[iModule];
938 AliDebug(1,Form("data for module %d missing!",iModule));
941 branch->SetAddress(&array);
943 nClusters+=array->GetEntriesFast();
945 if (array != emptyArray) {
953 Info("DigitsToRecPoints", "total number of found recpoints in ITS: %d\n",