Project
Loading...
Searching...
No Matches
HalfSegmentation.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#include "TClonesArray.h"
17
18#include <fairlogger/Logger.h>
19
20#include "MFTBase/Constants.h"
23#include "MFTBase/Geometry.h"
24#include "MFTBase/GeometryTGeo.h"
25
26using namespace o2::mft;
27
29
31
32//_____________________________________________________________________________
34
36
37//_____________________________________________________________________________
39{
40
41 if (source.mHalfDisks) {
42 mHalfDisks = new TClonesArray(*(source.mHalfDisks));
43 }
44}
45
50
51//_____________________________________________________________________________
52HalfSegmentation::HalfSegmentation(const Char_t* nameGeomFile, const Short_t id) : VSegmentation(), mHalfDisks(nullptr)
53{
54
55 Geometry* mftGeom = Geometry::instance();
56
57 UInt_t halfUniqueID = mftGeom->getObjectID(Geometry::HalfType, id);
58 SetUniqueID(halfUniqueID);
59 SetName(Form("%s_%d", GeometryTGeo::getMFTHalfPattern(), id));
60
61 mHalfDisks = new TClonesArray("o2::mft::HalfDiskSegmentation", constants::DisksNumber);
62 mHalfDisks->SetOwner(kTRUE);
63
64 // Create XML engine
65 auto* geomFile = new TXMLEngine;
66
67 // take access to main node
68 XMLDocPointer_t xmldoc = geomFile->ParseFile(nameGeomFile);
69 if (xmldoc == nullptr) {
70 delete geomFile;
71 LOG(fatal) << "Could not parse Geometry XML File named " << nameGeomFile;
72 }
73 XMLNodePointer_t mainnode = geomFile->DocGetRootElement(xmldoc);
74
75 // Find Half-MFT node in the XML file
76 XMLNodePointer_t halfnode;
77 findHalf(geomFile, mainnode, halfnode);
78
79 // Create Half Disks belonging to that Half-MFT
80 createHalfDisks(geomFile, halfnode);
81
82 // Release memory
83 geomFile->FreeDoc(xmldoc);
84 delete geomFile;
85}
86
87//_____________________________________________________________________________
89{
90
91 if (mHalfDisks) {
92 mHalfDisks->Delete();
93 }
94 delete mHalfDisks;
95}
96
98
99//_____________________________________________________________________________
100void HalfSegmentation::Clear(const Option_t* /*opt*/)
101{
102
103 if (mHalfDisks) {
104 mHalfDisks->Delete();
105 }
106 delete mHalfDisks;
107 mHalfDisks = nullptr;
108}
109
111
112//_____________________________________________________________________________
113void HalfSegmentation::createHalfDisks(TXMLEngine* xml, XMLNodePointer_t node)
114{
115 // this function display all accessible information about xml node and its children
116 Int_t idisk;
117 Int_t nladder;
118 Double_t pos[3] = {0., 0., 0.};
119 Double_t ang[3] = {0., 0., 0.};
120
121 Geometry* mftGeom = Geometry::instance();
122
123 TString nodeName = xml->GetNodeName(node);
124 if (!nodeName.CompareTo("disk")) {
125 XMLAttrPointer_t attr = xml->GetFirstAttr(node);
126 while (attr != nullptr) {
127 TString attrName = xml->GetAttrName(attr);
128 TString attrVal = xml->GetAttrValue(attr);
129 if (!attrName.CompareTo("idisk")) {
130 idisk = attrVal.Atoi();
131 if (idisk >= constants::DisksNumber || idisk < 0) {
132 LOG(fatal) << "Wrong disk number : " << idisk;
133 }
134 } else if (!attrName.CompareTo("nladder")) {
135 nladder = attrVal.Atoi();
136 } else if (!attrName.CompareTo("xpos")) {
137 pos[0] = attrVal.Atof();
138 } else if (!attrName.CompareTo("ypos")) {
139 pos[1] = attrVal.Atof();
140 } else if (!attrName.CompareTo("zpos")) {
141 pos[2] = attrVal.Atof();
142 } else if (!attrName.CompareTo("phi")) {
143 ang[0] = attrVal.Atof();
144 } else if (!attrName.CompareTo("theta")) {
145 ang[1] = attrVal.Atof();
146 } else if (!attrName.CompareTo("psi")) {
147 ang[2] = attrVal.Atof();
148 } else {
149 LOG(error) << "Unknwon Attribute name " << xml->GetAttrName(attr);
150 }
151 attr = xml->GetNextAttr(attr);
152 }
153
154 UInt_t diskUniqueID = mftGeom->getObjectID(Geometry::HalfDiskType, mftGeom->getHalfID(GetUniqueID()), idisk);
155
156 auto* halfDisk = new HalfDiskSegmentation(diskUniqueID);
157 halfDisk->setPosition(pos);
158 halfDisk->setRotationAngles(ang);
159 halfDisk->setNLadders(nladder);
160 halfDisk->createLadders(xml, node);
161 if (halfDisk->getNLaddersBuild() != halfDisk->getNLadders()) {
162 LOG(fatal) << "Number of ladder build " << halfDisk->getNLaddersBuild()
163 << " does not correspond to the number declared " << halfDisk->getNLadders() << " Check XML file";
164 }
165 new ((*mHalfDisks)[idisk]) HalfDiskSegmentation(*halfDisk);
166 delete halfDisk;
167 }
168
169 // display all child nodes
170 XMLNodePointer_t child = xml->GetChild(node);
171 while (child != nullptr) {
172 createHalfDisks(xml, child);
173 child = xml->GetNext(child);
174 }
175}
176
178
179//_____________________________________________________________________________
180void HalfSegmentation::findHalf(TXMLEngine* xml, XMLNodePointer_t node, XMLNodePointer_t& retnode)
181{
182 // Find in the XML Geometry File the node corresponding to the Half-MFT being build
183 // Set Position and Orientation of the Half-MFT
184 Int_t isTop;
185 Int_t ndisk;
186 Double_t pos[3] = {0., 0., 0.};
187 Double_t ang[3] = {0., 0., 0.};
188
189 TString nodeName = xml->GetNodeName(node);
190 if (!nodeName.CompareTo("half")) {
191 XMLAttrPointer_t attr = xml->GetFirstAttr(node);
192 while (attr != nullptr) {
193 TString attrName = xml->GetAttrName(attr);
194 TString attrVal = xml->GetAttrValue(attr);
195 if (!attrName.CompareTo("top")) {
196 isTop = attrVal.Atoi();
197 if (isTop > 1 || isTop < 0) {
198 LOG(fatal) << "Wrong Half MFT number : " << isTop;
199 }
200 } else if (!attrName.CompareTo("ndisk")) {
201 ndisk = attrVal.Atoi();
202 if (ndisk > 5 || ndisk < 0) {
203 LOG(error) << "Wrong number of disk : " << ndisk;
204 }
205
206 } else if (!attrName.CompareTo("xpos")) {
207 pos[0] = attrVal.Atof();
208 } else if (!attrName.CompareTo("ypos")) {
209 pos[1] = attrVal.Atof();
210 } else if (!attrName.CompareTo("zpos")) {
211 pos[2] = attrVal.Atof();
212 } else if (!attrName.CompareTo("phi")) {
213 ang[0] = attrVal.Atof();
214 } else if (!attrName.CompareTo("theta")) {
215 ang[1] = attrVal.Atof();
216 } else if (!attrName.CompareTo("psi")) {
217 ang[2] = attrVal.Atof();
218 } else {
219 LOG(error) << "Unknwon Attribute name " << xml->GetAttrName(attr);
220 }
221
222 attr = xml->GetNextAttr(attr);
223 }
224
225 Geometry* mftGeom = Geometry::instance();
226 if (isTop == mftGeom->getHalfID(GetUniqueID())) {
229 retnode = node;
230 return;
231 }
232 }
233
234 // display all child nodes
235 XMLNodePointer_t child = xml->GetChild(node);
236 while (child != nullptr) {
237 findHalf(xml, child, retnode);
238 child = xml->GetNext(child);
239 }
240}
Constants for the MFT; distance unit is cm.
Class for the description of the structure of a half-disk.
ClassImp(HalfSegmentation)
Segmentation class for each half of the ALICE Muon Forward Tracker.
Class handling both virtual segmentation and real volumes.
uint16_t pos
Definition RawData.h:3
static const Char_t * getMFTHalfPattern()
UInt_t getObjectID(ObjectTypes type, Int_t half=-1, Int_t disk=-1, Int_t plane=-1, Int_t ladder=-1, Int_t chip=-1) const
Returns the object Unique ID.
Definition Geometry.cxx:150
Int_t getHalfID(UInt_t uniqueID) const
Returns Half-MFT ID based on Unique ID provided.
Definition Geometry.h:103
static Geometry * instance()
Singleton access.
Definition Geometry.cxx:98
void Clear(const Option_t *) override
Clear the TClonesArray holding the HalfDiskSegmentation objects.
HalfSegmentation()
Default constructor.
void setRotationAngles(const Double_t *ang)
Set The rotation angles. Unit is [deg].
void setPosition(const Double_t *pos)
Set Position of the Element. Unit is [cm].
GLsizei GLsizei GLchar * source
Definition glcorearb.h:798
constexpr Int_t DisksNumber
Definition Constants.h:27
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"