KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVLayer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 $Id: KVLayer.cpp,v 1.17 2006/10/19 14:32:43 franklan Exp $
3  kvlayer.cpp - description
4  -------------------
5  begin : Thu May 16 2002
6  copyright : (C) 2002 by J.D. Frankland
7  email : frankland@ganil.fr
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 #include "Riostream.h"
19 #include "KVLayer.h"
20 #include "KVRing.h"
21 #include "TGeoManager.h"
22 #include "TGeoMatrix.h"
23 
24 using namespace std;
25 
27 
28 
29 
33 {
34  //default ctor
35  SetType("LAYER");
36 }
37 
38 
39 
40 
42 
43 KVLayer::~KVLayer()
44 {
45 }
46 
47 
48 
49 
52 
53 Int_t KVLayer::Compare(const TObject* obj) const
54 {
55  //For sorting lists of layer according to layer number.
56  if (GetNumber() < ((KVLayer*) obj)->GetNumber())
57  return -1;
58  else if (GetNumber() > ((KVLayer*) obj)->GetNumber())
59  return 1;
60  else
61  return 0;
62 }
63 
64 
65 
69 
70 const Char_t* KVLayer::GetName() const
71 {
72  //If name of layer has not been explicitly set with SetName(Char_t*),
73  //return name as Layer 1, Layer 2 etc.
74 
75  static TString fDyName;
76  if (!strcmp(fName.Data(), "")) {
77  fDyName.Form("Layer %d", GetNumber());
78  return fDyName;
79  }
80  else
81  return fName.Data();
82 }
83 
84 
85 
86 
87 
90 
92 {
93  // Create and return TGeoVolume representing detectors in this layer
94 
95  TGeoVolume* mother_vol = gGeoManager->MakeVolumeAssembly(GetName());
96  //**** BUILD & ADD Rings ****
97  TIter next(GetStructures());
98  KVRing* det;
99  while ((det = (KVRing*)next())) {
100  TGeoVolume* det_vol = det->GetGeoVolume();
101  // position ring in layer
102  TGeoTranslation* tr = new TGeoTranslation(0, 0, det->GetDistance()); //distance set in KVRing::GetGeoVolume()
103  mother_vol->AddNode(det_vol, 1, tr);
104  }
105  return mother_vol;
106 }
107 
108 
109 
112 
114 {
115  // Construct and position a TGeoVolume shape to represent this layer in the current geometry
116  if (!gGeoManager) return;
117 
118  // get volume for layer
119  TGeoVolume* vol = GetGeoVolume();
120 
121  // add to geometry
122  TGeoTranslation* tr = new TGeoTranslation(0, 0, 0);
123 
124  // add ring volume to geometry
125  gGeoManager->GetTopVolume()->AddNode(vol, 1, tr);
126 }
127 
128 
129 
130 
int Int_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
char Char_t
R__EXTERN TGeoManager * gGeoManager
Set of detectors at a similar distance from target (obsolete)
Definition: KVLayer.h:32
virtual TGeoVolume * GetGeoVolume()
Create and return TGeoVolume representing detectors in this layer.
Definition: KVLayer.cpp:91
const Char_t * GetName() const
Definition: KVLayer.cpp:70
virtual void AddToGeometry()
Construct and position a TGeoVolume shape to represent this layer in the current geometry.
Definition: KVLayer.cpp:113
Int_t Compare(const TObject *obj) const
For sorting lists of layer according to layer number.
Definition: KVLayer.cpp:53
virtual Double_t GetDistance(void) const
Definition: KVPosition.h:189
Ring in INDRA array (obsolete)
Definition: KVRing.h:19
virtual TGeoVolume * GetGeoVolume()
Create and return TGeoVolume representing detectors in this ring.
Definition: KVRing.cpp:139
TGeoVolumeAssembly * MakeVolumeAssembly(const char *name)
TGeoVolume * GetTopVolume() const
virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
const char * Data() const
void Form(const char *fmt,...)