#include "AliAlignObj.h"
#include "AliCDBEntry.h"
#include "AliCDBManager.h"
+#include "AliGRPManager.h"
#include "AliCDBStorage.h"
#include "AliCTPRawData.h"
#include "AliCentralTrigger.h"
fSetRunNumberFromDataCalled(kFALSE),
fEmbeddingFlag(kFALSE),
fLego(NULL),
+ fKey(0),
+ fUseVertexFromCDB(0),
+ fUseMagFieldFromGRP(0),
+ fGRPWriteLocation(Form("local://%s", gSystem->pwd())),
fQADetectors("ALL"),
fQATasks("ALL"),
fRunQA(kTRUE),
// Set CDB lock: from now on it is forbidden to reset the run number
// or the default storage or to activate any further storage!
- AliCDBManager::Instance()->SetLock(1);
+ ULong_t key = AliCDBManager::Instance()->SetLock(1);
+ if (key) fKey = key;
}
//_____________________________________________________________________________
//
// Initialize ALICE Simulation run
//
-
gAlice->Announce();
+ //
+ // If requested set the mag. field from the GRP entry.
+ // After this the field is loccked and cannot be changed by Config.C
+ if (fUseMagFieldFromGRP) {
+ AliGRPManager grpM;
+ grpM.ReadGRPEntry();
+ grpM.SetMagField();
+ AliInfo("Field is locked now. It cannot be changed in Config.C");
+ }
+//
+// Execute Config.C
gROOT->LoadMacro(fConfigFileName.Data());
gInterpreter->ProcessLine(gAlice->GetConfigFunction());
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 (fUseVertexFromCDB) {
+ Double_t vtxPos[3] = {0., 0., 0.};
+ Double_t vtxSig[3] = {0., 0., 0.};
+ AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD");
+ AliESDVertex* vertex = dynamic_cast<AliESDVertex*> (entry->GetObject());
+ if (vertex) {
+ vertex->GetXYZ(vtxPos);
+ vertex->GetSigmaXYZ(vtxSig);
+ AliInfo("Overwriting Config.C vertex settings !");
+ AliInfo(Form("Vertex position from OCDB entry: x = %13.3f, y = %13.3f, z = %13.3f (sigma = %13.3f)\n",
+ vtxPos[0], vtxPos[1], vtxPos[2], vtxSig[2]));
+
+ AliGenerator *gen = gAlice->GetMCApp()->Generator();
+ gen->SetOrigin(vtxPos[0], vtxPos[1], vtxPos[2]); // vertex position
+ gen->SetSigmaZ(vtxSig[2]);
+ }
+ }
+
if(AliCDBManager::Instance()->GetRun() >= 0) {
AliRunLoader::Instance()->SetRunNumber(AliCDBManager::Instance()->GetRun());
AliRunLoader::Instance()->SetNumberOfEventsPerRun(fNEvents);
}
AliRunLoader::Instance()->CdGAFile();
-
+
+
AliPDG::AddParticlesToPdgDataBase();
gMC->SetMagField(TGeoGlobalMagField::Instance()->GetField());
// Now store the entry in OCDB
AliCDBManager* man = AliCDBManager::Instance();
+
+ man->SetLock(0, fKey);
+
+ AliCDBStorage* sto = man->GetStorage(fGRPWriteLocation.Data());
+
AliCDBId id("GRP/GRP/Data", man->GetRun(), man->GetRun(), 1, 1);
AliCDBMetaData *metadata= new AliCDBMetaData();
metadata->SetResponsible("alice-off@cern.ch");
metadata->SetComment("Automatically produced GRP entry for Monte Carlo");
- man->Put(grpObj,id,metadata);
+ sto->Put(grpObj,id,metadata);
+ man->SetLock(1, fKey);
}
void SetWriteGRPEntry(Bool_t flag = kTRUE) { fWriteGRPEntry = flag; }
void WriteGRPEntry();
+ void UseVertexFromCDB() {fUseVertexFromCDB = kTRUE;}
+ void UseMagFieldFromGRP() {fUseMagFieldFromGRP = kTRUE;}
+ void SetGRPWriteLocation(char* loc) {fGRPWriteLocation = loc;}
private:
TObjArray fEventsPerFile; // number of events per file for given detectors and data types
TObjArray* fBkgrdFileNames; // names of background files for merging
- TObjArray* fAlignObjArray; // array with the alignment objects to be applied to the geometry
+ TObjArray* fAlignObjArray; // array with the alignment objects to be applied to the geometry
Bool_t fUseBkgrdVertex; // use vertex from background in case of merging
Bool_t fRegionOfInterest; // digitization in region of interest
TString fCDBUri; //! Uri of the default CDB storage
- TString fQARefUri; //! Uri of the default QA reference storage
- TObjArray fSpecCDBUri; //! Array with detector specific CDB storages
+ TString fQARefUri; //! Uri of the default QA reference storage
+ TObjArray fSpecCDBUri; //! Array with detector specific CDB storages
Int_t fRun; //! Run number, will be passed to CDB and gAlice!!
Int_t fSeed; //! Seed for random number generator
Bool_t fInitCDBCalled; //! flag to check if CDB storages are already initialized
Bool_t fInitRunNumberCalled; //! flag to check if run number is already initialized
Bool_t fSetRunNumberFromDataCalled; //! flag to check if run number is already loaded from run loader
- Bool_t fEmbeddingFlag; // Flag for embedding
- AliLego *fLego; //! Pointer to aliLego object if it exists
+ Bool_t fEmbeddingFlag; // Flag for embedding
+ AliLego *fLego; //! Pointer to aliLego object if it exists
+ // OCDB
+ ULong_t fKey; //! current CDB key
+ 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
//QA stuff
static const Int_t fgkNDetectors = 15 ; // number of detectors