#include "AliHeader.h"
#include "AliGenEventHeader.h"
#include "AliMC.h"
+#include "AliHLTSimulation.h"
+#include "AliQADataMakerSteer.h"
ClassImp(AliSimulation)
AliSimulation *AliSimulation::fgInstance = 0;
+const char* AliSimulation::fgkDetectorName[AliSimulation::fgkNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"};
//_____________________________________________________________________________
AliSimulation::AliSimulation(const char* configFileName, const char* cdbUri,
fCDBUri(cdbUri),
fRemoteCDBUri(""),
fSpecCDBUri(),
- fEmbeddingFlag(kFALSE)
+ fEmbeddingFlag(kFALSE),
+ fRunQA(kTRUE),
+ fRunHLT("default")
{
// create simulation object with default parameters
fgInstance = this;
SetGAliceFile("galice.root");
+
+// for QA
+ for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++)
+ fQACycles[iDet] = 999999;
}
//_____________________________________________________________________________
fCDBUri(sim.fCDBUri),
fRemoteCDBUri(sim.fRemoteCDBUri),
fSpecCDBUri(),
- fEmbeddingFlag(sim.fEmbeddingFlag)
+ fEmbeddingFlag(sim.fEmbeddingFlag),
+ fRunQA(kTRUE),
+ fRunHLT(sim.fRunHLT)
{
// copy constructor
if (sim.fSpecCDBUri[i]) fSpecCDBUri.Add(sim.fSpecCDBUri[i]->Clone());
}
fgInstance = this;
+
+// for QA
+ for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++)
+ fQACycles[iDet] = sim.fQACycles[iDet];
}
//_____________________________________________________________________________
// Remote storage (the Grid storage) is used if it is activated
// and if the object is not found in the default storage
- if (man->IsRemoteStorageSet())
- {
- AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
- AliWarning("Remote CDB storage has been already set !");
- AliWarning(Form("Ignoring the remote storage declared in AliSimulation: %s",fRemoteCDBUri.Data()));
- AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
- fRemoteCDBUri = "";
- }
- else {
- AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
- AliDebug(2, Form("Remote CDB storage is set to: %s",fRemoteCDBUri.Data()));
- AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
- man->SetRemoteStorage(fRemoteCDBUri);
- }
+ // OBSOLETE: Removed
+ // if (man->IsRemoteStorageSet())
+ // {
+ // AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ // AliWarning("Remote CDB storage has been already set !");
+ // AliWarning(Form("Ignoring the remote storage declared in AliSimulation: %s",fRemoteCDBUri.Data()));
+ // AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ // fRemoteCDBUri = "";
+ // }
+ // else {
+ // AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ // AliDebug(2, Form("Remote CDB storage is set to: %s",fRemoteCDBUri.Data()));
+ // AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ // man->SetRemoteStorage(fRemoteCDBUri);
+ // }
// Now activate the detector specific CDB storage locations
for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) {
{
// run the generation, simulation and digitization
- AliCodeTimerAuto("")
+
+ AliCodeTimerAuto("")
InitCDBStorage();
if (!RunSimulation()) if (fStopOnError) return kFALSE;
}
+ //QA
+ if (fRunQA)
+ if (!RunQA("ALL", AliQA::kHITS))
+ if (fStopOnError)
+ return kFALSE ;
+
// Set run number in CDBManager (if it is not already set in RunSimulation)
if (!SetRunNumber()) if (fStopOnError) return kFALSE;
// hits -> summable digits
if (!fMakeSDigits.IsNull()) {
if (!RunSDigitization(fMakeSDigits)) if (fStopOnError) return kFALSE;
+ //QA
+ if (fRunQA)
+ RunQA(fMakeSDigits, AliQA::kSDIGITS) ;
}
+
// summable digits -> digits
if (!fMakeDigits.IsNull()) {
if (!RunDigitization(fMakeDigits, fMakeDigitsFromHits)) {
if (fStopOnError) return kFALSE;
}
+ //QA
+ if (fRunQA)
+ if (!RunQA(fMakeDigits, AliQA::kDIGITS) )
+ if (fStopOnError)
+ return kFALSE ;
}
// hits -> digits
if (!RunHitsDigitization(fMakeDigitsFromHits)) {
if (fStopOnError) return kFALSE;
}
+ //QA
+ if (fRunQA)
+ if( !RunQA(fMakeDigitsFromHits, AliQA::kDIGITS) )
+ if (fStopOnError)
+ return kFALSE ;
+
}
// digits -> trigger
}
}
+ // run HLT simulation
+ if (!fRunHLT.IsNull()) {
+ if (!RunHLT()) {
+ if (fStopOnError) return kFALSE;
+ }
+ }
+
return kTRUE;
}
if (IsSelected(det->GetName(), detStr)) {
AliInfo(Form("creating summable digits for %s", det->GetName()));
AliCodeTimerAuto(Form("creating summable digits for %s", det->GetName()));
+
det->Hits2SDigits();
}
}
}
} // detectors
+
//
// If ESD information available obtain reconstructed vertex and store in header.
if (esdOK) {
return kTRUE;
}
+
+//_____________________________________________________________________________
+Int_t AliSimulation::GetDetIndex(const char* detector)
+{
+ // return the detector index corresponding to detector
+ Int_t index = -1 ;
+ for (index = 0; index < fgkNDetectors ; index++) {
+ if ( strcmp(detector, fgkDetectorName[index]) == 0 )
+ break ;
+ }
+ return index ;
+}
+
+//_____________________________________________________________________________
+Bool_t AliSimulation::RunHLT()
+{
+ // Run the HLT simulation
+ // HLT simulation is implemented in HLT/sim/AliHLTSimulation
+ // Disabled if fRunHLT is empty, default vaule is "default".
+ // AliSimulation::SetRunHLT can be used to set the options for HLT simulation
+ // The default simulation depends on the HLT component libraries and their
+ // corresponding agents which define components and chains to run. See
+ // http://web.ift.uib.no/~kjeks/doc/alice-hlt/
+ // http://web.ift.uib.no/~kjeks/doc/alice-hlt/classAliHLTModuleAgent.html
+ //
+ // The libraries to be loaded can be specified as an option.
+ // <pre>
+ // AliSimulation sim;
+ // sim.SetRunHLT("libAliHLTSample.so");
+ // </pre>
+ // will only load <tt>libAliHLTSample.so</tt>
+
+ // Other available options:
+ // \li loglevel=<i>level</i> <br>
+ // logging level for this processing
+ // \li alilog=off
+ // disable redirection of log messages to AliLog class
+ // \li config=<i>macro</i>
+ // configuration macro
+ // \li localrec=<i>configuration</i>
+ // comma separated list of configurations to be run during simulation
+
+ int iResult=0;
+ AliRunLoader* pRunLoader = LoadRun("READ");
+ if (!pRunLoader) return kFALSE;
+
+ // load the library dynamically
+ gSystem->Load(ALIHLTSIMULATION_LIBRARY);
+
+ // check for the library version
+ AliHLTSimulationGetLibraryVersion_t fctVersion=(AliHLTSimulationGetLibraryVersion_t)(gSystem->DynFindSymbol(ALIHLTSIMULATION_LIBRARY, ALIHLTSIMULATION_GET_LIBRARY_VERSION));
+ if (!fctVersion) {
+ AliError(Form("can not load library %s", ALIHLTSIMULATION_LIBRARY));
+ return kFALSE;
+ }
+ if (fctVersion()!= ALIHLTSIMULATION_LIBRARY_VERSION) {
+ AliError(Form("%s version does not match: compiled for version %d, loaded %d", ALIHLTSIMULATION_LIBRARY, ALIHLTSIMULATION_LIBRARY_VERSION, fctVersion()));
+ return kFALSE;
+ }
+
+ // print compile info
+ typedef void (*CompileInfo)( char*& date, char*& time);
+ CompileInfo fctInfo=(CompileInfo)gSystem->DynFindSymbol(ALIHLTSIMULATION_LIBRARY, "CompileInfo");
+ if (fctInfo) {
+ char* date="";
+ char* time="";
+ (*fctInfo)(date, time);
+ if (!date) date="unknown";
+ if (!time) time="unknown";
+ AliInfo(Form("%s build on %s (%s)", ALIHLTSIMULATION_LIBRARY, date, time));
+ } else {
+ AliInfo(Form("no build info available for %s", ALIHLTSIMULATION_LIBRARY));
+ }
+
+ // create instance of the HLT simulation
+ AliHLTSimulationCreateInstance_t fctCreate=(AliHLTSimulationCreateInstance_t)(gSystem->DynFindSymbol(ALIHLTSIMULATION_LIBRARY, ALIHLTSIMULATION_CREATE_INSTANCE));
+ AliHLTSimulation* pHLT=NULL;
+ if (fctCreate==NULL || (pHLT=(fctCreate()))==NULL) {
+ AliError(Form("can not create instance of HLT simulation (creator %p)", fctCreate));
+ return kFALSE;
+ }
+
+ // init the HLT simulation
+ if (fRunHLT.CompareTo("default")==0) fRunHLT="";
+ AliHLTSimulationInit_t fctInit=(AliHLTSimulationInit_t)(gSystem->DynFindSymbol(ALIHLTSIMULATION_LIBRARY, ALIHLTSIMULATION_INIT));
+ if (fctInit==NULL || (iResult=(fctInit(pHLT, pRunLoader, fRunHLT.Data())))<0) {
+ AliError(Form("can not init HLT simulation: error %d (init %p)", iResult, fctInit));
+ } else {
+ // run the HLT simulation
+ AliHLTSimulationRun_t fctRun=(AliHLTSimulationRun_t)(gSystem->DynFindSymbol(ALIHLTSIMULATION_LIBRARY, ALIHLTSIMULATION_RUN));
+ if (fctRun==NULL || (iResult=(fctRun(pHLT, pRunLoader)))<0) {
+ AliError(Form("can not run HLT simulation: error %d (run %p)", iResult, fctRun));
+ }
+ }
+
+ // delete the instance
+ AliHLTSimulationDeleteInstance_t fctDelete=(AliHLTSimulationDeleteInstance_t)(gSystem->DynFindSymbol(ALIHLTSIMULATION_LIBRARY, ALIHLTSIMULATION_DELETE_INSTANCE));
+ if (fctDelete==NULL || fctDelete(pHLT)<0) {
+ AliError(Form("can not delete instance of HLT simulation (creator %p)", fctDelete));
+ }
+ pHLT=NULL;
+
+ return iResult>=0?kTRUE:kFALSE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliSimulation::RunQA(const char* detectors, AliQA::TASKINDEX task)
+{
+// run the QA on summable digits pr digits
+
+ AliQADataMakerSteer qas ;
+ qas.Reset() ;
+ return qas.Run(task);
+}
+