From 966f69390f91f586f4b5dd86bb60cbd3c204a3d9 Mon Sep 17 00:00:00 2001 From: cblume Date: Wed, 26 Aug 2009 15:47:50 +0000 Subject: [PATCH] Introduce the digits parameter class which is supposed to store digits information for the raw data headers --- TRD/AliTRDSimParam.cxx | 6 + TRD/AliTRDSimParam.h | 6 +- TRD/AliTRDdigitizer.cxx | 42 +--- TRD/AliTRDdigitizer.h | 4 +- TRD/AliTRDdigitsManager.cxx | 453 +++++++++++++++++++++++------------- TRD/AliTRDdigitsManager.h | 20 +- TRD/AliTRDdigitsParam.cxx | 123 ++++++++++ TRD/AliTRDdigitsParam.h | 42 ++++ TRD/CMake_libTRDbase.txt | 1 + TRD/TRDbaseLinkDef.h | 1 + TRD/libTRDbase.pkg | 1 + 11 files changed, 483 insertions(+), 216 deletions(-) create mode 100644 TRD/AliTRDdigitsParam.cxx create mode 100644 TRD/AliTRDdigitsParam.h diff --git a/TRD/AliTRDSimParam.cxx b/TRD/AliTRDSimParam.cxx index f8614987891..3016a80d0a6 100644 --- a/TRD/AliTRDSimParam.cxx +++ b/TRD/AliTRDSimParam.cxx @@ -99,6 +99,7 @@ AliTRDSimParam::AliTRDSimParam() ,fTimeCoupling(0.0) ,fTimeStructOn(kFALSE) ,fPRFOn(kFALSE) + ,fNTimeBins(0) { // // Default constructor @@ -152,6 +153,9 @@ void AliTRDSimParam::Init() // The pad response function fPRFOn = kTRUE; + // The number of time bins + fNTimeBins = 24; + ReInit(); } @@ -199,6 +203,7 @@ AliTRDSimParam::AliTRDSimParam(const AliTRDSimParam &p) ,fTimeCoupling(p.fTimeCoupling) ,fTimeStructOn(p.fTimeStructOn) ,fPRFOn(p.fPRFOn) + ,fNTimeBins(p.fNTimeBins) { // // Copy constructor @@ -269,6 +274,7 @@ void AliTRDSimParam::Copy(TObject &p) const target->fPadCoupling = fPadCoupling; target->fTimeCoupling = fTimeCoupling; target->fPRFOn = fPRFOn; + target->fNTimeBins = fNTimeBins; if (target->fTRFsmp) { delete[] target->fTRFsmp; diff --git a/TRD/AliTRDSimParam.h b/TRD/AliTRDSimParam.h index d8de572074f..d99ece5726f 100644 --- a/TRD/AliTRDSimParam.h +++ b/TRD/AliTRDSimParam.h @@ -45,6 +45,7 @@ class AliTRDSimParam : public TObject { void SetTimeCoupling(Float_t v) { fTimeCoupling = v; } void SetTimeStruct(Bool_t tsOn = 1) { fTimeStructOn = tsOn; } void SetPadResponse(Int_t prfOn = 1) { fPRFOn = prfOn; } + void SetNTimeBins(Int_t ntb) { fNTimeBins = ntb; } Float_t GetGasGain() const { return fGasGain; } Float_t GetNoise() const { return fNoise; } @@ -56,6 +57,7 @@ class AliTRDSimParam : public TObject { Float_t GetTRFhi() const { return fTRFhi; } Float_t GetPadCoupling() const { return fPadCoupling; } Float_t GetTimeCoupling() const { return fTimeCoupling; } + Int_t GetNTimeBins() const { return fNTimeBins; } Bool_t DiffusionOn() const { return fDiffusionOn; } Bool_t ElAttachOn() const { return fElAttachOn; } @@ -106,6 +108,8 @@ class AliTRDSimParam : public TObject { Int_t fPRFOn; // Switch for the pad response + Int_t fNTimeBins; // Number of time bins + private: // This is a singleton, constructor is private! @@ -115,7 +119,7 @@ class AliTRDSimParam : public TObject { void Init(); void SampleTRF(); - ClassDef(AliTRDSimParam,4) // The TRD simulation parameters + ClassDef(AliTRDSimParam,5) // The TRD simulation parameters }; diff --git a/TRD/AliTRDdigitizer.cxx b/TRD/AliTRDdigitizer.cxx index 003e6b292c7..66a029d7869 100644 --- a/TRD/AliTRDdigitizer.cxx +++ b/TRD/AliTRDdigitizer.cxx @@ -66,6 +66,8 @@ #include "AliTRDCommonParam.h" #include "AliTRDfeeParam.h" #include "AliTRDmcmSim.h" +#include "AliTRDdigitsParam.h" + #include "Cal/AliTRDCalROC.h" #include "Cal/AliTRDCalDet.h" @@ -90,8 +92,6 @@ AliTRDdigitizer::AliTRDdigitizer() // AliTRDdigitizer default constructor // - Init(); - } //_____________________________________________________________________________ @@ -113,8 +113,6 @@ AliTRDdigitizer::AliTRDdigitizer(const Text_t *name, const Text_t *title) // AliTRDdigitizer constructor // - Init(); - } //_____________________________________________________________________________ @@ -137,8 +135,6 @@ AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager // AliTRDdigitizer constructor // - Init(); - } //_____________________________________________________________________________ @@ -160,32 +156,6 @@ AliTRDdigitizer::AliTRDdigitizer(AliRunDigitizer *manager) // AliTRDdigitizer constructor // - Init(); - -} - -//_____________________________________________________________________________ -Bool_t AliTRDdigitizer::Init() -{ - // - // Initialize the digitizer with default values - // - - fRunLoader = 0; - fDigitsManager = 0; - fSDigitsManager = 0; - fSDigitsManagerList = 0; - fTRD = 0; - fGeo = 0; - - fEvent = 0; - fMasks = 0; - fCompress = kTRUE; - fSDigits = kFALSE; - fMergeSignalOnly = kFALSE; - - return AliDigitizer::Init(); - } //_____________________________________________________________________________ @@ -221,7 +191,7 @@ AliTRDdigitizer::~AliTRDdigitizer() fDigitsManager = 0; } - if (fDigitsManager) { //typo? fSDigitsManager? + if (fSDigitsManager) { delete fSDigitsManager; fSDigitsManager = 0; } @@ -860,7 +830,7 @@ Bool_t AliTRDdigitizer::ConvertHits(Int_t det * commonParam->GetSamplingFrequency())) - 1; } - Int_t nTimeTotal = calibration->GetNumberOfTimeBins(); + Int_t nTimeTotal = fDigitsManager->GetDigitsParam()->GetNTimeBins(); Float_t samplingRate = commonParam->GetSamplingFrequency(); Float_t elAttachProp = simParam->GetElAttachProp() / 100.0; @@ -1214,7 +1184,7 @@ Bool_t AliTRDdigitizer::Signal2ADC(Int_t det, AliTRDarraySignal *signals) Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows(); Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols(); - Int_t nTimeTotal = calibration->GetNumberOfTimeBins(); + Int_t nTimeTotal = fDigitsManager->GetDigitsParam()->GetNTimeBins(); // The gainfactor calibration objects const AliTRDCalDet *calGainFactorDet = calibration->GetGainFactorDet(); @@ -1330,7 +1300,7 @@ Bool_t AliTRDdigitizer::Signal2SDigits(Int_t det, AliTRDarraySignal *signals) Int_t nRowMax = fGeo->GetPadPlane(det)->GetNrows(); Int_t nColMax = fGeo->GetPadPlane(det)->GetNcols(); - Int_t nTimeTotal = calibration->GetNumberOfTimeBins(); + Int_t nTimeTotal = fDigitsManager->GetDigitsParam()->GetNTimeBins(); // Get the container for the digits of this detector diff --git a/TRD/AliTRDdigitizer.h b/TRD/AliTRDdigitizer.h index 1ad73051f6f..af091731f38 100644 --- a/TRD/AliTRDdigitizer.h +++ b/TRD/AliTRDdigitizer.h @@ -86,8 +86,6 @@ class AliTRDdigitizer : public AliDigitizer { protected: - virtual Bool_t Init(); - AliRunLoader *fRunLoader; //! Local pointer AliTRDdigitsManager *fDigitsManager; //! Manager for the output digits AliTRDdigitsManager *fSDigitsManager; //! Manager for the summed input s-digits @@ -101,7 +99,7 @@ class AliTRDdigitizer : public AliDigitizer { Bool_t fSDigits; // Switch for the summable digits Bool_t fMergeSignalOnly; // Merge only detectors that contain a signal - ClassDef(AliTRDdigitizer,19) // Produces TRD-Digits + ClassDef(AliTRDdigitizer,20) // Produces TRD-Digits }; #endif diff --git a/TRD/AliTRDdigitsManager.cxx b/TRD/AliTRDdigitsManager.cxx index 1d83f94f37d..deb75daa817 100644 --- a/TRD/AliTRDdigitsManager.cxx +++ b/TRD/AliTRDdigitsManager.cxx @@ -31,6 +31,8 @@ #include "AliTRDarrayADC.h" #include "AliTRDarraySignal.h" #include "AliTRDdigit.h" +#include "AliTRDdigitsParam.h" +#include "AliTRDSimParam.h" #include "AliTRDgeometry.h" #include "AliTRDSignalIndex.h" @@ -50,25 +52,25 @@ AliTRDdigitsManager::AliTRDdigitsManager(Bool_t rawRec) ,fHasSDigits(0) ,fSignalIndexes(NULL) ,fUseDictionaries(kTRUE) - ,fTreeD(0) - ,fBranch(0) ,fDets(AliTRDgeometry::Ndet()) ,fRawRec(rawRec) + ,fDigitsParam(0) { // // Default constructor // - if(fRawRec) + if (fRawRec) { - fDets=1; - fRawRec=kTRUE; + fDets = 1; + fRawRec = kTRUE; } for (Int_t iDict = 0; iDict < kNDict; iDict++) { fDict[iDict] = NULL; - } + } + } //_____________________________________________________________________________ @@ -80,10 +82,9 @@ AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m) ,fHasSDigits(m.fHasSDigits) ,fSignalIndexes(NULL) ,fUseDictionaries(kTRUE) - ,fTreeD(m.fTree) - ,fBranch(m.fBranch) ,fDets(m.fDets) ,fRawRec(m.fRawRec) + ,fDigitsParam(NULL) { // // AliTRDdigitsManager copy constructor @@ -123,6 +124,12 @@ AliTRDdigitsManager::~AliTRDdigitsManager() fSignalIndexes = NULL; } + if (fDigitsParam) + { + delete fDigitsParam; + fDigitsParam = NULL; + } + } //_____________________________________________________________________________ @@ -150,15 +157,16 @@ void AliTRDdigitsManager::Copy(TObject &m) const ((AliTRDdigitsManager &) m).fEvent = fEvent; ((AliTRDdigitsManager &) m).fHasSDigits = fHasSDigits; - ((AliTRDdigitsManager &) m).fDigits = fDigits; - for(Int_t i=0; iDelete(); delete fDigits; } fDigits = new TObjArray(fDets); for (Int_t index = 0; index < fDets; index++) - fDigits->AddAt(new AliTRDarraySignal(),index); + { + fDigits->AddAt(new AliTRDarraySignal(),index); + } } else { - if(fDigits) + if (fDigits) { fDigits->Delete(); delete fDigits; } fDigits = new TObjArray(fDets); - for (Int_t index = 0; index < fDets;index++) - fDigits->AddAt(new AliTRDarrayADC(),index); + for (Int_t index = 0; index < fDets; index++) + { + fDigits->AddAt(new AliTRDarrayADC(),index); + } } if (fUseDictionaries) { - for(Int_t iDict = 0; iDict < kNDict; iDict++) - if(fDict[iDict]) - { - fDict[iDict]->Delete(); - delete fDict[iDict]; - } - for(Int_t iDict = 0; iDict < kNDict; iDict++) - fDict[iDict] = new TObjArray(fDets); - for (Int_t iDict = 0; iDict < kNDict; iDict++) - for (Int_t index = 0; index < fDets; index++) - fDict[iDict]->AddAt(new AliTRDarrayDictionary(),index); + { + if (fDict[iDict]) + { + fDict[iDict]->Delete(); + delete fDict[iDict]; + } + fDict[iDict] = new TObjArray(fDets); + for (Int_t index = 0; index < fDets; index++) + { + fDict[iDict]->AddAt(new AliTRDarrayDictionary(),index); + } + } } - if(fSignalIndexes) + if (fSignalIndexes) { fSignalIndexes->Delete(); delete fSignalIndexes; } fSignalIndexes = new TObjArray(fDets); - for (Int_t i = 0; i < fDets; i++) - fSignalIndexes->AddLast(new AliTRDSignalIndex()); + for (Int_t i = 0; i < fDets; i++) + { + fSignalIndexes->AddLast(new AliTRDSignalIndex()); + } + + if (fDigitsParam) + { + delete fDigitsParam; + } + fDigitsParam = new AliTRDdigitsParam(); + fDigitsParam->SetNTimeBins(AliTRDSimParam::Instance()->GetNTimeBins()); } @@ -237,13 +259,17 @@ void AliTRDdigitsManager::ResetArrays() { fDigits = new TObjArray(fDets); for (Int_t index = 0; index < fDets; index++) - fDigits->AddAt(new AliTRDarraySignal(),index); + { + fDigits->AddAt(new AliTRDarraySignal(),index); + } } else { fDigits = new TObjArray(fDets); for (Int_t index = 0; index < fDets; index++) - fDigits->AddAt(new AliTRDarrayADC(),index); + { + fDigits->AddAt(new AliTRDarrayADC(),index); + } } for (Int_t iDict = 0; iDict < kNDict; iDict++) @@ -252,27 +278,32 @@ void AliTRDdigitsManager::ResetArrays() { fDict[iDict]->Delete(); delete fDict[iDict]; - fDict[iDict]=NULL; + fDict[iDict] = NULL; } } if (fUseDictionaries) { - for(Int_t iDict = 0; iDict < kNDict; iDict++) - fDict[iDict] = new TObjArray(fDets); - for (Int_t iDict = 0; iDict < kNDict; iDict++) - for (Int_t index = 0; index < fDets; index++) - fDict[iDict]->AddAt(new AliTRDarrayDictionary(),index); + { + fDict[iDict] = new TObjArray(fDets); + for (Int_t index = 0; index < fDets; index++) + { + fDict[iDict]->AddAt(new AliTRDarrayDictionary(),index); + } + } } - if(fSignalIndexes) + if (fSignalIndexes) { fSignalIndexes->Delete(); delete fSignalIndexes; } fSignalIndexes = new TObjArray(fDets); for (Int_t i = 0; i < fDets; i++) - fSignalIndexes->AddLast(new AliTRDSignalIndex()); + { + fSignalIndexes->AddLast(new AliTRDSignalIndex()); + } + } //_____________________________________________________________________________ @@ -289,17 +320,24 @@ void AliTRDdigitsManager::ResetArrays(Int_t det) RemoveIndexes(recoDet); if (fHasSDigits) - fDigits->AddAt(new AliTRDarraySignal(),recoDet); + { + fDigits->AddAt(new AliTRDarraySignal(),recoDet); + } else - fDigits->AddAt(new AliTRDarrayADC(),recoDet); + { + fDigits->AddAt(new AliTRDarrayADC(),recoDet); + } if (fUseDictionaries) { for (Int_t iDict = 0; iDict < kNDict; iDict++) - fDict[iDict]->AddAt(new AliTRDarrayDictionary(),recoDet); + { + fDict[iDict]->AddAt(new AliTRDarrayDictionary(),recoDet); + } } fSignalIndexes->AddAt(new AliTRDSignalIndex(),recoDet); + } //_____________________________________________________________________________ @@ -346,15 +384,18 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree * const tree) // Make the branch for the digits if (fDigits) { - if(fHasSDigits) + if (fHasSDigits) { const AliTRDarraySignal *kDigits = (AliTRDarraySignal *) fDigits->At(0); if (kDigits) { if (!fTree) return kFALSE; AliDebug(1,"Making branch for SDigits!\n"); - TBranch* branch = fTree->GetBranch("TRDdigits"); - if (!branch) fTree->Branch("TRDdigits","AliTRDarraySignal",&kDigits,buffersize,99); + TBranch *branch = fTree->GetBranch("TRDdigits"); + if (!branch) + { + fTree->Branch("TRDdigits","AliTRDarraySignal",&kDigits,buffersize,99); + } AliDebug(1,"Making branch TRDdigits\n"); } else @@ -363,15 +404,18 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree * const tree) } } - if(!fHasSDigits) + if (!fHasSDigits) { const AliTRDarrayADC *kDigits = (AliTRDarrayADC *) fDigits->At(0); if (kDigits) { if (!fTree) return kFALSE; AliDebug(1,"Making branch for Digits!\n"); - TBranch* branch = fTree->GetBranch("TRDdigits"); - if (!branch) fTree->Branch("TRDdigits","AliTRDarrayADC",&kDigits,buffersize,99); + TBranch *branch = fTree->GetBranch("TRDdigits"); + if (!branch) + { + fTree->Branch("TRDdigits","AliTRDarrayADC",&kDigits,buffersize,99); + } AliDebug(1,"Making branch TRDdigits\n"); } else @@ -380,10 +424,12 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree * const tree) } } - } + } else { + status = kFALSE; + } if (fUseDictionaries) @@ -400,8 +446,11 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree * const tree) { if (!fTree) return kFALSE; AliDebug(2,"Making branch for dictionary!\n"); - TBranch* branch = fTree->GetBranch(branchname); - if (!branch) fTree->Branch(branchname,"AliTRDarrayDictionary",&kDictionary,buffersize,99); + TBranch *branch = fTree->GetBranch(branchname); + if (!branch) + { + fTree->Branch(branchname,"AliTRDarrayDictionary",&kDictionary,buffersize,99); + } AliDebug(1,Form("Making branch %s\n",branchname)); } else @@ -415,7 +464,19 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree * const tree) } } } - + + if (fDigitsParam) + { + const AliTRDdigitsParam *kDigitsParam = fDigitsParam; + if (!fTree) return kFALSE; + TBranch *branch = fTree->GetBranch("TRDdigitsParam"); + if (!branch) + { + fTree->Branch("TRDdigitsParam","AliTRDdigitsParam",&kDigitsParam,buffersize,99); + } + AliDebug(1,"Making branch AliTRDdigitsParam\n"); + } + return status; } @@ -440,25 +501,30 @@ Bool_t AliTRDdigitsManager::ReadDigits(TTree * const tree) CreateArrays(); } - status = LoadArray(fDigits,"TRDdigits",fTree); + status = LoadArrayDigits(); if (fUseDictionaries) { - for (Int_t iDict = 0; iDict < kNDict; iDict++) + status = LoadArrayDict(); + if (status == kFALSE) { - Char_t branchname[15]; - sprintf(branchname,"TRDdictionary%d",iDict); - status = LoadArrayDict(fDict[iDict],branchname,fTree); - if (status == kFALSE) - { - fUseDictionaries = kFALSE; - AliWarning("Unable to load dict arrays. Will not use them.\n"); - break; - } - } + fUseDictionaries = kFALSE; + AliWarning("Unable to load dict arrays. Will not use them.\n"); + } + } + + if (!LoadDigitsParam()) { + AliWarning("Could not read digits parameter."); + if (fDigitsParam) { + delete fDigitsParam; } + AliWarning(Form("Create default version of digits parameter (NTimeBin=%d).\n" + ,AliTRDSimParam::Instance()->GetNTimeBins())); + fDigitsParam = new AliTRDdigitsParam(); + fDigitsParam->SetNTimeBins(AliTRDSimParam::Instance()->GetNTimeBins()); + } - return kTRUE; + return status; } @@ -469,25 +535,18 @@ Bool_t AliTRDdigitsManager::WriteDigits() // Writes out the TRD-digits and the dictionaries // - // Store the contents of the detector array in the tree - - if (!StoreArray(fDigits,"TRDdigits",fTree)) + if (!StoreArrayDigits()) { - AliError("Error while storing digits in branch TRDdigits\n"); + AliError("Error while storing digits\n"); return kFALSE; } if (fUseDictionaries) { - for (Int_t iDict = 0; iDict < kNDict; iDict++) + if (!StoreArrayDict()) { - Char_t branchname[15]; - sprintf(branchname,"TRDdictionary%d",iDict); - if (!StoreArrayDict(fDict[iDict],branchname,fTree)) - { - AliError(Form("Error while storing dictionary in branch %s\n",branchname)); - return kFALSE; - } + AliError("Error while storing dictionaries in branch\n"); + return kFALSE; } } @@ -720,7 +779,6 @@ void AliTRDdigitsManager::RemoveIndexes(Int_t det) } - //_____________________________________________________________________________ void AliTRDdigitsManager::ClearIndexes(Int_t det) { @@ -757,7 +815,7 @@ Bool_t AliTRDdigitsManager::BuildIndexes(Int_t det) digits = (AliTRDarrayADC *) GetDigits(det); } - //digits should be expanded by now!!! + // digits should be expanded by now!!! if (digits->GetNtime() > 0) { digits->Expand(); @@ -802,58 +860,52 @@ Bool_t AliTRDdigitsManager::BuildIndexes(Int_t det) } //_____________________________________________________________________________ -Bool_t AliTRDdigitsManager::LoadArray(TObjArray * const object - , const Char_t *branchname - , TTree * const tree) +Bool_t AliTRDdigitsManager::LoadArrayDigits() { // - // Loads all detectors of the array from the branch of - // the digits tree - // Adapted from code of the class AliTRDsegmentArray + // Loads the (s-)digits arrays for all detectors // - fTreeD = tree; - - if (!fTreeD) + if (!fTree) { AliError("Digits tree is not defined\n"); return kFALSE; } + Bool_t status = kTRUE; + // Get the branch - fBranch = fTreeD->GetBranch(branchname); - if (!fBranch) + TBranch *branch = fTree->GetBranch("TRDdigits"); + if (!branch) { - AliError(Form("Branch %s is not defined\n",branchname)); + AliError("Branch TRDdigits is not defined\n"); return kFALSE; } // Loop through all detectors and read them from the tree - Bool_t status = kTRUE; for (Int_t iDet = 0; iDet < fDets; iDet++) { - if(fHasSDigits) + if (fHasSDigits) { - AliTRDarraySignal *dataArray = (AliTRDarraySignal *) object->At(iDet); + AliTRDarraySignal *dataArray = (AliTRDarraySignal *) fDigits->At(iDet); if (!dataArray) { status = kFALSE; break; } - - fBranch->SetAddress(&dataArray); - fBranch->GetEntry(iDet); + branch->SetAddress(&dataArray); + branch->GetEntry(iDet); } else { - AliTRDarrayADC *dataArray = (AliTRDarrayADC *) object->At(iDet); + AliTRDarrayADC *dataArray = (AliTRDarrayADC *) fDigits->At(iDet); if (!dataArray) { status = kFALSE; - break; + break; } - fBranch->SetAddress(&dataArray); - fBranch->GetEntry(iDet); + branch->SetAddress(&dataArray); + branch->GetEntry(iDet); } } @@ -862,63 +914,94 @@ Bool_t AliTRDdigitsManager::LoadArray(TObjArray * const object } //________________________________________________________________________________________________ -Bool_t AliTRDdigitsManager::LoadArrayDict(TObjArray * const object - , const Char_t *branchname - , TTree * const tree) +Bool_t AliTRDdigitsManager::LoadArrayDict() { // - // Loads all detectors of the array from the branch of - // the dictionary tree - // Adapted from code of the class AliTRDsegmentArray + // Loads dictionary arrays for all detectors // - fTreeD = tree; + if (!fTree) + { + AliError("Digits tree is not defined\n"); + return kFALSE; + } + + Bool_t status = kTRUE; + + for (Int_t iDict = 0; iDict < kNDict; iDict++) + { + + // Get the branch + Char_t branchname[15]; + sprintf(branchname,"TRDdictionary%d",iDict); + TBranch *branch = fTree->GetBranch(branchname); + if (!branch) + { + AliError(Form("Branch %s is not defined\n",branchname)); + return kFALSE; + } + + // Loop through all detectors and read them from the tree + for (Int_t iDet = 0; iDet < fDets; iDet++) + { + AliTRDarrayDictionary *dataArray = (AliTRDarrayDictionary *) fDict[iDict]->At(iDet); + if (!dataArray) + { + status = kFALSE; + break; + } + branch->SetAddress(&dataArray); + branch->GetEntry(iDet); + } + + } + + return status; + +} + +//_____________________________________________________________________________ +Bool_t AliTRDdigitsManager::LoadDigitsParam() +{ + // + // Loads the digits parameter object from the digits tree + // - if (!fTreeD) + if (!fTree) { AliError("Digits tree is not defined\n"); return kFALSE; } // Get the branch - fBranch = fTreeD->GetBranch(branchname); - if (!fBranch) + TBranch *branch = fTree->GetBranch("TRDdigitsParam"); + if (!branch) { - AliError(Form("Branch %s is not defined\n",branchname)); + AliError("Branch TRDdigitsParam is not defined\n"); return kFALSE; } - // Loop through all detectors and read them from the tree - Bool_t status = kTRUE; - for (Int_t iDet = 0; iDet < fDets; iDet++) + // Read the parameter object + AliTRDdigitsParam *digitsParam = fDigitsParam; + if (!digitsParam) { - AliTRDarrayDictionary *dataArray = (AliTRDarrayDictionary *) object->At(iDet); - if (!dataArray) - { - status = kFALSE; - break; - } - fBranch->SetAddress(&dataArray); - fBranch->GetEntry(iDet); + return kFALSE; } - return status; + branch->SetAddress(&digitsParam); + branch->GetEntry(); + + return kTRUE; } //_____________________________________________________________________________ -Bool_t AliTRDdigitsManager::StoreArray(TObjArray * const array1 - , const Char_t *branchname - , TTree * const tree) +Bool_t AliTRDdigitsManager::StoreArrayDigits() { // - // Stores all the detectors of the array in the branch of - // the digits tree - // Adapted from code of the class AliTRDsegmentArray + // Stores the digit arrays for all detectors // - fTree = tree; - if (!fTree) { AliError("Digits tree is not defined\n"); @@ -926,10 +1009,10 @@ Bool_t AliTRDdigitsManager::StoreArray(TObjArray * const array1 } // Get the branch - fBranch = fTree->GetBranch(branchname); - if (!fBranch) + TBranch *branch = fTree->GetBranch("TRDdigits"); + if (!branch) { - AliError(Form("Branch %s is not defined\n",branchname)); + AliError("Branch TRDdigits is not defined\n"); return kFALSE; } @@ -939,25 +1022,25 @@ Bool_t AliTRDdigitsManager::StoreArray(TObjArray * const array1 { if (fHasSDigits) { - const AliTRDarraySignal *kDataArray = (AliTRDarraySignal *) array1->At(iDet); + const AliTRDarraySignal *kDataArray = (AliTRDarraySignal *) fDigits->At(iDet); if (!kDataArray) { status = kFALSE; break; } - fBranch->SetAddress(&kDataArray); - fBranch->Fill(); + branch->SetAddress(&kDataArray); + branch->Fill(); } else { - const AliTRDarrayADC *kDataArray = (AliTRDarrayADC *) array1->At(iDet); + const AliTRDarrayADC *kDataArray = (AliTRDarrayADC *) fDigits->At(iDet); if (!kDataArray) { status = kFALSE; break; } - fBranch->SetAddress(&kDataArray); - fBranch->Fill(); + branch->SetAddress(&kDataArray); + branch->Fill(); } } @@ -966,18 +1049,58 @@ Bool_t AliTRDdigitsManager::StoreArray(TObjArray * const array1 } //_____________________________________________________________________________ -Bool_t AliTRDdigitsManager::StoreArrayDict(TObjArray * const array3 - , const Char_t *branchname - , TTree * const tree) +Bool_t AliTRDdigitsManager::StoreArrayDict() { // - // Stores all the dictionary arrays of the detectors of the array in the branch of - // the dictionary tree - // Adapted from code of the class AliTRDsegmentArray + // Stores the dictionary arrays for all detectors // - // AliDebug(1,"Storing Arrays of Dictionary"); - fTree = tree; + if (!fTree) + { + AliError("Digits tree is not defined\n"); + return kFALSE; + } + + Bool_t status = kTRUE; + + for (Int_t iDict = 0; iDict < kNDict; iDict++) + { + + // Get the branch + Char_t branchname[15]; + sprintf(branchname,"TRDdictionary%d",iDict); + TBranch *branch = fTree->GetBranch(branchname); + if (!branch) + { + AliError(Form("Branch %s is not defined\n",branchname)); + return kFALSE; + } + + // Loop through all detectors and fill them into the tree + for (Int_t iDet = 0; iDet < fDets; iDet++) + { + const AliTRDarrayDictionary *kDataArray = (AliTRDarrayDictionary *) fDict[iDict]->At(iDet); + if (!kDataArray) + { + status = kFALSE; + break; + } + branch->SetAddress(&kDataArray); + branch->Fill(); + } + + } + + return status; + +} + +//_____________________________________________________________________________ +Bool_t AliTRDdigitsManager::StoreDigitsParam() +{ + // + // Stores the digits parameter object from the digits tree + // if (!fTree) { @@ -986,27 +1109,23 @@ Bool_t AliTRDdigitsManager::StoreArrayDict(TObjArray * const array3 } // Get the branch - fBranch = fTree->GetBranch(branchname); - if (!fBranch) + TBranch *branch = fTree->GetBranch("TRDdigitsParam"); + if (!branch) { - AliError(Form("Branch %s is not defined\n",branchname)); + AliError("Branch TRDdigitsParam is not defined\n"); return kFALSE; } - // Loop through all detectors and fill them into the tree - Bool_t status = kTRUE; - for (Int_t iDet = 0; iDet < fDets; iDet++) + // Fill the digits object in the tree + const AliTRDdigitsParam *kDigitsParam = fDigitsParam; + if (!kDigitsParam) { - const AliTRDarrayDictionary *kDataArray = (AliTRDarrayDictionary *) array3->At(iDet); - if (!kDataArray) - { - status = kFALSE; - break; - } - fBranch->SetAddress(&kDataArray); - fBranch->Fill(); + return kFALSE; } + branch->SetAddress(&kDigitsParam); + branch->Fill(); - return status; + return kTRUE; } + diff --git a/TRD/AliTRDdigitsManager.h b/TRD/AliTRDdigitsManager.h index 63b076c97bc..e7482a63908 100644 --- a/TRD/AliTRDdigitsManager.h +++ b/TRD/AliTRDdigitsManager.h @@ -20,6 +20,7 @@ class AliTRDSignalIndex; class AliTRDarrayADC; class AliTRDarraySignal; class AliTRDarrayDictionary; +class AliTRDdigitsParam; class AliTRDdigitsManager : public TObject { @@ -60,7 +61,7 @@ class AliTRDdigitsManager : public TObject { AliTRDarrayADC *GetDigits(Int_t det) const; AliTRDarraySignal *GetSDigits(Int_t det) const; AliTRDarrayDictionary *GetDictionary(Int_t det, Int_t i) const; - + AliTRDdigitsParam *GetDigitsParam() const { return fDigitsParam; }; AliTRDSignalIndex *GetIndexes(Int_t det); TObjArray *GetIndexes() const { return fSignalIndexes; }; @@ -73,11 +74,13 @@ class AliTRDdigitsManager : public TObject { Short_t GetDigitAmp(Int_t row, Int_t col, Int_t time, Int_t det) const; UChar_t GetPadStatus(Int_t row, Int_t col, Int_t time, Int_t det) const; - Bool_t LoadArray(TObjArray * const object, const Char_t *branchname, TTree * const tree=0); - Bool_t LoadArrayDict(TObjArray * const object, const Char_t *branchname, TTree * const tree=0); - Bool_t StoreArray(TObjArray * const array1, const Char_t *branchname, TTree * const tree=0); - Bool_t StoreArrayDict(TObjArray * const array3, const Char_t *branchname, TTree * const tree=0); - + Bool_t LoadArrayDigits(); + Bool_t LoadArrayDict(); + Bool_t LoadDigitsParam(); + Bool_t StoreArrayDigits(); + Bool_t StoreArrayDict(); + Bool_t StoreDigitsParam(); + protected: static const Int_t fgkNDict; // Number of track dictionary arrays @@ -88,12 +91,11 @@ class AliTRDdigitsManager : public TObject { Bool_t fHasSDigits; // Switch for the summable digits TObjArray *fSignalIndexes; // Provides access to the active pads and tbins Bool_t fUseDictionaries; // Use dictionaries or not (case of real data) - TTree *fTreeD; // Tree with detector objects - TBranch *fBranch; // Branchaddress Int_t fDets; // No of Detectors Bool_t fRawRec; // Reconstruct from raw files? If its kTRUE then the TObjArrays have only one entry. + AliTRDdigitsParam *fDigitsParam; // Parameters of the digits - ClassDef(AliTRDdigitsManager,7) // Manages the TRD digits + ClassDef(AliTRDdigitsManager,8) // Manages the TRD digits }; #endif diff --git a/TRD/AliTRDdigitsParam.cxx b/TRD/AliTRDdigitsParam.cxx new file mode 100644 index 00000000000..e76c5e60759 --- /dev/null +++ b/TRD/AliTRDdigitsParam.cxx @@ -0,0 +1,123 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id: AliTRDdigitsParam.cxx 34070 2009-08-04 15:34:53Z cblume $ */ + +/////////////////////////////////////////////////////////////////////////////// +// // +// Class containing parameters for digits // +// // +/////////////////////////////////////////////////////////////////////////////// + +#include "AliLog.h" + +#include "AliTRDdigitsParam.h" +#include "AliTRDcalibDB.h" + +ClassImp(AliTRDdigitsParam) + +//_____________________________________________________________________________ +AliTRDdigitsParam::AliTRDdigitsParam() + :TObject() + ,fCheckOCDB(kTRUE) + ,fNTimeBins(0) +{ + // + // Default constructor + // + +} + +//_____________________________________________________________________________ +AliTRDdigitsParam::~AliTRDdigitsParam() +{ + // + // Destructor + // + +} + +//_____________________________________________________________________________ +AliTRDdigitsParam::AliTRDdigitsParam(const AliTRDdigitsParam &p) + :TObject(p) + ,fCheckOCDB(p.fCheckOCDB) + ,fNTimeBins(p.fNTimeBins) +{ + // + // Copy constructor + // + +} + +//_____________________________________________________________________________ +AliTRDdigitsParam &AliTRDdigitsParam::operator=(const AliTRDdigitsParam &p) +{ + // + // Assignment operator + // + + if (this != &p) { + ((AliTRDdigitsParam &) p).Copy(*this); + } + + return *this; + +} + +//_____________________________________________________________________________ +void AliTRDdigitsParam::Copy(TObject &p) const +{ + // + // Copy function + // + + AliTRDdigitsParam *target = dynamic_cast (&p); + if (!target) { + return; + } + + target->fCheckOCDB = fCheckOCDB; + target->fNTimeBins = fNTimeBins; + +} + +//_____________________________________________________________________________ +Bool_t AliTRDdigitsParam::SetNTimeBins(Int_t ntb) +{ + // + // Sets the number of time bins + // Per default an automatic consistency check with the corresponding + // OCDB entry is performed. This check can be disabled by setting + // SetCheckOCDB(kFALSE) + // + + fNTimeBins = ntb; + + if (fCheckOCDB) { + Int_t nTimeBinsOCDB = AliTRDcalibDB::Instance()->GetNumberOfTimeBins(); + if (fNTimeBins == nTimeBinsOCDB) { + return kTRUE; + } + else { + AliWarning(Form("Number of timebins does not match OCDB value (%d, %d)" + ,fNTimeBins,nTimeBinsOCDB)); + return kFALSE; + } + } + else { + return kTRUE; + } + +} diff --git a/TRD/AliTRDdigitsParam.h b/TRD/AliTRDdigitsParam.h new file mode 100644 index 00000000000..f821e9d0c1a --- /dev/null +++ b/TRD/AliTRDdigitsParam.h @@ -0,0 +1,42 @@ +#ifndef ALITRDDIGITSPARAM_H +#define ALITRDDIGITSPARAM_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/////////////////////////////////////////////////////////////////////////////// +// // +// Class containing parameters for digits // +// // +/////////////////////////////////////////////////////////////////////////////// + +/* $Id: AliTRDdigitsParam.h 34070 2009-08-04 15:34:53Z cblume $ */ + +#include "TObject.h" + +class AliTRDdigitsParam : public TObject +{ + + public: + + AliTRDdigitsParam(); + AliTRDdigitsParam(const AliTRDdigitsParam &p); + AliTRDdigitsParam &operator=(const AliTRDdigitsParam &p); + virtual ~AliTRDdigitsParam(); + + virtual void Copy(TObject &p) const; + + void SetCheckOCDB(Bool_t check = kTRUE) { fCheckOCDB = check; } + Bool_t SetNTimeBins(Int_t ntb); + + Bool_t CheckOCDB() const { return fCheckOCDB; } + Int_t GetNTimeBins() const { return fNTimeBins; } + + protected: + + Bool_t fCheckOCDB; // Do a consistency check with the corresponding OCDB entry + Int_t fNTimeBins; // Number of timebins + + ClassDef(AliTRDdigitsParam,1) // The parameters for digits + +}; +#endif diff --git a/TRD/CMake_libTRDbase.txt b/TRD/CMake_libTRDbase.txt index cd0e135364c..01e96998b3a 100644 --- a/TRD/CMake_libTRDbase.txt +++ b/TRD/CMake_libTRDbase.txt @@ -8,6 +8,7 @@ set(SRCS AliTRDgeometry.cxx AliTRDdigit.cxx AliTRDdigitsManager.cxx + AliTRDdigitsParam.cxx AliTRDrawData.cxx AliTRDpadPlane.cxx AliTRDrawFastStream.cxx diff --git a/TRD/TRDbaseLinkDef.h b/TRD/TRDbaseLinkDef.h index faf940920bf..1e943fcd52b 100644 --- a/TRD/TRDbaseLinkDef.h +++ b/TRD/TRDbaseLinkDef.h @@ -20,6 +20,7 @@ #pragma link C++ class AliTRDdigit+; #pragma link C++ class AliTRDdigitsManager+; +#pragma link C++ class AliTRDdigitsParam+; #pragma link C++ class AliTRDrawData+; diff --git a/TRD/libTRDbase.pkg b/TRD/libTRDbase.pkg index fc0aadde027..d72efb51e41 100644 --- a/TRD/libTRDbase.pkg +++ b/TRD/libTRDbase.pkg @@ -7,6 +7,7 @@ SRCS= AliTRDarraySignal.cxx \ AliTRDgeometry.cxx \ AliTRDdigit.cxx \ AliTRDdigitsManager.cxx \ + AliTRDdigitsParam.cxx \ AliTRDrawData.cxx \ AliTRDpadPlane.cxx \ AliTRDrawStream.cxx \ -- 2.43.0