16#include "TClonesArray.h"
18#include <fairlogger/Logger.h>
24#include "MFTBase/GeometryTGeo.h"
42 mHalfDisks =
new TClonesArray(*(
source.mHalfDisks));
58 SetUniqueID(halfUniqueID);
62 mHalfDisks->SetOwner(kTRUE);
65 auto* geomFile =
new TXMLEngine;
68 XMLDocPointer_t xmldoc = geomFile->ParseFile(nameGeomFile);
69 if (xmldoc ==
nullptr) {
71 LOG(fatal) <<
"Could not parse Geometry XML File named " << nameGeomFile;
73 XMLNodePointer_t mainnode = geomFile->DocGetRootElement(xmldoc);
76 XMLNodePointer_t halfnode;
77 findHalf(geomFile, mainnode, halfnode);
80 createHalfDisks(geomFile, halfnode);
83 geomFile->FreeDoc(xmldoc);
104 mHalfDisks->Delete();
107 mHalfDisks =
nullptr;
113void HalfSegmentation::createHalfDisks(TXMLEngine* xml, XMLNodePointer_t node)
118 Double_t
pos[3] = {0., 0., 0.};
119 Double_t ang[3] = {0., 0., 0.};
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();
132 LOG(fatal) <<
"Wrong disk number : " << idisk;
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();
149 LOG(error) <<
"Unknwon Attribute name " << xml->GetAttrName(attr);
151 attr = xml->GetNextAttr(attr);
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";
170 XMLNodePointer_t child = xml->GetChild(node);
171 while (child !=
nullptr) {
172 createHalfDisks(xml, child);
173 child = xml->GetNext(child);
180void HalfSegmentation::findHalf(TXMLEngine* xml, XMLNodePointer_t node, XMLNodePointer_t& retnode)
186 Double_t
pos[3] = {0., 0., 0.};
187 Double_t ang[3] = {0., 0., 0.};
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;
200 }
else if (!attrName.CompareTo(
"ndisk")) {
201 ndisk = attrVal.Atoi();
202 if (ndisk > 5 || ndisk < 0) {
203 LOG(error) <<
"Wrong number of disk : " << ndisk;
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();
219 LOG(error) <<
"Unknwon Attribute name " << xml->GetAttrName(attr);
222 attr = xml->GetNextAttr(attr);
226 if (isTop == mftGeom->
getHalfID(GetUniqueID())) {
235 XMLNodePointer_t child = xml->GetChild(node);
236 while (child !=
nullptr) {
237 findHalf(xml, child, retnode);
238 child = xml->GetNext(child);
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.
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.
Int_t getHalfID(UInt_t uniqueID) const
Returns Half-MFT ID based on Unique ID provided.
static Geometry * instance()
Singleton access.
~HalfSegmentation() override
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
constexpr Int_t DisksNumber
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"