From 95867fd1a1e4c0184dffddff44ad89b1058d7e62 Mon Sep 17 00:00:00 2001 From: cblume Date: Wed, 30 Aug 2006 17:15:20 +0000 Subject: [PATCH] Fix bug in digitization of multiple events --- TRD/AliTRD.cxx | 12 ++-- TRD/AliTRDcalibDB.cxx | 129 +++++++++++++++++++++------------------- TRD/AliTRDdigitizer.cxx | 80 ++++++++++++++++++++++--- TRD/AliTRDdigitizer.h | 1 + 4 files changed, 148 insertions(+), 74 deletions(-) diff --git a/TRD/AliTRD.cxx b/TRD/AliTRD.cxx index 31f200e8d7e..debb130ec72 100644 --- a/TRD/AliTRD.cxx +++ b/TRD/AliTRD.cxx @@ -171,10 +171,12 @@ void AliTRD::Hits2Digits() fLoader->LoadHits("read"); } fLoader->LoadDigits("recreate"); + AliRunLoader *runLoader = fLoader->GetRunLoader(); for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) { - digitizer.Open(runLoader->GetFileName().Data(),iEvent); + runLoader->GetEvent(iEvent); + digitizer.Open(runLoader,iEvent); digitizer.MakeDigits(); digitizer.WriteDigits(); } @@ -203,10 +205,12 @@ void AliTRD::Hits2SDigits() fLoader->LoadHits("read"); } fLoader->LoadSDigits("recreate"); - AliRunLoader* runLoader = fLoader->GetRunLoader(); + + AliRunLoader *runLoader = fLoader->GetRunLoader(); for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) { - digitizer.Open(runLoader->GetFileName().Data(),iEvent); + runLoader->GetEvent(iEvent); + digitizer.Open(runLoader,iEvent); digitizer.MakeDigits(); digitizer.WriteDigits(); } @@ -217,7 +221,7 @@ void AliTRD::Hits2SDigits() } //_____________________________________________________________________________ -AliDigitizer *AliTRD::CreateDigitizer(AliRunDigitizer* manager) const +AliDigitizer *AliTRD::CreateDigitizer(AliRunDigitizer *manager) const { // // Creates a new digitizer object diff --git a/TRD/AliTRDcalibDB.cxx b/TRD/AliTRDcalibDB.cxx index ddb16c1fb91..ee96ceaf420 100644 --- a/TRD/AliTRDcalibDB.cxx +++ b/TRD/AliTRDcalibDB.cxx @@ -113,7 +113,7 @@ AliTRDcalibDB::AliTRDcalibDB() // TODO invalid calibration data to be used. // - for (Int_t i=0; i from the CDB. // - AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun); + AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun); if (!entry) { AliError(Form("Failed to get entry: %s",cdbPath)); return 0; } - AliInfo(Form("AliTRDcalibDB: Retrieved object: %s",cdbPath)); + AliDebug(1,Form("AliTRDcalibDB: Retrieved object: %s",cdbPath)); return entry; } //_____________________________________________________________________________ -const TObject* AliTRDcalibDB::CacheCDBEntry(Int_t id, const char* cdbPath) +const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath) { // // Caches the entry with cdb path @@ -286,9 +286,11 @@ const TObject* AliTRDcalibDB::CacheCDBEntry(Int_t id, const char* cdbPath) if (!fCDBCache[id]) { fCDBEntries[id] = GetCDBEntry(cdbPath); - if (fCDBEntries[id]) + if (fCDBEntries[id]) { fCDBCache[id] = fCDBEntries[id]->GetObject(); + } } + return fCDBCache[id]; } @@ -306,6 +308,7 @@ void AliTRDcalibDB::SetRun(Long64_t run) } fRun = run; + Invalidate(); } @@ -317,10 +320,10 @@ void AliTRDcalibDB::Invalidate() // Invalidates cache (when run number is changed). // - for (Int_t i=0; iGetCacheFlag() == kFALSE) { - if (fCDBEntries[i]->IsOwner() == kFALSE && fCDBCache[i]) { + if ((fCDBEntries[i]->IsOwner() == kFALSE) && fCDBCache[i]) { delete fCDBCache[i]; } delete fCDBEntries[i]; @@ -339,24 +342,24 @@ Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row) // Returns the drift velocity for the given pad. // - const AliTRDCalPad* calPad = dynamic_cast + const AliTRDCalPad *calPad = dynamic_cast (GetCachedCDBObject(kIDVdriftPad)); if (!calPad) { return -1; } - AliTRDCalROC* roc = calPad->GetCalROC(det); + AliTRDCalROC *roc = calPad->GetCalROC(det); if (!roc) { return -1; } - const AliTRDCalDet* calChamber = dynamic_cast + const AliTRDCalDet *calChamber = dynamic_cast (GetCachedCDBObject(kIDVdriftChamber)); if (!calChamber) { return -1; } - return calChamber->GetValue(det) * roc->GetValue(col, row); + return calChamber->GetValue(det) * roc->GetValue(col,row); } @@ -367,7 +370,7 @@ Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det) // Returns the average drift velocity for the given detector // - const AliTRDCalDet* calDet = dynamic_cast + const AliTRDCalDet *calDet = dynamic_cast (GetCachedCDBObject(kIDVdriftChamber)); if (!calDet) { return -1; @@ -384,24 +387,24 @@ Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row) // Returns t0 for the given pad. // - const AliTRDCalPad* calPad = dynamic_cast + const AliTRDCalPad *calPad = dynamic_cast (GetCachedCDBObject(kIDT0Pad)); if (!calPad) { return -1; } - AliTRDCalROC* roc = calPad->GetCalROC(det); + AliTRDCalROC *roc = calPad->GetCalROC(det); if (!roc) { return -1; } - const AliTRDCalDet* calChamber = dynamic_cast + const AliTRDCalDet *calChamber = dynamic_cast (GetCachedCDBObject(kIDT0Chamber)); if (!calChamber) { return -1; } - return calChamber->GetValue(det) * roc->GetValue(col, row); + return calChamber->GetValue(det) * roc->GetValue(col,row); } @@ -412,7 +415,7 @@ Float_t AliTRDcalibDB::GetT0Average(Int_t det) // Returns the average t0 for the given detector // - const AliTRDCalDet* calDet = dynamic_cast + const AliTRDCalDet *calDet = dynamic_cast (GetCachedCDBObject(kIDT0Chamber)); if (!calDet) { return -1; @@ -429,23 +432,23 @@ Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row) // Returns the gain factor for the given pad. // - const AliTRDCalPad* calPad = dynamic_cast + const AliTRDCalPad *calPad = dynamic_cast (GetCachedCDBObject(kIDGainFactorPad)); if (!calPad) { return -1; } - AliTRDCalROC* roc = calPad->GetCalROC(det); + AliTRDCalROC *roc = calPad->GetCalROC(det); if (!roc) return -1; - const AliTRDCalDet* calChamber = dynamic_cast + const AliTRDCalDet *calChamber = dynamic_cast (GetCachedCDBObject(kIDGainFactorChamber)); if (!calChamber) { return -1; } - return calChamber->GetValue(det) * roc->GetValue(col, row); + return calChamber->GetValue(det) * roc->GetValue(col,row); } @@ -456,7 +459,7 @@ Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det) // Returns the average gain factor for the given detector // - const AliTRDCalDet* calDet = dynamic_cast + const AliTRDCalDet *calDet = dynamic_cast (GetCachedCDBObject(kIDGainFactorChamber)); if (!calDet) { return -1; @@ -473,18 +476,18 @@ Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row) // Returns the PRF width for the given pad. // - const AliTRDCalPad* calPad = dynamic_cast + const AliTRDCalPad *calPad = dynamic_cast (GetCachedCDBObject(kIDPRFWidth)); if (!calPad) { return -1; } - AliTRDCalROC* roc = calPad->GetCalROC(det); + AliTRDCalROC *roc = calPad->GetCalROC(det); if (!roc) { return -1; } - return roc->GetValue(col, row); + return roc->GetValue(col,row); } @@ -495,7 +498,7 @@ Float_t AliTRDcalibDB::GetSamplingFrequency() // Returns the sampling frequency of the TRD read-out. // - const AliTRDCalGlobals* calGlobal = dynamic_cast + const AliTRDCalGlobals *calGlobal = dynamic_cast (GetCachedCDBObject(kIDGlobals)); if (!calGlobal) { return -1; @@ -512,7 +515,7 @@ Int_t AliTRDcalibDB::GetNumberOfTimeBins() // Returns the number of time bins which are read-out. // - const AliTRDCalGlobals* calGlobal = dynamic_cast + const AliTRDCalGlobals *calGlobal = dynamic_cast (GetCachedCDBObject(kIDGlobals)); if (!calGlobal) { return -1; @@ -529,18 +532,18 @@ Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row) // Returns the status of the given pad // - const AliTRDCalPadStatus* cal = dynamic_cast + const AliTRDCalPadStatus *cal = dynamic_cast (GetCachedCDBObject(kIDPadStatus)); if (!cal) { return -1; } - const AliTRDCalSingleChamberStatus* roc = cal->GetCalROC(det); + const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det); if (!roc) { return -1; } - return roc->GetStatus(col, row); + return roc->GetStatus(col,row); } @@ -554,18 +557,18 @@ Char_t AliTRDcalibDB::GetMCMStatus(Int_t det, Int_t col, Int_t row) // To translate pad column number into MCM number Int_t mcm = ((Int_t) col / 18); - const AliTRDCalMCMStatus* cal = dynamic_cast + const AliTRDCalMCMStatus *cal = dynamic_cast (GetCachedCDBObject(kIDMCMStatus)); if (!cal) { return -1; } - const AliTRDCalSingleChamberStatus* roc = cal->GetCalROC(det); + const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det); if (!roc) { return -1; } - return roc->GetStatus(mcm, row); + return roc->GetStatus(mcm,row); } @@ -576,7 +579,7 @@ Char_t AliTRDcalibDB::GetChamberStatus(Int_t det) // Returns the status of the given chamber // - const AliTRDCalChamberStatus* cal = dynamic_cast + const AliTRDCalChamberStatus *cal = dynamic_cast (GetCachedCDBObject(kIDChamberStatus)); if (!cal) { return -1; @@ -593,7 +596,7 @@ Char_t AliTRDcalibDB::GetSuperModuleStatus(Int_t sm) // Returns the status of the given chamber // - const AliTRDCalSuperModuleStatus* cal = dynamic_cast + const AliTRDCalSuperModuleStatus *cal = dynamic_cast (GetCachedCDBObject(kIDSuperModuleStatus)); if (!cal) { return -1; @@ -610,13 +613,13 @@ Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row) // Returns status, see name of functions for details ;-) // - const AliTRDCalPadStatus* cal = dynamic_cast - (GetCachedCDBObject(kIDPadStatus)); + const AliTRDCalPadStatus *cal = dynamic_cast + (GetCachedCDBObject(kIDPadStatus)); if (!cal) { return -1; } - return cal->IsMasked(det, col, row); + return cal->IsMasked(det,col,row); } @@ -627,13 +630,13 @@ Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row) // Returns status, see name of functions for details ;-) // - const AliTRDCalPadStatus* cal = dynamic_cast - (GetCachedCDBObject(kIDPadStatus)); + const AliTRDCalPadStatus *cal = dynamic_cast + (GetCachedCDBObject(kIDPadStatus)); if (!cal) { return -1; } - return cal->IsBridgedLeft(det, col, row); + return cal->IsBridgedLeft(det,col,row); } @@ -644,13 +647,13 @@ Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row) // Returns status, see name of functions for details ;-) // - const AliTRDCalPadStatus* cal = dynamic_cast - (GetCachedCDBObject(kIDPadStatus)); + const AliTRDCalPadStatus * cal = dynamic_cast + (GetCachedCDBObject(kIDPadStatus)); if (!cal) { return -1; } - return cal->IsBridgedRight(det, col, row); + return cal->IsBridgedRight(det,col,row); } @@ -661,13 +664,13 @@ Bool_t AliTRDcalibDB::IsMCMMasked(Int_t det, Int_t col, Int_t row) // Returns status, see name of functions for details ;-) // - const AliTRDCalMCMStatus* cal = dynamic_cast - (GetCachedCDBObject(kIDMCMStatus)); + const AliTRDCalMCMStatus * cal = dynamic_cast + (GetCachedCDBObject(kIDMCMStatus)); if (!cal) { return -1; } - return cal->IsMasked(det, col, row); + return cal->IsMasked(det,col,row); } @@ -678,8 +681,8 @@ Bool_t AliTRDcalibDB::IsChamberInstalled(Int_t det) // Returns status, see name of functions for details ;-) // - const AliTRDCalChamberStatus* cal = dynamic_cast - (GetCachedCDBObject(kIDChamberStatus)); + const AliTRDCalChamberStatus * cal = dynamic_cast + (GetCachedCDBObject(kIDChamberStatus)); if (!cal) { return -1; } @@ -695,8 +698,8 @@ Bool_t AliTRDcalibDB::IsChamberMasked(Int_t det) // Returns status, see name of functions for details ;-) // - const AliTRDCalChamberStatus* cal = dynamic_cast - (GetCachedCDBObject(kIDChamberStatus)); + const AliTRDCalChamberStatus * cal = dynamic_cast + (GetCachedCDBObject(kIDChamberStatus)); if (!cal) { return -1; } @@ -712,8 +715,8 @@ Bool_t AliTRDcalibDB::IsSuperModuleInstalled(Int_t det) // Returns status, see name of functions for details ;-) // - const AliTRDCalSuperModuleStatus* cal = dynamic_cast - (GetCachedCDBObject(kIDSuperModuleStatus)); + const AliTRDCalSuperModuleStatus * cal = dynamic_cast + (GetCachedCDBObject(kIDSuperModuleStatus)); if (!cal) { return -1; } @@ -729,8 +732,8 @@ Bool_t AliTRDcalibDB::IsSuperModuleMasked(Int_t det) // Returns status, see name of functions for details ;-) // - const AliTRDCalSuperModuleStatus* cal = dynamic_cast - (GetCachedCDBObject(kIDSuperModuleStatus)); + const AliTRDCalSuperModuleStatus * cal = dynamic_cast + (GetCachedCDBObject(kIDSuperModuleStatus)); if (!cal) { return -1; } @@ -746,7 +749,7 @@ const AliTRDCalPIDLQ* AliTRDcalibDB::GetPIDLQObject() // Returns the object storing the distributions for PID with likelihood // - return dynamic_cast (GetCachedCDBObject(kIDPIDLQ)); + return dynamic_cast (GetCachedCDBObject(kIDPIDLQ)); } @@ -757,7 +760,7 @@ const AliTRDCalMonitoring* AliTRDcalibDB::GetMonitoringObject() // Returns the object storing the monitoring data // - return dynamic_cast (GetCachedCDBObject(kIDMonitoringData)); + return dynamic_cast (GetCachedCDBObject(kIDMonitoringData)); } @@ -773,9 +776,11 @@ Float_t AliTRDcalibDB::GetOmegaTau(Float_t vdrift) // However, currently it is in use by simulation and reconstruction. // - AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance(); - if (!commonParam) + AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance(); + if (!commonParam) { return -1; + } + Float_t fieldAbs = TMath::Abs(commonParam->GetField()); Float_t fieldSgn = 1.0; if (fieldAbs > 0.0) { diff --git a/TRD/AliTRDdigitizer.cxx b/TRD/AliTRDdigitizer.cxx index c2d4560092a..b6910798c98 100644 --- a/TRD/AliTRDdigitizer.cxx +++ b/TRD/AliTRDdigitizer.cxx @@ -370,11 +370,11 @@ void AliTRDdigitizer::Copy(TObject &d) const // Do not copy timestructs, just invalidate lastvdrift. // Next time they are requested, they get recalculated if (target.fTimeStruct1) { - delete[] target.fTimeStruct1; + delete [] target.fTimeStruct1; target.fTimeStruct1 = 0; } if (target.fTimeStruct2) { - delete[] target.fTimeStruct2; + delete [] target.fTimeStruct2; target.fTimeStruct2 = 0; } target.fTimeLastVdrift = -1; @@ -424,12 +424,13 @@ void AliTRDdigitizer::Exec(Option_t *option) // Initialization // - AliRunLoader* orl = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); + AliRunLoader *orl = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); + if (InitDetector()) { - AliLoader* ogime = orl->GetLoader("TRDLoader"); + AliLoader *ogime = orl->GetLoader("TRDLoader"); - TTree* tree = 0; + TTree *tree = 0; if (fSDigits) { // If we produce SDigits tree = ogime->TreeS(); @@ -522,8 +523,8 @@ Bool_t AliTRDdigitizer::Open(const Char_t *file, Int_t nEvent) fRunLoader = AliRunLoader::Open(file,evfoldname,"UPDATE"); } if (!fRunLoader) { - AliError(Form("Can not open session for file %s.",file)); - return kFALSE; + AliError(Form("Can not open session for file %s.",file)); + return kFALSE; } if (!fRunLoader->GetAliRun()) { @@ -559,6 +560,69 @@ Bool_t AliTRDdigitizer::Open(const Char_t *file, Int_t nEvent) } else { // If we produce Digits + tree = loader->TreeD(); + if (!tree) { + loader->MakeTree("D"); + tree = loader->TreeD(); + } + } + return MakeBranch(tree); + } + else { + return kFALSE; + } + +} + +//_____________________________________________________________________________ +Bool_t AliTRDdigitizer::Open(AliRunLoader *runLoader, Int_t nEvent) +{ + // + // Opens a ROOT-file with TRD-hits and reads in the hit-tree + // + // Connect the AliRoot file containing Geometry, Kine, and Hits + // + + fRunLoader = runLoader; + if (!fRunLoader) { + AliError("RunLoader does not exist"); + return kFALSE; + } + + if (!fRunLoader->GetAliRun()) { + fRunLoader->LoadgAlice(); + } + gAlice = fRunLoader->GetAliRun(); + + if (gAlice) { + AliDebug(1,"AliRun object found on file.\n"); + } + else { + AliError("Could not find AliRun object.\n"); + return kFALSE; + } + + fEvent = nEvent; + + AliLoader *loader = fRunLoader->GetLoader("TRDLoader"); + if (!loader) { + AliError("Can not get TRD loader from Run Loader"); + return kFALSE; + } + + if (InitDetector()) { + TTree *tree = 0; + if (fSDigits) { + // If we produce SDigits + tree = loader->TreeS(); + if (!tree) { + loader->MakeTree("S"); + tree = loader->TreeS(); + } + } + else { + // If we produce Digits + tree = loader->TreeD(); if (!tree) { loader->MakeTree("D"); tree = loader->TreeD(); @@ -614,7 +678,7 @@ Bool_t AliTRDdigitizer::InitDetector() } //_____________________________________________________________________________ -Bool_t AliTRDdigitizer::MakeBranch(TTree* tree) const +Bool_t AliTRDdigitizer::MakeBranch(TTree *tree) const { // // Create the branches for the digits array diff --git a/TRD/AliTRDdigitizer.h b/TRD/AliTRDdigitizer.h index 63479dcb13e..a5f40cdd705 100644 --- a/TRD/AliTRDdigitizer.h +++ b/TRD/AliTRDdigitizer.h @@ -40,6 +40,7 @@ class AliTRDdigitizer : public AliDigitizer { void InitOutput(Int_t iEvent); virtual void Exec(Option_t *option = 0); virtual Bool_t Open(const Char_t *file, Int_t nEvent = 0); + virtual Bool_t Open(AliRunLoader *runLoader, Int_t nEvent = 0); virtual Bool_t MakeBranch(TTree *tree) const; virtual Bool_t MakeDigits(); -- 2.43.5