Skip to content

Commit

Permalink
If fUseDetectorsFromGRP (default) is TRUE, only detectors in the GRP …
Browse files Browse the repository at this point in the history
…will be simulated
  • Loading branch information
shahor02 committed May 21, 2015
1 parent 5e89815 commit d220fbf
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 6 deletions.
1 change: 1 addition & 0 deletions STEER/STEER/AliModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
Expand Down
74 changes: 70 additions & 4 deletions STEER/STEER/AliSimulation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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.};
Expand Down Expand Up @@ -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;
Expand All @@ -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()));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}
}
10 changes: 8 additions & 2 deletions STEER/STEER/AliSimulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit d220fbf

Please sign in to comment.