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 "AliITSNoiseSSDv2.h"
54 #include "AliITSGainSSDv2.h"
55 #include "AliITSBadChannelsSSDv2.h"
56 #include "AliITSNoiseSSD.h"
57 #include "AliITSGainSSD.h"
58 #include "AliITSBadChannelsSSD.h"
59 #include "AliITSsegmentationSPD.h"
60 #include "AliITSsegmentationSDD.h"
61 #include "AliITSsegmentationSSD.h"
65 const Int_t AliITSDetTypeRec::fgkNdettypes = 3;
66 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSPD = 240;
67 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSDD = 260;
68 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSSD = 1698;
70 ClassImp(AliITSDetTypeRec)
72 //________________________________________________________________
73 AliITSDetTypeRec::AliITSDetTypeRec(): TObject(),
93 // Standard Constructor
101 fReconstruction = new TObjArray(fgkNdettypes);
102 fDigits = new TObjArray(fgkNdettypes);
103 for(Int_t i=0; i<3; i++){
104 fClusterClassName[i]=0;
106 fRecPointClassName[i]=0;
108 fSSDCalibration=new AliITSCalibrationSSD();
109 fNdtype = new Int_t[fgkNdettypes];
110 fCtype = new TObjArray(fgkNdettypes);
111 fNctype = new Int_t[fgkNdettypes];
112 fNMod = new Int_t [fgkNdettypes];
113 fNMod[0] = fgkDefaultNModulesSPD;
114 fNMod[1] = fgkDefaultNModulesSDD;
115 fNMod[2] = fgkDefaultNModulesSSD;
116 fRecPoints = new TClonesArray("AliITSRecPoint",3000);
119 for(Int_t i=0;i<fgkNdettypes;i++){
127 //______________________________________________________________________
128 AliITSDetTypeRec::AliITSDetTypeRec(const AliITSDetTypeRec & rec):TObject(rec),
130 fITSgeom(rec.fITSgeom),
131 fReconstruction(rec.fReconstruction),
132 fSegmentation(rec.fSegmentation),
133 fCalibration(rec.fCalibration),
134 fSSDCalibration(rec.fSSDCalibration),
135 fSPDDead(rec.fSPDDead),
136 fPreProcess(rec.fPreProcess),
137 fPostProcess(rec.fPostProcess),
138 fDigits(rec.fDigits),
139 fDDLMapSDD(rec.fDDLMapSDD),
140 fRespSDD(rec.fRespSDD),
141 fNdtype(rec.fNdtype),
143 fNctype(rec.fNctype),
144 fRecPoints(rec.fRecPoints),
145 fNRecPoints(rec.fNRecPoints),
146 fSelectedVertexer(rec.fSelectedVertexer),
147 fFirstcall(rec.fFirstcall)
153 //______________________________________________________________________
154 AliITSDetTypeRec& AliITSDetTypeRec::operator=(const AliITSDetTypeRec& source){
155 // Assignment operator.
156 this->~AliITSDetTypeRec();
157 new(this) AliITSDetTypeRec(source);
162 //_____________________________________________________________________
163 AliITSDetTypeRec::~AliITSDetTypeRec(){
167 fReconstruction->Delete();
168 delete fReconstruction;
172 fSegmentation->Delete();
173 delete fSegmentation;
177 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
178 AliITSCalibration * calSPD = (AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSPD());
180 AliITSresponse* rspd = calSPD->GetResponse();
181 if(rspd) delete rspd;
184 AliITSCalibration * calSSD = (AliITSCalibration*)fCalibration->At(GetITSgeom()->GetStartSSD());
186 AliITSresponse* rssd = calSSD->GetResponse();
187 if(rssd) delete rssd;
189 fCalibration->Delete();
192 if(fRespSDD) delete fRespSDD;
193 if(fDDLMapSDD) delete fDDLMapSDD;
196 if(fSSDCalibration) delete fSSDCalibration;
198 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
204 if(fPreProcess) delete fPreProcess;
205 if(fPostProcess) delete fPostProcess;
212 fRecPoints->Delete();
225 if (fITSgeom) delete fITSgeom;
229 //___________________________________________________________________
230 void AliITSDetTypeRec::SetReconstructionModel(Int_t dettype,AliITSClusterFinder *clf){
232 //Set reconstruction model for detector type
234 if(fReconstruction==0) fReconstruction = new TObjArray(fgkNdettypes);
235 if(fReconstruction->At(dettype)!=0) delete fReconstruction->At(dettype);
236 fReconstruction->AddAt(clf,dettype);
238 //______________________________________________________________________
239 AliITSClusterFinder* AliITSDetTypeRec::GetReconstructionModel(Int_t dettype){
241 //Get reconstruction model for detector type
242 if(fReconstruction==0) {
243 Warning("GetReconstructionModel","fReconstruction is 0!");
246 return (AliITSClusterFinder*)fReconstruction->At(dettype);
249 //______________________________________________________________________
250 void AliITSDetTypeRec::SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg){
252 //Set segmentation model for detector type
254 if(fSegmentation==0) fSegmentation = new TObjArray(fgkNdettypes);
255 if(fSegmentation->At(dettype)!=0) delete fSegmentation->At(dettype);
256 fSegmentation->AddAt(seg,dettype);
259 //______________________________________________________________________
260 AliITSsegmentation* AliITSDetTypeRec::GetSegmentationModel(Int_t dettype){
262 //Get segmentation model for detector type
264 if(fSegmentation==0) {
265 Warning("GetSegmentationModel","fSegmentation is 0!");
268 return (AliITSsegmentation*)fSegmentation->At(dettype);
271 //_______________________________________________________________________
272 void AliITSDetTypeRec::SetCalibrationModel(Int_t iMod, AliITSCalibration *cal){
274 //Set calibration (response) for the module iMod of type dettype
275 if (fCalibration==0) {
276 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
277 fCalibration->SetOwner(kTRUE);
278 fCalibration->Clear();
281 if (fCalibration->At(iMod) != 0)
282 delete (AliITSCalibration*) fCalibration->At(iMod);
283 fCalibration->AddAt(cal,iMod);
286 //_______________________________________________________________________
287 void AliITSDetTypeRec::SetSPDDeadModel(Int_t iMod, AliITSCalibration *cal){
289 //Set dead pixel info for the SPD module iMod
291 fSPDDead = new TObjArray(fgkDefaultNModulesSPD);
292 fSPDDead->SetOwner(kTRUE);
296 if (fSPDDead->At(iMod) != 0)
297 delete (AliITSCalibration*) fSPDDead->At(iMod);
298 fSPDDead->AddAt(cal,iMod);
300 //_______________________________________________________________________
301 AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod){
303 //Get calibration model for module type
305 if(fCalibration==0) {
306 Warning("GetalibrationModel","fCalibration is 0!");
310 if(iMod<fgkDefaultNModulesSPD+fgkDefaultNModulesSDD){
311 return (AliITSCalibration*)fCalibration->At(iMod);
313 Int_t i=iMod-(fgkDefaultNModulesSPD+fgkDefaultNModulesSDD);
314 fSSDCalibration->SetModule(i);
315 return (AliITSCalibration*)fSSDCalibration;
319 //_______________________________________________________________________
320 AliITSCalibration* AliITSDetTypeRec::GetSPDDeadModel(Int_t iMod){
322 //Get SPD dead for module iMod
325 AliWarning("fSPDDead is 0!");
329 return (AliITSCalibration*)fSPDDead->At(iMod);
332 //______________________________________________________________________
333 void AliITSDetTypeRec::SetTreeAddressD(TTree *treeD){
334 // Set branch address for the tree of digits.
336 const char *det[4] = {"SPD","SDD","SSD","ITS"};
343 if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes);
344 for (i=0; i<fgkNdettypes; i++) {
345 digclass = GetDigitClassName(i);
346 if(!(fDigits->At(i))) {
347 fDigits->AddAt(new TClonesArray(digclass,1000),i);
351 if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]);
352 else sprintf(branchname,"%sDigits%d",det[3],i+1);
354 branch = treeD->GetBranch(branchname);
355 if (branch) branch->SetAddress(&((*fDigits)[i]));
360 //_______________________________________________________________________
361 TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree *tree, const char* name,
362 const char *classname,
363 void* address,Int_t size,
367 // Makes branch in given tree and diverts them to a separate file
373 Error("MakeBranchInTree","Making Branch %s Tree is NULL",name);
376 TBranch *branch = tree->GetBranch(name);
381 branch = tree->Branch(name,classname,address,size,splitlevel);
384 branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel);
390 //____________________________________________________________________
391 void AliITSDetTypeRec::SetDefaults(){
393 //Set defaults for segmentation and response
396 Warning("SetDefaults","null pointer to AliITSgeomGeom !");
400 AliITSsegmentation* seg;
401 if(!GetCalibration()) {AliFatal("Exit");exit(0);}
403 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
405 seg = new AliITSsegmentationSPD();
406 SetSegmentationModel(dettype,seg);
407 SetDigitClassName(dettype,"AliITSdigitSPD");
408 SetClusterClassName(dettype,"AliITSRawClusterSPD");
412 seg = new AliITSsegmentationSDD();
413 AliITSCalibrationSDD* cal=(AliITSCalibrationSDD*)GetCalibrationModel(fgkDefaultNModulesSPD+1);
414 if(cal->IsAMAt20MHz()){
415 seg->SetPadSize(seg->Dpz(0),20.);
416 seg->SetNPads(seg->Npz()/2,128);
418 SetSegmentationModel(dettype,seg);
419 SetDigitClassName(dettype,"AliITSdigitSDD");
420 SetClusterClassName(dettype,"AliITSRawClusterSDD");
423 AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD();
424 SetSegmentationModel(dettype,seg2);
425 SetDigitClassName(dettype,"AliITSdigitSSD");
426 SetClusterClassName(dettype,"AliITSRawClusterSSD");
431 //______________________________________________________________________
432 Bool_t AliITSDetTypeRec::GetCalibration() {
433 // Get Default calibration if a storage is not defined.
436 AliITSCalibration* cal = GetCalibrationModel(0);
443 // SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
444 // Int_t run=GetRunNumber();
446 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
447 if (fCalibration==0) {
448 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
449 fCalibration->SetOwner(!cacheStatus);
450 fCalibration->Clear();
453 // dead pixel are not used for local reconstruction
454 AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy");
455 AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead");
456 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
458 // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD");
459 AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
460 AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
461 AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
462 AliCDBEntry *entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD");
463 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD");
464 AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD");
465 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
466 // AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD");
467 AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD");
469 if(!entrySPD || !deadSPD || !entrySDD || !entryNoiseSSD || !entryGainSSD ||
470 !entryBadChannelsSSD ||
471 !entry2SPD || !entry2SDD || !drSpSDD || !ddlMapSDD || !mapTSDD ){
472 AliFatal("Calibration object retrieval failed! ");
476 TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
477 if(!cacheStatus)entrySPD->SetObject(NULL);
478 entrySPD->SetOwner(kTRUE);
480 TObjArray *caldeadSPD = (TObjArray *)deadSPD->GetObject();
481 if(!cacheStatus)deadSPD->SetObject(NULL);
482 deadSPD->SetOwner(kTRUE);
484 AliITSresponseSPD *pSPD = (AliITSresponseSPD*)entry2SPD->GetObject();
485 if(!cacheStatus)entry2SPD->SetObject(NULL);
486 entry2SPD->SetOwner(kTRUE);
488 TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
489 if(!cacheStatus)entrySDD->SetObject(NULL);
490 entrySDD->SetOwner(kTRUE);
492 AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
493 if(!cacheStatus)entry2SDD->SetObject(NULL);
494 entry2SDD->SetOwner(kTRUE);
496 TObjArray *drSp = (TObjArray *)drSpSDD->GetObject();
497 if(!cacheStatus)drSpSDD->SetObject(NULL);
498 drSpSDD->SetOwner(kTRUE);
500 AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
501 if(!cacheStatus)ddlMapSDD->SetObject(NULL);
502 ddlMapSDD->SetOwner(kTRUE);
504 // TObjArray *mapAn = (TObjArray *)mapASDD->GetObject();
505 // if(!cacheStatus)mapASDD->SetObject(NULL);
506 // mapASDD->SetOwner(kTRUE);
508 TObjArray *mapT = (TObjArray *)mapTSDD->GetObject();
509 if(!cacheStatus)mapTSDD->SetObject(NULL);
510 mapTSDD->SetOwner(kTRUE);
512 TObject *emptyssd = 0; TString ssdobjectname = 0;
513 AliITSNoiseSSDv2 *noiseSSD = new AliITSNoiseSSDv2();
514 emptyssd = (TObject *)entryNoiseSSD->GetObject();
515 ssdobjectname = emptyssd->GetName();
516 if(ssdobjectname=="TObjArray") {
517 TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject();
518 ReadOldSSDNoise(noiseSSDOld, noiseSSD);
520 else if(ssdobjectname=="AliITSNoiseSSDv2")
521 noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject();
522 if(!cacheStatus)entryNoiseSSD->SetObject(NULL);
523 entryNoiseSSD->SetOwner(kTRUE);
525 AliITSGainSSDv2 *gainSSD = new AliITSGainSSDv2();
526 emptyssd = (TObject *)entryGainSSD->GetObject();
527 ssdobjectname = emptyssd->GetName();
528 if(ssdobjectname=="Gain") {
529 TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject();
530 ReadOldSSDGain(gainSSDOld, gainSSD);
532 else if(ssdobjectname=="AliITSGainSSDv2")
533 gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject();
534 if(!cacheStatus)entryGainSSD->SetObject(NULL);
535 entryGainSSD->SetOwner(kTRUE);
537 AliITSBadChannelsSSDv2 *badChannelsSSD = new AliITSBadChannelsSSDv2();
538 emptyssd = (TObject *)entryBadChannelsSSD->GetObject();
539 ssdobjectname = emptyssd->GetName();
540 if(ssdobjectname=="TObjArray") {
541 TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject();
542 ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD);
544 else if(ssdobjectname=="AliITSBadChannelsSSDv2")
545 badChannelsSSD = (AliITSBadChannelsSSDv2*)entryBadChannelsSSD->GetObject();
546 if(!cacheStatus)entryBadChannelsSSD->SetObject(NULL);
547 entryBadChannelsSSD->SetOwner(kTRUE);
549 // DB entries are deleted. In this way metadeta objects are deleted as well
554 delete entryNoiseSSD;
556 delete entryBadChannelsSSD;
565 if ((!pSPD)||(!pSDD)|| (!calSPD) || (!caldeadSPD) ||(!calSDD) || (!drSp) || (!ddlsdd)
566 || (!mapT) || (!noiseSSD)|| (!gainSSD)|| (!badChannelsSSD)) {
567 AliWarning("Can not get calibration from calibration database !");
571 fNMod[0] = calSPD->GetEntries();
572 fNMod[1] = calSDD->GetEntries();
573 //fNMod[2] = noiseSSD->GetEntries();
574 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
575 fNMod[0], fNMod[1], fNMod[2]));
576 AliITSCalibration* cal;
577 for (Int_t i=0; i<fNMod[0]; i++) {
578 cal = (AliITSCalibration*) calSPD->At(i);
579 cal->SetResponse((AliITSresponse*)pSPD);
580 SetCalibrationModel(i, cal);
581 cal = (AliITSCalibration*) caldeadSPD->At(i);
582 SetSPDDeadModel(i, cal);
587 for(Int_t iddl=0; iddl<AliITSDDLModuleMapSDD::GetNDDLs(); iddl++){
588 for(Int_t icar=0; icar<AliITSDDLModuleMapSDD::GetNModPerDDL();icar++){
589 Int_t iMod=fDDLMapSDD->GetModuleNumber(iddl,icar);
590 if(iMod==-1) continue;
591 Int_t i=iMod - fgkDefaultNModulesSPD;
592 cal = (AliITSCalibration*) calSDD->At(i);
595 AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0);
596 // AliITSMapSDD* ma0 = (AliITSMapSDD*)mapAn->At(i0);
597 AliITSMapSDD* mt0 = (AliITSMapSDD*)mapT->At(i0);
598 AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1);
599 // AliITSMapSDD* ma1 = (AliITSMapSDD*)mapAn->At(i1);
600 AliITSMapSDD* mt1 = (AliITSMapSDD*)mapT->At(i1);
601 cal->SetDriftSpeed(0,arr0);
602 cal->SetDriftSpeed(1,arr1);
603 // cal->SetMapA(0,ma0);
604 // cal->SetMapA(1,ma1);
607 SetCalibrationModel(iMod, cal);
611 fSSDCalibration->SetNoise(noiseSSD);
612 fSSDCalibration->SetGain(gainSSD);
613 fSSDCalibration->SetBadChannels(badChannelsSSD);
614 //fSSDCalibration->FillBadChipMap();
618 for (Int_t i=0; i<fNMod[2]; i++) {
620 AliITSCalibrationSSD *calibSSD = new AliITSCalibrationSSD();
621 calibSSD->SetResponse((AliITSresponse*)pSSD);
623 AliITSNoiseSSD *noise = (AliITSNoiseSSD*) (noiseSSD->At(i));
624 calibSSD->SetNoise(noise);
625 AliITSPedestalSSD *pedestal = (AliITSPedestalSSD*) (pedestalSSD->At(i));
626 calibSSD->SetPedestal(pedestal);
627 AliITSGainSSD *gain = (AliITSGainSSD*) (gainSSD->At(i));
628 calibSSD->SetGain(gain);
629 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (badchannelsSSD->At(i));
630 calibSSD->SetBadChannels(bad);
631 calibSSD->FillBadChipMap();
633 Int_t iMod = i + fgkDefaultNModulesSPD + fgkDefaultNModulesSDD;
634 SetCalibrationModel(iMod, calibSSD);
642 //________________________________________________________________
643 void AliITSDetTypeRec::SetDefaultClusterFinders(){
645 //set defaults for standard cluster finder
648 Warning("SetDefaults","null pointer to AliITSgeom!");
652 AliITSClusterFinder *clf;
654 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
657 if(!GetReconstructionModel(dettype)){
658 TClonesArray *dig0 = DigitsAddress(0);
659 TClonesArray *rec0 = ClustersAddress(0);
660 clf = new AliITSClusterFinderSPD(this,dig0,rec0);
661 SetReconstructionModel(dettype,clf);
668 if(!GetReconstructionModel(dettype)){
669 TClonesArray *dig1 = DigitsAddress(1);
670 TClonesArray *rec1 = ClustersAddress(1);
671 clf = new AliITSClusterFinderSDD(this,dig1,rec1);
672 SetReconstructionModel(dettype,clf);
678 if(!GetReconstructionModel(dettype)){
679 TClonesArray* dig2 = DigitsAddress(2);
680 clf = new AliITSClusterFinderSSD(this,dig2);
681 SetReconstructionModel(dettype,clf);
690 //________________________________________________________________
691 void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){
693 //Set defaults for cluster finder V2
696 Warning("SetDefaults","Null pointer to AliITSgeom !");
700 AliITSClusterFinder *clf;
702 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
705 if(!GetReconstructionModel(dettype)){
706 clf = new AliITSClusterFinderV2SPD(this);
708 if(!rawdata) clf->SetDigits(DigitsAddress(0));
709 SetReconstructionModel(dettype,clf);
715 if(!GetReconstructionModel(dettype)){
716 clf = new AliITSClusterFinderV2SDD(this);
718 if(!rawdata) clf->SetDigits(DigitsAddress(1));
719 SetReconstructionModel(dettype,clf);
726 if(!GetReconstructionModel(dettype)){
727 clf = new AliITSClusterFinderV2SSD(this);
729 if(!rawdata) clf->SetDigits(DigitsAddress(2));
730 SetReconstructionModel(dettype,clf);
737 //______________________________________________________________________
738 void AliITSDetTypeRec::MakeBranch(TTree* tree, Option_t* option){
740 //Creates branches for clusters and recpoints
741 Bool_t cR = (strstr(option,"R")!=0);
742 Bool_t cRF = (strstr(option,"RF")!=0);
746 if(cR) MakeBranchR(tree);
747 if(cRF) MakeBranchRF(tree);
751 //___________________________________________________________________
752 void AliITSDetTypeRec::AddCluster(Int_t id, AliITSRawCluster *c){
754 // Adds a raw cluster to the list
755 TClonesArray &lc = *((TClonesArray*)fCtype->At(id));
758 new(lc[fNctype[id]++]) AliITSRawClusterSPD(*((AliITSRawClusterSPD*)c));
761 new(lc[fNctype[id]++]) AliITSRawClusterSDD(*((AliITSRawClusterSDD*)c));
764 new(lc[fNctype[id]++]) AliITSRawClusterSSD(*((AliITSRawClusterSSD*)c));
768 //___________________________________________________________________
769 void AliITSDetTypeRec::ResetDigits(){
770 // Reset number of digits and the digits array for the ITS detector.
773 for(Int_t i=0;i<fgkNdettypes;i++){
777 //___________________________________________________________________
778 void AliITSDetTypeRec::ResetDigits(Int_t branch){
779 // Reset number of digits and the digits array for this branch.
781 if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear();
782 if(fNdtype) fNdtype[branch]=0;
786 //__________________________________________________________________
787 void AliITSDetTypeRec::ResetClusters(){
789 //Resets number of clusters and the cluster array
790 for(Int_t i=0;i<fgkNdettypes;i++){
795 //__________________________________________________________________
796 void AliITSDetTypeRec::ResetClusters(Int_t i){
798 //Resets number of clusters and the cluster array for this branch
800 if (fCtype->At(i)) ((TClonesArray*)fCtype->At(i))->Clear();
801 if (fNctype) fNctype[i]=0;
803 //__________________________________________________________________
804 void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){
806 //Creates tree branches for recpoints
808 // cont char *file File name where RecPoints branch is to be written
809 // to. If blank it write the SDigits to the same
810 // file in which the Hits were found.
815 // only one branch for rec points for all detector types
816 Bool_t oFast= (strstr(opt,"Fast")!=0);
818 Char_t detname[10] = "ITS";
822 sprintf(branchname,"%sRecPointsF",detname);
824 sprintf(branchname,"%sRecPoints",detname);
827 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
829 MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99);
831 //______________________________________________________________________
832 void AliITSDetTypeRec::SetTreeAddressR(TTree *treeR){
833 // Set branch address for the Reconstructed points Trees.
835 // TTree *treeR Tree containing the RecPoints.
841 Char_t namedet[10]="ITS";
844 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
846 sprintf(branchname,"%sRecPoints",namedet);
847 branch = treeR->GetBranch(branchname);
849 branch->SetAddress(&fRecPoints);
851 sprintf(branchname,"%sRecPointsF",namedet);
852 branch = treeR->GetBranch(branchname);
854 branch->SetAddress(&fRecPoints);
859 //____________________________________________________________________
860 void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){
861 // Add a reconstructed space point to the list
863 // const AliITSRecPoint &r RecPoint class to be added to the tree
864 // of reconstructed points TreeR.
870 TClonesArray &lrecp = *fRecPoints;
871 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
874 //______________________________________________________________________
875 void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastentry,Option_t *opt, Bool_t v2){
876 // cluster finding and reconstruction of space points
877 // the condition below will disappear when the geom class will be
878 // initialized for all versions - for the moment it is only for v5 !
879 // 7 is the SDD beam test version
881 // TTree *treeD Digits tree
882 // TTree *treeR Clusters tree
883 // Int_t lastentry Offset for module when not all of the modules
885 // Option_t *opt String indicating which ITS sub-detectors should
886 // be processed. If ="All" then all of the ITS
887 // sub detectors are processed.
889 const char *all = strstr(opt,"All");
890 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
893 SetDefaultClusterFinders();
894 AliInfo("Original cluster finder has been selected\n");
897 SetDefaultClusterFindersV2();
898 AliInfo("V2 cluster finder has been selected \n");
901 AliITSClusterFinder *rec = 0;
902 Int_t id,module,first=0;
903 for(module=0;module<GetITSgeom()->GetIndexMax();module++){
904 id = GetITSgeom()->GetModuleType(module);
905 if (!all && !det[id]) continue;
906 if(det[id]) first = GetITSgeom()->GetStartDet(id);
907 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
908 TClonesArray *itsDigits = DigitsAddress(id);
910 AliFatal("The reconstruction class was not instanciated!");
911 ResetDigits(); // MvL: Not sure we neeed this when rereading anyways
913 treeD->GetEvent(lastentry+module);
915 treeD->GetEvent(lastentry+(module-first));
917 Int_t ndigits = itsDigits->GetEntriesFast();
919 rec->SetDetTypeRec(this);
920 rec->SetDigits(DigitsAddress(id));
921 // rec->SetClusters(ClustersAddress(id));
922 rec->FindRawClusters(module);
929 //______________________________________________________________________
930 void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){
931 // cluster finding and reconstruction of space points
932 // the condition below will disappear when the geom class will be
933 // initialized for all versions - for the moment it is only for v5 !
934 // 7 is the SDD beam test version
936 // AliRawReader *rawReader Pointer to the raw-data reader
937 // TTree *treeR Clusters tree
942 const char *all = strstr(opt,"All");
943 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
945 AliITSClusterFinderV2 *rec = 0;
948 TClonesArray *array=new TClonesArray("AliITSRecPoint",1000);
949 TBranch *branch = treeR->Branch("ITSRecPoints",&array);
952 TClonesArray** clusters = new TClonesArray*[GetITSgeom()->GetIndexMax()];
953 for (Int_t iModule = 0; iModule < GetITSgeom()->GetIndexMax(); iModule++) {
954 clusters[iModule] = NULL;
957 if (!all && !det[id]) continue;
958 rec = (AliITSClusterFinderV2*)GetReconstructionModel(id);
960 AliFatal("The reconstruction class was not instanciated");
961 rec->SetDetTypeRec(this);
962 rec->RawdataToClusters(rawReader,clusters);
965 TClonesArray *emptyArray=new TClonesArray("AliITSRecPoint");
966 for(Int_t iModule=0;iModule<GetITSgeom()->GetIndexMax();iModule++){
967 id = GetITSgeom()->GetModuleType(iModule);
968 if (!all && !det[id]) continue;
969 array = clusters[iModule];
971 AliDebug(1,Form("data for module %d missing!",iModule));
974 branch->SetAddress(&array);
976 nClusters+=array->GetEntriesFast();
978 if (array != emptyArray) {
986 Info("DigitsToRecPoints", "total number of found recpoints in ITS: %d\n",
991 //______________________________________________________________________
992 void AliITSDetTypeRec::ReadOldSSDNoise(TObjArray *array,
993 AliITSNoiseSSDv2 *noiseSSD) {
994 //Reads the old SSD calibration object and converts it to the new format
995 const Int_t fgkSSDSTRIPSPERMODULE = 1536;
996 const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768;
998 Int_t fNMod = array->GetEntries();
999 cout<<"Converting old calibration object for noise..."<<endl;
1002 Double_t noise = 0.0;
1003 for (Int_t iModule = 0; iModule < fNMod; iModule++) {
1004 AliITSNoiseSSD *noiseModule = (AliITSNoiseSSD*) (array->At(iModule));
1005 for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) {
1006 noise = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? noiseModule->GetNoiseP(iStrip) : noiseModule->GetNoiseN(1535 - iStrip);
1007 if(iStrip < fgkSSDPSIDESTRIPSPERMODULE)
1008 noiseSSD->AddNoiseP(iModule,iStrip,noise);
1009 if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE)
1010 noiseSSD->AddNoiseN(iModule,1535 - iStrip,noise);
1012 }//loop over modules
1015 //______________________________________________________________________
1016 void AliITSDetTypeRec::ReadOldSSDBadChannels(TObjArray *array,
1017 AliITSBadChannelsSSDv2 *badChannelsSSD) {
1018 //Reads the old SSD calibration object and converts it to the new format
1019 Int_t fNMod = array->GetEntries();
1020 cout<<"Converting old calibration object for bad channels..."<<endl;
1021 for (Int_t iModule = 0; iModule < fNMod; iModule++) {
1022 //for (Int_t iModule = 0; iModule < 1; iModule++) {
1023 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule));
1024 TArrayI arrayPSide = bad->GetBadPChannelsList();
1025 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
1026 badChannelsSSD->AddBadChannelP(iModule,
1028 (Char_t)arrayPSide.At(iPCounter));
1030 TArrayI arrayNSide = bad->GetBadNChannelsList();
1031 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
1032 badChannelsSSD->AddBadChannelN(iModule,
1034 (Char_t)arrayNSide.At(iNCounter));
1036 }//loop over modules
1039 //______________________________________________________________________
1040 void AliITSDetTypeRec::ReadOldSSDGain(TObjArray *array,
1041 AliITSGainSSDv2 *gainSSD) {
1042 //Reads the old SSD calibration object and converts it to the new format
1044 Int_t fNMod = array->GetEntries();
1045 cout<<"Converting old calibration object for gain..."<<endl;
1048 for (Int_t iModule = 0; iModule < fNMod; iModule++) {
1049 AliITSGainSSD *gainModule = (AliITSGainSSD*) (array->At(iModule));
1050 TArrayF arrayPSide = gainModule->GetGainP();
1051 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
1052 gainSSD->AddGainP(iModule,
1054 arrayPSide.At(iPCounter));
1055 TArrayF arrayNSide = gainModule->GetGainN();
1056 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
1057 gainSSD->AddGainN(iModule,
1059 arrayNSide.At(iNCounter));
1060 }//loop over modules