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 TGeoManager* AliGeomManager::fgGeometry = 0x0;
103 //_____________________________________________________________________________
104 void AliGeomManager::LoadGeometry(const char *geomFileName)
107 // Load geometry either from a file
108 // or from the corresponding CDB entry
111 if (geomFileName && (!gSystem->AccessPathName(geomFileName))) {
112 fgGeometry = TGeoManager::Import(geomFileName);
113 AliInfoClass(Form("From now on using geometry from custom geometry file %s",geomFileName));
117 AliCDBPath path("GRP","Geometry","Data");
119 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
120 if(!entry) AliFatalClass("Couldn't load geometry data from CDB!");
123 fgGeometry = (TGeoManager*) entry->GetObject();
124 if (!fgGeometry) AliFatalClass("Couldn't find TGeoManager in the specified CDB entry!");
126 AliInfoClass(Form("From now on using geometry from CDB base folder %s",
127 AliCDBManager::Instance()->GetURI("Geometry/Align/Data")));
133 //_____________________________________________________________________________
134 void AliGeomManager::SetGeometry(TGeoManager *geom)
136 // Load already active geometry
137 if (!geom) AliFatalClass("Pointer to the active geometry is 0x0!");
143 //_____________________________________________________________________________
144 AliGeomManager::AliGeomManager():
147 // default constructor
150 //_____________________________________________________________________________
151 AliGeomManager::~AliGeomManager()
156 //_____________________________________________________________________________
157 Int_t AliGeomManager::LayerSize(Int_t layerId)
159 // Get the layer size for layer corresponding to layerId.
160 // Implemented only for ITS,TPC,TRD,TOF and HMPID
162 if (layerId < kFirstLayer || layerId >= kLastLayer) {
163 AliErrorClass(Form("Invalid layer index %d ! Layer range is (%d -> %d) !",layerId,kFirstLayer,kLastLayer));
167 return fgLayerSize[layerId - kFirstLayer];
171 //_____________________________________________________________________________
172 const char* AliGeomManager::LayerName(Int_t layerId)
174 // Get the layer name corresponding to layerId.
175 // Implemented only for ITS,TPC,TRD,TOF and HMPID
177 if (layerId < kFirstLayer || layerId >= kLastLayer) {
178 AliErrorClass(Form("Invalid layer index %d ! Layer range is (%d -> %d) !",layerId,kFirstLayer,kLastLayer));
179 return "Invalid Layer!";
182 return fgLayerName[layerId - kFirstLayer];
186 //_____________________________________________________________________________
187 UShort_t AliGeomManager::LayerToVolUID(ELayerID layerId, Int_t modId)
189 // From detector (layer) name and module number (according to detector
190 // internal numbering) build the unique numerical identity of that volume
192 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
193 // remaining 11 for module ID inside det (2048 possible values).
194 // NO check for validity of given modId inside the layer for speed's sake.
196 return ((UShort_t(layerId) << 11) | UShort_t(modId));
199 //_____________________________________________________________________________
200 UShort_t AliGeomManager::LayerToVolUID(Int_t layerId, Int_t modId)
202 // From detector (layer) name and module number (according to detector
203 // internal numbering) build the unique numerical identity of that volume
205 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
206 // remaining 11 for module ID inside det (2048 possible values).
207 // NO check for validity of given modId inside the layer for speed's sake.
209 return ((UShort_t(layerId) << 11) | UShort_t(modId));
212 //_____________________________________________________________________________
213 UShort_t AliGeomManager::LayerToVolUIDSafe(ELayerID layerId, Int_t modId)
215 // From detector (layer) name and module number (according to detector
216 // internal numbering) build the unique numerical identity of that volume
218 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
219 // remaining 11 for module ID inside det (2048 possible values).
220 // Check validity of given modId inside the layer.
222 if(modId < 0 || modId >= LayerSize(layerId)){
223 AliErrorClass(Form("Invalid volume id %d ! Range of valid ids for layer \"%s\" is [0, %d] !",modId,LayerName(layerId),LayerSize(layerId)-1));
226 return ((UShort_t(layerId) << 11) | UShort_t(modId));
229 //_____________________________________________________________________________
230 UShort_t AliGeomManager::LayerToVolUIDSafe(Int_t layerId, Int_t modId)
232 // From detector (layer) name and module number (according to detector
233 // internal numbering) build the unique numerical identity of that volume
235 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
236 // remaining 11 for module ID inside det (2048 possible values).
237 // Check validity of given modId inside the layer.
239 if(modId < 0 || modId >= LayerSize(layerId)){
240 AliErrorClass(Form("Invalid volume id %d ! Range of valid ids for layer \"%s\" is [0, %d] !",modId,LayerName(layerId),LayerSize(layerId)-1));
243 return ((UShort_t(layerId) << 11) | UShort_t(modId));
246 //_____________________________________________________________________________
247 AliGeomManager::ELayerID AliGeomManager::VolUIDToLayer(UShort_t voluid, Int_t &modId)
249 // From voluid, unique numerical identity of that volume inside ALICE,
250 // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
251 // remaining 11 for module ID inside det (2048 possible values)), return
252 // the identity of the layer to which that volume belongs and sets the
253 // argument modId to the identity of that volume internally to the layer.
254 // NO check for validity of given voluid for speed's sake.
256 modId = voluid & 0x7ff;
258 return VolUIDToLayer(voluid);
261 //_____________________________________________________________________________
262 AliGeomManager::ELayerID AliGeomManager::VolUIDToLayer(UShort_t voluid)
264 // From voluid, unique numerical identity of that volume inside ALICE,
265 // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
266 // remaining 11 for module ID inside det (2048 possible values)), return
267 // the identity of the layer to which that volume belongs
268 // NO check for validity of given voluid for speed's sake.
270 return ELayerID(voluid >> 11);
273 //_____________________________________________________________________________
274 AliGeomManager::ELayerID AliGeomManager::VolUIDToLayerSafe(UShort_t voluid, Int_t &modId)
276 // From voluid, unique numerical identity of that volume inside ALICE,
277 // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
278 // remaining 11 for module ID inside det (2048 possible values)), returns
279 // the identity of the layer to which that volume belongs and sets the
280 // argument modId to the identity of that volume internally to the layer.
281 // Checks the validity of the given voluid
283 ELayerID layId = VolUIDToLayerSafe(voluid);
285 Int_t mId = Int_t(voluid & 0x7ff);
286 if( mId>=0 && mId<LayerSize(layId)){
292 AliErrorClass(Form("Invalid unique volume id: %d !",voluid));
294 return kInvalidLayer;
298 //_____________________________________________________________________________
299 AliGeomManager::ELayerID AliGeomManager::VolUIDToLayerSafe(UShort_t voluid)
301 // From voluid, unique numerical identity of that volume inside ALICE,
302 // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
303 // remaining 11 for module ID inside det (2048 possible values)), returns
304 // the identity of the layer to which that volume belongs
305 // Checks the validity of the given voluid
307 if( (voluid >> 11) < kLastLayer) return ELayerID(voluid >> 11);
309 AliErrorClass(Form("Invalid layer id: %d !",(voluid >> 11)));
310 return kInvalidLayer;
314 //_____________________________________________________________________________
315 Bool_t AliGeomManager::GetFromGeometry(const char *symname, AliAlignObj &alobj)
317 // Get the alignment object which corresponds to the symbolic volume name
318 // symname (in case equal to the TGeo volume path)
319 // The method is extremely slow due to the searching by string,
320 // therefore it should be used with great care!!
321 // This method returns FALSE if the symname of the object was not
322 // valid neither to get a TGeoPEntry nor as a volume path, or if the path
323 // associated to the TGeoPNEntry was not valid.
326 // Reset the alignment object
327 alobj.SetPars(0,0,0,0,0,0);
328 alobj.SetSymName(symname);
330 if (!fgGeometry || !fgGeometry->IsClosed()) {
331 AliErrorClass("Can't get the alignment object! gGeoManager doesn't exist or it is still opened!");
335 if (!fgGeometry->GetListOfPhysicalNodes()) {
336 AliErrorClass("Can't get the alignment object! gGeoManager doesn't contain any aligned nodes!");
341 TGeoPNEntry* pne = fgGeometry->GetAlignableEntry(symname);
343 path = pne->GetTitle();
345 AliWarningClass(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as a volume path!",symname));
348 TObjArray* nodesArr = fgGeometry->GetListOfPhysicalNodes();
349 TGeoPhysicalNode* node = NULL;
350 for (Int_t iNode = 0; iNode < nodesArr->GetEntriesFast(); iNode++) {
351 TGeoPhysicalNode* tempNode = (TGeoPhysicalNode*) nodesArr->UncheckedAt(iNode);
352 const char *nodePath = tempNode->GetName();
353 if (strcmp(path,nodePath) == 0) {
360 if (!fgGeometry->cd(path)) {
361 AliErrorClass(Form("%s not valid neither as symbolic volume name nor as volume path!",path));
365 AliWarningClass(Form("Volume (%s) has not been misaligned!",path));
370 TGeoHMatrix align,gprime,g,ginv,l;
371 gprime = *node->GetMatrix();
372 l = *node->GetOriginalMatrix();
373 g = *node->GetMatrix(node->GetLevel()-1);
376 align = gprime * ginv;
378 return alobj.SetMatrix(align);
382 //_____________________________________________________________________________
383 void AliGeomManager::InitAlignObjFromGeometry()
385 // Loop over all alignable volumes and extract
386 // the corresponding alignment objects from
389 if(fgAlignObjs[0]) return;
391 for (Int_t iLayer = kFirstLayer; iLayer < AliGeomManager::kLastLayer; iLayer++) {
392 fgAlignObjs[iLayer-kFirstLayer] = new AliAlignObj*[LayerSize(iLayer)];
393 for (Int_t iModule = 0; iModule < LayerSize(iLayer); iModule++) {
394 UShort_t volid = LayerToVolUID(iLayer,iModule);
395 fgAlignObjs[iLayer-kFirstLayer][iModule] = new AliAlignObjParams("",volid,0,0,0,0,0,0,kTRUE);
396 const char *symname = SymName(volid);
397 if (!GetFromGeometry(symname, *fgAlignObjs[iLayer-kFirstLayer][iModule]))
398 AliErrorClass(Form("Failed to extract the alignment object for the volume (ID=%d and path=%s) !",volid,symname));
404 //_____________________________________________________________________________
405 AliAlignObj* AliGeomManager::GetAlignObj(UShort_t voluid)
407 // Returns the alignment object for given volume ID
410 ELayerID layerId = VolUIDToLayer(voluid,modId);
411 return GetAlignObj(layerId,modId);
414 //_____________________________________________________________________________
415 AliAlignObj* AliGeomManager::GetAlignObj(ELayerID layerId, Int_t modId)
417 // Returns pointer to alignment object given its layer and module ID
419 if(modId<0 || modId>=fgLayerSize[layerId-kFirstLayer]){
420 AliWarningClass(Form("Module number %d not in the valid range (0->%d) !",modId,fgLayerSize[layerId-kFirstLayer]-1));
423 InitAlignObjFromGeometry();
425 return fgAlignObjs[layerId-kFirstLayer][modId];
428 //_____________________________________________________________________________
429 const char* AliGeomManager::SymName(UShort_t voluid)
431 // Returns the symbolic volume name for given volume ID
434 ELayerID layerId = VolUIDToLayer(voluid,modId);
435 return SymName(layerId,modId);
438 //_____________________________________________________________________________
439 const char* AliGeomManager::SymName(ELayerID layerId, Int_t modId)
441 // Returns the symbolic volume name given for a given layer
445 AliErrorClass("No geometry instance loaded yet!");
448 if(modId<0 || modId>=fgLayerSize[layerId-kFirstLayer]){
449 AliWarningClass(Form("Module number %d not in the valid range (0->%d) !",modId,fgLayerSize[layerId-kFirstLayer]-1));
453 TGeoPNEntry* pne = fgPNEntry[layerId-kFirstLayer][modId];
456 AliWarningClass(Form("Module %d of layer %s is not activated!",modId,LayerName(layerId)));
459 return pne->GetName();
463 //_____________________________________________________________________________
464 Bool_t AliGeomManager::CheckSymNamesLUT(const char* detsToBeChecked)
466 // Check the look-up table which associates the unique numerical identity of
467 // each alignable volume to the corresponding symbolic volume name.
468 // The LUT is now hold inside the geometry and handled by TGeo.
469 // The method is meant to be launched when loading a geometry to verify that
470 // no changes in the symbolic names have been introduced, which would prevent
471 // backward compatibility with alignment objects.
472 // To accept both complete and partial geometry, this method skips the check
473 // for TRD and TOF volumes which are missing in the partial geometry.
476 // TString detsString(detsToBeChecked);
477 // if(detsString.Contains("ALL")) detsString="ITS TPC TOF TRD HMPID PHOS EMCAL";
479 // Temporary measure to face the case of reconstruction over detectors not present in the geometry
480 TString detsString = "";
481 if(fgGeometry->CheckPath("ALIC_1/ITSV_1")) detsString+="ITS ";
482 if(fgGeometry->CheckPath("ALIC_1/TPC_M_1")) detsString+="TPC ";
485 TString baseTof("ALIC_1/B077_1/BSEGMO");
486 TString middleTof("_1/BTOF");
487 TString trailTof("_1/FTOA_0");
488 Bool_t tofActive=kFALSE;
490 for(Int_t sm=0; sm<18; sm++)
498 if(fgGeometry->CheckPath(tofsm.Data()))
504 if(tofActive) detsString+="TOF ";
507 TString baseTrd("ALIC_1/B077_1/BSEGMO");
508 TString middleTrd("_1/BTRD");
509 TString trailTrd("_1/UTR1_1");
510 Bool_t trdActive=kFALSE;
512 for(Int_t sm=0; sm<18; sm++)
520 if(fgGeometry->CheckPath(trdsm.Data()))
526 if(trdActive) detsString+="TRD ";
528 if(fgGeometry->CheckPath("ALIC_1/Hmp0_0")) detsString+="HMPID ";
530 TString phosMod, cpvMod;
531 TString basePhos("ALIC_1/PHOS_");
532 Bool_t phosActive=kFALSE;
533 Bool_t cpvActive=kFALSE;
535 for(Int_t pmod=0; pmod<5; pmod++)
537 phosMods[pmod]=kFALSE;
542 if(fgGeometry->CheckPath(phosMod.Data()))
545 phosMods[pmod]=kTRUE;
546 if(fgGeometry->CheckPath(cpvMod.Data())) cpvActive=kTRUE;
549 if(phosActive) detsString+="PHOS ";
551 if(fgGeometry->CheckPath("ALIC_1/XEN1_1")) detsString+="EMCAL";
555 TGeoPNEntry* pne = 0x0;
556 Int_t uid; // global unique identity
557 Int_t modnum; // unique id inside layer; in the following, set it to 0 at the start of each layer
559 if(detsString.Contains("ITS")){
560 /********************* ITS layers ***********************/
561 AliDebugClass(2,"Checking consistency of symbolic names for ITS layers");
562 TString strSPD = "ITS/SPD";
563 TString strSDD = "ITS/SDD";
564 TString strSSD = "ITS/SSD";
565 TString strStave = "/Stave";
566 TString strHalfStave = "/HalfStave";
567 TString strLadder = "/Ladder";
568 TString strSector = "/Sector";
569 TString strSensor = "/Sensor";
570 TString strEntryName1;
571 TString strEntryName2;
572 TString strEntryName3;
574 /********************* SPD layer1 ***********************/
578 for(Int_t cSect = 0; cSect<10; cSect++){
579 strEntryName1 = strSPD;
581 strEntryName1 += strSector;
582 strEntryName1 += cSect;
584 for(Int_t cStave =0; cStave<2; cStave++){
585 strEntryName2 = strEntryName1;
586 strEntryName2 += strStave;
587 strEntryName2 += cStave;
589 for (Int_t cHS=0; cHS<2; cHS++) {
590 strEntryName3 = strEntryName2;
591 strEntryName3 += strHalfStave;
592 strEntryName3 += cHS;
594 for(Int_t cLad =0; cLad<2; cLad++){
595 symname = strEntryName3;
596 symname += strLadder;
597 symname += cLad+cHS*2;
598 uid = LayerToVolUID(kSPD1,modnum++);
599 pne = fgGeometry->GetAlignableEntryByUID(uid);
602 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
605 sname = pne->GetName();
606 if(symname.CompareTo(sname))
608 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d."
609 "Expected was %s, found was %s!", uid, symname.Data(), sname));
618 /********************* SPD layer2 ***********************/
622 for(Int_t cSect = 0; cSect<10; cSect++){
623 strEntryName1 = strSPD;
625 strEntryName1 += strSector;
626 strEntryName1 += cSect;
628 for(Int_t cStave =0; cStave<4; cStave++){
629 strEntryName2 = strEntryName1;
630 strEntryName2 += strStave;
631 strEntryName2 += cStave;
633 for (Int_t cHS=0; cHS<2; cHS++) {
634 strEntryName3 = strEntryName2;
635 strEntryName3 += strHalfStave;
636 strEntryName3 += cHS;
638 for(Int_t cLad =0; cLad<2; cLad++){
639 symname = strEntryName3;
640 symname += strLadder;
641 symname += cLad+cHS*2;
642 uid = LayerToVolUID(kSPD2,modnum++);
643 pne = fgGeometry->GetAlignableEntryByUID(uid);
646 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
649 sname = pne->GetName();
650 if(symname.CompareTo(sname))
652 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d."
653 "Expected was %s, found was %s!", uid, symname.Data(), sname));
662 /********************* SDD layer1 ***********************/
666 for(Int_t c1 = 1; c1<=14; c1++){
667 strEntryName1 = strSDD;
669 strEntryName1 +=strLadder;
670 strEntryName1 += (c1-1);
671 for(Int_t c2 =1; c2<=6; c2++){
672 symname = strEntryName1;
673 symname += strSensor;
675 uid = LayerToVolUID(kSDD1,modnum++);
676 pne = fgGeometry->GetAlignableEntryByUID(uid);
679 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
682 sname = pne->GetName();
683 if(symname.CompareTo(sname))
685 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
686 "Expected was %s, found was %s!", uid, symname.Data(), sname));
693 /********************* SDD layer2 ***********************/
697 for(Int_t c1 = 1; c1<=22; c1++){
698 strEntryName1 = strSDD;
700 strEntryName1 +=strLadder;
701 strEntryName1 += (c1-1);
702 for(Int_t c2 = 1; c2<=8; c2++){
703 symname = strEntryName1;
704 symname += strSensor;
706 uid = LayerToVolUID(kSDD2,modnum++);
707 pne = fgGeometry->GetAlignableEntryByUID(uid);
710 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
713 sname = pne->GetName();
714 if(symname.CompareTo(sname))
716 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
717 "Expected was %s, found was %s!", uid, symname.Data(), sname));
724 /********************* SSD layer1 ***********************/
728 for(Int_t c1 = 1; c1<=34; c1++){
729 strEntryName1 = strSSD;
731 strEntryName1 +=strLadder;
732 strEntryName1 += (c1-1);
733 for(Int_t c2 = 1; c2<=22; c2++){
734 symname = strEntryName1;
735 symname += strSensor;
737 uid = LayerToVolUID(kSSD1,modnum++);
738 pne = fgGeometry->GetAlignableEntryByUID(uid);
741 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
744 sname = pne->GetName();
745 if(symname.CompareTo(sname))
747 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
748 "Expected was %s, found was %s!", uid, symname.Data(), sname));
755 /********************* SSD layer2 ***********************/
759 for(Int_t c1 = 1; c1<=38; c1++){
760 strEntryName1 = strSSD;
762 strEntryName1 +=strLadder;
763 strEntryName1 += (c1-1);
764 for(Int_t c2 = 1; c2<=25; c2++){
765 symname = strEntryName1;
766 symname += strSensor;
768 uid = LayerToVolUID(kSSD2,modnum++);
769 pne = fgGeometry->GetAlignableEntryByUID(uid);
772 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
775 sname = pne->GetName();
776 if(symname.CompareTo(sname))
778 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
779 "Expected was %s, found was %s!", uid, symname.Data(), sname));
786 AliDebugClass(2,"Consistency check for ITS symbolic names finished successfully.");
789 if(detsString.Contains("TPC"))
791 /*************** TPC inner and outer layers ****************/
793 AliDebugClass(2,"Checking consistency of symbolic names for TPC layers");
794 TString sAsector="TPC/EndcapA/Sector";
795 TString sCsector="TPC/EndcapC/Sector";
796 TString sInner="/InnerChamber";
797 TString sOuter="/OuterChamber";
799 /*************** TPC inner chambers' layer ****************/
803 for(Int_t cnt=1; cnt<=18; cnt++)
808 uid = LayerToVolUID(kTPC1,modnum++);
809 pne = fgGeometry->GetAlignableEntryByUID(uid);
812 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
815 sname = pne->GetName();
816 if(symname.CompareTo(sname))
818 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
819 "Expected was %s, found was %s!", uid, symname.Data(), sname));
824 for(Int_t cnt=1; cnt<=18; cnt++)
829 uid = LayerToVolUID(kTPC1,modnum++);
830 pne = fgGeometry->GetAlignableEntryByUID(uid);
833 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
836 sname = pne->GetName();
837 if(symname.CompareTo(sname))
839 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
840 "Expected was %s, found was %s!", uid, symname.Data(), sname));
846 /*************** TPC outer chambers' layer ****************/
850 for(Int_t cnt=1; cnt<=18; cnt++)
855 uid = LayerToVolUID(kTPC2,modnum++);
856 pne = fgGeometry->GetAlignableEntryByUID(uid);
859 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
862 sname = pne->GetName();
863 if(symname.CompareTo(sname))
865 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
866 "Expected was %s, found was %s!", uid, symname.Data(), sname));
871 for(Int_t cnt=1; cnt<=18; cnt++)
876 uid = LayerToVolUID(kTPC2,modnum++);
877 pne = fgGeometry->GetAlignableEntryByUID(uid);
880 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
883 sname = pne->GetName();
884 if(symname.CompareTo(sname))
886 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
887 "Expected was %s, found was %s!", uid, symname.Data(), sname));
893 AliDebugClass(2,"Consistency check for TPC symbolic names finished successfully.");
896 if(detsString.Contains("TOF"))
898 /********************* TOF layer ***********************/
900 AliDebugClass(2,"Checking consistency of symbolic names for TOF layers");
907 Int_t nStrips=nstrA+2*nstrB+2*nstrC;
909 TString snSM = "TOF/sm";
910 TString snSTRIP = "/strip";
912 for (Int_t isect = 0; isect < nSectors; isect++) {
913 for (Int_t istr = 1; istr <= nStrips; istr++) {
915 symname += Form("%02d",isect);
917 symname += Form("%02d",istr);
918 uid = LayerToVolUID(kTOF,modnum++);
919 if(!tofSMs[isect]) continue; // taking possible missing TOF sectors (partial geometry) into account
920 AliDebugClass(2,Form("Consistency check for symnames of TOF supermodule %d.",isect));
921 if ((isect==13 || isect==14 || isect==15) && (istr >= 39 && istr <= 53)) continue; //taking holes into account
922 pne = fgGeometry->GetAlignableEntryByUID(uid);
925 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
928 sname = pne->GetName();
929 if(symname.CompareTo(sname))
931 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
932 "Expected was %s, found was %s!", uid, symname.Data(), sname));
938 AliDebugClass(2,"Consistency check for TOF symbolic names finished successfully.");
941 if(detsString.Contains("HMPID"))
943 /********************* HMPID layer ***********************/
945 AliDebugClass(2,"Checking consistency of symbolic names for HMPID layers");
946 TString str = "/HMPID/Chamber";
948 for (modnum=0; modnum < 7; modnum++) {
951 uid = LayerToVolUID(kHMPID,modnum);
952 pne = fgGeometry->GetAlignableEntryByUID(uid);
955 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
958 sname = pne->GetName();
959 if(symname.CompareTo(sname))
961 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
962 "Expected was %s, found was %s!", uid, symname.Data(), sname));
967 AliDebugClass(2,"Consistency check for HMPID symbolic names finished successfully.");
970 if(detsString.Contains("TRD"))
972 /********************* TRD layers 1-6 *******************/
973 //!! 6 layers with index increasing in outwards direction
975 AliDebugClass(2,"Checking consistency of symbolic names for TRD layers");
976 Int_t arTRDlayId[6] = {kTRD1, kTRD2, kTRD3, kTRD4, kTRD5, kTRD6};
978 TString snStr = "TRD/sm";
979 TString snApp1 = "/st";
980 TString snApp2 = "/pl";
982 for(Int_t layer=0; layer<6; layer++){
984 for (Int_t isect = 0; isect < 18; isect++) {
985 for (Int_t icham = 0; icham < 5; icham++) {
987 symname += Form("%02d",isect);
992 uid = LayerToVolUID(arTRDlayId[layer],modnum++);
993 if(!trdSMs[isect]) continue;
994 AliDebugClass(2,Form("Consistency check for symnames of TRD supermodule %d.",isect));
995 if ((isect==13 || isect==14 || isect==15) && icham==2) continue; //keeping holes into account
996 pne = fgGeometry->GetAlignableEntryByUID(uid);
999 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1002 sname = pne->GetName();
1003 if(symname.CompareTo(sname))
1005 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1006 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1013 AliDebugClass(2,"Consistency check for TRD symbolic names finished successfully.");
1016 if(detsString.Contains("PHOS"))
1018 /********************* PHOS EMC layer ***********************/
1020 AliDebugClass(2,"Checking consistency of symbolic names for PHOS layers");
1022 TString str = "PHOS/Module";
1025 for (Int_t iModule=0; iModule < 5; iModule++) {
1026 if(!phosMods[iModule]) continue;
1028 symname += (iModule+1);
1029 uid = LayerToVolUID(kPHOS1,iModule);
1030 pne = fgGeometry->GetAlignableEntryByUID(uid);
1033 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1036 sname = pne->GetName();
1037 if(symname.CompareTo(sname))
1039 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1040 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1043 /********************* PHOS CPV layer ***********************/
1044 if(!cpvActive) continue;
1046 uid = LayerToVolUID(kPHOS2,iModule);
1047 pne = fgGeometry->GetAlignableEntryByUID(uid);
1050 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1053 sname = pne->GetName();
1054 if(symname.CompareTo(sname))
1056 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1057 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1061 AliDebugClass(2,"Consistency check for PHOS symbolic names finished successfully.");
1064 if(detsString.Contains("EMCAL"))
1066 /********************* EMCAL layer ***********************/
1068 AliDebugClass(2,"Checking consistency of symbolic names for EMCAL layers");
1069 TString str = "EMCAL/FullSupermodule";
1072 for (Int_t iModule=1; iModule <= 12; iModule++) {
1076 symname = "EMCAL/HalfSupermodule";
1077 symname += iModule-10;
1080 uid = LayerToVolUID(kEMCAL,modnum);
1081 pne = fgGeometry->GetAlignableEntryByUID(uid);
1084 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1087 sname = pne->GetName();
1088 if(symname.CompareTo(sname))
1090 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1091 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1096 AliDebugClass(2,"Consistency check for EMCAL symbolic names finished successfully.");
1103 //_____________________________________________________________________________
1104 void AliGeomManager::InitPNEntriesLUT()
1106 // Initialize the look-up table which associates the unique
1107 // numerical identity of each alignable volume to the
1108 // corresponding TGeoPNEntry.
1109 // The LUTs are static; they are created at the creation of the
1110 // AliGeomManager instance and recreated if the geometry has changed
1112 if (fgPNEntry[0]) return;
1115 AliErrorClass("Impossible to initialize PNEntries LUT without an active geometry");
1119 for (Int_t iLayer = 0; iLayer < (kLastLayer - kFirstLayer); iLayer++){
1120 fgPNEntry[iLayer] = new TGeoPNEntry*[fgLayerSize[iLayer]];
1121 for(Int_t modnum=0; modnum<fgLayerSize[iLayer]; modnum++){
1122 fgPNEntry[iLayer][modnum] = fgGeometry->GetAlignableEntryByUID(LayerToVolUID(iLayer+1,modnum));
1127 //______________________________________________________________________
1128 TGeoHMatrix* AliGeomManager::GetMatrix(TGeoPNEntry* pne)
1130 // Get the global transformation matrix for a given PNEntry
1131 // by quering the TGeoManager
1133 if (!fgGeometry || !fgGeometry->IsClosed()) {
1134 AliErrorClass("Can't get the global matrix! gGeoManager doesn't exist or it is still opened!");
1138 TGeoPhysicalNode *pnode = pne->GetPhysicalNode();
1139 if (pnode) return pnode->GetMatrix();
1141 const char* path = pne->GetTitle();
1142 if (!fgGeometry->cd(path)) {
1143 AliErrorClass(Form("Volume path %s not valid!",path));
1146 return fgGeometry->GetCurrentMatrix();
1149 //______________________________________________________________________
1150 TGeoHMatrix* AliGeomManager::GetMatrix(Int_t index)
1152 // Get the global transformation matrix for a given alignable volume
1153 // identified by its unique ID 'index' by quering the TGeoManager
1155 TGeoPNEntry *pne = GetPNEntry(index);
1156 if (!pne) return NULL;
1158 return GetMatrix(pne);
1161 //______________________________________________________________________
1162 TGeoHMatrix* AliGeomManager::GetMatrix(const char* symname)
1164 // Get the global transformation matrix for a given alignable volume
1165 // identified by its symbolic name 'symname' by quering the TGeoManager
1167 if (!fgGeometry || !fgGeometry->IsClosed()) {
1168 AliErrorClass("No active geometry or geometry not yet closed!");
1172 TGeoPNEntry* pne = fgGeometry->GetAlignableEntry(symname);
1173 if (!pne) return NULL;
1175 return GetMatrix(pne);
1178 //______________________________________________________________________
1179 Bool_t AliGeomManager::GetTranslation(Int_t index, Double_t t[3])
1181 // Get the translation vector for a given module 'index'
1182 // by quering the TGeoManager
1184 TGeoHMatrix *m = GetMatrix(index);
1185 if (!m) return kFALSE;
1187 Double_t *trans = m->GetTranslation();
1188 for (Int_t i = 0; i < 3; i++) t[i] = trans[i];
1193 //______________________________________________________________________
1194 Bool_t AliGeomManager::GetRotation(Int_t index, Double_t r[9])
1196 // Get the rotation matrix for a given module 'index'
1197 // by quering the TGeoManager
1199 TGeoHMatrix *m = GetMatrix(index);
1200 if (!m) return kFALSE;
1202 Double_t *rot = m->GetRotationMatrix();
1203 for (Int_t i = 0; i < 9; i++) r[i] = rot[i];
1208 //_____________________________________________________________________________
1209 Bool_t AliGeomManager::GetDeltaForBranch(Int_t index, TGeoHMatrix &inclusiveD)
1211 // The method sets the matrix passed as argument as the global delta
1212 // (for the volume referred by the unique index) including the displacements
1213 // of all parent volumes in the branch.
1216 TGeoHMatrix go,invgo;
1217 go = *GetOrigGlobalMatrix(index);
1218 invgo = go.Inverse();
1219 inclusiveD = *GetMatrix(index);
1220 inclusiveD.Multiply(&invgo);
1225 //_____________________________________________________________________________
1226 Bool_t AliGeomManager::GetDeltaForBranch(AliAlignObj& aao, TGeoHMatrix &inclusiveD)
1228 // The method sets the matrix passed as argument as the global delta
1229 // (for the volume referred by the alignment object) including the displacements
1230 // of all parent volumes in the brach.
1232 Int_t index = aao.GetVolUID();
1234 AliErrorClass("Either the alignment object or its index are not valid");
1237 return GetDeltaForBranch(index, inclusiveD);
1240 //______________________________________________________________________
1241 Bool_t AliGeomManager::GetOrigGlobalMatrix(const char* symname, TGeoHMatrix &m)
1243 // Get the global transformation matrix (ideal geometry) for a given alignable volume
1244 // The alignable volume is identified by 'symname' which has to be either a valid symbolic
1245 // name, the query being performed after alignment, or a valid volume path if the query is
1246 // performed before alignment.
1250 if (!fgGeometry || !fgGeometry->IsClosed()) {
1251 AliErrorClass("No active geometry or geometry not yet closed!");
1254 if (!fgGeometry->GetListOfPhysicalNodes()) {
1255 AliWarningClass("gGeoManager doesn't contain any aligned nodes!");
1256 if (!fgGeometry->cd(symname)) {
1257 AliErrorClass(Form("Volume path %s not valid!",symname));
1261 m = *fgGeometry->GetCurrentMatrix();
1266 TGeoPNEntry* pne = fgGeometry->GetAlignableEntry(symname);
1267 const char* path = NULL;
1269 m = *pne->GetGlobalOrig();
1272 AliWarningClass(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as a volume path!",symname));
1276 return GetOrigGlobalMatrixFromPath(path,m);
1279 //_____________________________________________________________________________
1280 Bool_t AliGeomManager::GetOrigGlobalMatrixFromPath(const char *path, TGeoHMatrix &m)
1282 // The method returns the global matrix for the volume identified by
1283 // 'path' in the ideal detector geometry.
1284 // The output global matrix is stored in 'm'.
1285 // Returns kFALSE in case TGeo has not been initialized or the volume
1286 // path is not valid.
1290 if (!fgGeometry || !fgGeometry->IsClosed()) {
1291 AliErrorClass("Can't get the original global matrix! gGeoManager doesn't exist or it is still opened!");
1295 if (!fgGeometry->CheckPath(path)) {
1296 AliErrorClass(Form("Volume path %s not valid!",path));
1300 TIter next(fgGeometry->GetListOfPhysicalNodes());
1301 fgGeometry->cd(path);
1303 while(fgGeometry->GetLevel()){
1305 TGeoPhysicalNode *physNode = NULL;
1307 TGeoNode *node = fgGeometry->GetCurrentNode();
1308 while ((physNode=(TGeoPhysicalNode*)next()))
1309 if (physNode->GetNode() == node) break;
1311 TGeoMatrix *lm = NULL;
1313 lm = physNode->GetOriginalMatrix();
1314 if (!lm) lm = node->GetMatrix();
1316 lm = node->GetMatrix();
1326 //_____________________________________________________________________________
1327 TGeoHMatrix* AliGeomManager::GetOrigGlobalMatrix(TGeoPNEntry* pne)
1329 // The method returns global matrix for the ideal detector geometry
1330 // using the corresponding TGeoPNEntry as an input.
1331 // The returned pointer should be copied by the user, since its content could
1332 // be overwritten by a following call to the method.
1333 // In case of missing TGeoManager the method returns NULL.
1335 if (!fgGeometry || !fgGeometry->IsClosed()) {
1336 AliErrorClass("Can't get the global matrix! gGeoManager doesn't exist or it is still opened!");
1340 return pne->GetGlobalOrig();
1343 //______________________________________________________________________
1344 TGeoHMatrix* AliGeomManager::GetOrigGlobalMatrix(Int_t index)
1346 // The method returns global matrix from the ideal detector geometry
1347 // for the volume identified by its index.
1348 // The returned pointer should be copied by the user, since its content could
1349 // be overwritten by a following call to the method.
1350 // In case of missing TGeoManager the method returns NULL.
1351 // If possible, the method uses the LUT of original ideal matrices
1352 // for fast access. The LUT is reset in case a
1353 // new geometry is loaded.
1355 TGeoPNEntry* pne = GetPNEntry(index);
1356 return pne->GetGlobalOrig();
1359 //______________________________________________________________________
1360 Bool_t AliGeomManager::GetOrigTranslation(Int_t index, Double_t t[3])
1362 // Get the original translation vector (ideal geometry)
1363 // for a given module 'index' by quering the TGeoManager
1365 TGeoHMatrix *m = GetOrigGlobalMatrix(index);
1366 if (!m) return kFALSE;
1368 Double_t *trans = m->GetTranslation();
1369 for (Int_t i = 0; i < 3; i++) t[i] = trans[i];
1374 //______________________________________________________________________
1375 Bool_t AliGeomManager::GetOrigRotation(Int_t index, Double_t r[9])
1377 // Get the original rotation matrix (ideal geometry)
1378 // for a given module 'index' by quering the TGeoManager
1380 TGeoHMatrix *m = GetOrigGlobalMatrix(index);
1381 if (!m) return kFALSE;
1383 Double_t *rot = m->GetRotationMatrix();
1384 for (Int_t i = 0; i < 9; i++) r[i] = rot[i];
1389 //______________________________________________________________________
1390 const TGeoHMatrix* AliGeomManager::GetTracking2LocalMatrix(Int_t index)
1392 // Get the matrix which transforms from the tracking to the local RS
1393 // The method queries directly the TGeoPNEntry
1395 TGeoPNEntry *pne = GetPNEntry(index);
1396 if (!pne) return NULL;
1398 const TGeoHMatrix *m = pne->GetMatrix();
1400 AliErrorClass(Form("TGeoPNEntry (%s) contains no tracking-to-local matrix !",pne->GetName()));
1405 //______________________________________________________________________
1406 Bool_t AliGeomManager::GetTrackingMatrix(Int_t index, TGeoHMatrix &m)
1408 // Get the matrix which transforms from the tracking r.s. to
1410 // Returns kFALSE in case of error.
1414 TGeoHMatrix *m1 = GetMatrix(index);
1415 if (!m1) return kFALSE;
1417 const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index);
1418 if (!m2) return kFALSE;
1426 //_____________________________________________________________________________
1427 TGeoPNEntry* AliGeomManager::GetPNEntry(Int_t voluid) {
1428 // Returns the TGeoPNEntry for the given global volume ID "voluid"
1431 ELayerID layerId = VolUIDToLayer(voluid,modId);
1432 return GetPNEntry(layerId,modId);
1435 //_____________________________________________________________________________
1436 TGeoPNEntry* AliGeomManager::GetPNEntry(ELayerID layerId, Int_t modId)
1438 // Returns the TGeoPNEntry for a given layer
1442 if(modId<0 || modId>=fgLayerSize[layerId-kFirstLayer]){
1443 AliWarningClass(Form("Module number %d not in the valid range (0->%d) !",modId,fgLayerSize[layerId-kFirstLayer]-1));
1447 return fgPNEntry[layerId-kFirstLayer][modId];
1450 //_____________________________________________________________________________
1451 void AliGeomManager::CheckOverlapsOverPNs(Double_t threshold)
1453 // Check for overlaps/extrusions on physical nodes only;
1454 // this overlap-checker is meant to be used to check overlaps/extrusions
1455 // originated by the application of alignment objects.
1458 TObjArray* ovexlist = new TObjArray(64);
1460 AliInfoClass("********* Checking overlaps/extrusions over physical nodes only *********");
1461 TObjArray* pnList = gGeoManager->GetListOfPhysicalNodes();
1462 TGeoVolume* mvol = 0;
1463 TGeoPhysicalNode* pn;
1464 TObjArray* overlaps = new TObjArray(64);
1465 overlaps->SetOwner();
1469 for(Int_t pni=0; pni<pnList->GetEntriesFast(); pni++){
1470 pn = (TGeoPhysicalNode*) pnList->UncheckedAt(pni);
1471 // checking the volume of the mother (go upper in the tree in case it is an assembly)
1473 while(((TGeoVolume*)pn->GetVolume(pn->GetLevel()-levup))->IsAssembly()) levup++;
1474 //Printf("Going to upper level");
1475 mvol = pn->GetVolume(pn->GetLevel()-levup);
1476 if(!mvol->IsSelected()){
1477 AliInfoClass(Form("Checking overlaps for volume %s",mvol->GetName()));
1478 mvol->CheckOverlaps(threshold);
1479 ovexlist = gGeoManager->GetListOfOverlaps();
1480 TIter next(ovexlist);
1482 while ((ov=(TGeoOverlap*)next())) overlaps->Add(ov->Clone());
1483 mvol->SelectVolume();
1486 mvol->SelectVolume(kTRUE); // clears the list of selected volumes
1488 AliInfoClass(Form("Number of overlapping/extruding PNs: %d",overlaps->GetEntriesFast()));
1492 TIter nextN(overlaps);
1494 while ((ovlp=(TGeoOverlap*)nextN())) ovlp->PrintInfo();
1500 //_____________________________________________________________________________
1501 Bool_t AliGeomManager::IsModuleInGeom(const char* module)
1503 // Return true if the module passed as argument is present in the current geometry
1506 TString subdet(module);
1508 if(subdet==TString("ACORDE"))
1510 if(fgGeometry->GetAlignableEntry("ACORDE/Array1")) return kTRUE;
1511 }else if(subdet==TString("EMCAL"))
1513 if(fgGeometry->GetAlignableEntry("EMCAL/FullSupermodule0") || fgGeometry->GetAlignableEntry("EMCAL/CosmicTestSupermodule0")) return kTRUE;
1514 }else if(subdet==TString("FMD"))
1516 if(fgGeometry->GetAlignableEntry("FMD/FMD1_T")) return kTRUE;
1517 }else if(subdet==TString("HMPID"))
1519 if(fgGeometry->GetAlignableEntry("/HMPID/Chamber0")) return kTRUE;
1520 }else if(subdet==TString("ITS"))
1522 if(fgGeometry->GetAlignableEntry("ITS")) return kTRUE;
1523 }else if(subdet==TString("MUON"))
1525 if(fgGeometry->GetAlignableEntry("/MUON/GM0")) return kTRUE;
1526 }else if(subdet==TString("PMD"))
1528 if(fgGeometry->GetAlignableEntry("PMD/Sector1")) return kTRUE;
1529 }else if(subdet==TString("PHOS"))
1531 if(fgGeometry->GetAlignableEntry("PHOS/Cradle0")) return kTRUE;
1532 }else if(subdet==TString("T0"))
1534 if(fgGeometry->GetAlignableEntry("/ALIC_1/0STR_1")) return kTRUE;
1535 }else if(subdet==TString("TRD"))
1537 if(fgGeometry->GetAlignableEntry("TRD/sm00")) return kTRUE;
1538 }else if(subdet==TString("TPC"))
1540 if(fgGeometry->GetAlignableEntry("TPC/EndcapA/Sector1/InnerChamber")) return kTRUE;
1541 }else if(subdet==TString("TOF"))
1543 if(fgGeometry->GetAlignableEntry("TOF/sm00/strip01")) return kTRUE;
1544 }else if(subdet==TString("VZERO"))
1546 if(fgGeometry->GetAlignableEntry("VZERO/V0C")) return kTRUE;
1547 }else if(subdet==TString("ZDC"))
1549 if(fgGeometry->GetAlignableEntry("ZDC/NeutronZDC_C")) return kTRUE;
1550 }else if(subdet==TString("FRAME"))
1552 if(fgGeometry->GetAlignableEntry("FRAME/Sector0")) return kTRUE;
1554 AliErrorClass(Form("%s is not a valid ALICE module name",module));
1559 //_____________________________________________________________________________
1560 Bool_t AliGeomManager::ApplyAlignObjsFromCDB(const char* AlignDetsList)
1562 // Calls AddAlignObjsFromCDBSingleDet for the detectors appearing in
1563 // the list passed as argument (called by AliSimulation and
1564 // AliReconstruction)
1565 // Read the alignment objects from CDB.
1566 // Each detector is supposed to have the
1567 // alignment objects in DET/Align/Data CDB path.
1568 // All the detector objects are then collected,
1569 // sorted by geometry level (starting from ALIC) and
1570 // then applied to the TGeo geometry.
1571 // Finally an overlaps check is performed.
1574 TObjArray alignObjArray;
1575 alignObjArray.Clear();
1576 alignObjArray.SetOwner(0);
1578 TString alObjsNotLoaded="";
1579 TString alObjsLoaded="";
1581 TString AlignDetsString(AlignDetsList);
1582 TObjArray *detsarr = AlignDetsString.Tokenize(' ');
1583 TIter iter(detsarr);
1584 TObjString *str = 0;
1586 while((str = (TObjString*) iter.Next())){
1587 TString det(str->String());
1588 AliInfoClass(Form("Loading alignment objs for %s",det.Data()));
1589 if(!LoadAlignObjsFromCDBSingleDet(det.Data(),alignObjArray)){
1590 alObjsNotLoaded += det.Data();
1591 alObjsNotLoaded += " ";
1593 alObjsLoaded += det.Data();
1594 alObjsLoaded += " ";
1600 if(!alObjsLoaded.IsNull()) AliInfoClass(Form("Alignment objects loaded for: %s",
1601 alObjsLoaded.Data()));
1602 if(!alObjsNotLoaded.IsNull()) AliInfoClass(Form("Didn't/couldn't load alignment objects for: %s",
1603 alObjsNotLoaded.Data()));
1605 return ApplyAlignObjsToGeom(alignObjArray);
1608 //_____________________________________________________________________________
1609 Bool_t AliGeomManager::LoadAlignObjsFromCDBSingleDet(const char* detName, TObjArray& alignObjArray)
1611 // Adds the alignable objects found in the CDBEntry for the detector
1612 // passed as argument to the array of all alignment objects to be applyed
1615 // Fills array of single detector's alignable objects from CDB
1617 AliDebugClass(2, Form("Loading alignment objs for detector: %s",detName));
1621 AliCDBPath path(detName,"Align","Data");
1623 entry=AliCDBManager::Instance()->Get(path.GetPath());
1625 AliDebugClass(2,Form("Couldn't load alignment data for detector %s",detName));
1629 TClonesArray *alignArray = (TClonesArray*) entry->GetObject();
1630 alignArray->SetOwner(0);
1631 AliDebugClass(2,Form("Found %d alignment objects for %s",
1632 alignArray->GetEntries(),detName));
1634 AliAlignObj *alignObj=0;
1635 TIter iter(alignArray);
1637 // loop over align objects in detector
1638 while( ( alignObj=(AliAlignObj *) iter.Next() ) ){
1639 alignObjArray.Add(alignObj);
1641 // delete entry --- Don't delete, it is cached!
1643 AliDebugClass(2, Form("fAlignObjArray entries: %d",alignObjArray.GetEntries() ));
1648 //_____________________________________________________________________________
1649 Bool_t AliGeomManager::ApplyAlignObjsToGeom(TObjArray& alignObjArray, Bool_t ovlpcheck)
1651 // Read collection of alignment objects (AliAlignObj derived) saved
1652 // in the TClonesArray alObjArray and apply them to gGeoManager
1654 alignObjArray.Sort();
1655 Int_t nvols = alignObjArray.GetEntriesFast();
1657 Bool_t flag = kTRUE;
1659 for(Int_t j=0; j<nvols; j++)
1661 AliAlignObj* alobj = (AliAlignObj*) alignObjArray.UncheckedAt(j);
1662 flag = alobj->ApplyToGeometry(ovlpcheck);
1665 AliWarningClass(Form("Error applying alignment object for volume %s !",alobj->GetSymName()));
1667 AliDebugClass(5,Form("Alignment object for volume %s applied successfully",alobj->GetSymName()));
1672 if (AliDebugLevelClass() > 5) {
1673 fgGeometry->CheckOverlaps(0.001);
1674 TObjArray* ovexlist = fgGeometry->GetListOfOverlaps();
1675 if(ovexlist->GetEntriesFast()){
1676 AliErrorClass("The application of alignment objects to the geometry caused huge overlaps/extrusions!");
1677 fgGeometry->PrintOverlaps();
1681 // Update the TGeoPhysicalNodes
1682 fgGeometry->RefreshPhysicalNodes();
1688 //_____________________________________________________________________________
1689 Bool_t AliGeomManager::ApplyAlignObjsToGeom(const char* fileName, const char* clArrayName)
1691 // read collection of alignment objects (AliAlignObj derived) saved
1692 // in the TClonesArray ClArrayName in the file fileName and apply
1693 // them to the geometry
1696 TFile* inFile = TFile::Open(fileName,"READ");
1697 if (!inFile || !inFile->IsOpen()) {
1698 AliErrorClass(Form("Could not open file %s !",fileName));
1702 TClonesArray* alignObjArray = ((TClonesArray*) inFile->Get(clArrayName));
1704 if (!alignObjArray) {
1705 AliErrorClass(Form("Could not get array (%s) from file (%s) !",clArrayName,fileName));
1709 return ApplyAlignObjsToGeom(*alignObjArray);
1713 //_____________________________________________________________________________
1714 Bool_t AliGeomManager::ApplyAlignObjsToGeom(AliCDBParam* param, AliCDBId& Id)
1716 // read collection of alignment objects (AliAlignObj derived) saved
1717 // in the TClonesArray ClArrayName in the AliCDBEntry identified by
1718 // param (to get the AliCDBStorage) and Id; apply the alignment objects
1722 AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage(param);
1723 AliCDBEntry* entry = storage->Get(Id);
1724 TClonesArray* alignObjArray = ((TClonesArray*) entry->GetObject());
1726 return ApplyAlignObjsToGeom(*alignObjArray);
1730 //_____________________________________________________________________________
1731 Bool_t AliGeomManager::ApplyAlignObjsToGeom(const char* uri, const char* path, Int_t runnum, Int_t version, Int_t sversion)
1733 // read collection of alignment objects (AliAlignObj derived) saved
1734 // in the TClonesArray ClArrayName in the AliCDBEntry identified by
1735 // param (to get the AliCDBStorage) and Id; apply the alignment objects
1739 AliCDBParam* param = AliCDBManager::Instance()->CreateParameter(uri);
1740 AliCDBId id(path, runnum, runnum, version, sversion);
1742 return ApplyAlignObjsToGeom(param, id);
1746 //_____________________________________________________________________________
1747 Bool_t AliGeomManager::ApplyAlignObjsToGeom(const char* detName, Int_t runnum, Int_t version, Int_t sversion)
1749 // read collection of alignment objects (AliAlignObj derived) saved
1750 // in the TClonesArray ClArrayName in the AliCDBEntry identified by
1751 // param (to get the AliCDBStorage) and Id; apply the alignment objects
1755 AliCDBPath path(detName,"Align","Data");
1756 AliCDBEntry* entry = AliCDBManager::Instance()->Get(path.GetPath(),runnum,version,sversion);
1758 if(!entry) return kFALSE;
1759 TClonesArray* alignObjArray = ((TClonesArray*) entry->GetObject());
1761 return ApplyAlignObjsToGeom(*alignObjArray);