Project
Loading...
Searching...
No Matches
LadderSegmentation.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 <fairlogger/Logger.h>
17
20#include "MFTBase/Geometry.h"
21#include "MFTBase/GeometryTGeo.h"
22
23using namespace o2::mft;
24
26
28
29//_____________________________________________________________________________
31
34
35//_____________________________________________________________________________
36LadderSegmentation::LadderSegmentation(UInt_t uniqueID) : VSegmentation(), mChips(nullptr)
37{
38
39 SetUniqueID(uniqueID);
40
41 Geometry* mftGeom = Geometry::instance();
42
43 SetName(Form("%s_%d_%d_%d", GeometryTGeo::getMFTLadderPattern(), mftGeom->getHalfID(GetUniqueID()),
44 mftGeom->getDiskID(GetUniqueID()), mftGeom->getLadderID(GetUniqueID())));
45
46 // constructor
47}
48
50
51//_____________________________________________________________________________
53 : VSegmentation(ladder), mNSensors(ladder.mNSensors)
54{
55 // copy constructor
56
57 if (ladder.mChips) {
58 mChips = new TClonesArray(*(ladder.mChips));
59 } else {
60 mChips = new TClonesArray("o2::mft::ChipSegmentation", mNSensors);
61 }
62
63 mChips->SetOwner(kTRUE);
64}
65
67
68//_____________________________________________________________________________
69void LadderSegmentation::createSensors(TXMLEngine* xml, XMLNodePointer_t node)
70{
71
72 if (!mChips) {
73 mChips = new TClonesArray("o2::mft::ChipSegmentation", mNSensors);
74 mChips->SetOwner(kTRUE);
75 }
76
77 Int_t ichip;
78 Double_t pos[3];
79 Double_t ang[3] = {0., 0., 0.};
80
81 Geometry* mftGeom = Geometry::instance();
82
83 TString nodeName = xml->GetNodeName(node);
84 if (!nodeName.CompareTo("chip")) {
85 XMLAttrPointer_t attr = xml->GetFirstAttr(node);
86 while (attr != nullptr) {
87 TString attrName = xml->GetAttrName(attr);
88 TString attrVal = xml->GetAttrValue(attr);
89 if (!attrName.CompareTo("ichip")) {
90 ichip = attrVal.Atoi();
91 if (ichip >= getNSensors() || ichip < 0) {
92 LOG(fatal) << "Wrong chip number : " << ichip;
93 }
94 } else if (!attrName.CompareTo("xpos")) {
95 pos[0] = attrVal.Atof();
96 } else if (!attrName.CompareTo("ypos")) {
97 pos[1] = attrVal.Atof();
98 } else if (!attrName.CompareTo("zpos")) {
99 pos[2] = attrVal.Atof();
100 } else if (!attrName.CompareTo("phi")) {
101 ang[0] = attrVal.Atof();
102 } else if (!attrName.CompareTo("theta")) {
103 ang[1] = attrVal.Atof();
104 } else if (!attrName.CompareTo("psi")) {
105 ang[2] = attrVal.Atof();
106 } else {
107 LOG(error) << "Unknwon Attribute name " << xml->GetAttrName(attr);
108 }
109 attr = xml->GetNextAttr(attr);
110 }
111
112 UInt_t chipUniqueID =
114 mftGeom->getHalfID(GetUniqueID()),
115 mftGeom->getDiskID(GetUniqueID()),
116 mftGeom->getPlaneID(GetUniqueID()),
117 mftGeom->getLadderID(GetUniqueID()),
118 ichip);
119
120 auto* chip = new ChipSegmentation(chipUniqueID);
121 // pos[0] = mftGeom->getSensorID(GetUniqueID())*
122 // (SegmentationAlpide::SensorSizeCols + Geometry::sSensorInterspace) + Geometry::sSensorSideOffset;
123 // pos[1] = Geometry::sSensorTopOffset;
124 // pos[2] = Geometry::sFlexThickness;
125 chip->setPosition(pos);
126 chip->setRotationAngles(ang);
127
128 new ((*mChips)[ichip]) ChipSegmentation(*chip);
129 delete chip;
130 }
131
132 // display all child nodes
133 XMLNodePointer_t child = xml->GetChild(node);
134 while (child != nullptr) {
135 createSensors(xml, child);
136 child = xml->GetNext(child);
137 }
138}
139
142
143//_____________________________________________________________________________
145{
146
147 if (sensorID < 0 || sensorID >= mNSensors) {
148 return nullptr;
149 }
150
151 ChipSegmentation* chip = (ChipSegmentation*)mChips->At(sensorID);
152
153 return chip;
154}
155
158
159//_____________________________________________________________________________
160void LadderSegmentation::print(Option_t* opt)
161{
162
163 getTransformation()->Print();
164 if (opt && (strstr(opt, "sensor") || strstr(opt, "s"))) {
165 for (int i = 0; i < getNSensors(); i++) {
166 getSensor(i)->Print("");
167 }
168 }
169}
Chip (sensor) segmentation description.
int32_t i
Class handling both virtual segmentation and real volumes.
ClassImp(LadderSegmentation)
Description of the virtual segmentation of a ladder.
uint16_t pos
Definition RawData.h:3
static const Char_t * getMFTLadderPattern()
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 getLadderID(UInt_t uniqueID) const
Returns Ladder ID based on Unique ID provided.
Definition Geometry.h:112
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
Int_t getPlaneID(UInt_t uniqueID) const
Returns Half-Disk plane (side) ID based on Unique ID provided.
Definition Geometry.h:109
Int_t getNSensors() const
Returns number of Sensor on the ladder.
void createSensors(TXMLEngine *xml, XMLNodePointer_t node)
Creates the Sensors Segmentation array on the Ladder.
LadderSegmentation()
Default constructor.
ChipSegmentation * getSensor(Int_t sensor) const
TGeoCombiTrans * getTransformation() const
Returns the Transformation Combining a Rotation followed by a Translation.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"