Project
Loading...
Searching...
No Matches
HalfDiskSegmentation.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
22#include "MFTBase/Geometry.h"
23#include "MFTBase/GeometryTGeo.h"
24
25using namespace o2::mft;
26using namespace o2::itsmft;
27
29
31
32//_____________________________________________________________________________
33HalfDiskSegmentation::HalfDiskSegmentation() : VSegmentation(), mNLadders(0), mLadders(nullptr) {}
34
37
38//_____________________________________________________________________________
39HalfDiskSegmentation::HalfDiskSegmentation(UInt_t uniqueID) : VSegmentation(), mNLadders(0), mLadders(nullptr)
40{
41
42 // constructor
43 SetUniqueID(uniqueID);
44
45 LOG(debug1) << "Start creating half-disk UniqueID = " << GetUniqueID();
46
47 Geometry* mftGeom = Geometry::instance();
48
49 SetName(Form("%s_%d_%d", GeometryTGeo::getMFTDiskPattern(), mftGeom->getHalfID(GetUniqueID()),
50 mftGeom->getDiskID(GetUniqueID())));
51
52 mLadders = new TClonesArray("o2::mft::LadderSegmentation");
53 mLadders->SetOwner(kTRUE);
54}
55
57
58//_____________________________________________________________________________
60 : VSegmentation(input), mNLadders(input.mNLadders)
61{
62
63 // copy constructor
64 if (input.mLadders) {
65 mLadders = new TClonesArray(*(input.mLadders));
66 } else {
67 mLadders = new TClonesArray("o2::mft::LadderSegmentation");
68 }
69 mLadders->SetOwner(kTRUE);
70}
71
72//_____________________________________________________________________________
74
76
77//_____________________________________________________________________________
78void HalfDiskSegmentation::Clear(const Option_t* /*opt*/)
79{
80
81 if (mLadders) {
82 mLadders->Delete();
83 }
84 delete mLadders;
85 mLadders = nullptr;
86}
87
89
90//_____________________________________________________________________________
91void HalfDiskSegmentation::createLadders(TXMLEngine* xml, XMLNodePointer_t node)
92{
93 Int_t iladder;
94 Int_t nsensor;
95 Double_t pos[3];
96 Double_t ang[3] = {0., 0., 0.};
97
98 Geometry* mftGeom = Geometry::instance();
99
100 TString nodeName = xml->GetNodeName(node);
101 if (!nodeName.CompareTo("ladder")) {
102 XMLAttrPointer_t attr = xml->GetFirstAttr(node);
103 while (attr != nullptr) {
104 TString attrName = xml->GetAttrName(attr);
105 TString attrVal = xml->GetAttrValue(attr);
106 if (!attrName.CompareTo("iladder")) {
107 iladder = attrVal.Atoi();
108 if (iladder >= getNLadders() || iladder < 0) {
109 LOG(fatal) << "Wrong ladder number : " << iladder;
110 }
111 } else if (!attrName.CompareTo("nsensor")) {
112 nsensor = attrVal.Atoi();
113 } else if (!attrName.CompareTo("xpos")) {
114 pos[0] = attrVal.Atof();
115 } else if (!attrName.CompareTo("ypos")) {
116 pos[1] = attrVal.Atof();
117 } else if (!attrName.CompareTo("zpos")) {
118 pos[2] = attrVal.Atof();
119 } else if (!attrName.CompareTo("phi")) {
120 ang[0] = attrVal.Atof();
121 } else if (!attrName.CompareTo("theta")) {
122 ang[1] = attrVal.Atof();
123 } else if (!attrName.CompareTo("psi")) {
124 ang[2] = attrVal.Atof();
125 } else {
126 LOG(error) << "Unknwon Attribute name " << xml->GetAttrName(attr);
127 }
128 attr = xml->GetNextAttr(attr);
129 }
130
131 Int_t plane = -1;
132 Int_t ladderID = iladder;
133 if (iladder < getNLadders() / 2) {
134 plane = 0;
135 } else {
136 plane = 1;
137 // ladderID -= getNLadders()/2;
138 }
139
140 UInt_t ladderUniqueID = mftGeom->getObjectID(Geometry::LadderType, mftGeom->getHalfID(GetUniqueID()),
141 mftGeom->getDiskID(GetUniqueID()), plane, ladderID);
142
143 auto* ladder = new LadderSegmentation(ladderUniqueID);
144 ladder->setNSensors(nsensor);
145 ladder->setPosition(pos);
146 ladder->setRotationAngles(ang);
147
148 ladder->createSensors(xml, node);
149
150 new ((*mLadders)[iladder]) LadderSegmentation(*ladder);
151 delete ladder;
152
153 // getLadder(iladder)->Print();
154 }
155
156 // display all child nodes
157 XMLNodePointer_t child = xml->GetChild(node);
158 while (child != nullptr) {
159 createLadders(xml, child);
160 child = xml->GetNext(child);
161 }
162}
163
165
166//_____________________________________________________________________________
168{
169
170 Int_t nChips = 0;
171
172 for (Int_t iLadder = 0; iLadder < mLadders->GetEntries(); iLadder++) {
173
174 LadderSegmentation* ladder = (LadderSegmentation*)mLadders->At(iLadder);
175 nChips += ladder->getNSensors();
176 }
177
178 return nChips;
179}
180
183
184//_____________________________________________________________________________
186{
187
188 getTransformation()->Print();
189 if (opt && (strstr(opt, "ladder") || strstr(opt, "l"))) {
190 for (int i = 0; i < getNLadders(); i++) {
191 getLadder(i)->Print(opt);
192 }
193 }
194}
int32_t i
ClassImp(HalfDiskSegmentation)
Class for the description of the structure of a half-disk.
Class handling both virtual segmentation and real volumes.
uint16_t pos
Definition RawData.h:3
Definition of the SegmentationAlpide class.
static const Char_t * getMFTDiskPattern()
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 getDiskID(UInt_t uniqueID) const
Returns Half-Disk ID based on Unique ID provided.
Definition Geometry.h:106
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 createLadders(TXMLEngine *xml, XMLNodePointer_t node)
Creates the Ladders on this half-Disk based on the information contained in the XML file.
Int_t getNLadders() const
Get the number of Ladder on the Half-Disk.
LadderSegmentation * getLadder(Int_t iLadder)
Returns pointer to the ladder segmentation object.
void Clear(const Option_t *) override
Clear the TClonesArray holding the ladder segmentations.
HalfDiskSegmentation()
Default constructor.
Int_t getNChips()
Returns the number of sensors on the Half-Disk.
Int_t getNSensors() const
Returns number of Sensor on the ladder.
TGeoCombiTrans * getTransformation() const
Returns the Transformation Combining a Rotation followed by a Translation.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"