Charged jets (pPb): Added leading track biased spectra
[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
107//_____________________________________________________________________________
0dd36168 108void AliGeomManager::Destroy()
109{
110 // destroy the manager as well as gGeoManager (if it was not attached to fgGeometry)
111 delete gGeoManager;
112 fgGeometry = gGeoManager = 0;
113 ResetPNEntriesLUT();
114}
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;
8cc543cb 574 TString baseEmcalSM("ALIC_1/XEN1_1/");
8e5d5edf 575 Bool_t emcalActive=kFALSE;
8cc543cb 576 Bool_t emcalSMs[22] = {kFALSE};
577 for(Int_t sm=0; sm<22; sm++)
8e5d5edf 578 {
579 emcalSM=baseEmcalSM;
580 if(sm<10){
8cc543cb 581 emcalSM += "SMOD_";
582 emcalSM += (sm+1);
583 }else if(sm/2 == 5){
584 emcalSM += "SM10_";
585 emcalSM += (sm-9);
586 }else if(sm > 11){
587 emcalSM += "DCSM_";
588 emcalSM += (sm-11);
8e5d5edf 589 }
590 if(fgGeometry->CheckPath(emcalSM.Data()))
591 {
592 emcalActive=kTRUE;
593 emcalSMs[sm]=kTRUE;
594 }
595 }
596 if(emcalActive) detsString+="EMCAL ";
597
ff5970a3 598
67dd5535 599 TString symname;
0bf7aade 600 const char* sname;
601 TGeoPNEntry* pne = 0x0;
602 Int_t uid; // global unique identity
603 Int_t modnum; // unique id inside layer; in the following, set it to 0 at the start of each layer
67dd5535 604
ff5970a3 605 if(detsString.Contains("ITS")){
67dd5535 606 /********************* ITS layers ***********************/
ff5970a3 607 AliDebugClass(2,"Checking consistency of symbolic names for ITS layers");
608 TString strSPD = "ITS/SPD";
609 TString strSDD = "ITS/SDD";
610 TString strSSD = "ITS/SSD";
611 TString strStave = "/Stave";
612 TString strHalfStave = "/HalfStave";
613 TString strLadder = "/Ladder";
614 TString strSector = "/Sector";
615 TString strSensor = "/Sensor";
616 TString strEntryName1;
617 TString strEntryName2;
618 TString strEntryName3;
619
620 /********************* SPD layer1 ***********************/
621 {
622 modnum = 0;
623
624 for(Int_t cSect = 0; cSect<10; cSect++){
625 strEntryName1 = strSPD;
626 strEntryName1 += 0;
627 strEntryName1 += strSector;
628 strEntryName1 += cSect;
629
630 for(Int_t cStave =0; cStave<2; cStave++){
631 strEntryName2 = strEntryName1;
632 strEntryName2 += strStave;
633 strEntryName2 += cStave;
634
635 for (Int_t cHS=0; cHS<2; cHS++) {
636 strEntryName3 = strEntryName2;
637 strEntryName3 += strHalfStave;
638 strEntryName3 += cHS;
639
640 for(Int_t cLad =0; cLad<2; cLad++){
641 symname = strEntryName3;
642 symname += strLadder;
643 symname += cLad+cHS*2;
644 uid = LayerToVolUID(kSPD1,modnum++);
645 pne = fgGeometry->GetAlignableEntryByUID(uid);
646 if(!pne)
647 {
648 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
649 return kFALSE;
650 }
651 sname = pne->GetName();
652 if(symname.CompareTo(sname))
653 {
654 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d."
655 "Expected was %s, found was %s!", uid, symname.Data(), sname));
656 return kFALSE;
657 }
0bf7aade 658 }
8f8273a4 659 }
67dd5535 660 }
661 }
662 }
ff5970a3 663
664 /********************* SPD layer2 ***********************/
665 {
666 modnum = 0;
667
668 for(Int_t cSect = 0; cSect<10; cSect++){
669 strEntryName1 = strSPD;
670 strEntryName1 += 1;
671 strEntryName1 += strSector;
672 strEntryName1 += cSect;
673
674 for(Int_t cStave =0; cStave<4; cStave++){
675 strEntryName2 = strEntryName1;
676 strEntryName2 += strStave;
677 strEntryName2 += cStave;
678
679 for (Int_t cHS=0; cHS<2; cHS++) {
680 strEntryName3 = strEntryName2;
681 strEntryName3 += strHalfStave;
682 strEntryName3 += cHS;
683
684 for(Int_t cLad =0; cLad<2; cLad++){
685 symname = strEntryName3;
686 symname += strLadder;
687 symname += cLad+cHS*2;
688 uid = LayerToVolUID(kSPD2,modnum++);
689 pne = fgGeometry->GetAlignableEntryByUID(uid);
690 if(!pne)
691 {
692 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
693 return kFALSE;
694 }
695 sname = pne->GetName();
696 if(symname.CompareTo(sname))
697 {
698 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d."
699 "Expected was %s, found was %s!", uid, symname.Data(), sname));
700 return kFALSE;
701 }
0bf7aade 702 }
8f8273a4 703 }
67dd5535 704 }
705 }
706 }
ff5970a3 707
708 /********************* SDD layer1 ***********************/
709 {
710 modnum=0;
711
712 for(Int_t c1 = 1; c1<=14; c1++){
713 strEntryName1 = strSDD;
714 strEntryName1 += 2;
715 strEntryName1 +=strLadder;
716 strEntryName1 += (c1-1);
717 for(Int_t c2 =1; c2<=6; c2++){
718 symname = strEntryName1;
719 symname += strSensor;
720 symname += (c2-1);
721 uid = LayerToVolUID(kSDD1,modnum++);
722 pne = fgGeometry->GetAlignableEntryByUID(uid);
723 if(!pne)
724 {
725 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
726 return kFALSE;
727 }
728 sname = pne->GetName();
729 if(symname.CompareTo(sname))
730 {
731 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
732 "Expected was %s, found was %s!", uid, symname.Data(), sname));
733 return kFALSE;
734 }
735 }
736 }
737 }
738
739 /********************* SDD layer2 ***********************/
740 {
741 modnum=0;
742
743 for(Int_t c1 = 1; c1<=22; c1++){
744 strEntryName1 = strSDD;
745 strEntryName1 += 3;
746 strEntryName1 +=strLadder;
747 strEntryName1 += (c1-1);
748 for(Int_t c2 = 1; c2<=8; c2++){
749 symname = strEntryName1;
750 symname += strSensor;
751 symname += (c2-1);
752 uid = LayerToVolUID(kSDD2,modnum++);
753 pne = fgGeometry->GetAlignableEntryByUID(uid);
754 if(!pne)
755 {
756 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
757 return kFALSE;
758 }
759 sname = pne->GetName();
760 if(symname.CompareTo(sname))
761 {
762 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
763 "Expected was %s, found was %s!", uid, symname.Data(), sname));
764 return kFALSE;
765 }
766 }
767 }
768 }
769
770 /********************* SSD layer1 ***********************/
771 {
772 modnum=0;
773
774 for(Int_t c1 = 1; c1<=34; c1++){
775 strEntryName1 = strSSD;
776 strEntryName1 += 4;
777 strEntryName1 +=strLadder;
778 strEntryName1 += (c1-1);
779 for(Int_t c2 = 1; c2<=22; c2++){
780 symname = strEntryName1;
781 symname += strSensor;
782 symname += (c2-1);
783 uid = LayerToVolUID(kSSD1,modnum++);
784 pne = fgGeometry->GetAlignableEntryByUID(uid);
785 if(!pne)
786 {
787 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
788 return kFALSE;
789 }
790 sname = pne->GetName();
791 if(symname.CompareTo(sname))
792 {
793 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
794 "Expected was %s, found was %s!", uid, symname.Data(), sname));
795 return kFALSE;
796 }
797 }
798 }
799 }
800
801 /********************* SSD layer2 ***********************/
802 {
803 modnum=0;
804
805 for(Int_t c1 = 1; c1<=38; c1++){
806 strEntryName1 = strSSD;
807 strEntryName1 += 5;
808 strEntryName1 +=strLadder;
809 strEntryName1 += (c1-1);
810 for(Int_t c2 = 1; c2<=25; c2++){
811 symname = strEntryName1;
812 symname += strSensor;
813 symname += (c2-1);
814 uid = LayerToVolUID(kSSD2,modnum++);
815 pne = fgGeometry->GetAlignableEntryByUID(uid);
816 if(!pne)
817 {
818 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
819 return kFALSE;
820 }
821 sname = pne->GetName();
822 if(symname.CompareTo(sname))
823 {
824 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
825 "Expected was %s, found was %s!", uid, symname.Data(), sname));
826 return kFALSE;
827 }
828 }
829 }
830 }
831
832 AliDebugClass(2,"Consistency check for ITS symbolic names finished successfully.");
67dd5535 833 }
834
ff5970a3 835 if(detsString.Contains("TPC"))
67dd5535 836 {
ff5970a3 837 /*************** TPC inner and outer layers ****************/
838
839 AliDebugClass(2,"Checking consistency of symbolic names for TPC layers");
840 TString sAsector="TPC/EndcapA/Sector";
841 TString sCsector="TPC/EndcapC/Sector";
842 TString sInner="/InnerChamber";
843 TString sOuter="/OuterChamber";
844
845 /*************** TPC inner chambers' layer ****************/
846 {
847 modnum = 0;
67dd5535 848
ff5970a3 849 for(Int_t cnt=1; cnt<=18; cnt++)
850 {
851 symname = sAsector;
852 symname += cnt;
853 symname += sInner;
854 uid = LayerToVolUID(kTPC1,modnum++);
0bf7aade 855 pne = fgGeometry->GetAlignableEntryByUID(uid);
856 if(!pne)
857 {
858 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
859 return kFALSE;
860 }
861 sname = pne->GetName();
862 if(symname.CompareTo(sname))
863 {
864 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
865 "Expected was %s, found was %s!", uid, symname.Data(), sname));
866 return kFALSE;
867 }
67dd5535 868 }
67dd5535 869
ff5970a3 870 for(Int_t cnt=1; cnt<=18; cnt++)
871 {
872 symname = sCsector;
873 symname += cnt;
874 symname += sInner;
875 uid = LayerToVolUID(kTPC1,modnum++);
0bf7aade 876 pne = fgGeometry->GetAlignableEntryByUID(uid);
877 if(!pne)
878 {
879 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
880 return kFALSE;
881 }
882 sname = pne->GetName();
883 if(symname.CompareTo(sname))
884 {
885 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
886 "Expected was %s, found was %s!", uid, symname.Data(), sname));
887 return kFALSE;
888 }
67dd5535 889 }
890 }
67dd5535 891
ff5970a3 892 /*************** TPC outer chambers' layer ****************/
893 {
894 modnum = 0;
67dd5535 895
ff5970a3 896 for(Int_t cnt=1; cnt<=18; cnt++)
897 {
898 symname = sAsector;
899 symname += cnt;
900 symname += sOuter;
901 uid = LayerToVolUID(kTPC2,modnum++);
0bf7aade 902 pne = fgGeometry->GetAlignableEntryByUID(uid);
903 if(!pne)
904 {
905 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
906 return kFALSE;
907 }
908 sname = pne->GetName();
909 if(symname.CompareTo(sname))
910 {
911 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
912 "Expected was %s, found was %s!", uid, symname.Data(), sname));
913 return kFALSE;
914 }
67dd5535 915 }
67dd5535 916
ff5970a3 917 for(Int_t cnt=1; cnt<=18; cnt++)
918 {
919 symname = sCsector;
920 symname += cnt;
921 symname += sOuter;
922 uid = LayerToVolUID(kTPC2,modnum++);
0bf7aade 923 pne = fgGeometry->GetAlignableEntryByUID(uid);
924 if(!pne)
925 {
926 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
927 return kFALSE;
928 }
929 sname = pne->GetName();
930 if(symname.CompareTo(sname))
931 {
932 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
933 "Expected was %s, found was %s!", uid, symname.Data(), sname));
934 return kFALSE;
935 }
67dd5535 936 }
937 }
67dd5535 938
ff5970a3 939 AliDebugClass(2,"Consistency check for TPC symbolic names finished successfully.");
67dd5535 940 }
941
ff5970a3 942 if(detsString.Contains("TOF"))
67dd5535 943 {
ff5970a3 944 /********************* TOF layer ***********************/
67dd5535 945
ff5970a3 946 AliDebugClass(2,"Checking consistency of symbolic names for TOF layers");
67dd5535 947 modnum=0;
ff5970a3 948
67dd5535 949 Int_t nstrA=15;
950 Int_t nstrB=19;
951 Int_t nstrC=19;
952 Int_t nSectors=18;
953 Int_t nStrips=nstrA+2*nstrB+2*nstrC;
0bf7aade 954
67dd5535 955 TString snSM = "TOF/sm";
956 TString snSTRIP = "/strip";
957
958 for (Int_t isect = 0; isect < nSectors; isect++) {
a55c71ed 959 if(tofSMs[isect]) AliDebugClass(3,Form("Consistency check for symnames of TOF supermodule %d.",isect));
67dd5535 960 for (Int_t istr = 1; istr <= nStrips; istr++) {
961 symname = snSM;
962 symname += Form("%02d",isect);
963 symname += snSTRIP;
964 symname += Form("%02d",istr);
0bf7aade 965 uid = LayerToVolUID(kTOF,modnum++);
83364444 966 if(!tofSMs[isect]) continue; // taking possible missing TOF sectors (partial geometry) into account
0bf7aade 967 if ((isect==13 || isect==14 || isect==15) && (istr >= 39 && istr <= 53)) continue; //taking holes into account
968 pne = fgGeometry->GetAlignableEntryByUID(uid);
969 if(!pne)
970 {
971 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
972 return kFALSE;
973 }
974 sname = pne->GetName();
975 if(symname.CompareTo(sname))
976 {
977 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
978 "Expected was %s, found was %s!", uid, symname.Data(), sname));
979 return kFALSE;
980 }
67dd5535 981 }
982 }
ff5970a3 983
984 AliDebugClass(2,"Consistency check for TOF symbolic names finished successfully.");
67dd5535 985 }
986
ff5970a3 987 if(detsString.Contains("HMPID"))
67dd5535 988 {
ff5970a3 989 /********************* HMPID layer ***********************/
990
991 AliDebugClass(2,"Checking consistency of symbolic names for HMPID layers");
67dd5535 992 TString str = "/HMPID/Chamber";
993
994 for (modnum=0; modnum < 7; modnum++) {
995 symname = str;
996 symname += modnum;
0bf7aade 997 uid = LayerToVolUID(kHMPID,modnum);
998 pne = fgGeometry->GetAlignableEntryByUID(uid);
999 if(!pne)
1000 {
1001 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1002 return kFALSE;
1003 }
1004 sname = pne->GetName();
1005 if(symname.CompareTo(sname))
1006 {
1007 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1008 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1009 return kFALSE;
1010 }
67dd5535 1011 }
ff5970a3 1012
1013 AliDebugClass(2,"Consistency check for HMPID symbolic names finished successfully.");
67dd5535 1014 }
1015
ff5970a3 1016 if(detsString.Contains("TRD"))
67dd5535 1017 {
ff5970a3 1018 /********************* TRD layers 1-6 *******************/
1019 //!! 6 layers with index increasing in outwards direction
1020
1021 AliDebugClass(2,"Checking consistency of symbolic names for TRD layers");
67dd5535 1022 Int_t arTRDlayId[6] = {kTRD1, kTRD2, kTRD3, kTRD4, kTRD5, kTRD6};
1023
1024 TString snStr = "TRD/sm";
1025 TString snApp1 = "/st";
1026 TString snApp2 = "/pl";
1027
1028 for(Int_t layer=0; layer<6; layer++){
1029 modnum=0;
a55c71ed 1030 AliDebugClass(3,Form("Consistency check for symnames of TRD layer %d.",layer));
67dd5535 1031 for (Int_t isect = 0; isect < 18; isect++) {
1032 for (Int_t icham = 0; icham < 5; icham++) {
1033 symname = snStr;
1034 symname += Form("%02d",isect);
1035 symname += snApp1;
1036 symname += icham;
1037 symname += snApp2;
1038 symname += layer;
0bf7aade 1039 uid = LayerToVolUID(arTRDlayId[layer],modnum++);
83364444 1040 if(!trdSMs[isect]) continue;
0bf7aade 1041 if ((isect==13 || isect==14 || isect==15) && icham==2) continue; //keeping holes into account
1042 pne = fgGeometry->GetAlignableEntryByUID(uid);
1043 if(!pne)
1044 {
1045 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1046 return kFALSE;
1047 }
1048 sname = pne->GetName();
1049 if(symname.CompareTo(sname))
1050 {
1051 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1052 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1053 return kFALSE;
1054 }
67dd5535 1055 }
1056 }
1057 }
ff5970a3 1058
1059 AliDebugClass(2,"Consistency check for TRD symbolic names finished successfully.");
67dd5535 1060 }
df117114 1061
ff5970a3 1062 if(detsString.Contains("PHOS"))
df117114 1063 {
ff5970a3 1064 /********************* PHOS EMC layer ***********************/
df117114 1065
ff5970a3 1066 AliDebugClass(2,"Checking consistency of symbolic names for PHOS layers");
1067
ff5970a3 1068 TString str = "PHOS/Module";
1069 modnum=0;
1070
6ead0654 1071 for (Int_t iModule=0; iModule < 5; iModule++) {
1072 if(!phosMods[iModule]) continue;
ff5970a3 1073 symname = str;
6ead0654 1074 symname += (iModule+1);
1075 uid = LayerToVolUID(kPHOS1,iModule);
ff5970a3 1076 pne = fgGeometry->GetAlignableEntryByUID(uid);
1077 if(!pne)
1078 {
1079 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1080 return kFALSE;
1081 }
1082 sname = pne->GetName();
1083 if(symname.CompareTo(sname))
1084 {
1085 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1086 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1087 return kFALSE;
1088 }
6ead0654 1089 /********************* PHOS CPV layer ***********************/
1090 if(!cpvActive) continue;
ff5970a3 1091 symname += "/CPV";
6ead0654 1092 uid = LayerToVolUID(kPHOS2,iModule);
ff5970a3 1093 pne = fgGeometry->GetAlignableEntryByUID(uid);
1094 if(!pne)
1095 {
1096 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1097 return kFALSE;
1098 }
1099 sname = pne->GetName();
1100 if(symname.CompareTo(sname))
1101 {
1102 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1103 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1104 return kFALSE;
1105 }
0bf7aade 1106 }
ff5970a3 1107 AliDebugClass(2,"Consistency check for PHOS symbolic names finished successfully.");
f47b9233 1108 }
1109
ff5970a3 1110 if(detsString.Contains("EMCAL"))
3dfc15c0 1111 {
ff5970a3 1112 /********************* EMCAL layer ***********************/
1113
1114 AliDebugClass(2,"Checking consistency of symbolic names for EMCAL layers");
3dfc15c0 1115 TString str = "EMCAL/FullSupermodule";
1116 modnum=0;
1117
8cc543cb 1118 for (Int_t iModule=0; iModule < 22; iModule++) {
1119 if(!emcalSMs[iModule]) continue;
3dfc15c0 1120 symname = str;
8cc543cb 1121 symname += iModule+1;
1122 if(iModule/2 == 5) {// 10,11
3dfc15c0 1123 symname = "EMCAL/HalfSupermodule";
8cc543cb 1124 symname += iModule-9;
1125 }else if(iModule > 11) {// 12 ~ 21
1126 symname = "EMCAL/DCALSupermodule";
1127 symname += iModule-11;
3dfc15c0 1128 }
8cc543cb 1129 modnum = iModule;
0bf7aade 1130 uid = LayerToVolUID(kEMCAL,modnum);
1131 pne = fgGeometry->GetAlignableEntryByUID(uid);
1132 if(!pne)
1133 {
1134 AliErrorClass(Form("In the currently loaded geometry there is no TGeoPNEntry with unique id %d",uid));
1135 return kFALSE;
1136 }
1137 sname = pne->GetName();
1138 if(symname.CompareTo(sname))
1139 {
1140 AliErrorClass(Form("Current loaded geometry differs in the definition of symbolic name for uid %d"
1141 "Expected was %s, found was %s!", uid, symname.Data(), sname));
1142 return kFALSE;
1143 }
3dfc15c0 1144 }
ff5970a3 1145
1146 AliDebugClass(2,"Consistency check for EMCAL symbolic names finished successfully.");
3dfc15c0 1147 }
0bf7aade 1148
1149 return kTRUE;
f47b9233 1150
67dd5535 1151}
1152
1153//_____________________________________________________________________________
1154void AliGeomManager::InitPNEntriesLUT()
1155{
1156 // Initialize the look-up table which associates the unique
1157 // numerical identity of each alignable volume to the
1158 // corresponding TGeoPNEntry.
1159 // The LUTs are static; they are created at the creation of the
1160 // AliGeomManager instance and recreated if the geometry has changed
1161 //
36b010bf 1162 if(!fgGeometry) {
1163 AliErrorClass("Impossible to initialize PNEntries LUT without an active geometry");
1164 return;
1165 }
25fad4e5 1166
67dd5535 1167 for (Int_t iLayer = 0; iLayer < (kLastLayer - kFirstLayer); iLayer++){
3564f2da 1168 if (!fgPNEntry[iLayer]) fgPNEntry[iLayer] = new TGeoPNEntry*[fgLayerSize[iLayer]];
36b010bf 1169 for(Int_t modnum=0; modnum<fgLayerSize[iLayer]; modnum++){
0bf7aade 1170 fgPNEntry[iLayer][modnum] = fgGeometry->GetAlignableEntryByUID(LayerToVolUID(iLayer+1,modnum));
36b010bf 1171 }
1172 }
1173}
1174
67dd5535 1175//______________________________________________________________________
53dd673d 1176TGeoHMatrix* AliGeomManager::GetMatrix(TGeoPNEntry * const pne)
67dd5535 1177{
5aedd709 1178 // Get the global transformation matrix for a given PNEntry
67dd5535 1179 // by quering the TGeoManager
1180
36b010bf 1181 if (!fgGeometry || !fgGeometry->IsClosed()) {
25fad4e5 1182 AliErrorClass("Can't get the global matrix! gGeoManager doesn't exist or it is still opened!");
1183 return NULL;
1184 }
5aedd709 1185
67dd5535 1186 TGeoPhysicalNode *pnode = pne->GetPhysicalNode();
1187 if (pnode) return pnode->GetMatrix();
1188
1189 const char* path = pne->GetTitle();
36b010bf 1190 if (!fgGeometry->cd(path)) {
67dd5535 1191 AliErrorClass(Form("Volume path %s not valid!",path));
1192 return NULL;
1193 }
36b010bf 1194 return fgGeometry->GetCurrentMatrix();
67dd5535 1195}
1196
1197//______________________________________________________________________
1198TGeoHMatrix* AliGeomManager::GetMatrix(Int_t index)
1199{
1200 // Get the global transformation matrix for a given alignable volume
1201 // identified by its unique ID 'index' by quering the TGeoManager
1202
67dd5535 1203 TGeoPNEntry *pne = GetPNEntry(index);
1204 if (!pne) return NULL;
1205
1206 return GetMatrix(pne);
1207}
1208
1209//______________________________________________________________________
1210TGeoHMatrix* AliGeomManager::GetMatrix(const char* symname)
1211{
1212 // Get the global transformation matrix for a given alignable volume
1213 // identified by its symbolic name 'symname' by quering the TGeoManager
1214
36b010bf 1215 if (!fgGeometry || !fgGeometry->IsClosed()) {
1216 AliErrorClass("No active geometry or geometry not yet closed!");
1217 return NULL;
1218 }
1219
1220 TGeoPNEntry* pne = fgGeometry->GetAlignableEntry(symname);
67dd5535 1221 if (!pne) return NULL;
1222
1223 return GetMatrix(pne);
1224}
1225
1226//______________________________________________________________________
1227Bool_t AliGeomManager::GetTranslation(Int_t index, Double_t t[3])
1228{
1229 // Get the translation vector for a given module 'index'
1230 // by quering the TGeoManager
1231
1232 TGeoHMatrix *m = GetMatrix(index);
1233 if (!m) return kFALSE;
1234
1235 Double_t *trans = m->GetTranslation();
1236 for (Int_t i = 0; i < 3; i++) t[i] = trans[i];
1237
1238 return kTRUE;
1239}
1240
1241//______________________________________________________________________
1242Bool_t AliGeomManager::GetRotation(Int_t index, Double_t r[9])
1243{
1244 // Get the rotation matrix for a given module 'index'
1245 // by quering the TGeoManager
1246
1247 TGeoHMatrix *m = GetMatrix(index);
1248 if (!m) return kFALSE;
1249
1250 Double_t *rot = m->GetRotationMatrix();
1251 for (Int_t i = 0; i < 9; i++) r[i] = rot[i];
1252
1253 return kTRUE;
1254}
1255
5d534fe3 1256//_____________________________________________________________________________
1257Bool_t AliGeomManager::GetDeltaForBranch(Int_t index, TGeoHMatrix &inclusiveD)
1258{
1259 // The method sets the matrix passed as argument as the global delta
1260 // (for the volume referred by the unique index) including the displacements
1261 // of all parent volumes in the branch.
1262 //
5d534fe3 1263
1264 TGeoHMatrix go,invgo;
1265 go = *GetOrigGlobalMatrix(index);
1266 invgo = go.Inverse();
5aedd709 1267 inclusiveD = *GetMatrix(index);
5d534fe3 1268 inclusiveD.Multiply(&invgo);
1269
1270 return kTRUE;
1271}
1272
1273//_____________________________________________________________________________
1274Bool_t AliGeomManager::GetDeltaForBranch(AliAlignObj& aao, TGeoHMatrix &inclusiveD)
1275{
1276 // The method sets the matrix passed as argument as the global delta
1277 // (for the volume referred by the alignment object) including the displacements
1278 // of all parent volumes in the brach.
1279 //
1280 Int_t index = aao.GetVolUID();
1281 if(!index){
1282 AliErrorClass("Either the alignment object or its index are not valid");
1283 return kFALSE;
1284 }
1285 return GetDeltaForBranch(index, inclusiveD);
1286}
1287
36b010bf 1288//______________________________________________________________________
1289Bool_t AliGeomManager::GetOrigGlobalMatrix(const char* symname, TGeoHMatrix &m)
67dd5535 1290{
36b010bf 1291 // Get the global transformation matrix (ideal geometry) for a given alignable volume
0bf7aade 1292 // The alignable volume is identified by 'symname' which has to be either a valid symbolic
1293 // name, the query being performed after alignment, or a valid volume path if the query is
1294 // performed before alignment.
1295 //
36b010bf 1296 m.Clear();
67dd5535 1297
36b010bf 1298 if (!fgGeometry || !fgGeometry->IsClosed()) {
1299 AliErrorClass("No active geometry or geometry not yet closed!");
67dd5535 1300 return kFALSE;
1301 }
36b010bf 1302 if (!fgGeometry->GetListOfPhysicalNodes()) {
67dd5535 1303 AliWarningClass("gGeoManager doesn't contain any aligned nodes!");
36b010bf 1304 if (!fgGeometry->cd(symname)) {
67dd5535 1305 AliErrorClass(Form("Volume path %s not valid!",symname));
1306 return kFALSE;
1307 }
1308 else {
36b010bf 1309 m = *fgGeometry->GetCurrentMatrix();
67dd5535 1310 return kTRUE;
1311 }
1312 }
1313
36b010bf 1314 TGeoPNEntry* pne = fgGeometry->GetAlignableEntry(symname);
67dd5535 1315 const char* path = NULL;
67dd5535 1316 if(pne){
0bf7aade 1317 m = *pne->GetGlobalOrig();
1318 return kTRUE;
67dd5535 1319 }else{
1320 AliWarningClass(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as a volume path!",symname));
1321 path=symname;
1322 }
1323
36b010bf 1324 return GetOrigGlobalMatrixFromPath(path,m);
1325}
1326
1327//_____________________________________________________________________________
1328Bool_t AliGeomManager::GetOrigGlobalMatrixFromPath(const char *path, TGeoHMatrix &m)
1329{
5aedd709 1330 // The method returns the global matrix for the volume identified by
1331 // 'path' in the ideal detector geometry.
1332 // The output global matrix is stored in 'm'.
1333 // Returns kFALSE in case TGeo has not been initialized or the volume
1334 // path is not valid.
36b010bf 1335 //
1336 m.Clear();
1337
1338 if (!fgGeometry || !fgGeometry->IsClosed()) {
1339 AliErrorClass("Can't get the original global matrix! gGeoManager doesn't exist or it is still opened!");
67dd5535 1340 return kFALSE;
1341 }
1342
36b010bf 1343 if (!fgGeometry->CheckPath(path)) {
1344 AliErrorClass(Form("Volume path %s not valid!",path));
1345 return kFALSE;
1346 }
67dd5535 1347
36b010bf 1348 TIter next(fgGeometry->GetListOfPhysicalNodes());
1349 fgGeometry->cd(path);
67dd5535 1350
36b010bf 1351 while(fgGeometry->GetLevel()){
67dd5535 1352
1353 TGeoPhysicalNode *physNode = NULL;
1354 next.Reset();
36b010bf 1355 TGeoNode *node = fgGeometry->GetCurrentNode();
67dd5535 1356 while ((physNode=(TGeoPhysicalNode*)next()))
1357 if (physNode->GetNode() == node) break;
1358
1359 TGeoMatrix *lm = NULL;
1360 if (physNode) {
5aedd709 1361 lm = physNode->GetOriginalMatrix();
1362 if (!lm) lm = node->GetMatrix();
67dd5535 1363 } else
1364 lm = node->GetMatrix();
1365
1366 m.MultiplyLeft(lm);
1367
36b010bf 1368 fgGeometry->CdUp();
67dd5535 1369 }
1370
1371 return kTRUE;
1372}
1373
36b010bf 1374//_____________________________________________________________________________
53dd673d 1375TGeoHMatrix* AliGeomManager::GetOrigGlobalMatrix(TGeoPNEntry * const pne)
36b010bf 1376{
1377 // The method returns global matrix for the ideal detector geometry
1378 // using the corresponding TGeoPNEntry as an input.
5aedd709 1379 // The returned pointer should be copied by the user, since its content could
1380 // be overwritten by a following call to the method.
1381 // In case of missing TGeoManager the method returns NULL.
1382 //
36b010bf 1383 if (!fgGeometry || !fgGeometry->IsClosed()) {
1384 AliErrorClass("Can't get the global matrix! gGeoManager doesn't exist or it is still opened!");
1385 return NULL;
1386 }
1387
0bf7aade 1388 return pne->GetGlobalOrig();
36b010bf 1389}
1390
67dd5535 1391//______________________________________________________________________
36b010bf 1392TGeoHMatrix* AliGeomManager::GetOrigGlobalMatrix(Int_t index)
67dd5535 1393{
5aedd709 1394 // The method returns global matrix from the ideal detector geometry
1395 // for the volume identified by its index.
1396 // The returned pointer should be copied by the user, since its content could
1397 // be overwritten by a following call to the method.
1398 // In case of missing TGeoManager the method returns NULL.
1399 // If possible, the method uses the LUT of original ideal matrices
1400 // for fast access. The LUT is reset in case a
36b010bf 1401 // new geometry is loaded.
5aedd709 1402 //
0bf7aade 1403 TGeoPNEntry* pne = GetPNEntry(index);
1404 return pne->GetGlobalOrig();
67dd5535 1405}
1406
1407//______________________________________________________________________
1408Bool_t AliGeomManager::GetOrigTranslation(Int_t index, Double_t t[3])
1409{
1410 // Get the original translation vector (ideal geometry)
1411 // for a given module 'index' by quering the TGeoManager
1412
36b010bf 1413 TGeoHMatrix *m = GetOrigGlobalMatrix(index);
1414 if (!m) return kFALSE;
67dd5535 1415
36b010bf 1416 Double_t *trans = m->GetTranslation();
67dd5535 1417 for (Int_t i = 0; i < 3; i++) t[i] = trans[i];
1418
1419 return kTRUE;
1420}
1421
1422//______________________________________________________________________
1423Bool_t AliGeomManager::GetOrigRotation(Int_t index, Double_t r[9])
1424{
1425 // Get the original rotation matrix (ideal geometry)
1426 // for a given module 'index' by quering the TGeoManager
1427
36b010bf 1428 TGeoHMatrix *m = GetOrigGlobalMatrix(index);
1429 if (!m) return kFALSE;
67dd5535 1430
36b010bf 1431 Double_t *rot = m->GetRotationMatrix();
67dd5535 1432 for (Int_t i = 0; i < 9; i++) r[i] = rot[i];
1433
1434 return kTRUE;
1435}
1436
1437//______________________________________________________________________
1438const TGeoHMatrix* AliGeomManager::GetTracking2LocalMatrix(Int_t index)
1439{
25fad4e5 1440 // Get the matrix which transforms from the tracking to the local RS
67dd5535 1441 // The method queries directly the TGeoPNEntry
1442
67dd5535 1443 TGeoPNEntry *pne = GetPNEntry(index);
1444 if (!pne) return NULL;
1445
1446 const TGeoHMatrix *m = pne->GetMatrix();
1447 if (!m)
5aedd709 1448 AliErrorClass(Form("TGeoPNEntry (%s) contains no tracking-to-local matrix !",pne->GetName()));
67dd5535 1449
1450 return m;
1451}
1452
1453//______________________________________________________________________
1454Bool_t AliGeomManager::GetTrackingMatrix(Int_t index, TGeoHMatrix &m)
1455{
1456 // Get the matrix which transforms from the tracking r.s. to
1457 // the global one.
1458 // Returns kFALSE in case of error.
1459
1460 m.Clear();
1461
1462 TGeoHMatrix *m1 = GetMatrix(index);
1463 if (!m1) return kFALSE;
1464
1465 const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index);
1466 if (!m2) return kFALSE;
1467
1468 m = *m1;
1469 m.Multiply(m2);
1470
1471 return kTRUE;
1472}
1473
1474//_____________________________________________________________________________
1475TGeoPNEntry* AliGeomManager::GetPNEntry(Int_t voluid) {
1476 // Returns the TGeoPNEntry for the given global volume ID "voluid"
1477 //
1478 Int_t modId;
1479 ELayerID layerId = VolUIDToLayer(voluid,modId);
1480 return GetPNEntry(layerId,modId);
1481}
1482
1483//_____________________________________________________________________________
67dd5535 1484TGeoPNEntry* AliGeomManager::GetPNEntry(ELayerID layerId, Int_t modId)
1485{
1486 // Returns the TGeoPNEntry for a given layer
1487 // and module ID
1488 //
25fad4e5 1489
67dd5535 1490 if(modId<0 || modId>=fgLayerSize[layerId-kFirstLayer]){
1491 AliWarningClass(Form("Module number %d not in the valid range (0->%d) !",modId,fgLayerSize[layerId-kFirstLayer]-1));
1492 return NULL;
1493 }
1494
1495 return fgPNEntry[layerId-kFirstLayer][modId];
1496}
1497
1498//_____________________________________________________________________________
5590c6c3 1499void AliGeomManager::CheckOverlapsOverPNs(Double_t threshold)
1500{
1501 // Check for overlaps/extrusions on physical nodes only;
1502 // this overlap-checker is meant to be used to check overlaps/extrusions
1503 // originated by the application of alignment objects.
1504 //
1505
1c00c47a 1506 TObjArray* ovexlist = 0x0;
5590c6c3 1507
1508 AliInfoClass("********* Checking overlaps/extrusions over physical nodes only *********");
1509 TObjArray* pnList = gGeoManager->GetListOfPhysicalNodes();
0cd61c1d 1510 TGeoVolume* mvol = 0;
5590c6c3 1511 TGeoPhysicalNode* pn;
1512 TObjArray* overlaps = new TObjArray(64);
1513 overlaps->SetOwner();
1514
1515 TStopwatch timer2;
1516 timer2.Start();
1517 for(Int_t pni=0; pni<pnList->GetEntriesFast(); pni++){
1518 pn = (TGeoPhysicalNode*) pnList->UncheckedAt(pni);
1519 // checking the volume of the mother (go upper in the tree in case it is an assembly)
1520 Int_t levup=1;
1521 while(((TGeoVolume*)pn->GetVolume(pn->GetLevel()-levup))->IsAssembly()) levup++;
1522 //Printf("Going to upper level");
1523 mvol = pn->GetVolume(pn->GetLevel()-levup);
1524 if(!mvol->IsSelected()){
1525 AliInfoClass(Form("Checking overlaps for volume %s",mvol->GetName()));
1526 mvol->CheckOverlaps(threshold);
1527 ovexlist = gGeoManager->GetListOfOverlaps();
1528 TIter next(ovexlist);
1529 TGeoOverlap *ov;
1530 while ((ov=(TGeoOverlap*)next())) overlaps->Add(ov->Clone());
1531 mvol->SelectVolume();
1532 }
1533 }
1534 mvol->SelectVolume(kTRUE); // clears the list of selected volumes
1535
1536 AliInfoClass(Form("Number of overlapping/extruding PNs: %d",overlaps->GetEntriesFast()));
1537 timer2.Stop();
1538 timer2.Print();
1539
1540 TIter nextN(overlaps);
1541 TGeoOverlap *ovlp;
1542 while ((ovlp=(TGeoOverlap*)nextN())) ovlp->PrintInfo();
1543
1544 overlaps->Delete();
1545 delete overlaps;
1546}
1547
1548//_____________________________________________________________________________
4fbb8e9d 1549Int_t AliGeomManager::GetNalignable(const char* module)
8cb26cdf 1550{
a1ecbc97 1551 // Get number of declared alignable volumes in current geometry
1552 // for the given detector "module" passed as a vaild detector name
1553 // if the detector name is invalid return -1
8cb26cdf 1554
4fbb8e9d 1555 // return the detector index corresponding to detector
1556 Int_t index = -1 ;
1557 for (index = 0; index < fgkNDetectors ; index++) {
1558 if ( strcmp(module, fgkDetectorName[index]) == 0 )
1559 break ;
1560 }
a1ecbc97 1561 if(index==fgkNDetectors) return -1;
4fbb8e9d 1562 return fgNalignable[index];
8cb26cdf 1563}
4fbb8e9d 1564
1565//_____________________________________________________________________________
1566void AliGeomManager::InitNalignable()
1567{
1568 // Set number of declared alignable volumes for given detector in current geometry
1569 // by looping on the list of PNEntries
1570 //
1571
1572 Int_t nAlE = gGeoManager->GetNAlignable(); // total number of alignable entries
1573 TGeoPNEntry *pne = 0;
4fbb8e9d 1574 const char* detName;
1575
1576 for (Int_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1577 detName = fgkDetectorName[iDet];
1578 Int_t nAlDet = 0;
1579
1580 for(Int_t iE = 0; iE < nAlE; iE++)
1581 {
1582 pne = gGeoManager->GetAlignableEntry(iE);
3564f2da 1583 TString pneName = pne->GetName();
1584 if(pneName.Contains(detName)) nAlDet++;
1585 if(!strcmp(detName,"GRP")) if(pneName.Contains("ABSO") || pneName.Contains("DIPO") ||
1586 pneName.Contains("FRAME") || pneName.Contains("PIPE") ||
1587 pneName.Contains("SHIL")) nAlDet++;
4fbb8e9d 1588 }
1589 fgNalignable[iDet] = nAlDet;
1590 }
8cb26cdf 1591
4fbb8e9d 1592}
1593
8cb26cdf 1594//_____________________________________________________________________________
917768e3 1595Bool_t AliGeomManager::ApplyAlignObjsFromCDB(const char* alignDetsList)
67dd5535 1596{
1597 // Calls AddAlignObjsFromCDBSingleDet for the detectors appearing in
1598 // the list passed as argument (called by AliSimulation and
1599 // AliReconstruction)
1600 // Read the alignment objects from CDB.
1601 // Each detector is supposed to have the
1602 // alignment objects in DET/Align/Data CDB path.
1603 // All the detector objects are then collected,
1604 // sorted by geometry level (starting from ALIC) and
1605 // then applied to the TGeo geometry.
1606 // Finally an overlaps check is performed.
1607 //
1608
36b010bf 1609 TObjArray alignObjArray;
1610 alignObjArray.Clear();
1611 alignObjArray.SetOwner(0);
67dd5535 1612
1613 TString alObjsNotLoaded="";
1614 TString alObjsLoaded="";
1615
917768e3 1616 TString alignDetsString(alignDetsList);
1617 TObjArray *detsarr = alignDetsString.Tokenize(' ');
67dd5535 1618 TIter iter(detsarr);
1619 TObjString *str = 0;
1620
1621 while((str = (TObjString*) iter.Next())){
1622 TString det(str->String());
2912a163 1623 AliDebugClass(5,Form("Loading alignment objs for %s",det.Data()));
36b010bf 1624 if(!LoadAlignObjsFromCDBSingleDet(det.Data(),alignObjArray)){
67dd5535 1625 alObjsNotLoaded += det.Data();
1626 alObjsNotLoaded += " ";
1627 } else {
1628 alObjsLoaded += det.Data();
1629 alObjsLoaded += " ";
1630 }
1631 }
b80b98e1 1632 detsarr->Delete();
1633 delete detsarr;
67dd5535 1634
36b010bf 1635 if(!alObjsLoaded.IsNull()) AliInfoClass(Form("Alignment objects loaded for: %s",
1636 alObjsLoaded.Data()));
451cbb1d 1637 if(!alObjsNotLoaded.IsNull())
1638 AliFatalClass(Form("Could not load alignment objects from OCDB for: %s",
36b010bf 1639 alObjsNotLoaded.Data()));
67dd5535 1640
9cb4fe0b 1641 return ApplyAlignObjsToGeom(alignObjArray);
67dd5535 1642}
1643
1644//_____________________________________________________________________________
36b010bf 1645Bool_t AliGeomManager::LoadAlignObjsFromCDBSingleDet(const char* detName, TObjArray& alignObjArray)
67dd5535 1646{
1647 // Adds the alignable objects found in the CDBEntry for the detector
1648 // passed as argument to the array of all alignment objects to be applyed
1649 // to geometry
1650 //
1651 // Fills array of single detector's alignable objects from CDB
1652
36b010bf 1653 AliDebugClass(2, Form("Loading alignment objs for detector: %s",detName));
67dd5535 1654
1655 AliCDBEntry *entry;
1656
1657 AliCDBPath path(detName,"Align","Data");
1658
1659 entry=AliCDBManager::Instance()->Get(path.GetPath());
1660 if(!entry){
36b010bf 1661 AliDebugClass(2,Form("Couldn't load alignment data for detector %s",detName));
67dd5535 1662 return kFALSE;
1663 }
1664 entry->SetOwner(1);
1665 TClonesArray *alignArray = (TClonesArray*) entry->GetObject();
1666 alignArray->SetOwner(0);
4fbb8e9d 1667 Int_t nAlObjs = alignArray->GetEntries();
1668 AliDebugClass(2,Form("Found %d alignment objects for %s",nAlObjs,detName));
1669 Int_t nAlVols = GetNalignable(detName);
1670 if(nAlObjs!=nAlVols) AliWarningClass(Form("%d alignment objects loaded for %s, which has %d alignable volumes",nAlObjs,detName,GetNalignable(detName)));
67dd5535 1671
1672 AliAlignObj *alignObj=0;
1673 TIter iter(alignArray);
1674
1675 // loop over align objects in detector
1676 while( ( alignObj=(AliAlignObj *) iter.Next() ) ){
36b010bf 1677 alignObjArray.Add(alignObj);
67dd5535 1678 }
1679 // delete entry --- Don't delete, it is cached!
1680
36b010bf 1681 AliDebugClass(2, Form("fAlignObjArray entries: %d",alignObjArray.GetEntries() ));
67dd5535 1682 return kTRUE;
1683
1684}
1685
1686//_____________________________________________________________________________
5590c6c3 1687Bool_t AliGeomManager::ApplyAlignObjsToGeom(TObjArray& alignObjArray, Bool_t ovlpcheck)
67dd5535 1688{
c8687cb5 1689 // Read collection of alignment objects (AliAlignObj derived) saved
1690 // in the TClonesArray alObjArray and apply them to gGeoManager
1691 //
1692 alignObjArray.Sort();
1693 Int_t nvols = alignObjArray.GetEntriesFast();
67dd5535 1694
c8687cb5 1695 Bool_t flag = kTRUE;
67dd5535 1696
c8687cb5 1697 for(Int_t j=0; j<nvols; j++)
67dd5535 1698 {
c8687cb5 1699 AliAlignObj* alobj = (AliAlignObj*) alignObjArray.UncheckedAt(j);
1700 if(!alobj->ApplyToGeometry(ovlpcheck))
1701 {
1702 flag = kFALSE;
1703 AliDebugClass(5,Form("Error applying alignment object for volume %s !",alobj->GetSymName()));
1704 }else{
1705 AliDebugClass(5,Form("Alignment object for volume %s applied successfully",alobj->GetSymName()));
1706 }
67dd5535 1707
c8687cb5 1708 }
bb1970d8 1709
c8687cb5 1710 if (AliDebugLevelClass() > 5) {
1711 fgGeometry->CheckOverlaps(0.001);
1712 TObjArray* ovexlist = fgGeometry->GetListOfOverlaps();
1713 if(ovexlist->GetEntriesFast()){
1714 AliErrorClass("The application of alignment objects to the geometry caused huge overlaps/extrusions!");
1715 fgGeometry->PrintOverlaps();
1716 }
1717 }
67dd5535 1718
c8687cb5 1719 // Update the TGeoPhysicalNodes
1720 fgGeometry->RefreshPhysicalNodes();
36b010bf 1721
c8687cb5 1722 return flag;
67dd5535 1723
1724}
1725
1726//_____________________________________________________________________________
1727Bool_t AliGeomManager::ApplyAlignObjsToGeom(const char* fileName, const char* clArrayName)
1728{
1729 // read collection of alignment objects (AliAlignObj derived) saved
1730 // in the TClonesArray ClArrayName in the file fileName and apply
1731 // them to the geometry
1732 //
1733
1734 TFile* inFile = TFile::Open(fileName,"READ");
1735 if (!inFile || !inFile->IsOpen()) {
1736 AliErrorClass(Form("Could not open file %s !",fileName));
1737 return kFALSE;
1738 }
1739
36b010bf 1740 TClonesArray* alignObjArray = ((TClonesArray*) inFile->Get(clArrayName));
67dd5535 1741 inFile->Close();
36b010bf 1742 if (!alignObjArray) {
67dd5535 1743 AliErrorClass(Form("Could not get array (%s) from file (%s) !",clArrayName,fileName));
1744 return kFALSE;
1745 }
1746
36b010bf 1747 return ApplyAlignObjsToGeom(*alignObjArray);
67dd5535 1748
1749}
1750
1751//_____________________________________________________________________________
67dd5535 1752Bool_t AliGeomManager::ApplyAlignObjsToGeom(const char* uri, const char* path, Int_t runnum, Int_t version, Int_t sversion)
1753{
1754 // read collection of alignment objects (AliAlignObj derived) saved
1755 // in the TClonesArray ClArrayName in the AliCDBEntry identified by
1756 // param (to get the AliCDBStorage) and Id; apply the alignment objects
1757 // to the geometry
1758 //
1759
5078a13f 1760 AliCDBStorage* storage = AliCDBManager::Instance()->GetStorage(uri);
67dd5535 1761 AliCDBId id(path, runnum, runnum, version, sversion);
5078a13f 1762 AliCDBEntry* entry = storage->Get(id);
1763 TClonesArray* alignObjArray = dynamic_cast<TClonesArray*>(entry->GetObject());
67dd5535 1764
5078a13f 1765 return ApplyAlignObjsToGeom(*alignObjArray);
67dd5535 1766
1767}
1768
1769//_____________________________________________________________________________
1770Bool_t AliGeomManager::ApplyAlignObjsToGeom(const char* detName, Int_t runnum, Int_t version, Int_t sversion)
1771{
1772 // read collection of alignment objects (AliAlignObj derived) saved
1773 // in the TClonesArray ClArrayName in the AliCDBEntry identified by
1774 // param (to get the AliCDBStorage) and Id; apply the alignment objects
1775 // to the geometry
1776 //
1777
1778 AliCDBPath path(detName,"Align","Data");
1779 AliCDBEntry* entry = AliCDBManager::Instance()->Get(path.GetPath(),runnum,version,sversion);
1780
1781 if(!entry) return kFALSE;
36b010bf 1782 TClonesArray* alignObjArray = ((TClonesArray*) entry->GetObject());
25fad4e5 1783
36b010bf 1784 return ApplyAlignObjsToGeom(*alignObjArray);
67dd5535 1785}
171c4ef9 1786
3564f2da 1787//_____________________________________________________________________________
1788void AliGeomManager::ResetPNEntriesLUT()
1789{
1790 // cleans static arrays containing the information on currently loaded geometry
1791 //
1792 for (Int_t iLayer = 0; iLayer < (kLastLayer - kFirstLayer); iLayer++){
1793 if (!fgPNEntry[iLayer]) continue;
1794 for (Int_t modnum=0; modnum<fgLayerSize[iLayer]; modnum++) fgPNEntry[iLayer][modnum] = 0;
1795 }
1796 //
1797}
1798