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