1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15 //-------------------------------------------------------------------------
16 // Implementation of AliGeomManager, the geometry manager class
17 // which interfaces to TGeo and the look-up table mapping unique
18 // volume indices to symbolic volume names. For that it collects
19 // several static methods.
20 //-------------------------------------------------------------------------
24 #include <TGeoManager.h>
25 #include <TObjString.h>
26 #include <TGeoPhysicalNode.h>
27 #include <TClonesArray.h>
28 #include <TGeoMatrix.h>
29 #include <TGeoPhysicalNode.h>
31 #include <TStopwatch.h>
32 #include <TGeoOverlap.h>
33 #include <TPluginManager.h>
36 #include "AliGeomManager.h"
38 #include "AliAlignObj.h"
39 #include "AliAlignObjParams.h"
40 #include "AliCDBManager.h"
41 #include "AliCDBStorage.h"
42 #include "AliCDBEntry.h"
44 ClassImp(AliGeomManager)
46 Int_t AliGeomManager::fgLayerSize[kLastLayer - kFirstLayer] = {
47 80, 160, // ITS SPD first and second layer
48 84, 176, // ITS SDD first and second layer
49 748, 950, // ITS SSD first and second layer
50 36, 36, // TPC inner and outer chambers
51 90, 90, 90, 90, 90, 90, // 6 TRD chambers' layers
59 const char* AliGeomManager::fgLayerName[kLastLayer - kFirstLayer] = {
60 "ITS inner pixels layer", "ITS outer pixels layer",
61 "ITS inner drifts layer", "ITS outer drifts layer",
62 "ITS inner strips layer", "ITS outer strips layer",
63 "TPC inner chambers layer", "TPC outer chambers layer",
64 "TRD chambers layer 1", "TRD chambers layer 2", "TRD chambers layer 3",
65 "TRD chambers layer 4", "TRD chambers layer 5", "TRD chambers layer 6",
67 "PHOS EMC layer","PHOS CPV layer",
73 TGeoPNEntry** AliGeomManager::fgPNEntry[kLastLayer - kFirstLayer] = {
87 AliAlignObj** AliGeomManager::fgAlignObjs[kLastLayer - kFirstLayer] = {
101 const char* AliGeomManager::fgkDetectorName[AliGeomManager::fgkNDetectors] = {"GRP","ITS","TPC","TRD","TOF","PHOS","HMPID","EMCAL","MUON","FMD","ZDC","PMD","T0","VZERO","ACORDE"
102 // #ifdef MFT_UPGRADE
107 Int_t AliGeomManager::fgNalignable[fgkNDetectors] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
108 // #ifdef MFT_UPGRADE
114 TGeoManager* AliGeomManager::fgGeometry = 0x0;
116 //_____________________________________________________________________________
117 void AliGeomManager::LoadGeometry(const char *geomFileName)
120 // Load geometry either from a file
121 // or from the corresponding CDB entry
123 if(fgGeometry->IsLocked()){
124 AliErrorClass("Cannot load a new geometry, the current one being locked. Setting internal geometry to null!!");
130 if (geomFileName && (!gSystem->AccessPathName(geomFileName))) {
131 fgGeometry = TGeoManager::Import(geomFileName);
132 AliInfoClass(Form("From now on using geometry from custom geometry file \"%s\"",geomFileName));
136 AliCDBPath path("GRP","Geometry","Data");
138 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
139 if(!entry) AliFatalClass("Couldn't load geometry data from CDB!");
142 fgGeometry = (TGeoManager*) entry->GetObject();
143 if (!fgGeometry) AliFatalClass("Couldn't find TGeoManager in the specified CDB entry!");
145 AliInfoClass(Form("From now on using geometry from CDB base folder \"%s\"",
146 AliCDBManager::Instance()->GetURI("GRP/Geometry/Data")));
153 //_____________________________________________________________________________
154 void AliGeomManager::SetGeometry(TGeoManager * const geom)
156 // Load already active geometry
157 if (!geom) AliFatalClass("Pointer to the active geometry is 0x0!");
164 //_____________________________________________________________________________
165 AliGeomManager::AliGeomManager():
168 // default constructor
171 //_____________________________________________________________________________
172 AliGeomManager::~AliGeomManager()
177 //_____________________________________________________________________________
178 Int_t AliGeomManager::LayerSize(Int_t layerId)
180 // Get the layer size for layer corresponding to layerId.
181 // Implemented only for ITS,TPC,TRD,TOF and HMPID
183 if (layerId < kFirstLayer || layerId >= kLastLayer) {
184 AliErrorClass(Form("Invalid layer index %d ! Layer range is (%d -> %d) !",layerId,kFirstLayer,kLastLayer));
188 return fgLayerSize[layerId - kFirstLayer];
192 //_____________________________________________________________________________
193 const char* AliGeomManager::LayerName(Int_t layerId)
195 // Get the layer name corresponding to layerId.
196 // Implemented only for ITS,TPC,TRD,TOF and HMPID
198 if (layerId < kFirstLayer || layerId >= kLastLayer) {
199 AliErrorClass(Form("Invalid layer index %d ! Layer range is (%d -> %d) !",layerId,kFirstLayer,kLastLayer));
200 return "Invalid Layer!";
203 return fgLayerName[layerId - kFirstLayer];
207 //_____________________________________________________________________________
208 UShort_t AliGeomManager::LayerToVolUID(ELayerID layerId, Int_t modId)
210 // From detector (layer) name and module number (according to detector
211 // internal numbering) build the unique numerical identity of that volume
213 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
214 // remaining 11 for module ID inside det (2048 possible values).
215 // NO check for validity of given modId inside the layer for speed's sake.
217 return ((UShort_t(layerId) << 11) | UShort_t(modId));
220 //_____________________________________________________________________________
221 UShort_t AliGeomManager::LayerToVolUID(Int_t layerId, Int_t modId)
223 // From detector (layer) name and module number (according to detector
224 // internal numbering) build the unique numerical identity of that volume
226 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
227 // remaining 11 for module ID inside det (2048 possible values).
228 // NO check for validity of given modId inside the layer for speed's sake.
230 return ((UShort_t(layerId) << 11) | UShort_t(modId));
233 //_____________________________________________________________________________
234 UShort_t AliGeomManager::LayerToVolUIDSafe(ELayerID layerId, Int_t modId)
236 // From detector (layer) name and module number (according to detector
237 // internal numbering) build the unique numerical identity of that volume
239 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
240 // remaining 11 for module ID inside det (2048 possible values).
241 // Check validity of given modId inside the layer.
243 if(modId < 0 || modId >= LayerSize(layerId)){
244 AliErrorClass(Form("Invalid volume id %d ! Range of valid ids for layer \"%s\" is [0, %d] !",modId,LayerName(layerId),LayerSize(layerId)-1));
247 return ((UShort_t(layerId) << 11) | UShort_t(modId));
250 //_____________________________________________________________________________
251 UShort_t AliGeomManager::LayerToVolUIDSafe(Int_t layerId, Int_t modId)
253 // From detector (layer) name and module number (according to detector
254 // internal numbering) build the unique numerical identity of that volume
256 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
257 // remaining 11 for module ID inside det (2048 possible values).
258 // Check validity of given modId inside the layer.
260 if(modId < 0 || modId >= LayerSize(layerId)){
261 AliErrorClass(Form("Invalid volume id %d ! Range of valid ids for layer \"%s\" is [0, %d] !",modId,LayerName(layerId),LayerSize(layerId)-1));
264 return ((UShort_t(layerId) << 11) | UShort_t(modId));
267 //_____________________________________________________________________________
268 AliGeomManager::ELayerID AliGeomManager::VolUIDToLayer(UShort_t voluid, Int_t &modId)
270 // From voluid, unique numerical identity of that volume inside ALICE,
271 // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
272 // remaining 11 for module ID inside det (2048 possible values)), return
273 // the identity of the layer to which that volume belongs and sets the
274 // argument modId to the identity of that volume internally to the layer.
275 // NO check for validity of given voluid for speed's sake.
277 modId = voluid & 0x7ff;
279 return VolUIDToLayer(voluid);
282 //_____________________________________________________________________________
283 AliGeomManager::ELayerID AliGeomManager::VolUIDToLayer(UShort_t voluid)
285 // From voluid, unique numerical identity of that volume inside ALICE,
286 // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
287 // remaining 11 for module ID inside det (2048 possible values)), return
288 // the identity of the layer to which that volume belongs
289 // NO check for validity of given voluid for speed's sake.
291 return ELayerID(voluid >> 11);
294 //_____________________________________________________________________________
295 AliGeomManager::ELayerID AliGeomManager::VolUIDToLayerSafe(UShort_t voluid, Int_t &modId)
297 // From voluid, unique numerical identity of that volume inside ALICE,
298 // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
299 // remaining 11 for module ID inside det (2048 possible values)), returns
300 // the identity of the layer to which that volume belongs and sets the
301 // argument modId to the identity of that volume internally to the layer.
302 // Checks the validity of the given voluid
304 ELayerID layId = VolUIDToLayerSafe(voluid);
305 if(layId != AliGeomManager::kInvalidLayer){
306 Int_t mId = Int_t(voluid & 0x7ff);
307 if( mId>=0 && mId<LayerSize(layId)){
313 AliErrorClass(Form("Invalid unique volume id: %d !",voluid));
315 return kInvalidLayer;
319 //_____________________________________________________________________________
320 AliGeomManager::ELayerID AliGeomManager::VolUIDToLayerSafe(UShort_t voluid)
322 // From voluid, unique numerical identity of that volume inside ALICE,
323 // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
324 // remaining 11 for module ID inside det (2048 possible values)), returns
325 // the identity of the layer to which that volume belongs
326 // Checks the validity of the given voluid
328 if( (voluid >> 11) < kLastLayer) return ELayerID(voluid >> 11);
330 AliErrorClass(Form("Invalid layer id: %d !",(voluid >> 11)));
331 return kInvalidLayer;
335 //_____________________________________________________________________________
336 Bool_t AliGeomManager::GetFromGeometry(const char *symname, AliAlignObj &alobj)
338 // Get the alignment object which corresponds to the symbolic volume name
339 // symname (in case equal to the TGeo volume path)
340 // The method is extremely slow due to the searching by string,
341 // therefore it should be used with great care!!
342 // This method returns FALSE if the symname of the object was not
343 // valid neither to get a TGeoPEntry nor as a volume path, or if the path
344 // associated to the TGeoPNEntry was not valid.
347 // Reset the alignment object
348 alobj.SetPars(0,0,0,0,0,0);
349 alobj.SetSymName(symname);
351 if (!fgGeometry || !fgGeometry->IsClosed()) {
352 AliErrorClass("Can't get the alignment object! gGeoManager doesn't exist or it is still opened!");
356 if (!fgGeometry->GetListOfPhysicalNodes()) {
357 AliErrorClass("Can't get the alignment object! gGeoManager doesn't contain any aligned nodes!");
362 TGeoPNEntry* pne = fgGeometry->GetAlignableEntry(symname);
364 path = pne->GetTitle();
366 AliWarningClass(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as a volume path!",symname));
369 TObjArray* nodesArr = fgGeometry->GetListOfPhysicalNodes();
370 TGeoPhysicalNode* node = NULL;
371 for (Int_t iNode = 0; iNode < nodesArr->GetEntriesFast(); iNode++) {
372 TGeoPhysicalNode* tempNode = (TGeoPhysicalNode*) nodesArr->UncheckedAt(iNode);
373 const char *nodePath = tempNode->GetName();
374 if (strcmp(path,nodePath) == 0) {
381 if (!fgGeometry->cd(path)) {
382 AliErrorClass(Form("%s not valid neither as symbolic volume name nor as volume path!",path));
386 AliWarningClass(Form("Volume (%s) has not been misaligned!",path));
391 TGeoHMatrix align,gprime,g,ginv,l;
392 gprime = *node->GetMatrix();
393 l = *node->GetOriginalMatrix();
394 g = *node->GetMatrix(node->GetLevel()-1);
397 align = gprime * ginv;
399 return alobj.SetMatrix(align);
403 //_____________________________________________________________________________
404 void AliGeomManager::InitAlignObjFromGeometry()
406 // Loop over all alignable volumes and extract
407 // the corresponding alignment objects from
410 for (Int_t iLayer = kFirstLayer; iLayer < AliGeomManager::kLastLayer; iLayer++) {
411 if (!fgAlignObjs[iLayer-kFirstLayer]) {
412 fgAlignObjs[iLayer-kFirstLayer] = new AliAlignObj*[LayerSize(iLayer)];
414 for (Int_t iModule = 0; iModule < LayerSize(iLayer); iModule++) {
415 UShort_t volid = LayerToVolUID(iLayer,iModule);
416 fgAlignObjs[iLayer-kFirstLayer][iModule] = new AliAlignObjParams("",volid,0,0,0,0,0,0,kTRUE);
417 const char *symname = SymName(volid);
418 if (!GetFromGeometry(symname, *fgAlignObjs[iLayer-kFirstLayer][iModule]))
419 AliErrorClass(Form("Failed to extract the alignment object for the volume (ID=%d and path=%s) !",volid,symname));
425 //_____________________________________________________________________________
426 AliAlignObj* AliGeomManager::GetAlignObj(UShort_t voluid)
428 // Returns the alignment object for given volume ID
431 ELayerID layerId = VolUIDToLayer(voluid,modId);
432 return GetAlignObj(layerId,modId);
435 //_____________________________________________________________________________
436 AliAlignObj* AliGeomManager::GetAlignObj(ELayerID layerId, Int_t modId)
438 // Returns pointer to alignment object given its layer and module ID
440 if(modId<0 || modId>=fgLayerSize[layerId-kFirstLayer]){
441 AliWarningClass(Form("Module number %d not in the valid range (0->%d) !",modId,fgLayerSize[layerId-kFirstLayer]-1));
444 InitAlignObjFromGeometry();
446 return fgAlignObjs[layerId-kFirstLayer][modId];
449 //_____________________________________________________________________________
450 const char* AliGeomManager::SymName(UShort_t voluid)
452 // Returns the symbolic volume name for given volume ID
455 ELayerID layerId = VolUIDToLayer(voluid,modId);
456 return SymName(layerId,modId);
459 //_____________________________________________________________________________
460 const char* AliGeomManager::SymName(ELayerID layerId, Int_t modId)
462 // Returns the symbolic volume name given for a given layer
466 AliErrorClass("No geometry instance loaded yet!");
469 if(modId<0 || modId>=fgLayerSize[layerId-kFirstLayer]){
470 AliWarningClass(Form("Module number %d not in the valid range (0->%d) !",modId,fgLayerSize[layerId-kFirstLayer]-1));
474 TGeoPNEntry* pne = fgPNEntry[layerId-kFirstLayer][modId];
477 AliWarningClass(Form("Module %d of layer %s is not activated!",modId,LayerName(layerId)));
480 return pne->GetName();
484 //_____________________________________________________________________________
485 Bool_t AliGeomManager::CheckSymNamesLUT(const char* /*detsToBeChecked*/)
487 // Check the look-up table which associates the unique numerical identity of
488 // each alignable volume to the corresponding symbolic volume name.
489 // The LUT is now held inside the geometry and handled by TGeo.
490 // The method is meant to be launched when loading a geometry to verify that
491 // no changes in the symbolic names have been introduced, which would prevent
492 // backward compatibility with alignment objects.
493 // To accept both complete and partial geometry, this method skips the check
494 // for TRD and TOF volumes which are missing in the partial geometry.
497 // TString detsString(detsToBeChecked);
498 // if(detsString.Contains("ALL")) detsString="ITS TPC TOF TRD HMPID PHOS EMCAL";
500 // Temporary measure to face the case of reconstruction over detectors not present in the geometry
501 TString detsString = "";
502 if(fgGeometry->CheckPath("ALIC_1/ITSV_1")) detsString+="ITS ";
503 if(fgGeometry->CheckPath("ALIC_1/TPC_M_1")) detsString+="TPC ";
506 TString baseTof("ALIC_1/B077_1/BSEGMO");
507 TString middleTof("_1/BTOF");
508 TString trailTof("_1/FTOA_0");
509 Bool_t tofActive=kFALSE;
511 for(Int_t sm=0; sm<18; sm++)
519 if(fgGeometry->CheckPath(tofsm.Data()))
525 if(tofActive) detsString+="TOF ";
528 TString baseTrd("ALIC_1/B077_1/BSEGMO");
529 TString middleTrd("_1/BTRD");
530 TString trailTrd("_1/UTR1_1");
531 Bool_t trdActive=kFALSE;
533 for(Int_t sm=0; sm<18; sm++)
541 if(fgGeometry->CheckPath(trdsm.Data()))
547 if(trdActive) detsString+="TRD ";
549 if(fgGeometry->CheckPath("ALIC_1/Hmp0_0")) detsString+="HMPID ";
551 TString phosMod, cpvMod;
552 TString basePhos("ALIC_1/PHOS_");
553 Bool_t phosActive=kFALSE;
554 Bool_t cpvActive=kFALSE;
556 for(Int_t pmod=0; pmod<5; pmod++)
558 phosMods[pmod]=kFALSE;
563 if(fgGeometry->CheckPath(phosMod.Data()))
566 phosMods[pmod]=kTRUE;
567 if(fgGeometry->CheckPath(cpvMod.Data())) cpvActive=kTRUE;
570 if(phosActive) detsString+="PHOS ";
572 // Check over the ten EMCAL full supermodules and the two EMCAL half supermodules
574 TString baseEmcalSM("ALIC_1/XEN1_1/SM");
575 Bool_t emcalActive=kFALSE;
576 Bool_t emcalSMs[12] = {kFALSE};
577 for(Int_t sm=0; sm<12; sm++)
587 if(fgGeometry->CheckPath(emcalSM.Data()))
593 if(emcalActive) detsString+="EMCAL ";
598 TGeoPNEntry* pne = 0x0;
599 Int_t uid; // global unique identity
600 Int_t modnum; // unique id inside layer; in the following, set it to 0 at the start of each layer
602 if(detsString.Contains("ITS")){
603 /********************* ITS layers ***********************/
604 AliDebugClass(2,"Checking consistency of symbolic names for ITS layers");
605 TString strSPD = "ITS/SPD";
606 TString strSDD = "ITS/SDD";
607 TString strSSD = "ITS/SSD";
608 TString strStave = "/Stave";
609 TString strHalfStave = "/HalfStave";
610 TString strLadder = "/Ladder";
611 TString strSector = "/Sector";
612 TString strSensor = "/Sensor";
613 TString strEntryName1;
614 TString strEntryName2;
615 TString strEntryName3;
617 /********************* SPD layer1 ***********************/
621 for(Int_t cSect = 0; cSect<10; cSect++){
622 strEntryName1 = strSPD;
624 strEntryName1 += strSector;
625 strEntryName1 += cSect;
627 for(Int_t cStave =0; cStave<2; cStave++){
628 strEntryName2 = strEntryName1;
629 strEntryName2 += strStave;
630 strEntryName2 += cStave;
632 for (Int_t cHS=0; cHS<2; cHS++) {
633 strEntryName3 = strEntryName2;
634 strEntryName3 += strHalfStave;
635 strEntryName3 += cHS;
637 for(Int_t cLad =0; cLad<2; cLad++){
638 symname = strEntryName3;
639 symname += strLadder;
640 symname += cLad+cHS*2;
641 uid = LayerToVolUID(kSPD1,modnum++);
642 pne = fgGeometry->GetAlignableEntryByUID(uid);
645 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
648 sname = pne->GetName();
649 if(symname.CompareTo(sname))
651 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d."
652 "Expected was %s, found was %s!", uid, symname.Data(), sname));
661 /********************* SPD layer2 ***********************/
665 for(Int_t cSect = 0; cSect<10; cSect++){
666 strEntryName1 = strSPD;
668 strEntryName1 += strSector;
669 strEntryName1 += cSect;
671 for(Int_t cStave =0; cStave<4; cStave++){
672 strEntryName2 = strEntryName1;
673 strEntryName2 += strStave;
674 strEntryName2 += cStave;
676 for (Int_t cHS=0; cHS<2; cHS++) {
677 strEntryName3 = strEntryName2;
678 strEntryName3 += strHalfStave;
679 strEntryName3 += cHS;
681 for(Int_t cLad =0; cLad<2; cLad++){
682 symname = strEntryName3;
683 symname += strLadder;
684 symname += cLad+cHS*2;
685 uid = LayerToVolUID(kSPD2,modnum++);
686 pne = fgGeometry->GetAlignableEntryByUID(uid);
689 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
692 sname = pne->GetName();
693 if(symname.CompareTo(sname))
695 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d."
696 "Expected was %s, found was %s!", uid, symname.Data(), sname));
705 /********************* SDD layer1 ***********************/
709 for(Int_t c1 = 1; c1<=14; c1++){
710 strEntryName1 = strSDD;
712 strEntryName1 +=strLadder;
713 strEntryName1 += (c1-1);
714 for(Int_t c2 =1; c2<=6; c2++){
715 symname = strEntryName1;
716 symname += strSensor;
718 uid = LayerToVolUID(kSDD1,modnum++);
719 pne = fgGeometry->GetAlignableEntryByUID(uid);
722 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
725 sname = pne->GetName();
726 if(symname.CompareTo(sname))
728 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
729 "Expected was %s, found was %s!", uid, symname.Data(), sname));
736 /********************* SDD layer2 ***********************/
740 for(Int_t c1 = 1; c1<=22; c1++){
741 strEntryName1 = strSDD;
743 strEntryName1 +=strLadder;
744 strEntryName1 += (c1-1);
745 for(Int_t c2 = 1; c2<=8; c2++){
746 symname = strEntryName1;
747 symname += strSensor;
749 uid = LayerToVolUID(kSDD2,modnum++);
750 pne = fgGeometry->GetAlignableEntryByUID(uid);
753 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
756 sname = pne->GetName();
757 if(symname.CompareTo(sname))
759 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
760 "Expected was %s, found was %s!", uid, symname.Data(), sname));
767 /********************* SSD layer1 ***********************/
771 for(Int_t c1 = 1; c1<=34; c1++){
772 strEntryName1 = strSSD;
774 strEntryName1 +=strLadder;
775 strEntryName1 += (c1-1);
776 for(Int_t c2 = 1; c2<=22; c2++){
777 symname = strEntryName1;
778 symname += strSensor;
780 uid = LayerToVolUID(kSSD1,modnum++);
781 pne = fgGeometry->GetAlignableEntryByUID(uid);
784 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
787 sname = pne->GetName();
788 if(symname.CompareTo(sname))
790 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
791 "Expected was %s, found was %s!", uid, symname.Data(), sname));
798 /********************* SSD layer2 ***********************/
802 for(Int_t c1 = 1; c1<=38; c1++){
803 strEntryName1 = strSSD;
805 strEntryName1 +=strLadder;
806 strEntryName1 += (c1-1);
807 for(Int_t c2 = 1; c2<=25; c2++){
808 symname = strEntryName1;
809 symname += strSensor;
811 uid = LayerToVolUID(kSSD2,modnum++);
812 pne = fgGeometry->GetAlignableEntryByUID(uid);
815 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
818 sname = pne->GetName();
819 if(symname.CompareTo(sname))
821 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
822 "Expected was %s, found was %s!", uid, symname.Data(), sname));
829 AliDebugClass(2,"Consistency check for ITS symbolic names finished successfully.");
832 if(detsString.Contains("TPC"))
834 /*************** TPC inner and outer layers ****************/
836 AliDebugClass(2,"Checking consistency of symbolic names for TPC layers");
837 TString sAsector="TPC/EndcapA/Sector";
838 TString sCsector="TPC/EndcapC/Sector";
839 TString sInner="/InnerChamber";
840 TString sOuter="/OuterChamber";
842 /*************** TPC inner chambers' layer ****************/
846 for(Int_t cnt=1; cnt<=18; cnt++)
851 uid = LayerToVolUID(kTPC1,modnum++);
852 pne = fgGeometry->GetAlignableEntryByUID(uid);
855 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
858 sname = pne->GetName();
859 if(symname.CompareTo(sname))
861 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
862 "Expected was %s, found was %s!", uid, symname.Data(), sname));
867 for(Int_t cnt=1; cnt<=18; cnt++)
872 uid = LayerToVolUID(kTPC1,modnum++);
873 pne = fgGeometry->GetAlignableEntryByUID(uid);
876 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
879 sname = pne->GetName();
880 if(symname.CompareTo(sname))
882 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
883 "Expected was %s, found was %s!", uid, symname.Data(), sname));
889 /*************** TPC outer chambers' layer ****************/
893 for(Int_t cnt=1; cnt<=18; cnt++)
898 uid = LayerToVolUID(kTPC2,modnum++);
899 pne = fgGeometry->GetAlignableEntryByUID(uid);
902 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
905 sname = pne->GetName();
906 if(symname.CompareTo(sname))
908 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
909 "Expected was %s, found was %s!", uid, symname.Data(), sname));
914 for(Int_t cnt=1; cnt<=18; cnt++)
919 uid = LayerToVolUID(kTPC2,modnum++);
920 pne = fgGeometry->GetAlignableEntryByUID(uid);
923 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
926 sname = pne->GetName();
927 if(symname.CompareTo(sname))
929 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
930 "Expected was %s, found was %s!", uid, symname.Data(), sname));
936 AliDebugClass(2,"Consistency check for TPC symbolic names finished successfully.");
939 if(detsString.Contains("TOF"))
941 /********************* TOF layer ***********************/
943 AliDebugClass(2,"Checking consistency of symbolic names for TOF layers");
950 Int_t nStrips=nstrA+2*nstrB+2*nstrC;
952 TString snSM = "TOF/sm";
953 TString snSTRIP = "/strip";
955 for (Int_t isect = 0; isect < nSectors; isect++) {
956 if(tofSMs[isect]) AliDebugClass(3,Form("Consistency check for symnames of TOF supermodule %d.",isect));
957 for (Int_t istr = 1; istr <= nStrips; istr++) {
959 symname += Form("%02d",isect);
961 symname += Form("%02d",istr);
962 uid = LayerToVolUID(kTOF,modnum++);
963 if(!tofSMs[isect]) continue; // taking possible missing TOF sectors (partial geometry) into account
964 if ((isect==13 || isect==14 || isect==15) && (istr >= 39 && istr <= 53)) continue; //taking holes into account
965 pne = fgGeometry->GetAlignableEntryByUID(uid);
968 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
971 sname = pne->GetName();
972 if(symname.CompareTo(sname))
974 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
975 "Expected was %s, found was %s!", uid, symname.Data(), sname));
981 AliDebugClass(2,"Consistency check for TOF symbolic names finished successfully.");
984 if(detsString.Contains("HMPID"))
986 /********************* HMPID layer ***********************/
988 AliDebugClass(2,"Checking consistency of symbolic names for HMPID layers");
989 TString str = "/HMPID/Chamber";
991 for (modnum=0; modnum < 7; modnum++) {
994 uid = LayerToVolUID(kHMPID,modnum);
995 pne = fgGeometry->GetAlignableEntryByUID(uid);
998 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1001 sname = pne->GetName();
1002 if(symname.CompareTo(sname))
1004 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1005 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1010 AliDebugClass(2,"Consistency check for HMPID symbolic names finished successfully.");
1013 if(detsString.Contains("TRD"))
1015 /********************* TRD layers 1-6 *******************/
1016 //!! 6 layers with index increasing in outwards direction
1018 AliDebugClass(2,"Checking consistency of symbolic names for TRD layers");
1019 Int_t arTRDlayId[6] = {kTRD1, kTRD2, kTRD3, kTRD4, kTRD5, kTRD6};
1021 TString snStr = "TRD/sm";
1022 TString snApp1 = "/st";
1023 TString snApp2 = "/pl";
1025 for(Int_t layer=0; layer<6; layer++){
1027 AliDebugClass(3,Form("Consistency check for symnames of TRD layer %d.",layer));
1028 for (Int_t isect = 0; isect < 18; isect++) {
1029 for (Int_t icham = 0; icham < 5; icham++) {
1031 symname += Form("%02d",isect);
1036 uid = LayerToVolUID(arTRDlayId[layer],modnum++);
1037 if(!trdSMs[isect]) continue;
1038 if ((isect==13 || isect==14 || isect==15) && icham==2) continue; //keeping holes into account
1039 pne = fgGeometry->GetAlignableEntryByUID(uid);
1042 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1045 sname = pne->GetName();
1046 if(symname.CompareTo(sname))
1048 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1049 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1056 AliDebugClass(2,"Consistency check for TRD symbolic names finished successfully.");
1059 if(detsString.Contains("PHOS"))
1061 /********************* PHOS EMC layer ***********************/
1063 AliDebugClass(2,"Checking consistency of symbolic names for PHOS layers");
1065 TString str = "PHOS/Module";
1068 for (Int_t iModule=0; iModule < 5; iModule++) {
1069 if(!phosMods[iModule]) continue;
1071 symname += (iModule+1);
1072 uid = LayerToVolUID(kPHOS1,iModule);
1073 pne = fgGeometry->GetAlignableEntryByUID(uid);
1076 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1079 sname = pne->GetName();
1080 if(symname.CompareTo(sname))
1082 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1083 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1086 /********************* PHOS CPV layer ***********************/
1087 if(!cpvActive) continue;
1089 uid = LayerToVolUID(kPHOS2,iModule);
1090 pne = fgGeometry->GetAlignableEntryByUID(uid);
1093 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1096 sname = pne->GetName();
1097 if(symname.CompareTo(sname))
1099 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1100 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1104 AliDebugClass(2,"Consistency check for PHOS symbolic names finished successfully.");
1107 if(detsString.Contains("EMCAL"))
1109 /********************* EMCAL layer ***********************/
1111 AliDebugClass(2,"Checking consistency of symbolic names for EMCAL layers");
1112 TString str = "EMCAL/FullSupermodule";
1115 for (Int_t iModule=1; iModule <= 12; iModule++) {
1116 if(!emcalSMs[iModule-1]) continue;
1120 symname = "EMCAL/HalfSupermodule";
1121 symname += iModule-10;
1124 uid = LayerToVolUID(kEMCAL,modnum);
1125 pne = fgGeometry->GetAlignableEntryByUID(uid);
1128 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1131 sname = pne->GetName();
1132 if(symname.CompareTo(sname))
1134 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1135 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1140 AliDebugClass(2,"Consistency check for EMCAL symbolic names finished successfully.");
1147 //_____________________________________________________________________________
1148 void AliGeomManager::InitPNEntriesLUT()
1150 // Initialize the look-up table which associates the unique
1151 // numerical identity of each alignable volume to the
1152 // corresponding TGeoPNEntry.
1153 // The LUTs are static; they are created at the creation of the
1154 // AliGeomManager instance and recreated if the geometry has changed
1157 AliErrorClass("Impossible to initialize PNEntries LUT without an active geometry");
1161 for (Int_t iLayer = 0; iLayer < (kLastLayer - kFirstLayer); iLayer++){
1162 if (!fgPNEntry[iLayer]) fgPNEntry[iLayer] = new TGeoPNEntry*[fgLayerSize[iLayer]];
1163 for(Int_t modnum=0; modnum<fgLayerSize[iLayer]; modnum++){
1164 fgPNEntry[iLayer][modnum] = fgGeometry->GetAlignableEntryByUID(LayerToVolUID(iLayer+1,modnum));
1169 //______________________________________________________________________
1170 TGeoHMatrix* AliGeomManager::GetMatrix(TGeoPNEntry * const pne)
1172 // Get the global transformation matrix for a given PNEntry
1173 // by quering the TGeoManager
1175 if (!fgGeometry || !fgGeometry->IsClosed()) {
1176 AliErrorClass("Can't get the global matrix! gGeoManager doesn't exist or it is still opened!");
1180 TGeoPhysicalNode *pnode = pne->GetPhysicalNode();
1181 if (pnode) return pnode->GetMatrix();
1183 const char* path = pne->GetTitle();
1184 if (!fgGeometry->cd(path)) {
1185 AliErrorClass(Form("Volume path %s not valid!",path));
1188 return fgGeometry->GetCurrentMatrix();
1191 //______________________________________________________________________
1192 TGeoHMatrix* AliGeomManager::GetMatrix(Int_t index)
1194 // Get the global transformation matrix for a given alignable volume
1195 // identified by its unique ID 'index' by quering the TGeoManager
1197 TGeoPNEntry *pne = GetPNEntry(index);
1198 if (!pne) return NULL;
1200 return GetMatrix(pne);
1203 //______________________________________________________________________
1204 TGeoHMatrix* AliGeomManager::GetMatrix(const char* symname)
1206 // Get the global transformation matrix for a given alignable volume
1207 // identified by its symbolic name 'symname' by quering the TGeoManager
1209 if (!fgGeometry || !fgGeometry->IsClosed()) {
1210 AliErrorClass("No active geometry or geometry not yet closed!");
1214 TGeoPNEntry* pne = fgGeometry->GetAlignableEntry(symname);
1215 if (!pne) return NULL;
1217 return GetMatrix(pne);
1220 //______________________________________________________________________
1221 Bool_t AliGeomManager::GetTranslation(Int_t index, Double_t t[3])
1223 // Get the translation vector for a given module 'index'
1224 // by quering the TGeoManager
1226 TGeoHMatrix *m = GetMatrix(index);
1227 if (!m) return kFALSE;
1229 Double_t *trans = m->GetTranslation();
1230 for (Int_t i = 0; i < 3; i++) t[i] = trans[i];
1235 //______________________________________________________________________
1236 Bool_t AliGeomManager::GetRotation(Int_t index, Double_t r[9])
1238 // Get the rotation matrix for a given module 'index'
1239 // by quering the TGeoManager
1241 TGeoHMatrix *m = GetMatrix(index);
1242 if (!m) return kFALSE;
1244 Double_t *rot = m->GetRotationMatrix();
1245 for (Int_t i = 0; i < 9; i++) r[i] = rot[i];
1250 //_____________________________________________________________________________
1251 Bool_t AliGeomManager::GetDeltaForBranch(Int_t index, TGeoHMatrix &inclusiveD)
1253 // The method sets the matrix passed as argument as the global delta
1254 // (for the volume referred by the unique index) including the displacements
1255 // of all parent volumes in the branch.
1258 TGeoHMatrix go,invgo;
1259 go = *GetOrigGlobalMatrix(index);
1260 invgo = go.Inverse();
1261 inclusiveD = *GetMatrix(index);
1262 inclusiveD.Multiply(&invgo);
1267 //_____________________________________________________________________________
1268 Bool_t AliGeomManager::GetDeltaForBranch(AliAlignObj& aao, TGeoHMatrix &inclusiveD)
1270 // The method sets the matrix passed as argument as the global delta
1271 // (for the volume referred by the alignment object) including the displacements
1272 // of all parent volumes in the brach.
1274 Int_t index = aao.GetVolUID();
1276 AliErrorClass("Either the alignment object or its index are not valid");
1279 return GetDeltaForBranch(index, inclusiveD);
1282 //______________________________________________________________________
1283 Bool_t AliGeomManager::GetOrigGlobalMatrix(const char* symname, TGeoHMatrix &m)
1285 // Get the global transformation matrix (ideal geometry) for a given alignable volume
1286 // The alignable volume is identified by 'symname' which has to be either a valid symbolic
1287 // name, the query being performed after alignment, or a valid volume path if the query is
1288 // performed before alignment.
1292 if (!fgGeometry || !fgGeometry->IsClosed()) {
1293 AliErrorClass("No active geometry or geometry not yet closed!");
1296 if (!fgGeometry->GetListOfPhysicalNodes()) {
1297 AliWarningClass("gGeoManager doesn't contain any aligned nodes!");
1298 if (!fgGeometry->cd(symname)) {
1299 AliErrorClass(Form("Volume path %s not valid!",symname));
1303 m = *fgGeometry->GetCurrentMatrix();
1308 TGeoPNEntry* pne = fgGeometry->GetAlignableEntry(symname);
1309 const char* path = NULL;
1311 m = *pne->GetGlobalOrig();
1314 AliWarningClass(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as a volume path!",symname));
1318 return GetOrigGlobalMatrixFromPath(path,m);
1321 //_____________________________________________________________________________
1322 Bool_t AliGeomManager::GetOrigGlobalMatrixFromPath(const char *path, TGeoHMatrix &m)
1324 // The method returns the global matrix for the volume identified by
1325 // 'path' in the ideal detector geometry.
1326 // The output global matrix is stored in 'm'.
1327 // Returns kFALSE in case TGeo has not been initialized or the volume
1328 // path is not valid.
1332 if (!fgGeometry || !fgGeometry->IsClosed()) {
1333 AliErrorClass("Can't get the original global matrix! gGeoManager doesn't exist or it is still opened!");
1337 if (!fgGeometry->CheckPath(path)) {
1338 AliErrorClass(Form("Volume path %s not valid!",path));
1342 TIter next(fgGeometry->GetListOfPhysicalNodes());
1343 fgGeometry->cd(path);
1345 while(fgGeometry->GetLevel()){
1347 TGeoPhysicalNode *physNode = NULL;
1349 TGeoNode *node = fgGeometry->GetCurrentNode();
1350 while ((physNode=(TGeoPhysicalNode*)next()))
1351 if (physNode->GetNode() == node) break;
1353 TGeoMatrix *lm = NULL;
1355 lm = physNode->GetOriginalMatrix();
1356 if (!lm) lm = node->GetMatrix();
1358 lm = node->GetMatrix();
1368 //_____________________________________________________________________________
1369 TGeoHMatrix* AliGeomManager::GetOrigGlobalMatrix(TGeoPNEntry * const pne)
1371 // The method returns global matrix for the ideal detector geometry
1372 // using the corresponding TGeoPNEntry as an input.
1373 // The returned pointer should be copied by the user, since its content could
1374 // be overwritten by a following call to the method.
1375 // In case of missing TGeoManager the method returns NULL.
1377 if (!fgGeometry || !fgGeometry->IsClosed()) {
1378 AliErrorClass("Can't get the global matrix! gGeoManager doesn't exist or it is still opened!");
1382 return pne->GetGlobalOrig();
1385 //______________________________________________________________________
1386 TGeoHMatrix* AliGeomManager::GetOrigGlobalMatrix(Int_t index)
1388 // The method returns global matrix from the ideal detector geometry
1389 // for the volume identified by its index.
1390 // The returned pointer should be copied by the user, since its content could
1391 // be overwritten by a following call to the method.
1392 // In case of missing TGeoManager the method returns NULL.
1393 // If possible, the method uses the LUT of original ideal matrices
1394 // for fast access. The LUT is reset in case a
1395 // new geometry is loaded.
1397 TGeoPNEntry* pne = GetPNEntry(index);
1398 return pne->GetGlobalOrig();
1401 //______________________________________________________________________
1402 Bool_t AliGeomManager::GetOrigTranslation(Int_t index, Double_t t[3])
1404 // Get the original translation vector (ideal geometry)
1405 // for a given module 'index' by quering the TGeoManager
1407 TGeoHMatrix *m = GetOrigGlobalMatrix(index);
1408 if (!m) return kFALSE;
1410 Double_t *trans = m->GetTranslation();
1411 for (Int_t i = 0; i < 3; i++) t[i] = trans[i];
1416 //______________________________________________________________________
1417 Bool_t AliGeomManager::GetOrigRotation(Int_t index, Double_t r[9])
1419 // Get the original rotation matrix (ideal geometry)
1420 // for a given module 'index' by quering the TGeoManager
1422 TGeoHMatrix *m = GetOrigGlobalMatrix(index);
1423 if (!m) return kFALSE;
1425 Double_t *rot = m->GetRotationMatrix();
1426 for (Int_t i = 0; i < 9; i++) r[i] = rot[i];
1431 //______________________________________________________________________
1432 const TGeoHMatrix* AliGeomManager::GetTracking2LocalMatrix(Int_t index)
1434 // Get the matrix which transforms from the tracking to the local RS
1435 // The method queries directly the TGeoPNEntry
1437 TGeoPNEntry *pne = GetPNEntry(index);
1438 if (!pne) return NULL;
1440 const TGeoHMatrix *m = pne->GetMatrix();
1442 AliErrorClass(Form("TGeoPNEntry (%s) contains no tracking-to-local matrix !",pne->GetName()));
1447 //______________________________________________________________________
1448 Bool_t AliGeomManager::GetTrackingMatrix(Int_t index, TGeoHMatrix &m)
1450 // Get the matrix which transforms from the tracking r.s. to
1452 // Returns kFALSE in case of error.
1456 TGeoHMatrix *m1 = GetMatrix(index);
1457 if (!m1) return kFALSE;
1459 const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index);
1460 if (!m2) return kFALSE;
1468 //_____________________________________________________________________________
1469 TGeoPNEntry* AliGeomManager::GetPNEntry(Int_t voluid) {
1470 // Returns the TGeoPNEntry for the given global volume ID "voluid"
1473 ELayerID layerId = VolUIDToLayer(voluid,modId);
1474 return GetPNEntry(layerId,modId);
1477 //_____________________________________________________________________________
1478 TGeoPNEntry* AliGeomManager::GetPNEntry(ELayerID layerId, Int_t modId)
1480 // Returns the TGeoPNEntry for a given layer
1484 if(modId<0 || modId>=fgLayerSize[layerId-kFirstLayer]){
1485 AliWarningClass(Form("Module number %d not in the valid range (0->%d) !",modId,fgLayerSize[layerId-kFirstLayer]-1));
1489 return fgPNEntry[layerId-kFirstLayer][modId];
1492 //_____________________________________________________________________________
1493 void AliGeomManager::CheckOverlapsOverPNs(Double_t threshold)
1495 // Check for overlaps/extrusions on physical nodes only;
1496 // this overlap-checker is meant to be used to check overlaps/extrusions
1497 // originated by the application of alignment objects.
1500 TObjArray* ovexlist = 0x0;
1502 AliInfoClass("********* Checking overlaps/extrusions over physical nodes only *********");
1503 TObjArray* pnList = gGeoManager->GetListOfPhysicalNodes();
1504 TGeoVolume* mvol = 0;
1505 TGeoPhysicalNode* pn;
1506 TObjArray* overlaps = new TObjArray(64);
1507 overlaps->SetOwner();
1511 for(Int_t pni=0; pni<pnList->GetEntriesFast(); pni++){
1512 pn = (TGeoPhysicalNode*) pnList->UncheckedAt(pni);
1513 // checking the volume of the mother (go upper in the tree in case it is an assembly)
1515 while(((TGeoVolume*)pn->GetVolume(pn->GetLevel()-levup))->IsAssembly()) levup++;
1516 //Printf("Going to upper level");
1517 mvol = pn->GetVolume(pn->GetLevel()-levup);
1518 if(!mvol->IsSelected()){
1519 AliInfoClass(Form("Checking overlaps for volume %s",mvol->GetName()));
1520 mvol->CheckOverlaps(threshold);
1521 ovexlist = gGeoManager->GetListOfOverlaps();
1522 TIter next(ovexlist);
1524 while ((ov=(TGeoOverlap*)next())) overlaps->Add(ov->Clone());
1525 mvol->SelectVolume();
1528 mvol->SelectVolume(kTRUE); // clears the list of selected volumes
1530 AliInfoClass(Form("Number of overlapping/extruding PNs: %d",overlaps->GetEntriesFast()));
1534 TIter nextN(overlaps);
1536 while ((ovlp=(TGeoOverlap*)nextN())) ovlp->PrintInfo();
1542 //_____________________________________________________________________________
1543 Int_t AliGeomManager::GetNalignable(const char* module)
1545 // Get number of declared alignable volumes in current geometry
1546 // for the given detector "module" passed as a vaild detector name
1547 // if the detector name is invalid return -1
1549 // return the detector index corresponding to detector
1551 for (index = 0; index < fgkNDetectors ; index++) {
1552 if ( strcmp(module, fgkDetectorName[index]) == 0 )
1555 if(index==fgkNDetectors) return -1;
1556 return fgNalignable[index];
1559 //_____________________________________________________________________________
1560 void AliGeomManager::InitNalignable()
1562 // Set number of declared alignable volumes for given detector in current geometry
1563 // by looping on the list of PNEntries
1566 Int_t nAlE = gGeoManager->GetNAlignable(); // total number of alignable entries
1567 TGeoPNEntry *pne = 0;
1568 const char* detName;
1570 for (Int_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1571 detName = fgkDetectorName[iDet];
1574 for(Int_t iE = 0; iE < nAlE; iE++)
1576 pne = gGeoManager->GetAlignableEntry(iE);
1577 TString pneName = pne->GetName();
1578 if(pneName.Contains(detName)) nAlDet++;
1579 if(!strcmp(detName,"GRP")) if(pneName.Contains("ABSO") || pneName.Contains("DIPO") ||
1580 pneName.Contains("FRAME") || pneName.Contains("PIPE") ||
1581 pneName.Contains("SHIL")) nAlDet++;
1583 fgNalignable[iDet] = nAlDet;
1588 //_____________________________________________________________________________
1589 Bool_t AliGeomManager::ApplyAlignObjsFromCDB(const char* AlignDetsList)
1591 // Calls AddAlignObjsFromCDBSingleDet for the detectors appearing in
1592 // the list passed as argument (called by AliSimulation and
1593 // AliReconstruction)
1594 // Read the alignment objects from CDB.
1595 // Each detector is supposed to have the
1596 // alignment objects in DET/Align/Data CDB path.
1597 // All the detector objects are then collected,
1598 // sorted by geometry level (starting from ALIC) and
1599 // then applied to the TGeo geometry.
1600 // Finally an overlaps check is performed.
1603 TObjArray alignObjArray;
1604 alignObjArray.Clear();
1605 alignObjArray.SetOwner(0);
1607 TString alObjsNotLoaded="";
1608 TString alObjsLoaded="";
1610 TString AlignDetsString(AlignDetsList);
1611 TObjArray *detsarr = AlignDetsString.Tokenize(' ');
1612 TIter iter(detsarr);
1613 TObjString *str = 0;
1615 while((str = (TObjString*) iter.Next())){
1616 TString det(str->String());
1617 AliDebugClass(5,Form("Loading alignment objs for %s",det.Data()));
1618 if(!LoadAlignObjsFromCDBSingleDet(det.Data(),alignObjArray)){
1619 alObjsNotLoaded += det.Data();
1620 alObjsNotLoaded += " ";
1622 alObjsLoaded += det.Data();
1623 alObjsLoaded += " ";
1629 if(!alObjsLoaded.IsNull()) AliInfoClass(Form("Alignment objects loaded for: %s",
1630 alObjsLoaded.Data()));
1631 if(!alObjsNotLoaded.IsNull())
1632 AliFatalClass(Form("Could not load alignment objects from OCDB for: %s",
1633 alObjsNotLoaded.Data()));
1635 return ApplyAlignObjsToGeom(alignObjArray);
1638 //_____________________________________________________________________________
1639 Bool_t AliGeomManager::LoadAlignObjsFromCDBSingleDet(const char* detName, TObjArray& alignObjArray)
1641 // Adds the alignable objects found in the CDBEntry for the detector
1642 // passed as argument to the array of all alignment objects to be applyed
1645 // Fills array of single detector's alignable objects from CDB
1647 AliDebugClass(2, Form("Loading alignment objs for detector: %s",detName));
1651 AliCDBPath path(detName,"Align","Data");
1653 entry=AliCDBManager::Instance()->Get(path.GetPath());
1655 AliDebugClass(2,Form("Couldn't load alignment data for detector %s",detName));
1659 TClonesArray *alignArray = (TClonesArray*) entry->GetObject();
1660 alignArray->SetOwner(0);
1661 Int_t nAlObjs = alignArray->GetEntries();
1662 AliDebugClass(2,Form("Found %d alignment objects for %s",nAlObjs,detName));
1663 Int_t nAlVols = GetNalignable(detName);
1664 if(nAlObjs!=nAlVols) AliWarningClass(Form("%d alignment objects loaded for %s, which has %d alignable volumes",nAlObjs,detName,GetNalignable(detName)));
1666 AliAlignObj *alignObj=0;
1667 TIter iter(alignArray);
1669 // loop over align objects in detector
1670 while( ( alignObj=(AliAlignObj *) iter.Next() ) ){
1671 alignObjArray.Add(alignObj);
1673 // delete entry --- Don't delete, it is cached!
1675 AliDebugClass(2, Form("fAlignObjArray entries: %d",alignObjArray.GetEntries() ));
1680 //_____________________________________________________________________________
1681 Bool_t AliGeomManager::ApplyAlignObjsToGeom(TObjArray& alignObjArray, Bool_t ovlpcheck)
1683 // Read collection of alignment objects (AliAlignObj derived) saved
1684 // in the TClonesArray alObjArray and apply them to gGeoManager
1686 alignObjArray.Sort();
1687 Int_t nvols = alignObjArray.GetEntriesFast();
1689 Bool_t flag = kTRUE;
1691 for(Int_t j=0; j<nvols; j++)
1693 AliAlignObj* alobj = (AliAlignObj*) alignObjArray.UncheckedAt(j);
1694 if(!alobj->ApplyToGeometry(ovlpcheck))
1697 AliDebugClass(5,Form("Error applying alignment object for volume %s !",alobj->GetSymName()));
1699 AliDebugClass(5,Form("Alignment object for volume %s applied successfully",alobj->GetSymName()));
1704 if (AliDebugLevelClass() > 5) {
1705 fgGeometry->CheckOverlaps(0.001);
1706 TObjArray* ovexlist = fgGeometry->GetListOfOverlaps();
1707 if(ovexlist->GetEntriesFast()){
1708 AliErrorClass("The application of alignment objects to the geometry caused huge overlaps/extrusions!");
1709 fgGeometry->PrintOverlaps();
1713 // Update the TGeoPhysicalNodes
1714 fgGeometry->RefreshPhysicalNodes();
1720 //_____________________________________________________________________________
1721 Bool_t AliGeomManager::ApplyAlignObjsToGeom(const char* fileName, const char* clArrayName)
1723 // read collection of alignment objects (AliAlignObj derived) saved
1724 // in the TClonesArray ClArrayName in the file fileName and apply
1725 // them to the geometry
1728 TFile* inFile = TFile::Open(fileName,"READ");
1729 if (!inFile || !inFile->IsOpen()) {
1730 AliErrorClass(Form("Could not open file %s !",fileName));
1734 TClonesArray* alignObjArray = ((TClonesArray*) inFile->Get(clArrayName));
1736 if (!alignObjArray) {
1737 AliErrorClass(Form("Could not get array (%s) from file (%s) !",clArrayName,fileName));
1741 return ApplyAlignObjsToGeom(*alignObjArray);
1745 //_____________________________________________________________________________
1746 Bool_t AliGeomManager::ApplyAlignObjsToGeom(AliCDBParam* param, AliCDBId& Id)
1748 // read collection of alignment objects (AliAlignObj derived) saved
1749 // in the TClonesArray ClArrayName in the AliCDBEntry identified by
1750 // param (to get the AliCDBStorage) and Id; apply the alignment objects
1754 AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage(param);
1755 AliCDBEntry* entry = storage->Get(Id);
1756 TClonesArray* alignObjArray = ((TClonesArray*) entry->GetObject());
1758 return ApplyAlignObjsToGeom(*alignObjArray);
1762 //_____________________________________________________________________________
1763 Bool_t AliGeomManager::ApplyAlignObjsToGeom(const char* uri, const char* path, Int_t runnum, Int_t version, Int_t sversion)
1765 // read collection of alignment objects (AliAlignObj derived) saved
1766 // in the TClonesArray ClArrayName in the AliCDBEntry identified by
1767 // param (to get the AliCDBStorage) and Id; apply the alignment objects
1771 AliCDBParam* param = AliCDBManager::Instance()->CreateParameter(uri);
1772 AliCDBId id(path, runnum, runnum, version, sversion);
1774 return ApplyAlignObjsToGeom(param, id);
1778 //_____________________________________________________________________________
1779 Bool_t AliGeomManager::ApplyAlignObjsToGeom(const char* detName, Int_t runnum, Int_t version, Int_t sversion)
1781 // read collection of alignment objects (AliAlignObj derived) saved
1782 // in the TClonesArray ClArrayName in the AliCDBEntry identified by
1783 // param (to get the AliCDBStorage) and Id; apply the alignment objects
1787 AliCDBPath path(detName,"Align","Data");
1788 AliCDBEntry* entry = AliCDBManager::Instance()->Get(path.GetPath(),runnum,version,sversion);
1790 if(!entry) return kFALSE;
1791 TClonesArray* alignObjArray = ((TClonesArray*) entry->GetObject());
1793 return ApplyAlignObjsToGeom(*alignObjArray);
1796 //_____________________________________________________________________________
1797 void AliGeomManager::ResetPNEntriesLUT()
1799 // cleans static arrays containing the information on currently loaded geometry
1801 for (Int_t iLayer = 0; iLayer < (kLastLayer - kFirstLayer); iLayer++){
1802 if (!fgPNEntry[iLayer]) continue;
1803 for (Int_t modnum=0; modnum<fgLayerSize[iLayer]; modnum++) fgPNEntry[iLayer][modnum] = 0;