From d220fbfc5eb9d09319e9fd9948c1305d76a7817a Mon Sep 17 00:00:00 2001 From: shahoian Date: Thu, 21 May 2015 18:18:54 +0200 Subject: [PATCH] If fUseDetectorsFromGRP (default) is TRUE, only detectors in the GRP will be simulated --- STEER/STEER/AliModule.h | 1 + STEER/STEER/AliSimulation.cxx | 74 +++++++++++++++++++++++++++++++++-- STEER/STEER/AliSimulation.h | 10 ++++- 3 files changed, 79 insertions(+), 6 deletions(-) diff --git a/STEER/STEER/AliModule.h b/STEER/STEER/AliModule.h index adccc8c32cd..9abebeb7804 100644 --- a/STEER/STEER/AliModule.h +++ b/STEER/STEER/AliModule.h @@ -52,6 +52,7 @@ class AliModule : public TNamed { virtual Int_t GetIshunt() const {return 0;} virtual void SetIshunt(Int_t) {} virtual Bool_t IsActive() const {return fActive;} + virtual void SetActive(Bool_t v=kTRUE) {fActive = v;} virtual Bool_t IsFolder() const {return kTRUE;} virtual Int_t& LoMedium() {return fLoMedium;} virtual Int_t& HiMedium() {return fHiMedium;} diff --git a/STEER/STEER/AliSimulation.cxx b/STEER/STEER/AliSimulation.cxx index b5cc751a05c..1a0688addee 100644 --- a/STEER/STEER/AliSimulation.cxx +++ b/STEER/STEER/AliSimulation.cxx @@ -214,6 +214,7 @@ AliSimulation::AliSimulation(const char* configFileName, fUseVertexFromCDB(0), fUseMagFieldFromGRP(0), fGRPWriteLocation(Form("local://%s", gSystem->pwd())), + fUseDetectorsFromGRP(kTRUE), fUseTimeStampFromCDB(0), fTimeStart(0), fTimeEnd(0), @@ -991,6 +992,12 @@ Bool_t AliSimulation::RunTrigger(const char* config, const char* detectors) if (!aCTP->LoadConfiguration( trconfiguration )) return kFALSE; + TObjArray* detArray = runLoader->GetAliRun()->Detectors(); + if (fUseDetectorsFromGRP) { + AliInfo("Will run only for detectors seen in the GRP"); + DeactivateDetectorsAbsentInGRP(detArray); + } + // digits -> trigger if( !aCTP->RunTrigger( runLoader , detectors ) ) { if (fStopOnError) { @@ -1073,9 +1080,9 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents) } AliSysInfo::AddStamp("RunSimulation_Config"); -// -// If requested obtain the vertex position and vertex sigma_z from the CDB -// This overwrites the settings from the Config.C + // + // If requested obtain the vertex position and vertex sigma_z from the CDB + // This overwrites the settings from the Config.C if (fUseVertexFromCDB) { Double_t vtxPos[3] = {0., 0., 0.}; Double_t vtxSig[3] = {0., 0., 0.}; @@ -1171,6 +1178,7 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents) // in the geometry loaded by AliGeomManager TString detsToBeChecked = ""; TObjArray* detArray = runLoader->GetAliRun()->Detectors(); + // for (Int_t iDet = 0; iDet < detArray->GetEntriesFast(); iDet++) { AliModule* det = (AliModule*) detArray->At(iDet); if (!det || !det->IsActive()) continue; @@ -1191,6 +1199,7 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents) // } // SetGAliceFile(runLoader->GetFileName()); + if (!gAlice->GetMCApp()->Generator()) { AliError(Form("gAlice has no generator object. " "Check your config file: %s", fConfigFileName.Data())); @@ -1250,6 +1259,16 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents) AliInfo("running gAlice"); AliSysInfo::AddStamp("Start_ProcessRun"); + + + if (fUseDetectorsFromGRP) { + TObjArray* detArr = runLoader->GetAliRun()->Detectors(); + AliInfo("Will run only for detectors seen in the GRP"); + DeactivateDetectorsAbsentInGRP(detArr); + } + // + + // Create the Root Tree with one branch per detector //Hits moved to begin event -> now we are crating separate tree for each event TVirtualMC::GetMC()->ProcessRun(nEvents); @@ -1346,9 +1365,15 @@ Bool_t AliSimulation::RunSDigitization(const char* detectors) AliRunLoader* runLoader = LoadRun(); if (!runLoader) return kFALSE; - + // TString detStr = detectors; TObjArray* detArray = runLoader->GetAliRun()->Detectors(); + // + if (fUseDetectorsFromGRP) { + AliInfo("Will run only for detectors seen in the GRP"); + DeactivateDetectorsAbsentInGRP(detArray); + } + // for (Int_t iDet = 0; iDet < detArray->GetEntriesFast(); iDet++) { AliModule* det = (AliModule*) detArray->At(iDet); if (!det || !det->IsActive()) continue; @@ -1410,6 +1435,12 @@ Bool_t AliSimulation::RunDigitization(const char* detectors, } AliRunLoader* runLoader = AliRunLoader::GetRunLoader(digInp.GetInputStream(0)->GetFolderName()); TObjArray* detArray = runLoader->GetAliRun()->Detectors(); + // + if (fUseDetectorsFromGRP) { + AliInfo("Will run only for detectors seen in the GRP"); + DeactivateDetectorsAbsentInGRP(detArray); + } + // for (Int_t iDet = 0; iDet < detArray->GetEntriesFast(); iDet++) { AliModule* det = (AliModule*) detArray->At(iDet); if (!det || !det->IsActive()) continue; @@ -1466,6 +1497,12 @@ Bool_t AliSimulation::RunHitsDigitization(const char* detectors) TString detStr = detectors; TObjArray* detArray = runLoader->GetAliRun()->Detectors(); + // + if (fUseDetectorsFromGRP) { + AliInfo("Will run only for detectors seen in the GRP"); + DeactivateDetectorsAbsentInGRP(detArray); + } + // for (Int_t iDet = 0; iDet < detArray->GetEntriesFast(); iDet++) { AliModule* det = (AliModule*) detArray->At(iDet); if (!det || !det->IsActive()) continue; @@ -1606,6 +1643,12 @@ Bool_t AliSimulation::WriteRawFiles(const char* detectors) } TObjArray* detArray = runLoader->GetAliRun()->Detectors(); + // + if (fUseDetectorsFromGRP) { + AliInfo("Will run only for detectors seen in the GRP"); + DeactivateDetectorsAbsentInGRP(detArray); + } + // for (Int_t iDet = 0; iDet < detArray->GetEntriesFast(); iDet++) { AliModule* det = (AliModule*) detArray->At(iDet); if (!det || !det->IsActive()) continue; @@ -2048,6 +2091,10 @@ Int_t AliSimulation::ConvertRaw2SDigits(const char* rawDirectory, const char* es // // Get list of detectors TObjArray* detArray = runLoader->GetAliRun()->Detectors(); + if (fUseDetectorsFromGRP) { + AliInfo("Will run only for detectors seen in the GRP"); + DeactivateDetectorsAbsentInGRP(detArray); + } // // Get Header AliHeader* header = runLoader->GetHeader(); @@ -2597,3 +2644,22 @@ void AliSimulation::StoreUsedCDBMaps() const fGAliceFileName.Data())); // } + +//_____________________________________________________________________________ +void AliSimulation::DeactivateDetectorsAbsentInGRP(TObjArray* detArr) +{ + // avoid simulating detectors not fount in GRP + AliGRPManager grpm; + grpm.ReadGRPEntry(); + const AliGRPObject* grpData = grpm.GetGRPData(); + Int_t activeDetectors = grpData->GetDetectorMask(); + TString detStrGRP = AliDAQ::ListOfTriggeredDetectors(activeDetectors); + for (int idt=detArr->GetEntriesFast();idt--;) { + AliModule* det = (AliModule*)detArr->At(idt); + if (!det || !det->IsActive()) continue; + if (!detStrGRP.Contains(det->GetName())) { + AliInfoF("Detector %s is not in GRP, disabling",det->GetName()); + det->SetActive(kFALSE); + } + } +} diff --git a/STEER/STEER/AliSimulation.h b/STEER/STEER/AliSimulation.h index 9cf13ffab54..15e272484d8 100644 --- a/STEER/STEER/AliSimulation.h +++ b/STEER/STEER/AliSimulation.h @@ -114,6 +114,7 @@ class AliSimulation: public TNamed { virtual const Char_t* GetGeometryFile() const {return fGeometryFile.Data();} virtual Bool_t IsGeometryFromFile() const {return !fGeometryFile.IsNull();} + void DeactivateDetectorsAbsentInGRP(TObjArray* detArr); // HLT void SetRunHLT(const char* options) {fRunHLT=options;} @@ -144,7 +145,10 @@ class AliSimulation: public TNamed { void UseTimeStampFromCDB() {fUseTimeStampFromCDB = kTRUE;} time_t GenerateTimeStamp() const; - + // + Bool_t GetUseDetectorsFromGRP() const {return fUseDetectorsFromGRP;} + void SetUseDetectorsFromGRP(Bool_t v=kTRUE) {fUseDetectorsFromGRP = v;} + // private: AliSimulation(const AliSimulation&); // Not implemented @@ -202,6 +206,8 @@ class AliSimulation: public TNamed { Bool_t fUseVertexFromCDB; // Flag to use Vertex from CDB Bool_t fUseMagFieldFromGRP; // Use magnetic field settings from GRP TString fGRPWriteLocation; // Location to write the GRP entry from simulation + + Bool_t fUseDetectorsFromGRP; // do not simulate detectors absent in the GRP Bool_t fUseTimeStampFromCDB;// Flag to generate event time-stamps according to SOR/EOR from GRP time_t fTimeStart; // SOR time-stamp @@ -224,7 +230,7 @@ class AliSimulation: public TNamed { Bool_t fWriteGRPEntry; // Write or not GRP entry corresponding to the settings in Config.C - ClassDef(AliSimulation, 13) // class for running generation, simulation and digitization + ClassDef(AliSimulation, 14) // class for running generation, simulation and digitization }; #endif