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 "AliCDBEntry.h"
30 #include "AliITSClusterFinder.h"
31 #include "AliITSClusterFinderV2SPD.h"
32 #include "AliITSClusterFinderV2SDD.h"
33 #include "AliITSClusterFinderV2SSD.h"
34 #include "AliITSDetTypeRec.h"
35 #include "AliITSDDLModuleMapSDD.h"
36 #include "AliITSRecPoint.h"
37 #include "AliITSCalibrationSDD.h"
38 #include "AliITSHLTforSDD.h"
39 #include "AliITSCalibrationSSD.h"
40 #include "AliITSNoiseSSDv2.h"
41 #include "AliITSGainSSDv2.h"
42 #include "AliITSBadChannelsSSDv2.h"
43 #include "AliITSNoiseSSD.h"
44 #include "AliITSGainSSD.h"
45 #include "AliITSBadChannelsSSD.h"
46 #include "AliITSresponseSDD.h"
47 #include "AliITSsegmentationSPD.h"
48 #include "AliITSsegmentationSDD.h"
49 #include "AliITSsegmentationSSD.h"
52 class AliITSDriftSpeedArraySDD;
54 class AliITSRecoParam;
56 const Int_t AliITSDetTypeRec::fgkNdettypes = 3;
57 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSPD = 240;
58 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSDD = 260;
59 const Int_t AliITSDetTypeRec::fgkDefaultNModulesSSD = 1698;
61 ClassImp(AliITSDetTypeRec)
63 //________________________________________________________________
64 AliITSDetTypeRec::AliITSDetTypeRec(): TObject(),
82 fFastOrFiredMap(1200){
83 // Standard Constructor
91 fReconstruction = new TObjArray(fgkNdettypes);
92 fDigits = new TObjArray(fgkNdettypes);
93 for(Int_t i=0; i<3; i++){
96 fSSDCalibration=new AliITSCalibrationSSD();
97 fNMod = new Int_t [fgkNdettypes];
98 fNMod[0] = fgkDefaultNModulesSPD;
99 fNMod[1] = fgkDefaultNModulesSDD;
100 fNMod[2] = fgkDefaultNModulesSSD;
101 fRecPoints = new TClonesArray("AliITSRecPoint",3000);
107 //______________________________________________________________________
108 AliITSDetTypeRec::AliITSDetTypeRec(const AliITSDetTypeRec & rec):TObject(rec),
110 fITSgeom(rec.fITSgeom),
111 fReconstruction(rec.fReconstruction),
112 fSegmentation(rec.fSegmentation),
113 fCalibration(rec.fCalibration),
114 fSSDCalibration(rec.fSSDCalibration),
115 fSPDDead(rec.fSPDDead),
116 fSPDFastOr(rec.fSPDFastOr),
117 fDigits(rec.fDigits),
118 fDDLMapSDD(rec.fDDLMapSDD),
119 fRespSDD(rec.fRespSDD),
120 fAveGainSDD(rec.fAveGainSDD),
121 fIsHLTmodeC(rec.fIsHLTmodeC),
122 fRecPoints(rec.fRecPoints),
123 fNRecPoints(rec.fNRecPoints),
124 fFirstcall(rec.fFirstcall),
125 fLoadOnlySPDCalib(rec.fLoadOnlySPDCalib),
126 fFastOrFiredMap(rec.fFastOrFiredMap){
131 //______________________________________________________________________
132 AliITSDetTypeRec& AliITSDetTypeRec::operator=(const AliITSDetTypeRec& source){
133 // Assignment operator.
134 this->~AliITSDetTypeRec();
135 new(this) AliITSDetTypeRec(source);
140 //_____________________________________________________________________
141 AliITSDetTypeRec::~AliITSDetTypeRec(){
145 fReconstruction->Delete();
146 delete fReconstruction;
150 fSegmentation->Delete();
151 delete fSegmentation;
155 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
156 fCalibration->Delete();
159 if(fRespSDD) delete fRespSDD;
160 if(fDDLMapSDD) delete fDDLMapSDD;
163 if(fSSDCalibration) delete fSSDCalibration;
165 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
177 fRecPoints->Delete();
183 if (fITSgeom) delete fITSgeom;
187 //___________________________________________________________________
188 void AliITSDetTypeRec::SetReconstructionModel(Int_t dettype,AliITSClusterFinder *clf){
190 //Set reconstruction model for detector type
192 if(fReconstruction==0) fReconstruction = new TObjArray(fgkNdettypes);
193 if(fReconstruction->At(dettype)!=0) delete fReconstruction->At(dettype);
194 fReconstruction->AddAt(clf,dettype);
196 //______________________________________________________________________
197 AliITSClusterFinder* AliITSDetTypeRec::GetReconstructionModel(Int_t dettype) const{
199 //Get reconstruction model for detector type
200 if(fReconstruction==0) {
201 Warning("GetReconstructionModel","fReconstruction is 0!");
204 return (AliITSClusterFinder*)fReconstruction->At(dettype);
207 //______________________________________________________________________
208 void AliITSDetTypeRec::SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg){
210 //Set segmentation model for detector type
212 if(fSegmentation==0) fSegmentation = new TObjArray(fgkNdettypes);
213 if(fSegmentation->At(dettype)!=0) delete fSegmentation->At(dettype);
214 fSegmentation->AddAt(seg,dettype);
217 //______________________________________________________________________
218 AliITSsegmentation* AliITSDetTypeRec::GetSegmentationModel(Int_t dettype) const {
220 //Get segmentation model for detector type
222 if(fSegmentation==0) {
223 Warning("GetSegmentationModel","fSegmentation is 0!");
226 return (AliITSsegmentation*)fSegmentation->At(dettype);
229 //_______________________________________________________________________
230 void AliITSDetTypeRec::SetCalibrationModel(Int_t iMod, AliITSCalibration *cal){
232 //Set calibration (response) for the module iMod of type dettype
233 if (fCalibration==0) {
234 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
235 fCalibration->SetOwner(kTRUE);
236 fCalibration->Clear();
239 if (fCalibration->At(iMod) != 0)
240 delete (AliITSCalibration*) fCalibration->At(iMod);
241 fCalibration->AddAt(cal,iMod);
244 //_______________________________________________________________________
245 void AliITSDetTypeRec::SetSPDDeadModel(Int_t iMod, AliITSCalibration *cal){
247 //Set dead pixel info for the SPD module iMod
249 fSPDDead = new TObjArray(fgkDefaultNModulesSPD);
250 fSPDDead->SetOwner(kTRUE);
254 if (fSPDDead->At(iMod) != 0)
255 delete (AliITSCalibration*) fSPDDead->At(iMod);
256 fSPDDead->AddAt(cal,iMod);
258 //_______________________________________________________________________
259 AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod) const {
261 //Get calibration model for module type
263 if(fCalibration==0) {
264 Warning("GetalibrationModel","fCalibration is 0!");
268 if(iMod<fgkDefaultNModulesSPD+fgkDefaultNModulesSDD){
269 return (AliITSCalibration*)fCalibration->At(iMod);
271 Int_t i=iMod-(fgkDefaultNModulesSPD+fgkDefaultNModulesSDD);
272 fSSDCalibration->SetModule(i);
273 return (AliITSCalibration*)fSSDCalibration;
277 //_______________________________________________________________________
278 AliITSCalibration* AliITSDetTypeRec::GetSPDDeadModel(Int_t iMod) const {
280 //Get SPD dead for module iMod
283 AliWarning("fSPDDead is 0!");
287 return (AliITSCalibration*)fSPDDead->At(iMod);
290 //______________________________________________________________________
291 void AliITSDetTypeRec::SetTreeAddressD(TTree* const treeD){
292 // Set branch address for the tree of digits.
294 const char *det[4] = {"SPD","SDD","SSD","ITS"};
296 const Char_t* digclass;
301 if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes);
302 for (i=0; i<fgkNdettypes; i++) {
303 digclass = GetDigitClassName(i);
304 if(!(fDigits->At(i))) {
305 fDigits->AddAt(new TClonesArray(digclass,1000),i);
309 if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]);
310 else sprintf(branchname,"%sDigits%d",det[3],i+1);
312 branch = treeD->GetBranch(branchname);
313 if (branch) branch->SetAddress(&((*fDigits)[i]));
318 //_______________________________________________________________________
319 TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree* const tree,
320 const char* name, const char *classname,
321 void* address,Int_t size,Int_t splitlevel)
324 // Makes branch in given tree and diverts them to a separate file
330 Error("MakeBranchInTree","Making Branch %s Tree is NULL",name);
333 TBranch *branch = tree->GetBranch(name);
338 branch = tree->Branch(name,classname,address,size,splitlevel);
341 branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel);
347 //____________________________________________________________________
348 void AliITSDetTypeRec::SetDefaults(){
350 //Set defaults for segmentation and response
353 Warning("SetDefaults","null pointer to AliITSgeomGeom !");
357 AliITSsegmentation* seg;
358 if(!GetCalibration()) {AliFatal("Exit");exit(0);}
360 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
362 seg = new AliITSsegmentationSPD();
363 SetSegmentationModel(dettype,seg);
364 SetDigitClassName(dettype,"AliITSdigitSPD");
366 if(fLoadOnlySPDCalib==kFALSE){
368 seg = new AliITSsegmentationSDD();
369 AliITSCalibrationSDD* cal=(AliITSCalibrationSDD*)GetCalibrationModel(fgkDefaultNModulesSPD+1);
370 if(cal->IsAMAt20MHz()){
371 seg->SetPadSize(seg->Dpz(0),20.);
372 seg->SetNPads(seg->Npz()/2,128);
374 SetSegmentationModel(dettype,seg);
375 SetDigitClassName(dettype,"AliITSdigitSDD");
379 AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD();
380 SetSegmentationModel(dettype,seg2);
381 SetDigitClassName(dettype,"AliITSdigitSSD");
385 //______________________________________________________________________
386 Bool_t AliITSDetTypeRec::GetCalibration() {
387 // Get Default calibration if a storage is not defined.
390 AliITSCalibration* cal = GetCalibrationModel(0);
396 // SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
397 // Int_t run=GetRunNumber();
399 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
400 if (fCalibration==0) {
401 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
402 fCalibration->SetOwner(!cacheStatus);
403 fCalibration->Clear();
406 Bool_t retCode=GetCalibrationSPD(cacheStatus);
407 if(retCode==kFALSE) return kFALSE;
409 if(fLoadOnlySPDCalib==kFALSE){
410 retCode=GetCalibrationSDD(cacheStatus);
411 if(retCode==kFALSE) return kFALSE;
412 retCode=GetCalibrationSSD(cacheStatus);
413 if(retCode==kFALSE) return kFALSE;
416 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
417 fNMod[0], fNMod[1], fNMod[2]));
420 //______________________________________________________________________
421 Bool_t AliITSDetTypeRec::GetCalibrationSPD(Bool_t cacheStatus) {
422 // Get SPD calibration objects from OCDB
423 // dead pixel are not used for local reconstruction
425 AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy");
426 AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead");
427 AliCDBEntry *fastOrSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDFastOr");
428 if(!entrySPD || !deadSPD || !fastOrSPD ){
429 AliFatal("SPD Calibration object retrieval failed! ");
433 TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
434 if(!cacheStatus)entrySPD->SetObject(NULL);
435 entrySPD->SetOwner(kTRUE);
437 TObjArray *caldeadSPD = (TObjArray *)deadSPD->GetObject();
438 if(!cacheStatus)deadSPD->SetObject(NULL);
439 deadSPD->SetOwner(kTRUE);
441 AliITSFastOrCalibrationSPD *calfastOrSPD = (AliITSFastOrCalibrationSPD *)fastOrSPD->GetObject();
442 if(!cacheStatus)fastOrSPD->SetObject(NULL);
443 fastOrSPD->SetOwner(kTRUE);
450 if ((!calSPD) || (!caldeadSPD) || (!calfastOrSPD)){
451 AliWarning("Can not get SPD calibration from calibration database !");
455 fNMod[0] = calSPD->GetEntries();
457 AliITSCalibration* cal;
458 for (Int_t i=0; i<fNMod[0]; i++) {
459 cal = (AliITSCalibration*) calSPD->At(i);
460 SetCalibrationModel(i, cal);
461 cal = (AliITSCalibration*) caldeadSPD->At(i);
462 SetSPDDeadModel(i, cal);
464 fSPDFastOr = calfastOrSPD;
469 //______________________________________________________________________
470 Bool_t AliITSDetTypeRec::GetCalibrationSDD(Bool_t cacheStatus) {
471 // Get SDD calibration objects from OCDB
473 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
474 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD");
475 AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD");
476 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
477 AliCDBEntry *hltforSDD = AliCDBManager::Instance()->Get("ITS/Calib/HLTforSDD");
478 // AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD");
479 AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD");
481 if(!entrySDD || !entry2SDD || !drSpSDD || !ddlMapSDD || !hltforSDD || !mapTSDD ){
482 AliFatal("SDD Calibration object retrieval failed! ");
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 AliITSHLTforSDD* hltsdd=(AliITSHLTforSDD*)hltforSDD->GetObject();
505 if(!cacheStatus)hltforSDD->SetObject(NULL);
506 hltforSDD->SetOwner(kTRUE);
508 // TObjArray *mapAn = (TObjArray *)mapASDD->GetObject();
509 // if(!cacheStatus)mapASDD->SetObject(NULL);
510 // mapASDD->SetOwner(kTRUE);
512 TObjArray *mapT = (TObjArray *)mapTSDD->GetObject();
513 if(!cacheStatus)mapTSDD->SetObject(NULL);
514 mapTSDD->SetOwner(kTRUE);
517 // DB entries are deleted. In this way metadeta objects are deleted as well
528 if ((!pSDD)||(!calSDD) || (!drSp) || (!ddlsdd) || (!hltsdd) || (!mapT) ){
529 AliWarning("Can not get SDD calibration from calibration database !");
533 fNMod[1] = calSDD->GetEntries();
537 fIsHLTmodeC=hltsdd->IsHLTmodeC();
538 AliITSCalibration* cal;
541 for(Int_t iddl=0; iddl<AliITSDDLModuleMapSDD::GetNDDLs(); iddl++){
542 for(Int_t icar=0; icar<AliITSDDLModuleMapSDD::GetNModPerDDL();icar++){
543 Int_t iMod=fDDLMapSDD->GetModuleNumber(iddl,icar);
544 if(iMod==-1) continue;
545 Int_t i=iMod - fgkDefaultNModulesSPD;
546 cal = (AliITSCalibration*) calSDD->At(i);
549 for(Int_t iAnode=0;iAnode< ((AliITSCalibrationSDD*)cal)->NOfAnodes(); iAnode++){
550 if(((AliITSCalibrationSDD*)cal)->IsBadChannel(iAnode)) continue;
551 avegain+= ((AliITSCalibrationSDD*)cal)->GetChannelGain(iAnode);
554 AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0);
555 // AliITSMapSDD* ma0 = (AliITSMapSDD*)mapAn->At(i0);
556 AliITSMapSDD* mt0 = (AliITSMapSDD*)mapT->At(i0);
557 AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1);
558 // AliITSMapSDD* ma1 = (AliITSMapSDD*)mapAn->At(i1);
559 AliITSMapSDD* mt1 = (AliITSMapSDD*)mapT->At(i1);
560 cal->SetDriftSpeed(0,arr0);
561 cal->SetDriftSpeed(1,arr1);
562 // cal->SetMapA(0,ma0);
563 // cal->SetMapA(1,ma1);
566 SetCalibrationModel(iMod, cal);
569 if(nGdAnodes) fAveGainSDD=avegain/nGdAnodes;
574 //______________________________________________________________________
575 Bool_t AliITSDetTypeRec::GetCalibrationSSD(Bool_t cacheStatus) {
576 // Get SSD calibration objects from OCDB
577 // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD");
579 AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
580 AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
581 AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
583 if(!entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD){
584 AliFatal("SSD Calibration object retrieval failed! ");
588 TObject *emptyssd = 0; TString ssdobjectname = 0;
589 AliITSNoiseSSDv2 *noiseSSD = new AliITSNoiseSSDv2();
590 emptyssd = (TObject *)entryNoiseSSD->GetObject();
591 ssdobjectname = emptyssd->GetName();
592 if(ssdobjectname=="TObjArray") {
593 TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject();
594 ReadOldSSDNoise(noiseSSDOld, noiseSSD);
596 else if(ssdobjectname=="AliITSNoiseSSDv2")
597 noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject();
598 if(!cacheStatus)entryNoiseSSD->SetObject(NULL);
599 entryNoiseSSD->SetOwner(kTRUE);
601 AliITSGainSSDv2 *gainSSD = new AliITSGainSSDv2();
602 emptyssd = (TObject *)entryGainSSD->GetObject();
603 ssdobjectname = emptyssd->GetName();
604 if(ssdobjectname=="Gain") {
605 TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject();
606 ReadOldSSDGain(gainSSDOld, gainSSD);
608 else if(ssdobjectname=="AliITSGainSSDv2")
609 gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject();
610 if(!cacheStatus)entryGainSSD->SetObject(NULL);
611 entryGainSSD->SetOwner(kTRUE);
613 AliITSBadChannelsSSDv2 *badChannelsSSD = new AliITSBadChannelsSSDv2();
614 emptyssd = (TObject *)entryBadChannelsSSD->GetObject();
615 ssdobjectname = emptyssd->GetName();
616 if(ssdobjectname=="TObjArray") {
617 TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject();
618 ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD);
620 else if(ssdobjectname=="AliITSBadChannelsSSDv2")
621 badChannelsSSD = (AliITSBadChannelsSSDv2*)entryBadChannelsSSD->GetObject();
622 if(!cacheStatus)entryBadChannelsSSD->SetObject(NULL);
623 entryBadChannelsSSD->SetOwner(kTRUE);
625 // DB entries are deleted. In this way metadeta objects are deleted as well
627 delete entryNoiseSSD;
629 delete entryBadChannelsSSD;
632 if ((!noiseSSD)|| (!gainSSD)|| (!badChannelsSSD)) {
633 AliWarning("Can not get SSD calibration from calibration database !");
637 fSSDCalibration->SetNoise(noiseSSD);
638 fSSDCalibration->SetGain(gainSSD);
639 fSSDCalibration->SetBadChannels(badChannelsSSD);
640 //fSSDCalibration->FillBadChipMap();
645 //________________________________________________________________
646 void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){
648 //Set defaults for cluster finder V2
651 Warning("SetDefaults","Null pointer to AliITSgeom !");
655 AliITSClusterFinder *clf;
657 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
660 if(!GetReconstructionModel(dettype)){
661 clf = new AliITSClusterFinderV2SPD(this);
663 if(!rawdata) clf->SetDigits(DigitsAddress(0));
664 SetReconstructionModel(dettype,clf);
670 if(!GetReconstructionModel(dettype)){
671 clf = new AliITSClusterFinderV2SDD(this);
673 if(!rawdata) clf->SetDigits(DigitsAddress(1));
674 SetReconstructionModel(dettype,clf);
681 if(!GetReconstructionModel(dettype)){
682 clf = new AliITSClusterFinderV2SSD(this);
684 if(!rawdata) clf->SetDigits(DigitsAddress(2));
685 SetReconstructionModel(dettype,clf);
692 //______________________________________________________________________
693 void AliITSDetTypeRec::MakeBranch(TTree* tree, Option_t* option){
695 //Creates branches for clusters and recpoints
696 Bool_t cR = (strstr(option,"R")!=0);
697 Bool_t cRF = (strstr(option,"RF")!=0);
701 if(cR) MakeBranchR(tree);
702 if(cRF) MakeBranchRF(tree);
706 //___________________________________________________________________
707 void AliITSDetTypeRec::ResetDigits(){
708 // Reset number of digits and the digits array for the ITS detector.
711 for(Int_t i=0;i<fgkNdettypes;i++){
715 //___________________________________________________________________
716 void AliITSDetTypeRec::ResetDigits(Int_t branch){
717 // Reset number of digits and the digits array for this branch.
719 if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear();
722 //__________________________________________________________________
723 void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){
725 //Creates tree branches for recpoints
727 // cont char *file File name where RecPoints branch is to be written
728 // to. If blank it write the SDigits to the same
729 // file in which the Hits were found.
734 // only one branch for rec points for all detector types
735 Bool_t oFast= (strstr(opt,"Fast")!=0);
737 Char_t detname[10] = "ITS";
741 sprintf(branchname,"%sRecPointsF",detname);
743 sprintf(branchname,"%sRecPoints",detname);
746 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
748 MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99);
750 //______________________________________________________________________
751 void AliITSDetTypeRec::SetTreeAddressR(TTree* const treeR){
752 // Set branch address for the Reconstructed points Trees.
754 // TTree *treeR Tree containing the RecPoints.
760 Char_t namedet[10]="ITS";
763 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
765 sprintf(branchname,"%sRecPoints",namedet);
766 branch = treeR->GetBranch(branchname);
768 branch->SetAddress(&fRecPoints);
770 sprintf(branchname,"%sRecPointsF",namedet);
771 branch = treeR->GetBranch(branchname);
773 branch->SetAddress(&fRecPoints);
778 //____________________________________________________________________
779 void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){
780 // Add a reconstructed space point to the list
782 // const AliITSRecPoint &r RecPoint class to be added to the tree
783 // of reconstructed points TreeR.
789 TClonesArray &lrecp = *fRecPoints;
790 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
793 //______________________________________________________________________
794 void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastentry,Option_t *opt, Int_t optCluFind){
795 // cluster finding and reconstruction of space points
796 // the condition below will disappear when the geom class will be
797 // initialized for all versions - for the moment it is only for v5 !
798 // 7 is the SDD beam test version
800 // TTree *treeD Digits tree
801 // TTree *treeR Clusters tree
802 // Int_t lastentry Offset for module when not all of the modules
804 // Option_t *opt String indicating which ITS sub-detectors should
805 // be processed. If ="All" then all of the ITS
806 // sub detectors are processed.
808 const char *all = strstr(opt,"All");
809 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
812 SetDefaultClusterFindersV2();
813 AliInfo("V2 cluster finder has been selected \n");
815 SetDefaultClusterFindersV2();
816 AliInfo("Cluster Finder Option not implemented, V2 cluster finder will be used \n");
819 AliITSClusterFinder *rec = 0;
820 Int_t id,module,first=0;
821 for(module=0;module<GetITSgeom()->GetIndexMax();module++){
822 id = GetITSgeom()->GetModuleType(module);
823 if (!all && !det[id]) continue;
824 if(det[id]) first = GetITSgeom()->GetStartDet(id);
825 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
826 TClonesArray *itsDigits = DigitsAddress(id);
828 AliFatal("The reconstruction class was not instanciated!");
829 ResetDigits(); // MvL: Not sure we neeed this when rereading anyways
831 treeD->GetEvent(lastentry+module);
833 treeD->GetEvent(lastentry+(module-first));
835 Int_t ndigits = itsDigits->GetEntriesFast();
837 rec->SetDetTypeRec(this);
838 rec->SetDigits(DigitsAddress(id));
839 // rec->SetClusters(ClustersAddress(id));
840 rec->FindRawClusters(module);
846 //______________________________________________________________________
847 void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){
848 // cluster finding and reconstruction of space points
849 // the condition below will disappear when the geom class will be
850 // initialized for all versions - for the moment it is only for v5 !
851 // 7 is the SDD beam test version
853 // AliRawReader *rawReader Pointer to the raw-data reader
854 // TTree *treeR Clusters tree
859 const char *all = strstr(opt,"All");
860 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
862 AliITSClusterFinder *rec = 0;
865 TClonesArray *array=new TClonesArray("AliITSRecPoint",1000);
866 TBranch *branch = treeR->Branch("ITSRecPoints",&array);
869 TClonesArray** clusters = new TClonesArray*[GetITSgeom()->GetIndexMax()];
870 for (Int_t iModule = 0; iModule < GetITSgeom()->GetIndexMax(); iModule++) {
871 clusters[iModule] = NULL;
874 if (!all && !det[id]) continue;
875 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
877 AliFatal("The reconstruction class was not instantiated");
878 rec->SetDetTypeRec(this);
879 rec->RawdataToClusters(rawReader,clusters);
882 TClonesArray *emptyArray=new TClonesArray("AliITSRecPoint");
883 for(Int_t iModule=0;iModule<GetITSgeom()->GetIndexMax();iModule++){
884 id = GetITSgeom()->GetModuleType(iModule);
885 if (!all && !det[id]) continue;
886 array = clusters[iModule];
888 AliDebug(1,Form("data for module %d missing!",iModule));
891 branch->SetAddress(&array);
893 nClusters+=array->GetEntriesFast();
895 if (array != emptyArray) {
903 Info("DigitsToRecPoints", "total number of found recpoints in ITS: %d\n",
908 //______________________________________________________________________
909 void AliITSDetTypeRec::ReadOldSSDNoise(const TObjArray *array,
910 AliITSNoiseSSDv2 *noiseSSD) {
911 //Reads the old SSD calibration object and converts it to the new format
912 const Int_t fgkSSDSTRIPSPERMODULE = 1536;
913 const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768;
915 Int_t gNMod = array->GetEntries();
916 cout<<"Converting old calibration object for noise..."<<endl;
919 Double_t noise = 0.0;
920 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
921 AliITSNoiseSSD *noiseModule = (AliITSNoiseSSD*) (array->At(iModule));
922 for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) {
923 noise = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? noiseModule->GetNoiseP(iStrip) : noiseModule->GetNoiseN(1535 - iStrip);
924 if(iStrip < fgkSSDPSIDESTRIPSPERMODULE)
925 noiseSSD->AddNoiseP(iModule,iStrip,noise);
926 if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE)
927 noiseSSD->AddNoiseN(iModule,1535 - iStrip,noise);
932 //______________________________________________________________________
933 void AliITSDetTypeRec::ReadOldSSDBadChannels(const TObjArray *array,
934 AliITSBadChannelsSSDv2 *badChannelsSSD) {
935 //Reads the old SSD calibration object and converts it to the new format
936 Int_t gNMod = array->GetEntries();
937 cout<<"Converting old calibration object for bad channels..."<<endl;
938 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
939 //for (Int_t iModule = 0; iModule < 1; iModule++) {
940 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule));
941 TArrayI arrayPSide = bad->GetBadPChannelsList();
942 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
943 badChannelsSSD->AddBadChannelP(iModule,
945 (Char_t)arrayPSide.At(iPCounter));
947 TArrayI arrayNSide = bad->GetBadNChannelsList();
948 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
949 badChannelsSSD->AddBadChannelN(iModule,
951 (Char_t)arrayNSide.At(iNCounter));
956 //______________________________________________________________________
957 void AliITSDetTypeRec::ReadOldSSDGain(const TObjArray *array,
958 AliITSGainSSDv2 *gainSSD) {
959 //Reads the old SSD calibration object and converts it to the new format
961 Int_t gNMod = array->GetEntries();
962 cout<<"Converting old calibration object for gain..."<<endl;
965 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
966 AliITSGainSSD *gainModule = (AliITSGainSSD*) (array->At(iModule));
967 TArrayF arrayPSide = gainModule->GetGainP();
968 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
969 gainSSD->AddGainP(iModule,
971 arrayPSide.At(iPCounter));
972 TArrayF arrayNSide = gainModule->GetGainN();
973 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
974 gainSSD->AddGainN(iModule,
976 arrayNSide.At(iNCounter));