X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDdigitsManager.cxx;h=fc0817829a64ced42f3c11f287a80818c8843bfb;hb=ef6f0bda9cfa8a17dfe7efd91dc405e6e101ebfc;hp=f80989b0473fd183cbc24e1365ca461acf1b7be4;hpb=ae63fafcea8661ce989ee3dfd8b12780de7037d3;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDdigitsManager.cxx b/TRD/AliTRDdigitsManager.cxx index f80989b0473..fc0817829a6 100644 --- a/TRD/AliTRDdigitsManager.cxx +++ b/TRD/AliTRDdigitsManager.cxx @@ -22,17 +22,17 @@ // // /////////////////////////////////////////////////////////////////////////////// -#include -#include #include -#include -#include "AliRun.h" + #include "AliLog.h" + #include "AliTRDdigitsManager.h" #include "AliTRDarrayDictionary.h" #include "AliTRDarrayADC.h" #include "AliTRDarraySignal.h" #include "AliTRDdigit.h" +#include "AliTRDdigitsParam.h" +#include "AliTRDSimParam.h" #include "AliTRDgeometry.h" #include "AliTRDSignalIndex.h" @@ -44,7 +44,7 @@ ClassImp(AliTRDdigitsManager) const Int_t AliTRDdigitsManager::fgkNDict = kNDict; //_____________________________________________________________________________ -AliTRDdigitsManager::AliTRDdigitsManager() +AliTRDdigitsManager::AliTRDdigitsManager(Bool_t rawRec) :TObject() ,fEvent(0) ,fTree(0) @@ -52,20 +52,25 @@ AliTRDdigitsManager::AliTRDdigitsManager() ,fHasSDigits(0) ,fSignalIndexes(NULL) ,fUseDictionaries(kTRUE) - ,fTreeD(0) - ,fBranch(0) + ,fDets(AliTRDgeometry::Ndet()) + ,fRawRec(rawRec) + ,fDigitsParam(0) { // // Default constructor // + + if (fRawRec) + { + fDets = 1; + fRawRec = kTRUE; + } for (Int_t iDict = 0; iDict < kNDict; iDict++) { fDict[iDict] = NULL; } - fSignalIndexes = new TObjArray(AliTRDgeometry::Ndet()); - } //_____________________________________________________________________________ @@ -77,13 +82,19 @@ 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 // + for (Int_t iDict = 0; iDict < kNDict; iDict++) + { + fDict[iDict] = NULL; + } + } //_____________________________________________________________________________ @@ -103,9 +114,12 @@ AliTRDdigitsManager::~AliTRDdigitsManager() for (Int_t iDict = 0; iDict < kNDict; iDict++) { - fDict[iDict]->Delete(); - delete fDict[iDict]; - fDict[iDict] = NULL; + if(fDict[iDict]) + { + fDict[iDict]->Delete(); + delete fDict[iDict]; + fDict[iDict] = NULL; + } } if (fSignalIndexes) @@ -115,6 +129,12 @@ AliTRDdigitsManager::~AliTRDdigitsManager() fSignalIndexes = NULL; } + if (fDigitsParam) + { + delete fDigitsParam; + fDigitsParam = NULL; + } + } //_____________________________________________________________________________ @@ -142,13 +162,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(AliTRDgeometry::Ndet()); - for (Int_t index = 0; index < AliTRDgeometry::Ndet(); index++) + fDigits = new TObjArray(fDets); + for (Int_t index = 0; index < fDets; index++) { - AliTRDarraySignal *chamber= new AliTRDarraySignal(); - chamber->SetNdet(index); - fDigits->AddAt(chamber,index); - } + fDigits->AddAt(new AliTRDarraySignal(),index); + } } else { - if(fDigits) + if (fDigits) { fDigits->Delete(); delete fDigits; } - fDigits = new TObjArray(AliTRDgeometry::Ndet()); - for (Int_t index = 0; index < AliTRDgeometry::Ndet(); index++) + fDigits = new TObjArray(fDets); + for (Int_t index = 0; index < fDets; index++) { - AliTRDarrayADC *chamber= new AliTRDarrayADC(); - chamber->SetNdet(index); - fDigits->AddAt(chamber,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(AliTRDgeometry::Ndet()); - } - for (Int_t iDict = 0; iDict < kNDict; iDict++) { - for (Int_t index = 0; index < AliTRDgeometry::Ndet(); index++) + if (fDict[iDict]) + { + fDict[iDict]->Delete(); + delete fDict[iDict]; + } + fDict[iDict] = new TObjArray(fDets); + for (Int_t index = 0; index < fDets; index++) { - AliTRDarrayDictionary *dictio= new AliTRDarrayDictionary(); - dictio->SetNdet(index); - fDict[iDict]->AddAt(dictio,index); - } + fDict[iDict]->AddAt(new AliTRDarrayDictionary(),index); + } } } - - for (Int_t i = 0; i < AliTRDgeometry::Ndet(); i++) + + if (fSignalIndexes) + { + fSignalIndexes->Delete(); + delete fSignalIndexes; + } + fSignalIndexes = new TObjArray(fDets); + for (Int_t i = 0; i < fDets; i++) { fSignalIndexes->AddLast(new AliTRDSignalIndex()); - } + } + + if (fDigitsParam) + { + delete fDigitsParam; + } + fDigitsParam = new AliTRDdigitsParam(); } //_____________________________________________________________________________ -void AliTRDdigitsManager::ResetArrays() +void AliTRDdigitsManager::ClearArrays(Int_t det) { // // Reset the data arrays // - if (fDigits) - { - fDigits->Delete(); - delete fDigits; - } - - for (Int_t iDict = 0; iDict < kNDict; iDict++) - { - if (fDict[iDict]) - { - fDict[iDict]->Delete(); - delete fDict[iDict]; - } - } + Int_t recoDet = fRawRec ? 0 : det; if (fHasSDigits) { - fDigits = new TObjArray(AliTRDgeometry::Ndet()); - for (Int_t index = 0; index < AliTRDgeometry::Ndet(); index++) - { - AliTRDarraySignal *chamber= new AliTRDarraySignal(); - chamber->SetNdet(index); - fDigits->AddAt(chamber,index); - } + ((AliTRDarraySignal*)fDigits->At(recoDet))->Reset(); } - else + else { - fDigits = new TObjArray(AliTRDgeometry::Ndet()); - for (Int_t index = 0; index < AliTRDgeometry::Ndet(); index++) - { - AliTRDarrayADC *chamber= new AliTRDarrayADC(); - chamber->SetNdet(index); - fDigits->AddAt(chamber,index); - } + ((AliTRDarrayADC*)fDigits->At(recoDet))->ConditionalReset((AliTRDSignalIndex*)fSignalIndexes->At(recoDet)); } - + if (fUseDictionaries) { - for(Int_t iDict = 0; iDict < kNDict; iDict++) - { - fDict[iDict] = new TObjArray(AliTRDgeometry::Ndet()); - } for (Int_t iDict = 0; iDict < kNDict; iDict++) { - for (Int_t index = 0; index < AliTRDgeometry::Ndet(); index++) - { - AliTRDarrayDictionary *dictio= new AliTRDarrayDictionary(); - dictio->SetNdet(index); - fDict[iDict]->AddAt(dictio,index); - } + ((AliTRDarrayDictionary*)fDict[iDict]->At(recoDet))->Reset(); } } - - for (Int_t i = 0; i < AliTRDgeometry::Ndet(); i++) - { - AliTRDSignalIndex *idx = (AliTRDSignalIndex *) fSignalIndexes->At(i); - if (idx) idx->Reset(); - } + + ((AliTRDSignalIndex*)fSignalIndexes->At(recoDet))->ResetContent(); } @@ -298,12 +284,9 @@ Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time, Int_t // Returns the amplitude of a digit // - if (!GetDigits(det)) - { - return 0; - } + if (!GetDigits(det)) return 0; - return ((Short_t) ((AliTRDarrayADC *) GetDigits(det))->GetDataB(row,col,time)); + return ((Short_t) ((AliTRDarrayADC *) GetDigits(det))->GetDataBits(row,col,time)); } @@ -314,17 +297,14 @@ UChar_t AliTRDdigitsManager::GetPadStatus(Int_t row, Int_t col, Int_t time, Int_ // Returns the pad status for the requested pad // - if (!GetDigits(det)) - { - return 0; - } + if (!GetDigits(det)) return 0; return ((UChar_t) ((AliTRDarrayADC *) GetDigits(det))->GetPadStatus(row,col,time)); } //_____________________________________________________________________________ -Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree) +Bool_t AliTRDdigitsManager::MakeBranch(TTree * const tree) { // // Creates the tree and branches for the digits and the dictionary @@ -341,15 +321,18 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree *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 @@ -358,15 +341,18 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree *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 @@ -375,10 +361,12 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree) } } - } + } else { + status = kFALSE; + } if (fUseDictionaries) @@ -386,8 +374,9 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree) // Make the branches for the dictionaries for (Int_t iDict = 0; iDict < kNDict; iDict++) { - Char_t branchname[15]; - sprintf(branchname,"TRDdictionary%d",iDict); + const Int_t kBranchname = 15; + Char_t branchname[kBranchname]; + snprintf(branchname,kBranchname,"TRDdictionary%d",iDict); if (fDict[iDict]) { const AliTRDarrayDictionary *kDictionary = (AliTRDarrayDictionary *) fDict[iDict]->At(0); @@ -395,8 +384,11 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree *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 @@ -410,13 +402,25 @@ Bool_t AliTRDdigitsManager::MakeBranch(TTree *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; } //_____________________________________________________________________________ -Bool_t AliTRDdigitsManager::ReadDigits(TTree *tree) +Bool_t AliTRDdigitsManager::ReadDigits(TTree * const tree) { // // Reads the digit information from the input file @@ -435,25 +439,31 @@ Bool_t AliTRDdigitsManager::ReadDigits(TTree *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->SetNTimeBinsAll(AliTRDSimParam::Instance()->GetNTimeBins()); + fDigitsParam->SetADCbaselineAll(AliTRDSimParam::Instance()->GetADCbaseline()); + } - return kTRUE; + return status; } @@ -461,30 +471,29 @@ Bool_t AliTRDdigitsManager::ReadDigits(TTree *tree) Bool_t AliTRDdigitsManager::WriteDigits() { // - // Writes out the TRD-digits and the dictionaries + // Writes out the TRD-digits, the dictionaries and the digitsPaam // - // 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; } } + + if (!StoreDigitsParam()) + { + AliError("Error while storing digitsParam\n"); + return kFALSE; + } // Write the new tree to the output file fTree->AutoSave(); @@ -530,7 +539,7 @@ Int_t AliTRDdigitsManager::GetTrack(Int_t track if ((track < 0) || (track >= kNDict)) { - AliError(Form("track %d out of bounds (size: %d, this: 0x%08x)",track,kNDict,this)); + AliError(Form("track %d out of bounds (size: %d, this: 0x%p)",track,kNDict,this)); return -1; } @@ -551,6 +560,8 @@ AliTRDarrayADC *AliTRDdigitsManager::GetDigits(Int_t det) const // Returns the digits array for one detector // + Int_t recoDet = fRawRec ? 0 : det; + if (!fDigits) { return 0x0; @@ -558,7 +569,8 @@ AliTRDarrayADC *AliTRDdigitsManager::GetDigits(Int_t det) const if (!fHasSDigits) { - return (AliTRDarrayADC *) fDigits->At(det); + ((AliTRDarrayADC *) fDigits->At(recoDet))->SetNdet(det); + return (AliTRDarrayADC *) fDigits->At(recoDet); } else { @@ -575,6 +587,8 @@ AliTRDarraySignal *AliTRDdigitsManager::GetSDigits(Int_t det) const // Returns the sdigits array for one detector // + Int_t recoDet = fRawRec ? 0 : det; + if (!fDigits) { // AliDebug(1,"NO FDIGITS!"); @@ -583,7 +597,8 @@ AliTRDarraySignal *AliTRDdigitsManager::GetSDigits(Int_t det) const if (fHasSDigits) { - return (AliTRDarraySignal *) fDigits->At(det); + ((AliTRDarraySignal *) fDigits->At(recoDet))->SetNdet(det); + return (AliTRDarraySignal *) fDigits->At(recoDet); } else { @@ -601,17 +616,20 @@ AliTRDarrayDictionary *AliTRDdigitsManager::GetDictionary(Int_t det // Returns the dictionary for one detector // + Int_t recoDet = fRawRec ? 0 : det; + if (fUseDictionaries == kFALSE) { return 0x0; } - return (AliTRDarrayDictionary *) fDict[i]->At(det); + ((AliTRDarrayDictionary *) fDigits->At(recoDet))->SetNdet(det); + return (AliTRDarrayDictionary *) fDict[i]->At(recoDet); } //_____________________________________________________________________________ -Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *digit) const +Int_t AliTRDdigitsManager::GetTrack(Int_t track, const AliTRDdigit * const digit) const { // // Returns the MC-track numbers from the dictionary for a given digit @@ -633,7 +651,9 @@ AliTRDSignalIndex *AliTRDdigitsManager::GetIndexes(Int_t det) // Returns indexes of active pads // - return (AliTRDSignalIndex *) fSignalIndexes->At(det); + Int_t recoDet = fRawRec ? 0 : det; + + return (AliTRDSignalIndex *) fSignalIndexes->At(recoDet); } @@ -644,16 +664,18 @@ void AliTRDdigitsManager::RemoveDigits(Int_t det) // Clear memory at det for Digits // - if (fDigits->At(det)) + Int_t recoDet = fRawRec ? 0 : det; + + if (fDigits->At(recoDet)) { if (fHasSDigits) { - AliTRDarraySignal *arr = (AliTRDarraySignal *) fDigits->RemoveAt(det); + AliTRDarraySignal *arr = (AliTRDarraySignal *) fDigits->RemoveAt(recoDet); delete arr; } else { - AliTRDarrayADC *arr = (AliTRDarrayADC *) fDigits->RemoveAt(det); + AliTRDarrayADC *arr = (AliTRDarrayADC *) fDigits->RemoveAt(recoDet); delete arr; } } @@ -667,6 +689,8 @@ void AliTRDdigitsManager::RemoveDictionaries(Int_t det) // Clear memory // + Int_t recoDet = fRawRec ? 0 : det; + if (fUseDictionaries == kFALSE) { return; @@ -674,23 +698,42 @@ void AliTRDdigitsManager::RemoveDictionaries(Int_t det) for (Int_t i = 0; i < kNDict; i++) { - if (fDict[i]->At(det)) + if (fDict[i]->At(recoDet)) { - AliTRDarrayDictionary *arr = (AliTRDarrayDictionary *) fDict[i]->RemoveAt(det); + AliTRDarrayDictionary *arr = (AliTRDarrayDictionary *) fDict[i]->RemoveAt(recoDet); delete arr; } } } +//_____________________________________________________________________________ +void AliTRDdigitsManager::RemoveIndexes(Int_t det) +{ + // + // Clear memory + // + + Int_t recoDet = fRawRec ? 0 : det; + + if (fSignalIndexes->At(recoDet)) + { + AliTRDSignalIndex *arr = (AliTRDSignalIndex *) fSignalIndexes->RemoveAt(recoDet); + delete arr; + } + +} + //_____________________________________________________________________________ void AliTRDdigitsManager::ClearIndexes(Int_t det) { // // Clear memory // + + Int_t recoDet = fRawRec ? 0 : det; - ((AliTRDSignalIndex *) fSignalIndexes->At(det))->ClearAll(); + ((AliTRDSignalIndex *) fSignalIndexes->At(recoDet))->ClearAll(); } @@ -717,7 +760,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(); @@ -742,7 +785,7 @@ Bool_t AliTRDdigitsManager::BuildIndexes(Int_t det) { for (Int_t it = 0; it < nTbins; it++) { - Int_t isig = digits->GetDataB(ir,ic,it); + Int_t isig = digits->GetDataBits(ir,ic,it); if (isig > 0) { indexes->AddIndexRC(ir,ic); @@ -762,58 +805,52 @@ Bool_t AliTRDdigitsManager::BuildIndexes(Int_t det) } //_____________________________________________________________________________ -Bool_t AliTRDdigitsManager::LoadArray(TObjArray *object - , const Char_t *branchname - , TTree *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 < AliTRDgeometry::Ndet(); iDet++) + 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); } } @@ -822,63 +859,94 @@ Bool_t AliTRDdigitsManager::LoadArray(TObjArray *object } //________________________________________________________________________________________________ -Bool_t AliTRDdigitsManager::LoadArrayDict(TObjArray *object - , const Char_t *branchname - , TTree *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; - if (!fTreeD) + for (Int_t iDict = 0; iDict < kNDict; iDict++) + { + + // Get the branch + Char_t branchname[15]; + snprintf(branchname,15,"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 (!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 < AliTRDgeometry::Ndet(); 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 *array1 - , const Char_t *branchname - , TTree *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"); @@ -886,38 +954,38 @@ Bool_t AliTRDdigitsManager::StoreArray(TObjArray *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; } // Loop through all detectors and fill them into the tree Bool_t status = kTRUE; - for (Int_t iDet = 0; iDet < AliTRDgeometry::Ndet(); iDet++) + for (Int_t iDet = 0; iDet < fDets; iDet++) { 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(); } } @@ -926,18 +994,58 @@ Bool_t AliTRDdigitsManager::StoreArray(TObjArray *array1 } //_____________________________________________________________________________ -Bool_t AliTRDdigitsManager::StoreArrayDict(TObjArray *array3 - , const Char_t *branchname - , TTree *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]; + snprintf(branchname,15,"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) { @@ -946,27 +1054,23 @@ Bool_t AliTRDdigitsManager::StoreArrayDict(TObjArray *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 < AliTRDgeometry::Ndet(); 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; } +