]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/STEER/AliGeomManager.cxx
implemented new LHCData records storage, added option to skip missing records in...
[u/mrichter/AliRoot.git] / STEER / STEER / AliGeomManager.cxx
CommitLineData
67dd5535 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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//-------------------------------------------------------------------------
21
22#include <TClass.h>
23#include <TFile.h>
24#include <TGeoManager.h>
25#include <TObjString.h>
26#include <TGeoPhysicalNode.h>
27#include <TClonesArray.h>
28#include <TGeoMatrix.h>
29#include <TGeoPhysicalNode.h>
99de26a3 30#include <TSystem.h>
5590c6c3 31#include <TStopwatch.h>
32#include <TGeoOverlap.h>
33#include <TPluginManager.h>
34#include <TROOT.h>
67dd5535 35
36#include "AliGeomManager.h"
37#include "AliLog.h"
38#include "AliAlignObj.h"
90dbf5fb 39#include "AliAlignObjParams.h"
67dd5535 40#include "AliCDBManager.h"
41#include "AliCDBStorage.h"
42#include "AliCDBEntry.h"
43
44ClassImp(AliGeomManager)
45
46Int_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
52 1638, // TOF
df117114 53 5, 5, // PHOS,CPV
67dd5535 54 7, // HMPID ??
3dfc15c0 55 1, // MUON ??
8cc543cb 56 22 // EMCAL and DCAL
67dd5535 57};
58
59const 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",
66 "TOF layer",
df117114 67 "PHOS EMC layer","PHOS CPV layer",
3dfc15c0 68 "HMPID layer",
69 "MUON ?",
70 "EMCAL layer"
67dd5535 71};
72
67dd5535 73TGeoPNEntry** AliGeomManager::fgPNEntry[kLastLayer - kFirstLayer] = {
74 0x0,0x0,
75 0x0,0x0,
76 0x0,0x0,
77 0x0,0x0,
78 0x0,0x0,0x0,
79 0x0,0x0,0x0,
80 0x0,
81 0x0,0x0,
82 0x0,
3dfc15c0 83 0x0,
67dd5535 84 0x0
85};
86
36b010bf 87AliAlignObj** AliGeomManager::fgAlignObjs[kLastLayer - kFirstLayer] = {
88 0x0,0x0,
89 0x0,0x0,
90 0x0,0x0,
91 0x0,0x0,
92 0x0,0x0,0x0,
93 0x0,0x0,0x0,
94 0x0,
95 0x0,0x0,
96 0x0,
3dfc15c0 97 0x0,
36b010bf 98 0x0
99};
67dd5535 100
c1c44db3 101const char* AliGeomManager::fgkDetectorName[AliGeomManager::fgkNDetectors] =
102{"GRP","ITS","TPC","TRD","TOF","PHOS","HMPID","EMCAL","MUON","FMD","ZDC","PMD","T0","VZERO","ACORDE","AD","MFT","FIT"};
38e7ce48 103Int_t AliGeomManager::fgNalignable[fgkNDetectors] = {0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
4fbb8e9d 104
67dd5535 105TGeoManager* AliGeomManager::fgGeometry = 0x0;
106
0dd36168 107//_____________________________________________________________________________
108void AliGeomManager::Destroy()
109{
110 // destroy the manager as well as gGeoManager (if it was not attached to fgGeometry)
acabf83e 111 TGeoManager::UnlockGeometry();
0dd36168 112 delete gGeoManager;
113 fgGeometry = gGeoManager = 0;
114 ResetPNEntriesLUT();
115}
116
67dd5535 117//_____________________________________________________________________________
36b010bf 118void AliGeomManager::LoadGeometry(const char *geomFileName)
67dd5535 119{
9d47e237 120 // initialization
121 // Load geometry either from a file
122 // or from the corresponding CDB entry
67dd5535 123
a9870fe8 124 if(fgGeometry->IsLocked()){
125 AliErrorClass("Cannot load a new geometry, the current one being locked. Setting internal geometry to null!!");
126 fgGeometry = NULL;
127 return;
128 }
129
36b010bf 130 fgGeometry = NULL;
b8cf7791 131 if (geomFileName && (!gSystem->AccessPathName(geomFileName))) {
36b010bf 132 fgGeometry = TGeoManager::Import(geomFileName);
4fbb8e9d 133 AliInfoClass(Form("From now on using geometry from custom geometry file \"%s\"",geomFileName));
36b010bf 134 }
135
136 if (!fgGeometry) {
36b010bf 137 AliCDBPath path("GRP","Geometry","Data");
138
139 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
140 if(!entry) AliFatalClass("Couldn't load geometry data from CDB!");
141
142 entry->SetOwner(0);
143 fgGeometry = (TGeoManager*) entry->GetObject();
144 if (!fgGeometry) AliFatalClass("Couldn't find TGeoManager in the specified CDB entry!");
b8cf7791 145
4fbb8e9d 146 AliInfoClass(Form("From now on using geometry from CDB base folder \"%s\"",
63484d8d 147 AliCDBManager::Instance()->GetURI("GRP/Geometry/Data")));
36b010bf 148 }
3564f2da 149 ResetPNEntriesLUT();
67dd5535 150 InitPNEntriesLUT();
4fbb8e9d 151 InitNalignable();
67dd5535 152}
153
9d47e237 154//_____________________________________________________________________________
53dd673d 155void AliGeomManager::SetGeometry(TGeoManager * const geom)
9d47e237 156{
157 // Load already active geometry
158 if (!geom) AliFatalClass("Pointer to the active geometry is 0x0!");
3564f2da 159 ResetPNEntriesLUT();
9d47e237 160 fgGeometry = geom;
9d47e237 161 InitPNEntriesLUT();
4fbb8e9d 162 InitNalignable();
9d47e237 163}
164
67dd5535 165//_____________________________________________________________________________
166AliGeomManager::AliGeomManager():
36b010bf 167 TObject()
67dd5535 168{
169 // default constructor
170}
171
172//_____________________________________________________________________________
173AliGeomManager::~AliGeomManager()
174{
175 // dummy destructor
67dd5535 176}
177
178//_____________________________________________________________________________
179Int_t AliGeomManager::LayerSize(Int_t layerId)
180{
181 // Get the layer size for layer corresponding to layerId.
182 // Implemented only for ITS,TPC,TRD,TOF and HMPID
183 //
184 if (layerId < kFirstLayer || layerId >= kLastLayer) {
185 AliErrorClass(Form("Invalid layer index %d ! Layer range is (%d -> %d) !",layerId,kFirstLayer,kLastLayer));
186 return 0;
187 }
188 else {
189 return fgLayerSize[layerId - kFirstLayer];
5aedd709 190 }
67dd5535 191}
192
193//_____________________________________________________________________________
194const char* AliGeomManager::LayerName(Int_t layerId)
195{
196 // Get the layer name corresponding to layerId.
197 // Implemented only for ITS,TPC,TRD,TOF and HMPID
198 //
199 if (layerId < kFirstLayer || layerId >= kLastLayer) {
200 AliErrorClass(Form("Invalid layer index %d ! Layer range is (%d -> %d) !",layerId,kFirstLayer,kLastLayer));
201 return "Invalid Layer!";
202 }
203 else {
204 return fgLayerName[layerId - kFirstLayer];
5aedd709 205 }
67dd5535 206}
207
208//_____________________________________________________________________________
209UShort_t AliGeomManager::LayerToVolUID(ELayerID layerId, Int_t modId)
210{
211 // From detector (layer) name and module number (according to detector
212 // internal numbering) build the unique numerical identity of that volume
213 // inside ALICE
214 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
215 // remaining 11 for module ID inside det (2048 possible values).
216 // NO check for validity of given modId inside the layer for speed's sake.
217 //
218 return ((UShort_t(layerId) << 11) | UShort_t(modId));
219}
220
221//_____________________________________________________________________________
222UShort_t AliGeomManager::LayerToVolUID(Int_t layerId, Int_t modId)
223{
224 // From detector (layer) name and module number (according to detector
225 // internal numbering) build the unique numerical identity of that volume
226 // inside ALICE
227 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
228 // remaining 11 for module ID inside det (2048 possible values).
229 // NO check for validity of given modId inside the layer for speed's sake.
230 //
231 return ((UShort_t(layerId) << 11) | UShort_t(modId));
232}
233
234//_____________________________________________________________________________
235UShort_t AliGeomManager::LayerToVolUIDSafe(ELayerID layerId, Int_t modId)
236{
237 // From detector (layer) name and module number (according to detector
238 // internal numbering) build the unique numerical identity of that volume
239 // inside ALICE
240 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
241 // remaining 11 for module ID inside det (2048 possible values).
242 // Check validity of given modId inside the layer.
243 //
244 if(modId < 0 || modId >= LayerSize(layerId)){
245 AliErrorClass(Form("Invalid volume id %d ! Range of valid ids for layer \"%s\" is [0, %d] !",modId,LayerName(layerId),LayerSize(layerId)-1));
246 return 0;
247 }
248 return ((UShort_t(layerId) << 11) | UShort_t(modId));
249}
250
251//_____________________________________________________________________________
252UShort_t AliGeomManager::LayerToVolUIDSafe(Int_t layerId, Int_t modId)
253{
254 // From detector (layer) name and module number (according to detector
255 // internal numbering) build the unique numerical identity of that volume
256 // inside ALICE
257 // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
258 // remaining 11 for module ID inside det (2048 possible values).
259 // Check validity of given modId inside the layer.
260 //
261 if(modId < 0 || modId >= LayerSize(layerId)){
262 AliErrorClass(Form("Invalid volume id %d ! Range of valid ids for layer \"%s\" is [0, %d] !",modId,LayerName(layerId),LayerSize(layerId)-1));
263 return 0;
264 }
265 return ((UShort_t(layerId) << 11) | UShort_t(modId));
266}
267
268//_____________________________________________________________________________
269AliGeomManager::ELayerID AliGeomManager::VolUIDToLayer(UShort_t voluid, Int_t &modId)
270{
271 // From voluid, unique numerical identity of that volume inside ALICE,
272 // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
273 // remaining 11 for module ID inside det (2048 possible values)), return
274 // the identity of the layer to which that volume belongs and sets the
275 // argument modId to the identity of that volume internally to the layer.
276 // NO check for validity of given voluid for speed's sake.
277 //
278 modId = voluid & 0x7ff;
279
280 return VolUIDToLayer(voluid);
281}
282
283//_____________________________________________________________________________
284AliGeomManager::ELayerID AliGeomManager::VolUIDToLayer(UShort_t voluid)
285{
286 // From voluid, unique numerical identity of that volume inside ALICE,
287 // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
288 // remaining 11 for module ID inside det (2048 possible values)), return
289 // the identity of the layer to which that volume belongs
290 // NO check for validity of given voluid for speed's sake.
291 //
292 return ELayerID(voluid >> 11);
293}
294
295//_____________________________________________________________________________
296AliGeomManager::ELayerID AliGeomManager::VolUIDToLayerSafe(UShort_t voluid, Int_t &modId)
297{
298 // From voluid, unique numerical identity of that volume inside ALICE,
299 // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
300 // remaining 11 for module ID inside det (2048 possible values)), returns
301 // the identity of the layer to which that volume belongs and sets the
302 // argument modId to the identity of that volume internally to the layer.
303 // Checks the validity of the given voluid
304 //
305 ELayerID layId = VolUIDToLayerSafe(voluid);
1d059662 306 if(layId != AliGeomManager::kInvalidLayer){
67dd5535 307 Int_t mId = Int_t(voluid & 0x7ff);
308 if( mId>=0 && mId<LayerSize(layId)){
309 modId = mId;
310 return layId;
311 }
312 }
313
314 AliErrorClass(Form("Invalid unique volume id: %d !",voluid));
315 modId = -1;
316 return kInvalidLayer;
317
318}
319
320//_____________________________________________________________________________
321AliGeomManager::ELayerID AliGeomManager::VolUIDToLayerSafe(UShort_t voluid)
322{
323 // From voluid, unique numerical identity of that volume inside ALICE,
324 // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
325 // remaining 11 for module ID inside det (2048 possible values)), returns
326 // the identity of the layer to which that volume belongs
327 // Checks the validity of the given voluid
328 //
329 if( (voluid >> 11) < kLastLayer) return ELayerID(voluid >> 11);
330
331 AliErrorClass(Form("Invalid layer id: %d !",(voluid >> 11)));
332 return kInvalidLayer;
333
334}
335
336//_____________________________________________________________________________
337Bool_t AliGeomManager::GetFromGeometry(const char *symname, AliAlignObj &alobj)
338{
339 // Get the alignment object which corresponds to the symbolic volume name
340 // symname (in case equal to the TGeo volume path)
341 // The method is extremely slow due to the searching by string,
342 // therefore it should be used with great care!!
343 // This method returns FALSE if the symname of the object was not
344 // valid neither to get a TGeoPEntry nor as a volume path, or if the path
345 // associated to the TGeoPNEntry was not valid.
346 //
347
348 // Reset the alignment object
349 alobj.SetPars(0,0,0,0,0,0);
350 alobj.SetSymName(symname);
351
36b010bf 352 if (!fgGeometry || !fgGeometry->IsClosed()) {
67dd5535 353 AliErrorClass("Can't get the alignment object! gGeoManager doesn't exist or it is still opened!");
354 return kFALSE;
355 }
356
36b010bf 357 if (!fgGeometry->GetListOfPhysicalNodes()) {
67dd5535 358 AliErrorClass("Can't get the alignment object! gGeoManager doesn't contain any aligned nodes!");
359 return kFALSE;
360 }
361
67dd5535 362 const char *path;
36b010bf 363 TGeoPNEntry* pne = fgGeometry->GetAlignableEntry(symname);
67dd5535 364 if(pne){
365 path = pne->GetTitle();
366 }else{
367 AliWarningClass(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as a volume path!",symname));
368 path = symname;
369 }
36b010bf 370 TObjArray* nodesArr = fgGeometry->GetListOfPhysicalNodes();
67dd5535 371 TGeoPhysicalNode* node = NULL;
372 for (Int_t iNode = 0; iNode < nodesArr->GetEntriesFast(); iNode++) {
373 TGeoPhysicalNode* tempNode = (TGeoPhysicalNode*) nodesArr->UncheckedAt(iNode);
374 const char *nodePath = tempNode->GetName();
375 if (strcmp(path,nodePath) == 0) {
376 node = tempNode;
377 break;
378 }
379 }
380
381 if (!node) {
36b010bf 382 if (!fgGeometry->cd(path)) {
67dd5535 383 AliErrorClass(Form("%s not valid neither as symbolic volume name nor as volume path!",path));
384 return kFALSE;
385 }
386 else {
387 AliWarningClass(Form("Volume (%s) has not been misaligned!",path));
388 return kTRUE;
389 }
390 }
391
392 TGeoHMatrix align,gprime,g,ginv,l;
393 gprime = *node->GetMatrix();
394 l = *node->GetOriginalMatrix();
395 g = *node->GetMatrix(node->GetLevel()-1);
396 g *= l;
397 ginv = g.Inverse();
398 align = gprime * ginv;
399
400 return alobj.SetMatrix(align);
401}
402
403
404//_____________________________________________________________________________
405void AliGeomManager::InitAlignObjFromGeometry()
406{
5aedd709 407 // Loop over all alignable volumes and extract
408 // the corresponding alignment objects from
409 // the TGeo geometry
3564f2da 410 //
67dd5535 411 for (Int_t iLayer = kFirstLayer; iLayer < AliGeomManager::kLastLayer; iLayer++) {
3564f2da 412 if (!fgAlignObjs[iLayer-kFirstLayer]) {
413 fgAlignObjs[iLayer-kFirstLayer] = new AliAlignObj*[LayerSize(iLayer)];
3564f2da 414 }
67dd5535 415 for (Int_t iModule = 0; iModule < LayerSize(iLayer); iModule++) {
416 UShort_t volid = LayerToVolUID(iLayer,iModule);
ebb8460f 417 fgAlignObjs[iLayer-kFirstLayer][iModule] = new AliAlignObjParams("",volid,0,0,0,0,0,0,kTRUE);
67dd5535 418 const char *symname = SymName(volid);
419 if (!GetFromGeometry(symname, *fgAlignObjs[iLayer-kFirstLayer][iModule]))
420 AliErrorClass(Form("Failed to extract the alignment object for the volume (ID=%d and path=%s) !",volid,symname));
421 }
422 }
5aedd709 423
67dd5535 424}
425
426//_____________________________________________________________________________
5aedd709 427AliAlignObj* AliGeomManager::GetAlignObj(UShort_t voluid)
428{
67dd5535 429 // Returns the alignment object for given volume ID
430 //
431 Int_t modId;
432 ELayerID layerId = VolUIDToLayer(voluid,modId);
433 return GetAlignObj(layerId,modId);
434}
435
436//_____________________________________________________________________________
437AliAlignObj* AliGeomManager::GetAlignObj(ELayerID layerId, Int_t modId)
438{
439 // Returns pointer to alignment object given its layer and module ID
440 //
441 if(modId<0 || modId>=fgLayerSize[layerId-kFirstLayer]){
442 AliWarningClass(Form("Module number %d not in the valid range (0->%d) !",modId,fgLayerSize[layerId-kFirstLayer]-1));
443 return NULL;
444 }
445 InitAlignObjFromGeometry();
446
447 return fgAlignObjs[layerId-kFirstLayer][modId];
448}
449
450//_____________________________________________________________________________
5aedd709 451const char* AliGeomManager::SymName(UShort_t voluid)
452{
67dd5535 453 // Returns the symbolic volume name for given volume ID
454 //
455 Int_t modId;
456 ELayerID layerId = VolUIDToLayer(voluid,modId);
457 return SymName(layerId,modId);
458}
459
460//_____________________________________________________________________________
461const char* AliGeomManager::SymName(ELayerID layerId, Int_t modId)
462{
463 // Returns the symbolic volume name given for a given layer
464 // and module ID
465 //
ff5970a3 466 if(!fgGeometry){
467 AliErrorClass("No geometry instance loaded yet!");
468 return NULL;
469 }
67dd5535 470 if(modId<0 || modId>=fgLayerSize[layerId-kFirstLayer]){
471 AliWarningClass(Form("Module number %d not in the valid range (0->%d) !",modId,fgLayerSize[layerId-kFirstLayer]-1));
472 return NULL;
473 }
67dd5535 474
a8629c62 475 TGeoPNEntry* pne = fgPNEntry[layerId-kFirstLayer][modId];
476 if(!pne)
477 {
478 AliWarningClass(Form("Module %d of layer %s is not activated!",modId,LayerName(layerId)));
479 return NULL;
480 }
481 return pne->GetName();
482
67dd5535 483}
484
485//_____________________________________________________________________________
9257a1bd 486Bool_t AliGeomManager::CheckSymNamesLUT(const char* /*detsToBeChecked*/)
67dd5535 487{
0bf7aade 488 // Check the look-up table which associates the unique numerical identity of
489 // each alignable volume to the corresponding symbolic volume name.
8e5d5edf 490 // The LUT is now held inside the geometry and handled by TGeo.
0bf7aade 491 // The method is meant to be launched when loading a geometry to verify that
492 // no changes in the symbolic names have been introduced, which would prevent
493 // backward compatibility with alignment objects.
494 // To accept both complete and partial geometry, this method skips the check
495 // for TRD and TOF volumes which are missing in the partial geometry.
496 //
67dd5535 497
ff5970a3 498// TString detsString(detsToBeChecked);
499// if(detsString.Contains("ALL")) detsString="ITS TPC TOF TRD HMPID PHOS EMCAL";
500
501 // Temporary measure to face the case of reconstruction over detectors not present in the geometry
502 TString detsString = "";
503 if(fgGeometry->CheckPath("ALIC_1/ITSV_1")) detsString+="ITS ";
504 if(fgGeometry->CheckPath("ALIC_1/TPC_M_1")) detsString+="TPC ";
83364444 505
506 TString tofsm;
507 TString baseTof("ALIC_1/B077_1/BSEGMO");
508 TString middleTof("_1/BTOF");
509 TString trailTof("_1/FTOA_0");
510 Bool_t tofActive=kFALSE;
511 Bool_t tofSMs[18];
512 for(Int_t sm=0; sm<18; sm++)
513 {
514 tofSMs[sm]=kFALSE;
515 tofsm=baseTof;
516 tofsm += sm;
517 tofsm += middleTof;
518 tofsm += sm;
519 tofsm += trailTof;
520 if(fgGeometry->CheckPath(tofsm.Data()))
521 {
522 tofActive=kTRUE;
523 tofSMs[sm]=kTRUE;
524 }
525 }
526 if(tofActive) detsString+="TOF ";
527
528 TString trdsm;
529 TString baseTrd("ALIC_1/B077_1/BSEGMO");
530 TString middleTrd("_1/BTRD");
531 TString trailTrd("_1/UTR1_1");
532 Bool_t trdActive=kFALSE;
533 Bool_t trdSMs[18];
534 for(Int_t sm=0; sm<18; sm++)
535 {
536 trdSMs[sm]=kFALSE;
537 trdsm=baseTrd;
538 trdsm += sm;
539 trdsm += middleTrd;
540 trdsm += sm;
541 trdsm += trailTrd;
542 if(fgGeometry->CheckPath(trdsm.Data()))
543 {
544 trdActive=kTRUE;
545 trdSMs[sm]=kTRUE;
546 }
547 }
548 if(trdActive) detsString+="TRD ";
549
ff5970a3 550 if(fgGeometry->CheckPath("ALIC_1/Hmp0_0")) detsString+="HMPID ";
6ead0654 551
552 TString phosMod, cpvMod;
553 TString basePhos("ALIC_1/PHOS_");
554 Bool_t phosActive=kFALSE;
555 Bool_t cpvActive=kFALSE;
556 Bool_t phosMods[5];
557 for(Int_t pmod=0; pmod<5; pmod++)
558 {
559 phosMods[pmod]=kFALSE;
560 phosMod = basePhos;
561 phosMod += (pmod+1);
562 cpvMod = phosMod;
563 cpvMod += "/PCPV_1";
564 if(fgGeometry->CheckPath(phosMod.Data()))
565 {
566 phosActive=kTRUE;
567 phosMods[pmod]=kTRUE;
568 if(fgGeometry->CheckPath(cpvMod.Data())) cpvActive=kTRUE;
569 }
570 }
571 if(phosActive) detsString+="PHOS ";
572
8e5d5edf 573 // Check over the ten EMCAL full supermodules and the two EMCAL half supermodules
574 TString emcalSM;
8cc543cb 575 TString baseEmcalSM("ALIC_1/XEN1_1/");
8e5d5edf 576 Bool_t emcalActive=kFALSE;
8cc543cb 577 Bool_t emcalSMs[22] = {kFALSE};
578 for(Int_t sm=0; sm<22; sm++)
8e5d5edf 579 {
580 emcalSM=baseEmcalSM;
581 if(sm<10){
8cc543cb 582 emcalSM += "SMOD_";
583 emcalSM += (sm+1);
584 }else if(sm/2 == 5){
585 emcalSM += "SM10_";
586 emcalSM += (sm-9);
587 }else if(sm > 11){
588 emcalSM += "DCSM_";
589 emcalSM += (sm-11);
8e5d5edf 590 }
591 if(fgGeometry->CheckPath(emcalSM.Data()))
592 {
593 emcalActive=kTRUE;
594 emcalSMs[sm]=kTRUE;
595 }
596 }
597 if(emcalActive) detsString+="EMCAL ";
598
ff5970a3 599
67dd5535 600 TString symname;
0bf7aade 601 const char* sname;
602 TGeoPNEntry* pne = 0x0;
603 Int_t uid; // global unique identity
604 Int_t modnum; // unique id inside layer; in the following, set it to 0 at the start of each layer
67dd5535 605
ff5970a3 606 if(detsString.Contains("ITS")){
67dd5535 607 /********************* ITS layers ***********************/
ff5970a3 608 AliDebugClass(2,"Checking consistency of symbolic names for ITS layers");
609 TString strSPD = "ITS/SPD";
610 TString strSDD = "ITS/SDD";
611 TString strSSD = "ITS/SSD";
612 TString strStave = "/Stave";
613 TString strHalfStave = "/HalfStave";
614 TString strLadder = "/Ladder";
615 TString strSector = "/Sector";
616 TString strSensor = "/Sensor";
617 TString strEntryName1;
618 TString strEntryName2;
619 TString strEntryName3;
620
621 /********************* SPD layer1 ***********************/
622 {
623 modnum = 0;
624
625 for(Int_t cSect = 0; cSect<10; cSect++){
626 strEntryName1 = strSPD;
627 strEntryName1 += 0;
628 strEntryName1 += strSector;
629 strEntryName1 += cSect;
630
631 for(Int_t cStave =0; cStave<2; cStave++){
632 strEntryName2 = strEntryName1;
633 strEntryName2 += strStave;
634 strEntryName2 += cStave;
635
636 for (Int_t cHS=0; cHS<2; cHS++) {
637 strEntryName3 = strEntryName2;
638 strEntryName3 += strHalfStave;
639 strEntryName3 += cHS;
640
641 for(Int_t cLad =0; cLad<2; cLad++){
642 symname = strEntryName3;
643 symname += strLadder;
644 symname += cLad+cHS*2;
645 uid = LayerToVolUID(kSPD1,modnum++);
646 pne = fgGeometry->GetAlignableEntryByUID(uid);
647 if(!pne)
648 {
649 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
650 return kFALSE;
651 }
652 sname = pne->GetName();
653 if(symname.CompareTo(sname))
654 {
655 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d."
656 "Expected was %s, found was %s!", uid, symname.Data(), sname));
657 return kFALSE;
658 }
0bf7aade 659 }
8f8273a4 660 }
67dd5535 661 }
662 }
663 }
ff5970a3 664
665 /********************* SPD layer2 ***********************/
666 {
667 modnum = 0;
668
669 for(Int_t cSect = 0; cSect<10; cSect++){
670 strEntryName1 = strSPD;
671 strEntryName1 += 1;
672 strEntryName1 += strSector;
673 strEntryName1 += cSect;
674
675 for(Int_t cStave =0; cStave<4; cStave++){
676 strEntryName2 = strEntryName1;
677 strEntryName2 += strStave;
678 strEntryName2 += cStave;
679
680 for (Int_t cHS=0; cHS<2; cHS++) {
681 strEntryName3 = strEntryName2;
682 strEntryName3 += strHalfStave;
683 strEntryName3 += cHS;
684
685 for(Int_t cLad =0; cLad<2; cLad++){
686 symname = strEntryName3;
687 symname += strLadder;
688 symname += cLad+cHS*2;
689 uid = LayerToVolUID(kSPD2,modnum++);
690 pne = fgGeometry->GetAlignableEntryByUID(uid);
691 if(!pne)
692 {
693 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
694 return kFALSE;
695 }
696 sname = pne->GetName();
697 if(symname.CompareTo(sname))
698 {
699 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d."
700 "Expected was %s, found was %s!", uid, symname.Data(), sname));
701 return kFALSE;
702 }
0bf7aade 703 }
8f8273a4 704 }
67dd5535 705 }
706 }
707 }
ff5970a3 708
709 /********************* SDD layer1 ***********************/
710 {
711 modnum=0;
712
713 for(Int_t c1 = 1; c1<=14; c1++){
714 strEntryName1 = strSDD;
715 strEntryName1 += 2;
716 strEntryName1 +=strLadder;
717 strEntryName1 += (c1-1);
718 for(Int_t c2 =1; c2<=6; c2++){
719 symname = strEntryName1;
720 symname += strSensor;
721 symname += (c2-1);
722 uid = LayerToVolUID(kSDD1,modnum++);
723 pne = fgGeometry->GetAlignableEntryByUID(uid);
724 if(!pne)
725 {
726 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
727 return kFALSE;
728 }
729 sname = pne->GetName();
730 if(symname.CompareTo(sname))
731 {
732 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
733 "Expected was %s, found was %s!", uid, symname.Data(), sname));
734 return kFALSE;
735 }
736 }
737 }
738 }
739
740 /********************* SDD layer2 ***********************/
741 {
742 modnum=0;
743
744 for(Int_t c1 = 1; c1<=22; c1++){
745 strEntryName1 = strSDD;
746 strEntryName1 += 3;
747 strEntryName1 +=strLadder;
748 strEntryName1 += (c1-1);
749 for(Int_t c2 = 1; c2<=8; c2++){
750 symname = strEntryName1;
751 symname += strSensor;
752 symname += (c2-1);
753 uid = LayerToVolUID(kSDD2,modnum++);
754 pne = fgGeometry->GetAlignableEntryByUID(uid);
755 if(!pne)
756 {
757 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
758 return kFALSE;
759 }
760 sname = pne->GetName();
761 if(symname.CompareTo(sname))
762 {
763 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
764 "Expected was %s, found was %s!", uid, symname.Data(), sname));
765 return kFALSE;
766 }
767 }
768 }
769 }
770
771 /********************* SSD layer1 ***********************/
772 {
773 modnum=0;
774
775 for(Int_t c1 = 1; c1<=34; c1++){
776 strEntryName1 = strSSD;
777 strEntryName1 += 4;
778 strEntryName1 +=strLadder;
779 strEntryName1 += (c1-1);
780 for(Int_t c2 = 1; c2<=22; c2++){
781 symname = strEntryName1;
782 symname += strSensor;
783 symname += (c2-1);
784 uid = LayerToVolUID(kSSD1,modnum++);
785 pne = fgGeometry->GetAlignableEntryByUID(uid);
786 if(!pne)
787 {
788 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
789 return kFALSE;
790 }
791 sname = pne->GetName();
792 if(symname.CompareTo(sname))
793 {
794 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
795 "Expected was %s, found was %s!", uid, symname.Data(), sname));
796 return kFALSE;
797 }
798 }
799 }
800 }
801
802 /********************* SSD layer2 ***********************/
803 {
804 modnum=0;
805
806 for(Int_t c1 = 1; c1<=38; c1++){
807 strEntryName1 = strSSD;
808 strEntryName1 += 5;
809 strEntryName1 +=strLadder;
810 strEntryName1 += (c1-1);
811 for(Int_t c2 = 1; c2<=25; c2++){
812 symname = strEntryName1;
813 symname += strSensor;
814 symname += (c2-1);
815 uid = LayerToVolUID(kSSD2,modnum++);
816 pne = fgGeometry->GetAlignableEntryByUID(uid);
817 if(!pne)
818 {
819 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
820 return kFALSE;
821 }
822 sname = pne->GetName();
823 if(symname.CompareTo(sname))
824 {
825 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
826 "Expected was %s, found was %s!", uid, symname.Data(), sname));
827 return kFALSE;
828 }
829 }
830 }
831 }
832
833 AliDebugClass(2,"Consistency check for ITS symbolic names finished successfully.");
67dd5535 834 }
835
ff5970a3 836 if(detsString.Contains("TPC"))
67dd5535 837 {
ff5970a3 838 /*************** TPC inner and outer layers ****************/
839
840 AliDebugClass(2,"Checking consistency of symbolic names for TPC layers");
841 TString sAsector="TPC/EndcapA/Sector";
842 TString sCsector="TPC/EndcapC/Sector";
843 TString sInner="/InnerChamber";
844 TString sOuter="/OuterChamber";
845
846 /*************** TPC inner chambers' layer ****************/
847 {
848 modnum = 0;
67dd5535 849
ff5970a3 850 for(Int_t cnt=1; cnt<=18; cnt++)
851 {
852 symname = sAsector;
853 symname += cnt;
854 symname += sInner;
855 uid = LayerToVolUID(kTPC1,modnum++);
0bf7aade 856 pne = fgGeometry->GetAlignableEntryByUID(uid);
857 if(!pne)
858 {
859 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
860 return kFALSE;
861 }
862 sname = pne->GetName();
863 if(symname.CompareTo(sname))
864 {
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));
867 return kFALSE;
868 }
67dd5535 869 }
67dd5535 870
ff5970a3 871 for(Int_t cnt=1; cnt<=18; cnt++)
872 {
873 symname = sCsector;
874 symname += cnt;
875 symname += sInner;
876 uid = LayerToVolUID(kTPC1,modnum++);
0bf7aade 877 pne = fgGeometry->GetAlignableEntryByUID(uid);
878 if(!pne)
879 {
880 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
881 return kFALSE;
882 }
883 sname = pne->GetName();
884 if(symname.CompareTo(sname))
885 {
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));
888 return kFALSE;
889 }
67dd5535 890 }
891 }
67dd5535 892
ff5970a3 893 /*************** TPC outer chambers' layer ****************/
894 {
895 modnum = 0;
67dd5535 896
ff5970a3 897 for(Int_t cnt=1; cnt<=18; cnt++)
898 {
899 symname = sAsector;
900 symname += cnt;
901 symname += sOuter;
902 uid = LayerToVolUID(kTPC2,modnum++);
0bf7aade 903 pne = fgGeometry->GetAlignableEntryByUID(uid);
904 if(!pne)
905 {
906 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
907 return kFALSE;
908 }
909 sname = pne->GetName();
910 if(symname.CompareTo(sname))
911 {
912 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
913 "Expected was %s, found was %s!", uid, symname.Data(), sname));
914 return kFALSE;
915 }
67dd5535 916 }
67dd5535 917
ff5970a3 918 for(Int_t cnt=1; cnt<=18; cnt++)
919 {
920 symname = sCsector;
921 symname += cnt;
922 symname += sOuter;
923 uid = LayerToVolUID(kTPC2,modnum++);
0bf7aade 924 pne = fgGeometry->GetAlignableEntryByUID(uid);
925 if(!pne)
926 {
927 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
928 return kFALSE;
929 }
930 sname = pne->GetName();
931 if(symname.CompareTo(sname))
932 {
933 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
934 "Expected was %s, found was %s!", uid, symname.Data(), sname));
935 return kFALSE;
936 }
67dd5535 937 }
938 }
67dd5535 939
ff5970a3 940 AliDebugClass(2,"Consistency check for TPC symbolic names finished successfully.");
67dd5535 941 }
942
ff5970a3 943 if(detsString.Contains("TOF"))
67dd5535 944 {
ff5970a3 945 /********************* TOF layer ***********************/
67dd5535 946
ff5970a3 947 AliDebugClass(2,"Checking consistency of symbolic names for TOF layers");
67dd5535 948 modnum=0;
ff5970a3 949
67dd5535 950 Int_t nstrA=15;
951 Int_t nstrB=19;
952 Int_t nstrC=19;
953 Int_t nSectors=18;
954 Int_t nStrips=nstrA+2*nstrB+2*nstrC;
0bf7aade 955
67dd5535 956 TString snSM = "TOF/sm";
957 TString snSTRIP = "/strip";
958
959 for (Int_t isect = 0; isect < nSectors; isect++) {
a55c71ed 960 if(tofSMs[isect]) AliDebugClass(3,Form("Consistency check for symnames of TOF supermodule %d.",isect));
67dd5535 961 for (Int_t istr = 1; istr <= nStrips; istr++) {
962 symname = snSM;
963 symname += Form("%02d",isect);
964 symname += snSTRIP;
965 symname += Form("%02d",istr);
0bf7aade 966 uid = LayerToVolUID(kTOF,modnum++);
83364444 967 if(!tofSMs[isect]) continue; // taking possible missing TOF sectors (partial geometry) into account
0bf7aade 968 if ((isect==13 || isect==14 || isect==15) && (istr >= 39 && istr <= 53)) continue; //taking holes into account
969 pne = fgGeometry->GetAlignableEntryByUID(uid);
970 if(!pne)
971 {
972 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
973 return kFALSE;
974 }
975 sname = pne->GetName();
976 if(symname.CompareTo(sname))
977 {
978 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
979 "Expected was %s, found was %s!", uid, symname.Data(), sname));
980 return kFALSE;
981 }
67dd5535 982 }
983 }
ff5970a3 984
985 AliDebugClass(2,"Consistency check for TOF symbolic names finished successfully.");
67dd5535 986 }
987
ff5970a3 988 if(detsString.Contains("HMPID"))
67dd5535 989 {
ff5970a3 990 /********************* HMPID layer ***********************/
991
992 AliDebugClass(2,"Checking consistency of symbolic names for HMPID layers");
67dd5535 993 TString str = "/HMPID/Chamber";
994
995 for (modnum=0; modnum < 7; modnum++) {
996 symname = str;
997 symname += modnum;
0bf7aade 998 uid = LayerToVolUID(kHMPID,modnum);
999 pne = fgGeometry->GetAlignableEntryByUID(uid);
1000 if(!pne)
1001 {
1002 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1003 return kFALSE;
1004 }
1005 sname = pne->GetName();
1006 if(symname.CompareTo(sname))
1007 {
1008 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1009 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1010 return kFALSE;
1011 }
67dd5535 1012 }
ff5970a3 1013
1014 AliDebugClass(2,"Consistency check for HMPID symbolic names finished successfully.");
67dd5535 1015 }
1016
ff5970a3 1017 if(detsString.Contains("TRD"))
67dd5535 1018 {
ff5970a3 1019 /********************* TRD layers 1-6 *******************/
1020 //!! 6 layers with index increasing in outwards direction
1021
1022 AliDebugClass(2,"Checking consistency of symbolic names for TRD layers");
67dd5535 1023 Int_t arTRDlayId[6] = {kTRD1, kTRD2, kTRD3, kTRD4, kTRD5, kTRD6};
1024
1025 TString snStr = "TRD/sm";
1026 TString snApp1 = "/st";
1027 TString snApp2 = "/pl";
1028
1029 for(Int_t layer=0; layer<6; layer++){
1030 modnum=0;
a55c71ed 1031 AliDebugClass(3,Form("Consistency check for symnames of TRD layer %d.",layer));
67dd5535 1032 for (Int_t isect = 0; isect < 18; isect++) {
1033 for (Int_t icham = 0; icham < 5; icham++) {
1034 symname = snStr;
1035 symname += Form("%02d",isect);
1036 symname += snApp1;
1037 symname += icham;
1038 symname += snApp2;
1039 symname += layer;
0bf7aade 1040 uid = LayerToVolUID(arTRDlayId[layer],modnum++);
83364444 1041 if(!trdSMs[isect]) continue;
0bf7aade 1042 if ((isect==13 || isect==14 || isect==15) && icham==2) continue; //keeping holes into account
1043 pne = fgGeometry->GetAlignableEntryByUID(uid);
1044 if(!pne)
1045 {
1046 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1047 return kFALSE;
1048 }
1049 sname = pne->GetName();
1050 if(symname.CompareTo(sname))
1051 {
1052 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1053 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1054 return kFALSE;
1055 }
67dd5535 1056 }
1057 }
1058 }
ff5970a3 1059
1060 AliDebugClass(2,"Consistency check for TRD symbolic names finished successfully.");
67dd5535 1061 }
df117114 1062
ff5970a3 1063 if(detsString.Contains("PHOS"))
df117114 1064 {
ff5970a3 1065 /********************* PHOS EMC layer ***********************/
df117114 1066
ff5970a3 1067 AliDebugClass(2,"Checking consistency of symbolic names for PHOS layers");
1068
ff5970a3 1069 TString str = "PHOS/Module";
1070 modnum=0;
1071
6ead0654 1072 for (Int_t iModule=0; iModule < 5; iModule++) {
1073 if(!phosMods[iModule]) continue;
ff5970a3 1074 symname = str;
6ead0654 1075 symname += (iModule+1);
1076 uid = LayerToVolUID(kPHOS1,iModule);
ff5970a3 1077 pne = fgGeometry->GetAlignableEntryByUID(uid);
1078 if(!pne)
1079 {
1080 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1081 return kFALSE;
1082 }
1083 sname = pne->GetName();
1084 if(symname.CompareTo(sname))
1085 {
1086 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1087 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1088 return kFALSE;
1089 }
6ead0654 1090 /********************* PHOS CPV layer ***********************/
1091 if(!cpvActive) continue;
ff5970a3 1092 symname += "/CPV";
6ead0654 1093 uid = LayerToVolUID(kPHOS2,iModule);
ff5970a3 1094 pne = fgGeometry->GetAlignableEntryByUID(uid);
1095 if(!pne)
1096 {
1097 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1098 return kFALSE;
1099 }
1100 sname = pne->GetName();
1101 if(symname.CompareTo(sname))
1102 {
1103 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1104 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1105 return kFALSE;
1106 }
0bf7aade 1107 }
ff5970a3 1108 AliDebugClass(2,"Consistency check for PHOS symbolic names finished successfully.");
f47b9233 1109 }
1110
ff5970a3 1111 if(detsString.Contains("EMCAL"))
3dfc15c0 1112 {
ff5970a3 1113 /********************* EMCAL layer ***********************/
1114
1115 AliDebugClass(2,"Checking consistency of symbolic names for EMCAL layers");
3dfc15c0 1116 TString str = "EMCAL/FullSupermodule";
1117 modnum=0;
1118
8cc543cb 1119 for (Int_t iModule=0; iModule < 22; iModule++) {
1120 if(!emcalSMs[iModule]) continue;
3dfc15c0 1121 symname = str;
8cc543cb 1122 symname += iModule+1;
1123 if(iModule/2 == 5) {// 10,11
3dfc15c0 1124 symname = "EMCAL/HalfSupermodule";
8cc543cb 1125 symname += iModule-9;
1126 }else if(iModule > 11) {// 12 ~ 21
1127 symname = "EMCAL/DCALSupermodule";
1128 symname += iModule-11;
3dfc15c0 1129 }
8cc543cb 1130 modnum = iModule;
0bf7aade 1131 uid = LayerToVolUID(kEMCAL,modnum);
1132 pne = fgGeometry->GetAlignableEntryByUID(uid);
1133 if(!pne)
1134 {
1135 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1136 return kFALSE;
1137 }
1138 sname = pne->GetName();
1139 if(symname.CompareTo(sname))
1140 {
1141 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1142 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1143 return kFALSE;
1144 }
3dfc15c0 1145 }
ff5970a3 1146
1147 AliDebugClass(2,"Consistency check for EMCAL symbolic names finished successfully.");
3dfc15c0 1148 }
0bf7aade 1149
1150 return kTRUE;
f47b9233 1151
67dd5535 1152}
1153
1154//_____________________________________________________________________________
1155void AliGeomManager::InitPNEntriesLUT()
1156{
1157 // Initialize the look-up table which associates the unique
1158 // numerical identity of each alignable volume to the
1159 // corresponding TGeoPNEntry.
1160 // The LUTs are static; they are created at the creation of the
1161 // AliGeomManager instance and recreated if the geometry has changed
1162 //
36b010bf 1163 if(!fgGeometry) {
1164 AliErrorClass("Impossible to initialize PNEntries LUT without an active geometry");
1165 return;
1166 }
25fad4e5 1167
67dd5535 1168 for (Int_t iLayer = 0; iLayer < (kLastLayer - kFirstLayer); iLayer++){
3564f2da 1169 if (!fgPNEntry[iLayer]) fgPNEntry[iLayer] = new TGeoPNEntry*[fgLayerSize[iLayer]];
36b010bf 1170 for(Int_t modnum=0; modnum<fgLayerSize[iLayer]; modnum++){
0bf7aade 1171 fgPNEntry[iLayer][modnum] = fgGeometry->GetAlignableEntryByUID(LayerToVolUID(iLayer+1,modnum));
36b010bf 1172 }
1173 }
1174}
1175
67dd5535 1176//______________________________________________________________________
53dd673d 1177TGeoHMatrix* AliGeomManager::GetMatrix(TGeoPNEntry * const pne)
67dd5535 1178{
5aedd709 1179 // Get the global transformation matrix for a given PNEntry
67dd5535 1180 // by quering the TGeoManager
1181
36b010bf 1182 if (!fgGeometry || !fgGeometry->IsClosed()) {
25fad4e5 1183 AliErrorClass("Can't get the global matrix! gGeoManager doesn't exist or it is still opened!");
1184 return NULL;
1185 }
5aedd709 1186
67dd5535 1187 TGeoPhysicalNode *pnode = pne->GetPhysicalNode();
1188 if (pnode) return pnode->GetMatrix();
1189
1190 const char* path = pne->GetTitle();
36b010bf 1191 if (!fgGeometry->cd(path)) {
67dd5535 1192 AliErrorClass(Form("Volume path %s not valid!",path));
1193 return NULL;
1194 }
36b010bf 1195 return fgGeometry->GetCurrentMatrix();
67dd5535 1196}
1197
1198//______________________________________________________________________
1199TGeoHMatrix* AliGeomManager::GetMatrix(Int_t index)
1200{
1201 // Get the global transformation matrix for a given alignable volume
1202 // identified by its unique ID 'index' by quering the TGeoManager
1203
67dd5535 1204 TGeoPNEntry *pne = GetPNEntry(index);
1205 if (!pne) return NULL;
1206
1207 return GetMatrix(pne);
1208}
1209
1210//______________________________________________________________________
1211TGeoHMatrix* AliGeomManager::GetMatrix(const char* symname)
1212{
1213 // Get the global transformation matrix for a given alignable volume
1214 // identified by its symbolic name 'symname' by quering the TGeoManager
1215
36b010bf 1216 if (!fgGeometry || !fgGeometry->IsClosed()) {
1217 AliErrorClass("No active geometry or geometry not yet closed!");
1218 return NULL;
1219 }
1220
1221 TGeoPNEntry* pne = fgGeometry->GetAlignableEntry(symname);
67dd5535 1222 if (!pne) return NULL;
1223
1224 return GetMatrix(pne);
1225}
1226
1227//______________________________________________________________________
1228Bool_t AliGeomManager::GetTranslation(Int_t index, Double_t t[3])
1229{
1230 // Get the translation vector for a given module 'index'
1231 // by quering the TGeoManager
1232
1233 TGeoHMatrix *m = GetMatrix(index);
1234 if (!m) return kFALSE;
1235
1236 Double_t *trans = m->GetTranslation();
1237 for (Int_t i = 0; i < 3; i++) t[i] = trans[i];
1238
1239 return kTRUE;
1240}
1241
1242//______________________________________________________________________
1243Bool_t AliGeomManager::GetRotation(Int_t index, Double_t r[9])
1244{
1245 // Get the rotation matrix for a given module 'index'
1246 // by quering the TGeoManager
1247
1248 TGeoHMatrix *m = GetMatrix(index);
1249 if (!m) return kFALSE;
1250
1251 Double_t *rot = m->GetRotationMatrix();
1252 for (Int_t i = 0; i < 9; i++) r[i] = rot[i];
1253
1254 return kTRUE;
1255}
1256
5d534fe3 1257//_____________________________________________________________________________
1258Bool_t AliGeomManager::GetDeltaForBranch(Int_t index, TGeoHMatrix &inclusiveD)
1259{
1260 // The method sets the matrix passed as argument as the global delta
1261 // (for the volume referred by the unique index) including the displacements
1262 // of all parent volumes in the branch.
1263 //
5d534fe3 1264
1265 TGeoHMatrix go,invgo;
1266 go = *GetOrigGlobalMatrix(index);
1267 invgo = go.Inverse();
5aedd709 1268 inclusiveD = *GetMatrix(index);
5d534fe3 1269 inclusiveD.Multiply(&invgo);
1270
1271 return kTRUE;
1272}
1273
1274//_____________________________________________________________________________
1275Bool_t AliGeomManager::GetDeltaForBranch(AliAlignObj& aao, TGeoHMatrix &inclusiveD)
1276{
1277 // The method sets the matrix passed as argument as the global delta
1278 // (for the volume referred by the alignment object) including the displacements
1279 // of all parent volumes in the brach.
1280 //
1281 Int_t index = aao.GetVolUID();
1282 if(!index){
1283 AliErrorClass("Either the alignment object or its index are not valid");
1284 return kFALSE;
1285 }
1286 return GetDeltaForBranch(index, inclusiveD);
1287}
1288
36b010bf 1289//______________________________________________________________________
1290Bool_t AliGeomManager::GetOrigGlobalMatrix(const char* symname, TGeoHMatrix &m)
67dd5535 1291{
36b010bf 1292 // Get the global transformation matrix (ideal geometry) for a given alignable volume
0bf7aade 1293 // The alignable volume is identified by 'symname' which has to be either a valid symbolic
1294 // name, the query being performed after alignment, or a valid volume path if the query is
1295 // performed before alignment.
1296 //
36b010bf 1297 m.Clear();
67dd5535 1298
36b010bf 1299 if (!fgGeometry || !fgGeometry->IsClosed()) {
1300 AliErrorClass("No active geometry or geometry not yet closed!");
67dd5535 1301 return kFALSE;
1302 }
36b010bf 1303 if (!fgGeometry->GetListOfPhysicalNodes()) {
67dd5535 1304 AliWarningClass("gGeoManager doesn't contain any aligned nodes!");
36b010bf 1305 if (!fgGeometry->cd(symname)) {
67dd5535 1306 AliErrorClass(Form("Volume path %s not valid!",symname));
1307 return kFALSE;
1308 }
1309 else {
36b010bf 1310 m = *fgGeometry->GetCurrentMatrix();
67dd5535 1311 return kTRUE;
1312 }
1313 }
1314
36b010bf 1315 TGeoPNEntry* pne = fgGeometry->GetAlignableEntry(symname);
67dd5535 1316 const char* path = NULL;
67dd5535 1317 if(pne){
0bf7aade 1318 m = *pne->GetGlobalOrig();
1319 return kTRUE;
67dd5535 1320 }else{
1321 AliWarningClass(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as a volume path!",symname));
1322 path=symname;
1323 }
1324
36b010bf 1325 return GetOrigGlobalMatrixFromPath(path,m);
1326}
1327
1328//_____________________________________________________________________________
1329Bool_t AliGeomManager::GetOrigGlobalMatrixFromPath(const char *path, TGeoHMatrix &m)
1330{
5aedd709 1331 // The method returns the global matrix for the volume identified by
1332 // 'path' in the ideal detector geometry.
1333 // The output global matrix is stored in 'm'.
1334 // Returns kFALSE in case TGeo has not been initialized or the volume
1335 // path is not valid.
36b010bf 1336 //
1337 m.Clear();
1338
1339 if (!fgGeometry || !fgGeometry->IsClosed()) {
1340 AliErrorClass("Can't get the original global matrix! gGeoManager doesn't exist or it is still opened!");
67dd5535 1341 return kFALSE;
1342 }
1343
36b010bf 1344 if (!fgGeometry->CheckPath(path)) {
1345 AliErrorClass(Form("Volume path %s not valid!",path));
1346 return kFALSE;
1347 }
67dd5535 1348
36b010bf 1349 TIter next(fgGeometry->GetListOfPhysicalNodes());
1350 fgGeometry->cd(path);
67dd5535 1351
36b010bf 1352 while(fgGeometry->GetLevel()){
67dd5535 1353
1354 TGeoPhysicalNode *physNode = NULL;
1355 next.Reset();
36b010bf 1356 TGeoNode *node = fgGeometry->GetCurrentNode();
67dd5535 1357 while ((physNode=(TGeoPhysicalNode*)next()))
1358 if (physNode->GetNode() == node) break;
1359
1360 TGeoMatrix *lm = NULL;
1361 if (physNode) {
5aedd709 1362 lm = physNode->GetOriginalMatrix();
1363 if (!lm) lm = node->GetMatrix();
67dd5535 1364 } else
1365 lm = node->GetMatrix();
1366
1367 m.MultiplyLeft(lm);
1368
36b010bf 1369 fgGeometry->CdUp();
67dd5535 1370 }
1371
1372 return kTRUE;
1373}
1374
36b010bf 1375//_____________________________________________________________________________
53dd673d 1376TGeoHMatrix* AliGeomManager::GetOrigGlobalMatrix(TGeoPNEntry * const pne)
36b010bf 1377{
1378 // The method returns global matrix for the ideal detector geometry
1379 // using the corresponding TGeoPNEntry as an input.
5aedd709 1380 // The returned pointer should be copied by the user, since its content could
1381 // be overwritten by a following call to the method.
1382 // In case of missing TGeoManager the method returns NULL.
1383 //
36b010bf 1384 if (!fgGeometry || !fgGeometry->IsClosed()) {
1385 AliErrorClass("Can't get the global matrix! gGeoManager doesn't exist or it is still opened!");
1386 return NULL;
1387 }
1388
0bf7aade 1389 return pne->GetGlobalOrig();
36b010bf 1390}
1391
67dd5535 1392//______________________________________________________________________
36b010bf 1393TGeoHMatrix* AliGeomManager::GetOrigGlobalMatrix(Int_t index)
67dd5535 1394{
5aedd709 1395 // The method returns global matrix from the ideal detector geometry
1396 // for the volume identified by its index.
1397 // The returned pointer should be copied by the user, since its content could
1398 // be overwritten by a following call to the method.
1399 // In case of missing TGeoManager the method returns NULL.
1400 // If possible, the method uses the LUT of original ideal matrices
1401 // for fast access. The LUT is reset in case a
36b010bf 1402 // new geometry is loaded.
5aedd709 1403 //
0bf7aade 1404 TGeoPNEntry* pne = GetPNEntry(index);
1405 return pne->GetGlobalOrig();
67dd5535 1406}
1407
1408//______________________________________________________________________
1409Bool_t AliGeomManager::GetOrigTranslation(Int_t index, Double_t t[3])
1410{
1411 // Get the original translation vector (ideal geometry)
1412 // for a given module 'index' by quering the TGeoManager
1413
36b010bf 1414 TGeoHMatrix *m = GetOrigGlobalMatrix(index);
1415 if (!m) return kFALSE;
67dd5535 1416
36b010bf 1417 Double_t *trans = m->GetTranslation();
67dd5535 1418 for (Int_t i = 0; i < 3; i++) t[i] = trans[i];
1419
1420 return kTRUE;
1421}
1422
1423//______________________________________________________________________
1424Bool_t AliGeomManager::GetOrigRotation(Int_t index, Double_t r[9])
1425{
1426 // Get the original rotation matrix (ideal geometry)
1427 // for a given module 'index' by quering the TGeoManager
1428
36b010bf 1429 TGeoHMatrix *m = GetOrigGlobalMatrix(index);
1430 if (!m) return kFALSE;
67dd5535 1431
36b010bf 1432 Double_t *rot = m->GetRotationMatrix();
67dd5535 1433 for (Int_t i = 0; i < 9; i++) r[i] = rot[i];
1434
1435 return kTRUE;
1436}
1437
1438//______________________________________________________________________
1439const TGeoHMatrix* AliGeomManager::GetTracking2LocalMatrix(Int_t index)
1440{
25fad4e5 1441 // Get the matrix which transforms from the tracking to the local RS
67dd5535 1442 // The method queries directly the TGeoPNEntry
1443
67dd5535 1444 TGeoPNEntry *pne = GetPNEntry(index);
1445 if (!pne) return NULL;
1446
1447 const TGeoHMatrix *m = pne->GetMatrix();
1448 if (!m)
5aedd709 1449 AliErrorClass(Form("TGeoPNEntry (%s) contains no tracking-to-local matrix !",pne->GetName()));
67dd5535 1450
1451 return m;
1452}
1453
1454//______________________________________________________________________
1455Bool_t AliGeomManager::GetTrackingMatrix(Int_t index, TGeoHMatrix &m)
1456{
1457 // Get the matrix which transforms from the tracking r.s. to
1458 // the global one.
1459 // Returns kFALSE in case of error.
1460
1461 m.Clear();
1462
1463 TGeoHMatrix *m1 = GetMatrix(index);
1464 if (!m1) return kFALSE;
1465
1466 const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index);
1467 if (!m2) return kFALSE;
1468
1469 m = *m1;
1470 m.Multiply(m2);
1471
1472 return kTRUE;
1473}
1474
1475//_____________________________________________________________________________
1476TGeoPNEntry* AliGeomManager::GetPNEntry(Int_t voluid) {
1477 // Returns the TGeoPNEntry for the given global volume ID "voluid"
1478 //
1479 Int_t modId;
1480 ELayerID layerId = VolUIDToLayer(voluid,modId);
1481 return GetPNEntry(layerId,modId);
1482}
1483
67dd5535 1484//_____________________________________________________________________________
1485TGeoPNEntry* AliGeomManager::GetPNEntry(ELayerID layerId, Int_t modId)
1486{
1487 // Returns the TGeoPNEntry for a given layer
1488 // and module ID
1489 //
25fad4e5 1490
67dd5535 1491 if(modId<0 || modId>=fgLayerSize[layerId-kFirstLayer]){
1492 AliWarningClass(Form("Module number %d not in the valid range (0->%d) !",modId,fgLayerSize[layerId-kFirstLayer]-1));
1493 return NULL;
1494 }
1495
1496 return fgPNEntry[layerId-kFirstLayer][modId];
1497}
1498
5590c6c3 1499//_____________________________________________________________________________
1500void AliGeomManager::CheckOverlapsOverPNs(Double_t threshold)
1501{
1502 // Check for overlaps/extrusions on physical nodes only;
1503 // this overlap-checker is meant to be used to check overlaps/extrusions
1504 // originated by the application of alignment objects.
1505 //
1506
1c00c47a 1507 TObjArray* ovexlist = 0x0;
5590c6c3 1508
1509 AliInfoClass("********* Checking overlaps/extrusions over physical nodes only *********");
1510 TObjArray* pnList = gGeoManager->GetListOfPhysicalNodes();
0cd61c1d 1511 TGeoVolume* mvol = 0;
5590c6c3 1512 TGeoPhysicalNode* pn;
1513 TObjArray* overlaps = new TObjArray(64);
1514 overlaps->SetOwner();
1515
1516 TStopwatch timer2;
1517 timer2.Start();
1518 for(Int_t pni=0; pni<pnList->GetEntriesFast(); pni++){
1519 pn = (TGeoPhysicalNode*) pnList->UncheckedAt(pni);
1520 // checking the volume of the mother (go upper in the tree in case it is an assembly)
1521 Int_t levup=1;
1522 while(((TGeoVolume*)pn->GetVolume(pn->GetLevel()-levup))->IsAssembly()) levup++;
1523 //Printf("Going to upper level");
1524 mvol = pn->GetVolume(pn->GetLevel()-levup);
1525 if(!mvol->IsSelected()){
1526 AliInfoClass(Form("Checking overlaps for volume %s",mvol->GetName()));
1527 mvol->CheckOverlaps(threshold);
1528 ovexlist = gGeoManager->GetListOfOverlaps();
1529 TIter next(ovexlist);
1530 TGeoOverlap *ov;
1531 while ((ov=(TGeoOverlap*)next())) overlaps->Add(ov->Clone());
1532 mvol->SelectVolume();
1533 }
1534 }
1535 mvol->SelectVolume(kTRUE); // clears the list of selected volumes
1536
1537 AliInfoClass(Form("Number of overlapping/extruding PNs: %d",overlaps->GetEntriesFast()));
1538 timer2.Stop();
1539 timer2.Print();
1540
1541 TIter nextN(overlaps);
1542 TGeoOverlap *ovlp;
1543 while ((ovlp=(TGeoOverlap*)nextN())) ovlp->PrintInfo();
1544
1545 overlaps->Delete();
1546 delete overlaps;
1547}
1548
8cb26cdf 1549//_____________________________________________________________________________
4fbb8e9d 1550Int_t AliGeomManager::GetNalignable(const char* module)
8cb26cdf 1551{
a1ecbc97 1552 // Get number of declared alignable volumes in current geometry
1553 // for the given detector "module" passed as a vaild detector name
1554 // if the detector name is invalid return -1
8cb26cdf 1555
4fbb8e9d 1556 // return the detector index corresponding to detector
1557 Int_t index = -1 ;
1558 for (index = 0; index < fgkNDetectors ; index++) {
1559 if ( strcmp(module, fgkDetectorName[index]) == 0 )
1560 break ;
1561 }
a1ecbc97 1562 if(index==fgkNDetectors) return -1;
4fbb8e9d 1563 return fgNalignable[index];
8cb26cdf 1564}
4fbb8e9d 1565
1566//_____________________________________________________________________________
1567void AliGeomManager::InitNalignable()
1568{
1569 // Set number of declared alignable volumes for given detector in current geometry
1570 // by looping on the list of PNEntries
1571 //
1572
1573 Int_t nAlE = gGeoManager->GetNAlignable(); // total number of alignable entries
1574 TGeoPNEntry *pne = 0;
4fbb8e9d 1575 const char* detName;
1576
1577 for (Int_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1578 detName = fgkDetectorName[iDet];
1579 Int_t nAlDet = 0;
1580
1581 for(Int_t iE = 0; iE < nAlE; iE++)
1582 {
1583 pne = gGeoManager->GetAlignableEntry(iE);
3564f2da 1584 TString pneName = pne->GetName();
1585 if(pneName.Contains(detName)) nAlDet++;
1586 if(!strcmp(detName,"GRP")) if(pneName.Contains("ABSO") || pneName.Contains("DIPO") ||
1587 pneName.Contains("FRAME") || pneName.Contains("PIPE") ||
1588 pneName.Contains("SHIL")) nAlDet++;
4fbb8e9d 1589 }
1590 fgNalignable[iDet] = nAlDet;
1591 }
8cb26cdf 1592
4fbb8e9d 1593}
1594
67dd5535 1595//_____________________________________________________________________________
917768e3 1596Bool_t AliGeomManager::ApplyAlignObjsFromCDB(const char* alignDetsList)
67dd5535 1597{
1598 // Calls AddAlignObjsFromCDBSingleDet for the detectors appearing in
1599 // the list passed as argument (called by AliSimulation and
1600 // AliReconstruction)
1601 // Read the alignment objects from CDB.
1602 // Each detector is supposed to have the
1603 // alignment objects in DET/Align/Data CDB path.
1604 // All the detector objects are then collected,
1605 // sorted by geometry level (starting from ALIC) and
1606 // then applied to the TGeo geometry.
1607 // Finally an overlaps check is performed.
1608 //
1609
36b010bf 1610 TObjArray alignObjArray;
1611 alignObjArray.Clear();
1612 alignObjArray.SetOwner(0);
67dd5535 1613
1614 TString alObjsNotLoaded="";
1615 TString alObjsLoaded="";
1616
917768e3 1617 TString alignDetsString(alignDetsList);
1618 TObjArray *detsarr = alignDetsString.Tokenize(' ');
67dd5535 1619 TIter iter(detsarr);
1620 TObjString *str = 0;
1621
1622 while((str = (TObjString*) iter.Next())){
1623 TString det(str->String());
2912a163 1624 AliDebugClass(5,Form("Loading alignment objs for %s",det.Data()));
36b010bf 1625 if(!LoadAlignObjsFromCDBSingleDet(det.Data(),alignObjArray)){
67dd5535 1626 alObjsNotLoaded += det.Data();
1627 alObjsNotLoaded += " ";
1628 } else {
1629 alObjsLoaded += det.Data();
1630 alObjsLoaded += " ";
1631 }
1632 }
b80b98e1 1633 detsarr->Delete();
1634 delete detsarr;
67dd5535 1635
36b010bf 1636 if(!alObjsLoaded.IsNull()) AliInfoClass(Form("Alignment objects loaded for: %s",
1637 alObjsLoaded.Data()));
451cbb1d 1638 if(!alObjsNotLoaded.IsNull())
1639 AliFatalClass(Form("Could not load alignment objects from OCDB for: %s",
36b010bf 1640 alObjsNotLoaded.Data()));
67dd5535 1641
9cb4fe0b 1642 return ApplyAlignObjsToGeom(alignObjArray);
67dd5535 1643}
1644
1645//_____________________________________________________________________________
36b010bf 1646Bool_t AliGeomManager::LoadAlignObjsFromCDBSingleDet(const char* detName, TObjArray& alignObjArray)
67dd5535 1647{
1648 // Adds the alignable objects found in the CDBEntry for the detector
1649 // passed as argument to the array of all alignment objects to be applyed
1650 // to geometry
1651 //
1652 // Fills array of single detector's alignable objects from CDB
1653
36b010bf 1654 AliDebugClass(2, Form("Loading alignment objs for detector: %s",detName));
67dd5535 1655
1656 AliCDBEntry *entry;
1657
1658 AliCDBPath path(detName,"Align","Data");
1659
1660 entry=AliCDBManager::Instance()->Get(path.GetPath());
1661 if(!entry){
36b010bf 1662 AliDebugClass(2,Form("Couldn't load alignment data for detector %s",detName));
67dd5535 1663 return kFALSE;
1664 }
1665 entry->SetOwner(1);
1666 TClonesArray *alignArray = (TClonesArray*) entry->GetObject();
1667 alignArray->SetOwner(0);
4fbb8e9d 1668 Int_t nAlObjs = alignArray->GetEntries();
1669 AliDebugClass(2,Form("Found %d alignment objects for %s",nAlObjs,detName));
1670 Int_t nAlVols = GetNalignable(detName);
1671 if(nAlObjs!=nAlVols) AliWarningClass(Form("%d alignment objects loaded for %s, which has %d alignable volumes",nAlObjs,detName,GetNalignable(detName)));
67dd5535 1672
1673 AliAlignObj *alignObj=0;
1674 TIter iter(alignArray);
1675
1676 // loop over align objects in detector
1677 while( ( alignObj=(AliAlignObj *) iter.Next() ) ){
36b010bf 1678 alignObjArray.Add(alignObj);
67dd5535 1679 }
1680 // delete entry --- Don't delete, it is cached!
1681
36b010bf 1682 AliDebugClass(2, Form("fAlignObjArray entries: %d",alignObjArray.GetEntries() ));
67dd5535 1683 return kTRUE;
1684
1685}
1686
1687//_____________________________________________________________________________
5590c6c3 1688Bool_t AliGeomManager::ApplyAlignObjsToGeom(TObjArray& alignObjArray, Bool_t ovlpcheck)
67dd5535 1689{
c8687cb5 1690 // Read collection of alignment objects (AliAlignObj derived) saved
1691 // in the TClonesArray alObjArray and apply them to gGeoManager
1692 //
1693 alignObjArray.Sort();
1694 Int_t nvols = alignObjArray.GetEntriesFast();
67dd5535 1695
c8687cb5 1696 Bool_t flag = kTRUE;
67dd5535 1697
c8687cb5 1698 for(Int_t j=0; j<nvols; j++)
67dd5535 1699 {
c8687cb5 1700 AliAlignObj* alobj = (AliAlignObj*) alignObjArray.UncheckedAt(j);
1701 if(!alobj->ApplyToGeometry(ovlpcheck))
1702 {
1703 flag = kFALSE;
1704 AliDebugClass(5,Form("Error applying alignment object for volume %s !",alobj->GetSymName()));
1705 }else{
1706 AliDebugClass(5,Form("Alignment object for volume %s applied successfully",alobj->GetSymName()));
1707 }
67dd5535 1708
c8687cb5 1709 }
bb1970d8 1710
c8687cb5 1711 if (AliDebugLevelClass() > 5) {
1712 fgGeometry->CheckOverlaps(0.001);
1713 TObjArray* ovexlist = fgGeometry->GetListOfOverlaps();
1714 if(ovexlist->GetEntriesFast()){
1715 AliErrorClass("The application of alignment objects to the geometry caused huge overlaps/extrusions!");
1716 fgGeometry->PrintOverlaps();
1717 }
1718 }
67dd5535 1719
c8687cb5 1720 // Update the TGeoPhysicalNodes
1721 fgGeometry->RefreshPhysicalNodes();
36b010bf 1722
c8687cb5 1723 return flag;
67dd5535 1724
1725}
1726
1727//_____________________________________________________________________________
1728Bool_t AliGeomManager::ApplyAlignObjsToGeom(const char* fileName, const char* clArrayName)
1729{
1730 // read collection of alignment objects (AliAlignObj derived) saved
1731 // in the TClonesArray ClArrayName in the file fileName and apply
1732 // them to the geometry
1733 //
1734
1735 TFile* inFile = TFile::Open(fileName,"READ");
1736 if (!inFile || !inFile->IsOpen()) {
1737 AliErrorClass(Form("Could not open file %s !",fileName));
1738 return kFALSE;
1739 }
1740
36b010bf 1741 TClonesArray* alignObjArray = ((TClonesArray*) inFile->Get(clArrayName));
67dd5535 1742 inFile->Close();
36b010bf 1743 if (!alignObjArray) {
67dd5535 1744 AliErrorClass(Form("Could not get array (%s) from file (%s) !",clArrayName,fileName));
1745 return kFALSE;
1746 }
1747
36b010bf 1748 return ApplyAlignObjsToGeom(*alignObjArray);
67dd5535 1749
1750}
1751
67dd5535 1752//_____________________________________________________________________________
1753Bool_t AliGeomManager::ApplyAlignObjsToGeom(const char* uri, const char* path, Int_t runnum, Int_t version, Int_t sversion)
1754{
1755 // read collection of alignment objects (AliAlignObj derived) saved
1756 // in the TClonesArray ClArrayName in the AliCDBEntry identified by
1757 // param (to get the AliCDBStorage) and Id; apply the alignment objects
1758 // to the geometry
1759 //
1760
5078a13f 1761 AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage(uri);
67dd5535 1762 AliCDBId id(path, runnum, runnum, version, sversion);
5078a13f 1763 AliCDBEntry* entry = storage->Get(id);
1764 TClonesArray* alignObjArray = dynamic_cast<TClonesArray*>(entry->GetObject());
67dd5535 1765
5078a13f 1766 return ApplyAlignObjsToGeom(*alignObjArray);
67dd5535 1767
1768}
1769
1770//_____________________________________________________________________________
1771Bool_t AliGeomManager::ApplyAlignObjsToGeom(const char* detName, Int_t runnum, Int_t version, Int_t sversion)
1772{
1773 // read collection of alignment objects (AliAlignObj derived) saved
1774 // in the TClonesArray ClArrayName in the AliCDBEntry identified by
1775 // param (to get the AliCDBStorage) and Id; apply the alignment objects
1776 // to the geometry
1777 //
1778
1779 AliCDBPath path(detName,"Align","Data");
1780 AliCDBEntry* entry = AliCDBManager::Instance()->Get(path.GetPath(),runnum,version,sversion);
1781
1782 if(!entry) return kFALSE;
36b010bf 1783 TClonesArray* alignObjArray = ((TClonesArray*) entry->GetObject());
25fad4e5 1784
36b010bf 1785 return ApplyAlignObjsToGeom(*alignObjArray);
67dd5535 1786}
171c4ef9 1787
3564f2da 1788//_____________________________________________________________________________
1789void AliGeomManager::ResetPNEntriesLUT()
1790{
1791 // cleans static arrays containing the information on currently loaded geometry
1792 //
1793 for (Int_t iLayer = 0; iLayer < (kLastLayer - kFirstLayer); iLayer++){
1794 if (!fgPNEntry[iLayer]) continue;
1795 for (Int_t modnum=0; modnum<fgLayerSize[iLayer]; modnum++) fgPNEntry[iLayer][modnum] = 0;
1796 }
1797 //
1798}
1799