// Author: F.Carminati
// Federico.Carminati@cern.ch
+#include <string.h>
+
#include <RVersion.h>
#include <TArrayI.h>
#include <TClonesArray.h>
// at InitGeometry().
//
- if(gAlice->IsRootGeometry()){ //load geometry either from CDB or from file
- if(gAlice->IsGeomFromCDB()){
+ if(AliSimulation::Instance()->IsGeometryFromFile()){ //load geometry either from CDB or from file
+ if(IsGeometryFromCDB()){
AliInfo("Loading geometry from CDB default storage");
AliCDBPath path("GRP","Geometry","Data");
AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
if (!gGeoManager) AliFatal("TGeoManager object not found in the specified CDB entry!");
}else{
// Load geometry
- const char *geomfilename = gAlice->GetGeometryFileName();
+ const char *geomfilename = AliSimulation::Instance()->GetGeometryFile();
if(gSystem->ExpandPathName(geomfilename)){
AliInfo(Form("Loading geometry from file:\n %40s",geomfilename));
TGeoManager::Import(geomfilename);
return;
}
}
+ gMC->SetRootGeometry();
}else{
// Create modules, materials, geometry
if (!gGeoManager) new TGeoManager("ALICE", "ALICE geometry");
//_______________________________________________________________________
Bool_t AliMC::MisalignGeometry()
{
-// Call misalignment code if AliSimulation object was defined.
-
- if(!gAlice->IsRootGeometry()){
- //Set alignable volumes for the whole geometry
- SetAllAlignableVolumes();
- }
- // Misalign geometry via AliSimulation instance
- if (!AliSimulation::Instance()) return kFALSE;
- AliGeomManager::SetGeometry(gGeoManager);
- if(!AliGeomManager::CheckSymNamesLUT("ALL"))
+ // Call misalignment code if AliSimulation object was defined.
+
+ if(!AliSimulation::Instance()->IsGeometryFromFile()){
+ //Set alignable volumes for the whole geometry
+ SetAllAlignableVolumes();
+ }
+ // Misalign geometry via AliSimulation instance
+ if (!AliSimulation::Instance()) return kFALSE;
+ AliGeomManager::SetGeometry(gGeoManager);
+ if(!AliGeomManager::CheckSymNamesLUT("ALL"))
AliFatal("Current loaded geometry differs in the definition of symbolic names!");
-
- return AliSimulation::Instance()->MisalignGeometry(AliRunLoader::Instance());
+
+ return AliSimulation::Instance()->MisalignGeometry(AliRunLoader::Instance());
}
//_______________________________________________________________________
AliInfo("Optical properties definition");
while((detector = dynamic_cast<AliModule*>(next()))) {
// Initialise detector geometry
- if(gAlice->IsRootGeometry()) detector->CreateMaterials();
+ if(AliSimulation::Instance()->IsGeometryFromFile()) detector->CreateMaterials();
// Initialise detector optical properties
detector->DefineOpticalProperties();
}
}
}
+//_______________________________________________________________________
+void AliMC::SetGeometryFromCDB()
+{
+ // Set the loading of geometry from cdb instead of creating it
+ // A default CDB storage needs to be set before this method is called
+ if(AliCDBManager::Instance()->IsDefaultStorageSet() &&
+ AliCDBManager::Instance()->GetRun() >= 0)
+ AliSimulation::Instance()->SetGeometryFile("*OCDB*");
+ else
+ AliError("Loading of geometry from CDB ignored. First set a default CDB storage!");
+}
+
+//_______________________________________________________________________
+Bool_t AliMC::IsGeometryFromCDB() const
+{
+ return (strcmp(AliSimulation::Instance()->GetGeometryFile(),"*OCDB*")==0);
+}
+
//_______________________________________________________________________
void AliMC::SetAllAlignableVolumes()
{
const Int_t kncuts=10;
- const Int_t knflags=11;
+ const Int_t knflags=12;
const Int_t knpars=kncuts+knflags;
const char kpars[knpars][7] = {"CUTGAM" ,"CUTELE","CUTNEU","CUTHAD","CUTMUO",
"BCUTE","BCUTM","DCUTE","DCUTM","PPCUTM","ANNI",
"BREM","COMP","DCAY","DRAY","HADR","LOSS",
- "MULS","PAIR","PHOT","RAYL"};
+ "MULS","PAIR","PHOT","RAYL","STRA"};
char line[256];
char detName[7];
char* filtmp;
for(i=0;i<kncuts;i++) cut[i]=-99;
for(i=0;i<knflags;i++) flag[i]=-99;
itmed=0;
- for(i=0;i<256;i++) line[i]='\0';
+ memset(line,0,256);
// Read up to the end of line excluded
- iret=fscanf(lun,"%[^\n]",line);
+ iret=fscanf(lun,"%255[^\n]",line);
if(iret<0) {
//End of file
fclose(lun);
if(!iret) continue;
if(line[0]=='*') continue;
// Read the numbers
- iret=sscanf(line,"%s %d %f %f %f %f %f %f %f %f %f %f %d %d %d %d %d %d %d %d %d %d %d",
+ iret=sscanf(line,"%s %d %f %f %f %f %f %f %f %f %f %f %d %d %d %d %d %d %d %d %d %d %d %d",
detName,&itmed,&cut[0],&cut[1],&cut[2],&cut[3],&cut[4],&cut[5],&cut[6],&cut[7],&cut[8],
&cut[9],&flag[0],&flag[1],&flag[2],&flag[3],&flag[4],&flag[5],&flag[6],&flag[7],
- &flag[8],&flag[9],&flag[10]);
+ &flag[8],&flag[9],&flag[10],&flag[11]);
if(!iret) continue;
if(iret<0) {
//reading error
// Add a hit to detector id
//
TObjArray &dets = *gAlice->Modules();
- if(dets[id]) dynamic_cast<AliModule*>(dets[id])->AddHit(track,vol,hits);
+ if(dets[id]) static_cast<AliModule*>(dets[id])->AddHit(track,vol,hits);
}
//_______________________________________________________________________
// Add digit to detector id
//
TObjArray &dets = *gAlice->Modules();
- if(dets[id]) dynamic_cast<AliModule*>(dets[id])->AddDigit(tracks,digits);
+ if(dets[id]) static_cast<AliModule*>(dets[id])->AddDigit(tracks,digits);
}
//_______________________________________________________________________
}
//_______________________________________________________________________
-void AliMC::RemapTrackReferencesIDs(Int_t *map)
+void AliMC::RemapTrackReferencesIDs(const Int_t *map)
{
//
// Remapping track reference
fTmpFileTR = new TFile("TrackRefsTmp.root", "recreate");
fTmpTreeTR = new TTree("TreeTR", "Track References");
TClonesArray* pRef = &fTmpTrackReferences;
- fTmpTreeTR->Branch("TrackReferences", "TClonesArray", &pRef, 4000);
+ fTmpTreeTR->Branch("TrackReferences", &pRef, 4000);
}
//_______________________________________________________________________
AliDebug(1, "fRunLoader->MakeTrackRefsContainer()");
rl->MakeTrackRefsContainer();
TTree * treeTR = rl->TreeTR();
- if (treeTR){
// make branch for central track references
- TBranch *branch;
TClonesArray* pRef = &fTrackReferences;
- branch = treeTR->Branch("TrackReferences", &pRef);
- branch->SetAddress(&pRef);
- }
+ treeTR->Branch("TrackReferences", &pRef);
AliStack* stack = rl->Stack();
Int_t np = stack->GetNprimary();