#include "AliCDBManager.h"
#include "AliAlignObj.h"
#include "AliCentralTrigger.h"
-#include "AliDAQConfig.h"
+#include "AliDAQ.h"
#include "AliDigitizer.h"
#include "AliGenerator.h"
#include "AliLog.h"
#include "AliVertexGenFile.h"
#include "AliCentralTrigger.h"
#include "AliCTPRawData.h"
+#include "AliRawReaderFile.h"
+#include "AliESD.h"
+#include "AliHeader.h"
+#include "AliGenEventHeader.h"
ClassImp(AliSimulation)
fAlignObjArray(NULL),
fUseBkgrdVertex(kTRUE),
fRegionOfInterest(kFALSE),
- fCDBUri(cdbUri)
+ fCDBUri(cdbUri),
+ fSpecCDBUri(),
+ fEmbeddingFlag(kFALSE)
{
// create simulation object with default parameters
fAlignObjArray(NULL),
fUseBkgrdVertex(sim.fUseBkgrdVertex),
fRegionOfInterest(sim.fRegionOfInterest),
- fCDBUri(sim.fCDBUri)
+ fCDBUri(sim.fCDBUri),
+ fSpecCDBUri(),
+ fEmbeddingFlag(sim.fEmbeddingFlag)
{
// copy constructor
if (!sim.fBkgrdFileNames->At(i)) continue;
fBkgrdFileNames->Add(sim.fBkgrdFileNames->At(i)->Clone());
}
+
+ for (Int_t i = 0; i < sim.fSpecCDBUri.GetEntriesFast(); i++) {
+ if (sim.fSpecCDBUri[i]) fSpecCDBUri.Add(sim.fSpecCDBUri[i]->Clone());
+ }
+
}
//_____________________________________________________________________________
fBkgrdFileNames->Delete();
delete fBkgrdFileNames;
}
+
+ fSpecCDBUri.Delete();
}
}
//_____________________________________________________________________________
-void AliSimulation::InitCDBStorage(const char* uri)
+void AliSimulation::InitCDBStorage()
{
// activate a default CDB storage
// First check if we have any CDB storage set, because it is used
// to retrieve the calibration and alignment constants
AliCDBManager* man = AliCDBManager::Instance();
- if (!man->IsDefaultStorageSet())
+ if (man->IsDefaultStorageSet())
{
- AliWarningClass("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
- AliWarningClass("Default CDB storage not yet set");
- AliWarningClass(Form("Using default storage declared in AliSimulation: %s",uri));
- AliWarningClass("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
- SetDefaultStorage(uri);
- }
-
+ AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ AliWarning("Default CDB storage has been already set !");
+ AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data()));
+ AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ fCDBUri = "";
+ }
+ else {
+ AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ AliDebug(2, Form("Default CDB storage is set to: %s",fCDBUri.Data()));
+ AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ man->SetDefaultStorage(fCDBUri);
+ }
+
+ // Now activate the detector specific CDB storage locations
+ for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) {
+ TObject* obj = fSpecCDBUri[i];
+ if (!obj) continue;
+ AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle()));
+ AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ man->SetSpecificStorage(obj->GetName(), obj->GetTitle());
+ }
+ man->Print();
}
//_____________________________________________________________________________
void AliSimulation::SetDefaultStorage(const char* uri) {
-// activate a default CDB storage
+// Store the desired default CDB storage location
+// Activate it later within the Run() method
- AliCDBManager::Instance()->SetDefaultStorage(uri);
+ fCDBUri = uri;
}
//_____________________________________________________________________________
-void AliSimulation::SetSpecificStorage(const char* detName, const char* uri) {
-// activate a detector-specific CDB storage
+void AliSimulation::SetSpecificStorage(const char* calibType, const char* uri) {
+// Store a detector-specific CDB storage location
+// Activate it later within the Run() method
+
+ AliCDBPath aPath(calibType);
+ if(!aPath.IsValid()){
+ AliError(Form("Not a valid path: %s", calibType));
+ return;
+ }
- AliCDBManager::Instance()->SetSpecificStorage(detName, uri);
+ TObject* obj = fSpecCDBUri.FindObject(calibType);
+ if (obj) fSpecCDBUri.Remove(obj);
+ fSpecCDBUri.Add(new TNamed(calibType, uri));
}
}
if (AliDebugLevelClass() >= 1) {
- gGeoManager->GetTopNode()->CheckOverlaps(20);
+ gGeoManager->GetTopNode()->CheckOverlaps(1);
TObjArray* ovexlist = gGeoManager->GetListOfOverlaps();
if(ovexlist->GetEntriesFast()){
AliError("The application of alignment objects to the geometry caused huge overlaps/extrusions!");
// to the TGeo geometry passed as argument
//
- InitCDBStorage("local://$ALICE_ROOT");
AliCDBPath path(detName,"Align","Data");
AliCDBEntry* entry = AliCDBManager::Instance()->Get(path.GetPath(),runnum,version,sversion);
if ((detStr.CompareTo("ALL") == 0)) detStr = "";
dataNotLoaded += detStr;
- AliInfo(Form("Alignment data loaded for: %s",
+ if(!dataLoaded.IsNull()) AliInfo(Form("Alignment data loaded for: %s",
dataLoaded.Data()));
- AliInfo(Form("Didn't/couldn't load alignment data for: %s",
+ if(!dataNotLoaded.IsNull()) AliInfo(Form("Didn't/couldn't load alignment data for: %s",
dataNotLoaded.Data()));
} // fLoadAlignFromCDB flag
}
}
+
+ // Update the internal geometry of modules (ITS needs it)
+ TString detStr = fLoadAlignData;
+ 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;
+ if (IsSelected(det->GetName(), detStr)) {
+ det->UpdateInternalGeometry();
+ }
+ } // end loop over detectors
+
+
if (delRunLoader) delete runLoader;
return kTRUE;
fBkgrdFileNames->Add(fileNameStr);
}
+void AliSimulation::EmbedInto(const char* fileName, Int_t nSignalPerBkgrd)
+{
+// add a file with background events for embeddin
+ MergeWith(fileName, nSignalPerBkgrd);
+ fEmbeddingFlag = kTRUE;
+}
//_____________________________________________________________________________
Bool_t AliSimulation::Run(Int_t nEvents)
{
// run the generation, simulation and digitization
- InitCDBStorage(fCDBUri);
+ InitCDBStorage();
if (nEvents > 0) fNEvents = nEvents;
if (!gGeoManager) if (fStopOnError) return kFALSE;
if (!MisalignGeometry()) if (fStopOnError) return kFALSE;
}
-
+
// hits -> summable digits
if (!fMakeSDigits.IsNull()) {
if (!RunSDigitization(fMakeSDigits)) if (fStopOnError) return kFALSE;
}
}
- runLoader->MakeTree( "CT" );
+ runLoader->MakeTree( "GG" );
AliCentralTrigger* aCTP = runLoader->GetTrigger();
// Load Descriptors
aCTP->LoadDescriptor( des );
// }
MisalignGeometry(runLoader);
- // Temporary fix by A.Gheata
- // Could be removed with the next Root version (>5.11)
- if (gGeoManager) {
- TIter next(gGeoManager->GetListOfVolumes());
- TGeoVolume *vol;
- while ((vol = (TGeoVolume *)next())) {
- if (vol->GetVoxels()) {
- if (vol->GetVoxels()->NeedRebuild()) {
- vol->GetVoxels()->Voxelize();
- vol->FindOverlaps();
- }
- }
- }
- }
-
// Export (mis)aligned geometry
if (gGeoManager) gGeoManager->Export("misaligned_geometry.root");
if (fBkgrdFileNames) nStreams = fBkgrdFileNames->GetEntriesFast() + 1;
Int_t signalPerBkgrd = GetNSignalPerBkgrd();
AliRunDigitizer* manager = new AliRunDigitizer(nStreams, signalPerBkgrd);
+ // manager->SetEmbeddingFlag(fEmbeddingFlag);
manager->SetInputStream(0, fGAliceFileName.Data());
for (Int_t iStream = 1; iStream < nStreams; iStream++) {
const char* fileName = ((TObjString*)
if (IsSelected(det->GetName(), detStr) &&
!IsSelected(det->GetName(), detExcl)) {
AliDigitizer* digitizer = det->CreateDigitizer(manager);
+
if (!digitizer) {
AliError(Form("no digitizer for %s", det->GetName()));
if (fStopOnError) return kFALSE;
AliInfo(Form("converting raw data DDL files to DATE file %s", dateFileName));
char command[256];
- sprintf(command, "dateStream -D -o %s -# %d -C",
+ // Note the option -s. It is used in order to avoid
+ // the generation of SOR/EOR events.
+ sprintf(command, "dateStream -s -D -o %s -# %d -C",
dateFileName, runLoader->GetNumberOfEvents());
FILE* pipe = gSystem->OpenPipe(command, "w");
Int_t prevLDC = -1;
// loop over detectors and DDLs
- for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
- for (Int_t iDDL = 0; iDDL < kDetectorDDLs[iDet]; iDDL++) {
+ for (Int_t iDet = 0; iDet < AliDAQ::kNDetectors; iDet++) {
+ for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls(iDet); iDDL++) {
- Int_t ddlID = 0x100*iDet + iDDL;
+ Int_t ddlID = AliDAQ::DdlID(iDet,iDDL);
Int_t ldcID = Int_t(ldc + 0.0001);
- ldc += kDetectorLDCs[iDet] / kDetectorDDLs[iDet];
+ ldc += AliDAQ::NumberOfLdcs(iDet) / AliDAQ::NumberOfDdls(iDet);
char rawFileName[256];
- sprintf(rawFileName, "raw%d/%s_%d.ddl",
- iEvent, kDetectors[iDet], ddlID);
+ sprintf(rawFileName, "raw%d/%s",
+ iEvent, AliDAQ::DdlFileName(iDet,iDDL));
// check existence and size of raw data file
FILE* file = fopen(rawFileName, "rb");
// convert a DATE file to a root file with the program "alimdc"
// ALIMDC setup
- const Int_t kDBSize = 1000000000;
+ const Int_t kDBSize = 2000000000;
const Int_t kTagDBSize = 1000000000;
const Bool_t kFilter = kFALSE;
- const Int_t kCompression = 1;
+ const Int_t kCompression = 0;
char* path = gSystem->Which(gSystem->Getenv("PATH"), "alimdc");
if (!path) {
const char* rawDBFS[2] = { "/tmp/mdc1", "/tmp/mdc2" };
const char* tagDBFS = "/tmp/mdc1/tags";
- const char* runDBFS = "/tmp/mdc1/meta";
// User defined file system locations
if (gSystem->Getenv("ALIMDC_RAWDB1"))
rawDBFS[1] = gSystem->Getenv("ALIMDC_RAWDB2");
if (gSystem->Getenv("ALIMDC_TAGDB"))
tagDBFS = gSystem->Getenv("ALIMDC_TAGDB");
- if (gSystem->Getenv("ALIMDC_RUNDB"))
- runDBFS = gSystem->Getenv("ALIMDC_RUNDB");
gSystem->Exec(Form("rm -rf %s",rawDBFS[0]));
gSystem->Exec(Form("rm -rf %s",rawDBFS[1]));
gSystem->Exec(Form("rm -rf %s",tagDBFS));
- gSystem->Exec(Form("rm -rf %s",runDBFS));
gSystem->Exec(Form("mkdir %s",rawDBFS[0]));
gSystem->Exec(Form("mkdir %s",rawDBFS[1]));
gSystem->Exec(Form("mkdir %s",tagDBFS));
- gSystem->Exec(Form("mkdir %s",runDBFS));
Int_t result = gSystem->Exec(Form("alimdc %d %d %d %d %s",
kDBSize, kTagDBSize, kFilter, kCompression, dateFileName));
gSystem->Exec(Form("rm -rf %s",rawDBFS[0]));
gSystem->Exec(Form("rm -rf %s",rawDBFS[1]));
gSystem->Exec(Form("rm -rf %s",tagDBFS));
- gSystem->Exec(Form("rm -rf %s",runDBFS));
return (result == 0);
}
// get the number of signal events
if (nEvents <= 0) {
AliRunLoader* runLoader =
- AliRunLoader::Open(fGAliceFileName.Data(), "SIGNAL");
+ AliRunLoader::Open(fGAliceFileName.Data(), "SIGNAL");
if (!runLoader) return 1;
+
nEvents = runLoader->GetNumberOfEvents();
delete runLoader;
}
// get the number of background events
const char* fileName = ((TObjString*)
(fBkgrdFileNames->At(iBkgrdFile)))->GetName();
- AliRunLoader* runLoader =
+ AliRunLoader* runLoader =
AliRunLoader::Open(fileName, "BKGRD");
if (!runLoader) continue;
Int_t nBkgrdEvents = runLoader->GetNumberOfEvents();
delete runLoader;
-
+
// get or calculate the number of signal per background events
Int_t nSignalPerBkgrd = fBkgrdFileNames->At(iBkgrdFile)->GetUniqueID();
if (nSignalPerBkgrd <= 0) {
return result;
}
+
+Bool_t AliSimulation::ConvertRaw2SDigits(const char* rawDirectory, const char* esdFileName)
+{
+//
+// Steering routine to convert raw data in directory rawDirectory/ to fake SDigits.
+// These can be used for embedding of MC tracks into RAW data using the standard
+// merging procedure.
+//
+// If an ESD file is given the reconstructed vertex is taken from it and stored in the event header.
+//
+ if (!gAlice) {
+ AliError("no gAlice object. Restart aliroot and try again.");
+ return kFALSE;
+ }
+ if (gAlice->Modules()->GetEntries() > 0) {
+ AliError("gAlice was already run. Restart aliroot and try again.");
+ return kFALSE;
+ }
+
+ AliInfo(Form("initializing gAlice with config file %s",fConfigFileName.Data()));
+ StdoutToAliInfo(StderrToAliError(gAlice->Init(fConfigFileName.Data());););
+//
+// Initialize CDB
+ InitCDBStorage();
+ AliCDBManager* man = AliCDBManager::Instance();
+ man->SetRun(0); // Should this come from rawdata header ?
+
+ Int_t iDet;
+ //
+ // Get the runloader
+ AliRunLoader* runLoader = gAlice->GetRunLoader();
+ //
+ // Open esd file if available
+ TFile* esdFile = TFile::Open(esdFileName);
+ Bool_t esdOK = (esdFile != 0);
+ AliESD* esd = new AliESD;
+ TTree* treeESD = 0;
+ if (esdOK) {
+ treeESD = (TTree*) esdFile->Get("esdTree");
+ if (!treeESD) {
+ AliWarning("No ESD tree found");
+ esdOK = kFALSE;
+ } else {
+ treeESD->SetBranchAddress("ESD", &esd);
+ }
+ }
+ //
+ // Create the RawReader
+ AliRawReaderFile* rawReader = new AliRawReaderFile(rawDirectory);
+ //
+ // Get list of detectors
+ TObjArray* detArray = runLoader->GetAliRun()->Detectors();
+ //
+ // Get Header
+ AliHeader* header = runLoader->GetHeader();
+ //
+ // Event loop
+ Int_t nev = 0;
+ while(kTRUE) {
+ if (!(rawReader->NextEvent())) break;
+ //
+ // Detector loop
+ for (iDet = 0; iDet < detArray->GetEntriesFast(); iDet++) {
+ AliModule* det = (AliModule*) detArray->At(iDet);
+ AliInfo(Form("Calling Raw2SDigits for %s\n", det->GetName()));
+ det->Raw2SDigits(rawReader);
+ rawReader->Reset();
+ } // detectors
+
+ //
+ // If ESD information available obtain reconstructed vertex and store in header.
+ if (esdOK) {
+ treeESD->GetEvent(nev);
+ const AliESDVertex* esdVertex = esd->GetPrimaryVertex();
+ Double_t position[3];
+ esdVertex->GetXYZ(position);
+ AliGenEventHeader* mcHeader = new AliGenEventHeader("ESD");
+ TArrayF mcV;
+ mcV.Set(3);
+ for (Int_t i = 0; i < 3; i++) mcV[i] = position[i];
+ mcHeader->SetPrimaryVertex(mcV);
+ header->Reset(0,nev);
+ header->SetGenEventHeader(mcHeader);
+ printf("***** Saved vertex %f %f %f \n", position[0], position[1], position[2]);
+ }
+ nev++;
+//
+// Finish the event
+ runLoader->TreeE()->Fill();
+ runLoader->SetNextEvent();
+ } // events
+
+ delete rawReader;
+//
+// Finish the run
+ runLoader->CdGAFile();
+ runLoader->WriteHeader("OVERWRITE");
+ runLoader->WriteRunLoader();
+
+ return kTRUE;
+}