#include "AliTrackPointArray.h"
#include "AliCDBManager.h"
+#include "AliCDBEntry.h"
+#include "AliAlignObj.h"
ClassImp(AliReconstruction)
fStopOnError(kFALSE),
fCheckPointLevel(0),
fOptions(),
+ fLoadAlignFromCDB(kTRUE),
+ fLoadAlignData("ALL"),
fRunLoader(NULL),
fRawReader(NULL),
fVertexer(NULL),
+ fAlignObjArray(NULL),
fWriteAlignmentData(kFALSE),
fCDBUri(cdbUri)
{
fTracker[iDet] = NULL;
}
AliPID pid;
- // Import TGeo geometry
- TString geom(gSystem->DirName(gAliceFilename));
- geom += "/geometry.root";
- TGeoManager::Import(geom.Data());
}
//_____________________________________________________________________________
fStopOnError(rec.fStopOnError),
fCheckPointLevel(0),
fOptions(),
+ fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
+ fLoadAlignData(rec.fLoadAlignData),
fRunLoader(NULL),
fRawReader(NULL),
fVertexer(NULL),
+ fAlignObjArray(rec.fAlignObjArray),
fWriteAlignmentData(rec.fWriteAlignmentData),
fCDBUri(rec.fCDBUri)
{
}
+//_____________________________________________________________________________
+Bool_t AliReconstruction::SetRunNumber()
+{
+ // The method is called in Run() in order
+ // to set a correct run number.
+ // In case of raw data reconstruction the
+ // run number is taken from the raw data header
+
+ if(AliCDBManager::Instance()->GetRun() < 0) {
+ if (!fRunLoader) {
+ AliError("No run loader is found !");
+ return kFALSE;
+ }
+ // read run number from gAlice
+ AliCDBManager::Instance()->SetRun(fRunLoader->GetAliRun()->GetRunNumber());
+ AliInfo(Form("Run number: %d",AliCDBManager::Instance()->GetRun()));
+ }
+ return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliReconstruction::ApplyAlignObjsToGeom(TObjArray* alObjArray)
+{
+ // Read collection of alignment objects (AliAlignObj derived) saved
+ // in the TClonesArray ClArrayName and apply them to the geometry
+ // manager singleton.
+ //
+ alObjArray->Sort();
+ Int_t nvols = alObjArray->GetEntriesFast();
+
+ for(Int_t j=0; j<nvols; j++)
+ {
+ AliAlignObj* alobj = (AliAlignObj*) alObjArray->UncheckedAt(j);
+ if (alobj->ApplyToGeometry() == kFALSE)
+ return kFALSE;
+ }
+
+ if (AliDebugLevelClass() >= 1) {
+ gGeoManager->CheckOverlaps(20);
+ TObjArray* ovexlist = gGeoManager->GetListOfOverlaps();
+ if(ovexlist->GetEntriesFast()){
+ AliError("The application of alignment objects to the geometry caused huge overlaps/extrusions!");
+ }
+ }
+
+ return kTRUE;
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliReconstruction::SetAlignObjArraySingleDet(const char* detName)
+{
+ // Fills array of single detector's alignable objects from CDB
+
+ AliDebug(2, Form("Loading alignment data for detector: %s",detName));
+
+ AliCDBEntry *entry;
+
+ AliCDBPath path(detName,"Align","Data");
+
+ entry=AliCDBManager::Instance()->Get(path.GetPath());
+ if(!entry){
+ AliDebug(2,Form("Couldn't load alignment data for detector %s",detName));
+ return kFALSE;
+ }
+ entry->SetOwner(1);
+ TClonesArray *alignArray = (TClonesArray*) entry->GetObject();
+ alignArray->SetOwner(0);
+ AliDebug(2,Form("Found %d alignment objects for %s",
+ alignArray->GetEntries(),detName));
+
+ AliAlignObj *alignObj=0;
+ TIter iter(alignArray);
+
+ // loop over align objects in detector
+ while( ( alignObj=(AliAlignObj *) iter.Next() ) ){
+ fAlignObjArray->Add(alignObj);
+ }
+ // delete entry --- Don't delete, it is cached!
+
+ AliDebug(2, Form("fAlignObjArray entries: %d",fAlignObjArray->GetEntries() ));
+ return kTRUE;
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
+{
+ // Read the alignment objects from CDB.
+ // Each detector is supposed to have the
+ // alignment objects in DET/Align/Data CDB path.
+ // All the detector objects are then collected,
+ // sorted by geometry level (starting from ALIC) and
+ // then applied to the TGeo geometry.
+ // Finally an overlaps check is performed.
+
+ // Load alignment data from CDB and fill fAlignObjArray
+ if(fLoadAlignFromCDB){
+ if(!fAlignObjArray) fAlignObjArray = new TObjArray();
+
+ //fAlignObjArray->RemoveAll();
+ fAlignObjArray->Clear();
+ fAlignObjArray->SetOwner(0);
+
+ TString detStr = detectors;
+ TString dataNotLoaded="";
+ TString dataLoaded="";
+
+ for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
+ if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
+ if(!SetAlignObjArraySingleDet(fgkDetectorName[iDet])){
+ dataNotLoaded += fgkDetectorName[iDet];
+ dataNotLoaded += " ";
+ } else {
+ dataLoaded += fgkDetectorName[iDet];
+ dataLoaded += " ";
+ }
+ } // end loop over detectors
+
+ if ((detStr.CompareTo("ALL") == 0)) detStr = "";
+ dataNotLoaded += detStr;
+ AliInfo(Form("Alignment data loaded for: %s",
+ dataLoaded.Data()));
+ AliInfo(Form("Didn't/couldn't load alignment data for: %s",
+ dataNotLoaded.Data()));
+ } // fLoadAlignFromCDB flag
+
+ // Check if the array with alignment objects was
+ // provided by the user. If yes, apply the objects
+ // to the present TGeo geometry
+ if (fAlignObjArray) {
+ if (gGeoManager && gGeoManager->IsClosed()) {
+ if (ApplyAlignObjsToGeom(fAlignObjArray) == kFALSE) {
+ AliError("The application of misalignment failed! Restart aliroot and try again. ");
+ return kFALSE;
+ }
+ }
+ else {
+ AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
+ return kFALSE;
+ }
+ }
+
+ return kTRUE;
+}
//_____________________________________________________________________________
void AliReconstruction::SetGAliceFile(const char* fileName)
// get the run loader
if (!InitRunLoader()) return kFALSE;
+ // Set run number in CDBManager (if it is not already set by the user)
+ if (!SetRunNumber()) if (fStopOnError) return kFALSE;
+
+ // Import ideal TGeo geometry and apply misalignment
+ if (!gGeoManager) {
+ TString geom(gSystem->DirName(fGAliceFileName));
+ geom += "/geometry.root";
+ TGeoManager::Import(geom.Data());
+ if (!gGeoManager) if (fStopOnError) return kFALSE;
+ }
+ if (!MisalignGeometry(fLoadAlignData)) if (fStopOnError) return kFALSE;
+
+ // 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();
+ }
+ }
+ }
+ }
+
// local reconstruction
if (!fRunLocalReconstruction.IsNull()) {
if (!RunLocalReconstruction(fRunLocalReconstruction)) {
SetRunLocalReconstruction(detectors);
SetRunTracking(detectors);
SetFillESD(detectors);};
+ void SetLoadAlignFromCDB(Bool_t load) {fLoadAlignFromCDB = load;};
+ void SetLoadAlignData(const char* detectors)
+ {fLoadAlignData = detectors;};
void SetUniformFieldTracking(){fUniformField=kTRUE;}
void SetNonuniformFieldTracking(){fUniformField=kFALSE;}
void SetDefaultStorage(const char* uri);
void SetSpecificStorage(const char* detName, const char* uri);
+ Bool_t SetRunNumber();
+
+ Bool_t SetAlignObjArraySingleDet(const char* detName);
+ Bool_t MisalignGeometry(const TString& detectors);
+
+ void SetAlignObjArray(TObjArray *array)
+ {fAlignObjArray = array;
+ fLoadAlignFromCDB = kFALSE;}
+ Bool_t ApplyAlignObjsToGeom(TObjArray* alObjArray);
+
virtual Bool_t Run(const char* input,
Int_t firstEvent, Int_t lastEvent = -1);
Bool_t Run(const char* input = NULL)
Bool_t fStopOnError; // stop or continue on errors
Int_t fCheckPointLevel; // level of ESD check points
TObjArray fOptions; // options for reconstructor objects
+ Bool_t fLoadAlignFromCDB; // Load alignment data from CDB and apply it to geometry or not
+ TString fLoadAlignData; // Load alignment data from CDB for these detectors
AliRunLoader* fRunLoader; //! current run loader object
AliRawReader* fRawReader; //! current raw data reader
AliVertexer* fVertexer; //! vertexer for ITS
AliTracker* fTracker[fgkNDetectors]; //! trackers
+ TObjArray* fAlignObjArray; // array with the alignment objects to be applied to the geometry
Bool_t fWriteAlignmentData; // write track space-points flag
TString fCDBUri; // Uri of the default CDB storage
TString str = name; gSystem->ExpandPathName(str);
return !gSystem->AccessPathName(str.Data(),mode);
}
-
-//_____________________________________________________________________________
-Bool_t AliRun::ApplyAlignObjsToGeom(TObjArray* AlObjArray)
-{
- // Read collection of alignment objects (AliAlignObj derived) saved
- // in the TClonesArray ClArrayName and apply them to the geometry
- // manager singleton.
- //
- AlObjArray->Sort();
- Int_t nvols = AlObjArray->GetEntriesFast();
-
- for(Int_t j=0; j<nvols; j++)
- {
- AliAlignObj* alobj = (AliAlignObj*) AlObjArray->UncheckedAt(j);
- if (alobj->ApplyToGeometry() == kFALSE)
- return kFALSE;
- }
-
- if (AliDebugLevelClass() >= 1) {
- gGeoManager->CheckOverlaps(20);
- TObjArray* ovexlist = gGeoManager->GetListOfOverlaps();
- if(ovexlist->GetEntriesFast()){
- AliErrorClass("The application of alignment objects to the geometry caused huge overlaps/extrusions!");
- }
- }
-
- return kTRUE;
-
-}
-
else ::Warning(method, "method is depricated\nPlease use: %s", replace);
}
- // Method to introduce the detector misliagnment
- // It is called by AliSimulation
- static Bool_t ApplyAlignObjsToGeom(TObjArray* AlObjArray);
-
protected:
virtual void Tree2Tree(Option_t *option, const char *detector=0);
Int_t fRun; //! Current run number
fEventsPerFile.Add(obj);
}
+//_____________________________________________________________________________
+Bool_t AliSimulation::ApplyAlignObjsToGeom(TObjArray* alObjArray)
+{
+ // Read collection of alignment objects (AliAlignObj derived) saved
+ // in the TClonesArray ClArrayName and apply them to the geometry
+ // manager singleton.
+ //
+ alObjArray->Sort();
+ Int_t nvols = alObjArray->GetEntriesFast();
+
+ for(Int_t j=0; j<nvols; j++)
+ {
+ AliAlignObj* alobj = (AliAlignObj*) alObjArray->UncheckedAt(j);
+ if (alobj->ApplyToGeometry() == kFALSE)
+ return kFALSE;
+ }
+
+ if (AliDebugLevelClass() >= 1) {
+ gGeoManager->CheckOverlaps(20);
+ TObjArray* ovexlist = gGeoManager->GetListOfOverlaps();
+ if(ovexlist->GetEntriesFast()){
+ AliError("The application of alignment objects to the geometry caused huge overlaps/extrusions!");
+ }
+ }
+
+ return kTRUE;
+
+}
+
//_____________________________________________________________________________
Bool_t AliSimulation::ApplyAlignObjsToGeom(const char* fileName, const char* clArrayName)
{
return kFALSE;
}
- return gAlice->ApplyAlignObjsToGeom(alObjArray);
+ return ApplyAlignObjsToGeom(alObjArray);
}
AliCDBEntry* entry = storage->Get(Id);
TClonesArray* AlObjArray = ((TClonesArray*) entry->GetObject());
- return gAlice->ApplyAlignObjsToGeom(AlObjArray);
+ return ApplyAlignObjsToGeom(AlObjArray);
}
if(!entry) return kFALSE;
TClonesArray* AlObjArray = ((TClonesArray*) entry->GetObject());
- return gAlice->ApplyAlignObjsToGeom(AlObjArray);
-}
-
-
-//_____________________________________________________________________________
-void AliSimulation::SetAlignObjArray(const char* detectors)
-{
- // Fills array of detectors' alignable objects from CDB
- // detectors can be "ALL" or "ITS TPC ..."
-
- AliRunLoader* runLoader = LoadRun();
- if (!runLoader) return;
-
- InitCDBStorage(fCDBUri);
-
- if(!fAlignObjArray) fAlignObjArray = new TObjArray();
- fAlignObjArray->SetOwner(0); // AliCDBEntry is owner of the align objects!
- fAlignObjArray->Clear();
-
- TString detStr = detectors;
- TObjArray* detArray = runLoader->GetAliRun()->Detectors();
- TString dataNotLoaded="";
- TString dataLoaded="";
-
- 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)) {
-
- if(!SetAlignObjArraySingleDet(det->GetName())){
- dataNotLoaded += det->GetName();
- dataNotLoaded += " ";
- } else {
- dataLoaded += det->GetName();
- dataLoaded += " ";
- }
- }
- } // end loop over all detectors
-
- if ((detStr.CompareTo("ALL") == 0)) detStr = "";
- dataNotLoaded += detStr;
- AliInfo(Form("Alignment data loaded for: %s",
- dataLoaded.Data()));
- AliInfo(Form("Didn't/couldn't load alignment data for: %s",
- dataNotLoaded.Data()));
-
- AliDebug(2, Form("fAlignObjArray entries: %d",fAlignObjArray->GetEntries() ));
- delete detArray;
-
+ return ApplyAlignObjsToGeom(AlObjArray);
}
//_____________________________________________________________________________
}
+//_____________________________________________________________________________
+Bool_t AliSimulation::MisalignGeometry(AliRunLoader *runLoader)
+{
+ // Read the alignment objects from CDB.
+ // Each detector is supposed to have the
+ // alignment objects in DET/Align/Data CDB path.
+ // All the detector objects are then collected,
+ // sorted by geometry level (starting from ALIC) and
+ // then applied to the TGeo geometry.
+ // Finally an overlaps check is performed.
+
+ Bool_t delRunLoader = kFALSE;
+ if (!runLoader) {
+ runLoader = LoadRun("READ");
+ if (!runLoader) return kFALSE;
+ delRunLoader = kTRUE;
+ }
+
+ // Load alignment data from CDB and fill fAlignObjArray
+ if(fLoadAlignFromCDB){
+ if(!fAlignObjArray) fAlignObjArray = new TObjArray();
+
+ //fAlignObjArray->RemoveAll();
+ fAlignObjArray->Clear();
+ fAlignObjArray->SetOwner(0);
+
+ TString detStr = fLoadAlignData;
+ TString dataNotLoaded="";
+ TString dataLoaded="";
+
+ 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)) {
+ if(!SetAlignObjArraySingleDet(det->GetName())){
+ dataNotLoaded += det->GetName();
+ dataNotLoaded += " ";
+ } else {
+ dataLoaded += det->GetName();
+ dataLoaded += " ";
+ }
+ }
+ } // end loop over detectors
+
+ if ((detStr.CompareTo("ALL") == 0)) detStr = "";
+ dataNotLoaded += detStr;
+ AliInfo(Form("Alignment data loaded for: %s",
+ dataLoaded.Data()));
+ AliInfo(Form("Didn't/couldn't load alignment data for: %s",
+ dataNotLoaded.Data()));
+ } // fLoadAlignFromCDB flag
+
+ // Check if the array with alignment objects was
+ // provided by the user. If yes, apply the objects
+ // to the present TGeo geometry
+ if (fAlignObjArray) {
+ if (gGeoManager && gGeoManager->IsClosed()) {
+ if (ApplyAlignObjsToGeom(fAlignObjArray) == kFALSE) {
+ AliError("The application of misalignment failed! Restart aliroot and try again. ");
+ return kFALSE;
+ }
+ }
+ else {
+ AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
+ return kFALSE;
+ }
+ }
+
+ if (delRunLoader) delete runLoader;
+
+ return kTRUE;
+}
+
+
+//_____________________________________________________________________________
+Bool_t AliSimulation::SetRunNumber()
+{
+ // Set the CDB manager run number
+ // The run number is retrieved from gAlice
+
+ if(AliCDBManager::Instance()->GetRun() < 0) {
+ AliRunLoader* runLoader = LoadRun("READ");
+ if (!runLoader) return kFALSE;
+ else {
+ AliCDBManager::Instance()->SetRun(runLoader->GetAliRun()->GetRunNumber());
+ AliInfo(Form("Run number: %d",AliCDBManager::Instance()->GetRun()));
+ delete runLoader;
+ }
+ }
+ return kTRUE;
+}
+
//_____________________________________________________________________________
void AliSimulation::MergeWith(const char* fileName, Int_t nSignalPerBkgrd)
{
if (!RunSimulation()) if (fStopOnError) return kFALSE;
}
+ // Set run number in CDBManager (if it is not already set in RunSimulation)
+ if (!SetRunNumber()) if (fStopOnError) return kFALSE;
+
+ // Load and misalign the geometry
+ if (!gGeoManager) {
+ TGeoManager::Import("geometry.root");
+ 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;
gAlice->Init(fConfigFileName.Data());
););
- // Set run number in CDBManager (here????)
+ // Set run number in CDBManager
AliCDBManager::Instance()->SetRun(gAlice->GetRunNumber());
AliInfo(Form("Run number: %d",AliCDBManager::Instance()->GetRun()));
// Export ideal geometry
if (gGeoManager) gGeoManager->Export("geometry.root");
- // Load alignment data from CDB and fill fAlignObjArray
- if(fLoadAlignFromCDB){
- if(!fAlignObjArray) fAlignObjArray = new TObjArray();
-
- //fAlignObjArray->RemoveAll();
- fAlignObjArray->Clear();
- fAlignObjArray->SetOwner(0);
-
- TString detStr = fLoadAlignData;
- TString dataNotLoaded="";
- TString dataLoaded="";
-
- 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)) {
- if(!SetAlignObjArraySingleDet(det->GetName())){
- dataNotLoaded += det->GetName();
- dataNotLoaded += " ";
- } else {
- dataLoaded += det->GetName();
- dataLoaded += " ";
- }
- }
- } // end loop over detectors
-
- if ((detStr.CompareTo("ALL") == 0)) detStr = "";
- dataNotLoaded += detStr;
- AliInfo(Form("Alignment data loaded for: %s",
- dataLoaded.Data()));
- AliInfo(Form("Didn't/couldn't load alignment data for: %s",
- dataNotLoaded.Data()));
- } // fLoadAlignFromCDB flag
-
- // Check if the array with alignment objects was
- // provided by the user. If yes, apply the objects
- // to the present TGeo geometry
- if (fAlignObjArray) {
- if (gGeoManager && gGeoManager->IsClosed()) {
- if (gAlice->ApplyAlignObjsToGeom(fAlignObjArray) == kFALSE) {
- AliError("The application of misalignment failed! Restart aliroot and try again. ");
- return kFALSE;
- }
- }
- else {
- AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
- return kFALSE;
- }
- }
-
- // Export (mis)aligned geometry
- if (gGeoManager) gGeoManager->Export("misaligned_geometry.root");
+ // Misalign geometry
+ if (!MisalignGeometry(runLoader)) return kFALSE;
// Temporary fix by A.Gheata
// Could be removed with the next Root version (>5.11)
}
}
+ // Export (mis)aligned geometry
+ if (gGeoManager) gGeoManager->Export("misaligned_geometry.root");
+
// AliRunLoader* runLoader = gAlice->GetRunLoader();
// if (!runLoader) {
// AliError(Form("gAlice has no run loader object. "
{fWriteRawData = detectors; fRawDataFileName = fileName;
fDeleteIntermediateFiles = deleteIntermediateFiles;};
- static Bool_t ApplyAlignObjsToGeom(const char* fileName,
- const char* clArrayName);
- static Bool_t ApplyAlignObjsToGeom(AliCDBParam* param,
- AliCDBId& Id);
- static Bool_t ApplyAlignObjsToGeom(const char* uri, const char* path,
- Int_t runnum, Int_t version,
- Int_t sversion);
- static Bool_t ApplyAlignObjsToGeom(const char* detName, Int_t runnum, Int_t version,
- Int_t sversion);
+ Bool_t ApplyAlignObjsToGeom(TObjArray* alObjArray);
+
+ Bool_t ApplyAlignObjsToGeom(const char* fileName,
+ const char* clArrayName);
+ Bool_t ApplyAlignObjsToGeom(AliCDBParam* param,
+ AliCDBId& Id);
+ Bool_t ApplyAlignObjsToGeom(const char* uri, const char* path,
+ Int_t runnum, Int_t version,
+ Int_t sversion);
+ Bool_t ApplyAlignObjsToGeom(const char* detName, Int_t runnum, Int_t version,
+ Int_t sversion);
void SetAlignObjArray(TObjArray *array)
- {fAlignObjArray = array;
- fLoadAlignFromCDB = kFALSE;}
+ {fAlignObjArray = array;
+ fLoadAlignFromCDB = kFALSE;}
- void SetAlignObjArray(const char* detectors="ALL");
Bool_t SetAlignObjArraySingleDet(const char* detName);
+
+ Bool_t MisalignGeometry(AliRunLoader *runLoader = NULL);
+
+ Bool_t SetRunNumber();
// CDB storage activation
static void InitCDBStorage(const char *uri);