0x0
};
+const char* AliGeomManager::fgkDetectorName[AliGeomManager::fgkNDetectors] = {"GRP","ITS","TPC","TRD","TOF","PHOS","HMPID","EMCAL","MUON","FMD","ZDC","PMD","T0","VZERO","ACORDE"};
+Int_t AliGeomManager::fgNalignable[fgkNDetectors] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+
TGeoManager* AliGeomManager::fgGeometry = 0x0;
//_____________________________________________________________________________
// Load geometry either from a file
// or from the corresponding CDB entry
+ if(fgGeometry->IsLocked()){
+ AliErrorClass("Cannot load a new geometry, the current one being locked. Setting internal geometry to null!!");
+ fgGeometry = NULL;
+ return;
+ }
+
fgGeometry = NULL;
if (geomFileName && (!gSystem->AccessPathName(geomFileName))) {
fgGeometry = TGeoManager::Import(geomFileName);
- AliInfoClass(Form("From now on using geometry from custom geometry file %s",geomFileName));
+ AliInfoClass(Form("From now on using geometry from custom geometry file \"%s\"",geomFileName));
}
if (!fgGeometry) {
fgGeometry = (TGeoManager*) entry->GetObject();
if (!fgGeometry) AliFatalClass("Couldn't find TGeoManager in the specified CDB entry!");
- AliInfoClass(Form("From now on using geometry from CDB base folder %s",
+ AliInfoClass(Form("From now on using geometry from CDB base folder \"%s\"",
AliCDBManager::Instance()->GetURI("Geometry/Align/Data")));
}
-
+ ResetPNEntriesLUT();
InitPNEntriesLUT();
+ InitNalignable();
}
//_____________________________________________________________________________
-void AliGeomManager::SetGeometry(TGeoManager *geom)
+void AliGeomManager::SetGeometry(TGeoManager * const geom)
{
// Load already active geometry
if (!geom) AliFatalClass("Pointer to the active geometry is 0x0!");
-
+ ResetPNEntriesLUT();
fgGeometry = geom;
InitPNEntriesLUT();
+ InitNalignable();
}
//_____________________________________________________________________________
// Checks the validity of the given voluid
//
ELayerID layId = VolUIDToLayerSafe(voluid);
- if(layId){
+ if(layId != AliGeomManager::kInvalidLayer){
Int_t mId = Int_t(voluid & 0x7ff);
if( mId>=0 && mId<LayerSize(layId)){
modId = mId;
// Loop over all alignable volumes and extract
// the corresponding alignment objects from
// the TGeo geometry
-
- if(fgAlignObjs[0]) return;
-
+ //
for (Int_t iLayer = kFirstLayer; iLayer < AliGeomManager::kLastLayer; iLayer++) {
- fgAlignObjs[iLayer-kFirstLayer] = new AliAlignObj*[LayerSize(iLayer)];
+ if (!fgAlignObjs[iLayer-kFirstLayer]) {
+ fgAlignObjs[iLayer-kFirstLayer] = new AliAlignObj*[LayerSize(iLayer)];
+ }
for (Int_t iModule = 0; iModule < LayerSize(iLayer); iModule++) {
UShort_t volid = LayerToVolUID(iLayer,iModule);
fgAlignObjs[iLayer-kFirstLayer][iModule] = new AliAlignObjParams("",volid,0,0,0,0,0,0,kTRUE);
}
//_____________________________________________________________________________
-Bool_t AliGeomManager::CheckSymNamesLUT(const char* detsToBeChecked)
+Bool_t AliGeomManager::CheckSymNamesLUT(const char* /*detsToBeChecked*/)
{
// Check the look-up table which associates the unique numerical identity of
// each alignable volume to the corresponding symbolic volume name.
- // The LUT is now hold inside the geometry and handled by TGeo.
+ // The LUT is now held inside the geometry and handled by TGeo.
// The method is meant to be launched when loading a geometry to verify that
// no changes in the symbolic names have been introduced, which would prevent
// backward compatibility with alignment objects.
}
if(trdActive) detsString+="TRD ";
- if(fgGeometry->CheckPath("ALIC_1/B077_1/BSEGMO0_1/BTRD0_1/UTR1_1")) detsString+="TRD ";
if(fgGeometry->CheckPath("ALIC_1/Hmp0_0")) detsString+="HMPID ";
- if(fgGeometry->CheckPath("ALIC_1/PHOS_1")) detsString+="PHOS ";
- if(fgGeometry->CheckPath("ALIC_1/XEN1_1")) detsString+="EMCAL";
-
+ TString phosMod, cpvMod;
+ TString basePhos("ALIC_1/PHOS_");
+ Bool_t phosActive=kFALSE;
+ Bool_t cpvActive=kFALSE;
+ Bool_t phosMods[5];
+ for(Int_t pmod=0; pmod<5; pmod++)
+ {
+ phosMods[pmod]=kFALSE;
+ phosMod = basePhos;
+ phosMod += (pmod+1);
+ cpvMod = phosMod;
+ cpvMod += "/PCPV_1";
+ if(fgGeometry->CheckPath(phosMod.Data()))
+ {
+ phosActive=kTRUE;
+ phosMods[pmod]=kTRUE;
+ if(fgGeometry->CheckPath(cpvMod.Data())) cpvActive=kTRUE;
+ }
+ }
+ if(phosActive) detsString+="PHOS ";
+
+ // Check over the ten EMCAL full supermodules and the two EMCAL half supermodules
+ TString emcalSM;
+ TString baseEmcalSM("ALIC_1/XEN1_1/SM");
+ Bool_t emcalActive=kFALSE;
+ Bool_t emcalSMs[12] = {kFALSE};
+ for(Int_t sm=0; sm<12; sm++)
+ {
+ emcalSM=baseEmcalSM;
+ if(sm<10){
+ emcalSM += "OD_";
+ emcalSM += (sm+1);
+ }else{
+ emcalSM += "10_";
+ emcalSM += (sm-9);
+ }
+ if(fgGeometry->CheckPath(emcalSM.Data()))
+ {
+ emcalActive=kTRUE;
+ emcalSMs[sm]=kTRUE;
+ }
+ }
+ if(emcalActive) detsString+="EMCAL ";
+
+
TString symname;
const char* sname;
TGeoPNEntry* pne = 0x0;
TString snSTRIP = "/strip";
for (Int_t isect = 0; isect < nSectors; isect++) {
+ if(tofSMs[isect]) AliDebugClass(3,Form("Consistency check for symnames of TOF supermodule %d.",isect));
for (Int_t istr = 1; istr <= nStrips; istr++) {
symname = snSM;
symname += Form("%02d",isect);
symname += Form("%02d",istr);
uid = LayerToVolUID(kTOF,modnum++);
if(!tofSMs[isect]) continue; // taking possible missing TOF sectors (partial geometry) into account
- AliDebugClass(2,Form("Consistency check for symnames of TOF supermodule %d.",isect));
if ((isect==13 || isect==14 || isect==15) && (istr >= 39 && istr <= 53)) continue; //taking holes into account
pne = fgGeometry->GetAlignableEntryByUID(uid);
if(!pne)
for(Int_t layer=0; layer<6; layer++){
modnum=0;
+ AliDebugClass(3,Form("Consistency check for symnames of TRD layer %d.",layer));
for (Int_t isect = 0; isect < 18; isect++) {
for (Int_t icham = 0; icham < 5; icham++) {
symname = snStr;
symname += layer;
uid = LayerToVolUID(arTRDlayId[layer],modnum++);
if(!trdSMs[isect]) continue;
- AliDebugClass(2,Form("Consistency check for symnames of TRD supermodule %d.",isect));
if ((isect==13 || isect==14 || isect==15) && icham==2) continue; //keeping holes into account
pne = fgGeometry->GetAlignableEntryByUID(uid);
if(!pne)
AliDebugClass(2,"Checking consistency of symbolic names for PHOS layers");
- {
TString str = "PHOS/Module";
modnum=0;
- for (Int_t iModule=1; iModule <= 5; iModule++) {
+ for (Int_t iModule=0; iModule < 5; iModule++) {
+ if(!phosMods[iModule]) continue;
symname = str;
- symname += iModule;
- modnum = iModule-1;
- uid = LayerToVolUID(kPHOS1,modnum);
+ symname += (iModule+1);
+ uid = LayerToVolUID(kPHOS1,iModule);
pne = fgGeometry->GetAlignableEntryByUID(uid);
if(!pne)
{
"Expected was %s, found was %s!", uid, symname.Data(), sname));
return kFALSE;
}
- }
- }
-
- /********************* PHOS CPV layer ***********************/
- {
- TString str = "PHOS/Module";
- modnum=0;
-
- for (Int_t iModule=1; iModule <= 5; iModule++) {
- symname = str;
- symname += iModule;
+ /********************* PHOS CPV layer ***********************/
+ if(!cpvActive) continue;
symname += "/CPV";
- modnum = iModule-1;
- uid = LayerToVolUID(kPHOS2,modnum);
+ uid = LayerToVolUID(kPHOS2,iModule);
pne = fgGeometry->GetAlignableEntryByUID(uid);
if(!pne)
{
return kFALSE;
}
}
- }
-
AliDebugClass(2,"Consistency check for PHOS symbolic names finished successfully.");
}
modnum=0;
for (Int_t iModule=1; iModule <= 12; iModule++) {
+ if(!emcalSMs[iModule-1]) continue;
symname = str;
symname += iModule;
if(iModule >10) {
// The LUTs are static; they are created at the creation of the
// AliGeomManager instance and recreated if the geometry has changed
//
- if (fgPNEntry[0]) return;
-
if(!fgGeometry) {
AliErrorClass("Impossible to initialize PNEntries LUT without an active geometry");
return;
}
for (Int_t iLayer = 0; iLayer < (kLastLayer - kFirstLayer); iLayer++){
- fgPNEntry[iLayer] = new TGeoPNEntry*[fgLayerSize[iLayer]];
+ if (!fgPNEntry[iLayer]) fgPNEntry[iLayer] = new TGeoPNEntry*[fgLayerSize[iLayer]];
for(Int_t modnum=0; modnum<fgLayerSize[iLayer]; modnum++){
fgPNEntry[iLayer][modnum] = fgGeometry->GetAlignableEntryByUID(LayerToVolUID(iLayer+1,modnum));
}
}
//______________________________________________________________________
-TGeoHMatrix* AliGeomManager::GetMatrix(TGeoPNEntry* pne)
+TGeoHMatrix* AliGeomManager::GetMatrix(TGeoPNEntry * const pne)
{
// Get the global transformation matrix for a given PNEntry
// by quering the TGeoManager
}
//_____________________________________________________________________________
-TGeoHMatrix* AliGeomManager::GetOrigGlobalMatrix(TGeoPNEntry* pne)
+TGeoHMatrix* AliGeomManager::GetOrigGlobalMatrix(TGeoPNEntry * const pne)
{
// The method returns global matrix for the ideal detector geometry
// using the corresponding TGeoPNEntry as an input.
// originated by the application of alignment objects.
//
- TObjArray* ovexlist = new TObjArray(64);
+ TObjArray* ovexlist = 0x0;
AliInfoClass("********* Checking overlaps/extrusions over physical nodes only *********");
TObjArray* pnList = gGeoManager->GetListOfPhysicalNodes();
delete overlaps;
}
+//_____________________________________________________________________________
+Int_t AliGeomManager::GetNalignable(const char* module)
+{
+ // Get number of declared alignable volumes in current geometry
+ // for the given detector "module" passed as a vaild detector name
+ // if the detector name is invalid return -1
+
+ // return the detector index corresponding to detector
+ Int_t index = -1 ;
+ for (index = 0; index < fgkNDetectors ; index++) {
+ if ( strcmp(module, fgkDetectorName[index]) == 0 )
+ break ;
+ }
+ if(index==fgkNDetectors) return -1;
+ return fgNalignable[index];
+}
+
+//_____________________________________________________________________________
+void AliGeomManager::InitNalignable()
+{
+ // Set number of declared alignable volumes for given detector in current geometry
+ // by looping on the list of PNEntries
+ //
+
+ Int_t nAlE = gGeoManager->GetNAlignable(); // total number of alignable entries
+ TGeoPNEntry *pne = 0;
+ const char* detName;
+
+ for (Int_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
+ detName = fgkDetectorName[iDet];
+ Int_t nAlDet = 0;
+
+ for(Int_t iE = 0; iE < nAlE; iE++)
+ {
+ pne = gGeoManager->GetAlignableEntry(iE);
+ TString pneName = pne->GetName();
+ if(pneName.Contains(detName)) nAlDet++;
+ if(!strcmp(detName,"GRP")) if(pneName.Contains("ABSO") || pneName.Contains("DIPO") ||
+ pneName.Contains("FRAME") || pneName.Contains("PIPE") ||
+ pneName.Contains("SHIL")) nAlDet++;
+ }
+ fgNalignable[iDet] = nAlDet;
+ }
+
+}
+
//_____________________________________________________________________________
Bool_t AliGeomManager::ApplyAlignObjsFromCDB(const char* AlignDetsList)
{
while((str = (TObjString*) iter.Next())){
TString det(str->String());
- AliInfoClass(Form("Loading alignment objs for %s",det.Data()));
+ AliDebugClass(5,Form("Loading alignment objs for %s",det.Data()));
if(!LoadAlignObjsFromCDBSingleDet(det.Data(),alignObjArray)){
alObjsNotLoaded += det.Data();
alObjsNotLoaded += " ";
if(!alObjsLoaded.IsNull()) AliInfoClass(Form("Alignment objects loaded for: %s",
alObjsLoaded.Data()));
- if(!alObjsNotLoaded.IsNull()) AliInfoClass(Form("Didn't/couldn't load alignment objects for: %s",
+ if(!alObjsNotLoaded.IsNull())
+ AliFatalClass(Form("Could not load alignment objects from OCDB for: %s",
alObjsNotLoaded.Data()));
return ApplyAlignObjsToGeom(alignObjArray);
entry->SetOwner(1);
TClonesArray *alignArray = (TClonesArray*) entry->GetObject();
alignArray->SetOwner(0);
- AliDebugClass(2,Form("Found %d alignment objects for %s",
- alignArray->GetEntries(),detName));
+ Int_t nAlObjs = alignArray->GetEntries();
+ AliDebugClass(2,Form("Found %d alignment objects for %s",nAlObjs,detName));
+ Int_t nAlVols = GetNalignable(detName);
+ if(nAlObjs!=nAlVols) AliWarningClass(Form("%d alignment objects loaded for %s, which has %d alignable volumes",nAlObjs,detName,GetNalignable(detName)));
AliAlignObj *alignObj=0;
TIter iter(alignArray);
//_____________________________________________________________________________
Bool_t AliGeomManager::ApplyAlignObjsToGeom(TObjArray& alignObjArray, Bool_t ovlpcheck)
{
- // Read collection of alignment objects (AliAlignObj derived) saved
- // in the TClonesArray alObjArray and apply them to gGeoManager
- //
- alignObjArray.Sort();
- Int_t nvols = alignObjArray.GetEntriesFast();
+ // Read collection of alignment objects (AliAlignObj derived) saved
+ // in the TClonesArray alObjArray and apply them to gGeoManager
+ //
+ alignObjArray.Sort();
+ Int_t nvols = alignObjArray.GetEntriesFast();
- Bool_t flag = kTRUE;
+ Bool_t flag = kTRUE;
- for(Int_t j=0; j<nvols; j++)
+ for(Int_t j=0; j<nvols; j++)
{
- AliAlignObj* alobj = (AliAlignObj*) alignObjArray.UncheckedAt(j);
- if (alobj->ApplyToGeometry(ovlpcheck) == kFALSE) flag = kFALSE;
+ AliAlignObj* alobj = (AliAlignObj*) alignObjArray.UncheckedAt(j);
+ if(!alobj->ApplyToGeometry(ovlpcheck))
+ {
+ flag = kFALSE;
+ AliDebugClass(5,Form("Error applying alignment object for volume %s !",alobj->GetSymName()));
+ }else{
+ AliDebugClass(5,Form("Alignment object for volume %s applied successfully",alobj->GetSymName()));
+ }
+
}
- if (AliDebugLevelClass() >= 1) {
- fgGeometry->GetTopNode()->CheckOverlaps(1);
- TObjArray* ovexlist = fgGeometry->GetListOfOverlaps();
- if(ovexlist->GetEntriesFast()){
- AliErrorClass("The application of alignment objects to the geometry caused huge overlaps/extrusions!");
- }
- }
+ if (AliDebugLevelClass() > 5) {
+ fgGeometry->CheckOverlaps(0.001);
+ TObjArray* ovexlist = fgGeometry->GetListOfOverlaps();
+ if(ovexlist->GetEntriesFast()){
+ AliErrorClass("The application of alignment objects to the geometry caused huge overlaps/extrusions!");
+ fgGeometry->PrintOverlaps();
+ }
+ }
- // Update the TGeoPhysicalNodes
- fgGeometry->RefreshPhysicalNodes();
+ // Update the TGeoPhysicalNodes
+ fgGeometry->RefreshPhysicalNodes();
- return flag;
+ return flag;
}
return ApplyAlignObjsToGeom(*alignObjArray);
}
+
+//_____________________________________________________________________________
+void AliGeomManager::ResetPNEntriesLUT()
+{
+ // cleans static arrays containing the information on currently loaded geometry
+ //
+ for (Int_t iLayer = 0; iLayer < (kLastLayer - kFirstLayer); iLayer++){
+ if (!fgPNEntry[iLayer]) continue;
+ for (Int_t modnum=0; modnum<fgLayerSize[iLayer]; modnum++) fgPNEntry[iLayer][modnum] = 0;
+ }
+ //
+}
+