Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 : * *
4 : * Author: The ALICE Off-line Project. *
5 : * Contributors are mentioned in the code where appropriate. *
6 : * *
7 : * Permission to use, copy, modify and distribute this software and its *
8 : * documentation strictly for non-commercial purposes is hereby granted *
9 : * without fee, provided that the above copyright notice appears in all *
10 : * copies and that both the copyright notice and this permission notice *
11 : * appear in the supporting documentation. The authors make no claims *
12 : * about the suitability of this software for any purpose. It is *
13 : * provided "as is" without express or implied warranty. *
14 : **************************************************************************/
15 :
16 : // $Id$
17 :
18 : //-----------------------------------------------------------------------------
19 : /// \class AliMFTHalfSegmentation
20 : ///
21 : /// Segmentation class for each half of the ALICE Muon Forward Tracker
22 : ///
23 : // author Raphael Tieulent <raphael.tieulent@cern.ch>
24 : //-----------------------------------------------------------------------------
25 :
26 : #include "TClonesArray.h"
27 :
28 : #include "AliLog.h"
29 :
30 : #include "AliMFTHalfDiskSegmentation.h"
31 : #include "AliMFTHalfSegmentation.h"
32 : #include "AliMFTGeometry.h"
33 :
34 : /// \cond CLASSIMP
35 14 : ClassImp(AliMFTHalfSegmentation);
36 : /// \endcond
37 :
38 : //====================================================================================================================================================
39 : /// Default constructor
40 : AliMFTHalfSegmentation::AliMFTHalfSegmentation():
41 0 : AliMFTVSegmentation(),
42 0 : fMFTHalfDisks(NULL)
43 0 : {
44 :
45 :
46 0 : }
47 :
48 : //====================================================================================================================================================
49 : /// Copy constructor
50 :
51 : AliMFTHalfSegmentation::AliMFTHalfSegmentation(const AliMFTHalfSegmentation& source):
52 0 : AliMFTVSegmentation(source),
53 0 : fMFTHalfDisks(NULL){
54 :
55 0 : if (source.fMFTHalfDisks) fMFTHalfDisks = new TClonesArray(*(source.fMFTHalfDisks));
56 :
57 :
58 0 : }
59 : //====================================================================================================================================================
60 : /// Constructor
61 : /// \param nameGeomFile Char_t * : name of the XML geometry file.
62 : /// By default it is : $ALICE_ROOT/ITSMFT/MFT/data/AliMFTGeometry.xml
63 : /// \param id Short_t : ID Of the Half-MFT to build (0=Bottom; 1=Top)
64 : AliMFTHalfSegmentation::AliMFTHalfSegmentation(const Char_t *nameGeomFile, const Short_t id):
65 0 : AliMFTVSegmentation(),
66 0 : fMFTHalfDisks(NULL)
67 0 : {
68 0 : AliMFTGeometry * mftGeom = AliMFTGeometry::Instance();
69 :
70 0 : UInt_t halfUniqueID = mftGeom->GetObjectID(AliMFTGeometry::kHalfMFTType, id);
71 0 : SetUniqueID(halfUniqueID);
72 0 : SetName(Form("MFT_H_%d",id));
73 :
74 :
75 0 : fMFTHalfDisks = new TClonesArray("AliMFTHalfDiskSegmentation", AliMFTConstants::kNDisks);
76 0 : fMFTHalfDisks -> SetOwner(kTRUE);
77 :
78 : // Create XML engine
79 0 : TXMLEngine* geomFile = new TXMLEngine;
80 :
81 : // take access to main node
82 0 : XMLDocPointer_t xmldoc = geomFile->ParseFile(nameGeomFile);
83 0 : if (xmldoc==0) {
84 0 : delete geomFile;
85 0 : AliFatal(Form("Could not parse Geometry XML File named %s ", nameGeomFile));
86 : }
87 0 : XMLNodePointer_t mainnode = geomFile->DocGetRootElement(xmldoc);
88 :
89 : // Find Half-MFT node in the XML file
90 0 : XMLNodePointer_t halfnode ;
91 0 : FindHalf(geomFile, mainnode, halfnode);
92 :
93 : // Create Half Disks belonging to that Half-MFT
94 0 : CreateHalfDisks(geomFile, halfnode);
95 :
96 :
97 : // Release memory
98 0 : geomFile->FreeDoc(xmldoc);
99 0 : delete geomFile;
100 :
101 :
102 0 : }
103 :
104 : //====================================================================================================================================================
105 :
106 0 : AliMFTHalfSegmentation::~AliMFTHalfSegmentation() {
107 :
108 0 : if (fMFTHalfDisks) fMFTHalfDisks->Delete();
109 0 : delete fMFTHalfDisks;
110 :
111 0 : }
112 :
113 : //====================================================================================================================================================
114 : ///Clear the TClonesArray holding the AliMFTHalfDiskSegmentation objects
115 :
116 : void AliMFTHalfSegmentation::Clear(const Option_t* /*opt*/) {
117 :
118 0 : if (fMFTHalfDisks) fMFTHalfDisks->Delete();
119 0 : delete fMFTHalfDisks;
120 0 : fMFTHalfDisks = NULL;
121 :
122 0 : }
123 :
124 : //====================================================================================
125 : ///Create the Half-Disks
126 : void AliMFTHalfSegmentation::CreateHalfDisks(TXMLEngine* xml, XMLNodePointer_t node)
127 : {
128 : // this function display all accessible information about xml node and its children
129 : Int_t idisk;
130 : Int_t nladder;
131 0 : Double_t pos[3]={0., 0., 0.};
132 0 : Double_t ang[3]={0., 0., 0.};
133 :
134 0 : TString nodeName = xml->GetNodeName(node);
135 0 : if (!nodeName.CompareTo("disk")) {
136 0 : XMLAttrPointer_t attr = xml->GetFirstAttr(node);
137 0 : while (attr!=0) {
138 0 : TString attrName = xml->GetAttrName(attr);
139 0 : TString attrVal = xml->GetAttrValue(attr);
140 0 : if(!attrName.CompareTo("idisk")){
141 0 : idisk = attrVal.Atoi();
142 0 : if (idisk>=AliMFTConstants::kNDisks || idisk<0) {
143 0 : AliFatal(Form(" Wrong Disk number : %d ",idisk));
144 : }
145 : } else
146 0 : if(!attrName.CompareTo("nladder")){
147 0 : nladder = attrVal.Atoi();
148 0 : } else
149 0 : if(!attrName.CompareTo("xpos")){
150 0 : pos[0] = attrVal.Atof();
151 0 : } else
152 0 : if(!attrName.CompareTo("ypos")){
153 0 : pos[1] = attrVal.Atof();
154 0 : } else
155 0 : if(!attrName.CompareTo("zpos")){
156 0 : pos[2] = attrVal.Atof();
157 0 : } else
158 0 : if(!attrName.CompareTo("phi")){
159 0 : ang[0] = attrVal.Atof();
160 0 : } else
161 0 : if(!attrName.CompareTo("theta")){
162 0 : ang[1] = attrVal.Atof();
163 0 : } else
164 0 : if(!attrName.CompareTo("psi")){
165 0 : ang[2] = attrVal.Atof();
166 0 : } else{
167 0 : AliError(Form(" Unknwon Attribute name %s ",xml->GetAttrName(attr)));
168 : }
169 :
170 0 : attr = xml->GetNextAttr(attr);
171 0 : }
172 :
173 0 : AliDebug(1,Form("Creating Half-Disk %d with %d Ladders at the position (%.2f,%.2f,%.2f) with angles (%.2f,%.2f,%.2f)",idisk,nladder,pos[0],pos[1],pos[2],ang[0],ang[1],ang[2]));
174 :
175 0 : AliMFTGeometry * mftGeom = AliMFTGeometry::Instance();
176 :
177 0 : UInt_t diskUniqueID = mftGeom->GetObjectID(AliMFTGeometry::kHalfDiskType,
178 0 : mftGeom->GetHalfMFTID(GetUniqueID()),
179 : idisk );
180 :
181 :
182 0 : AliMFTHalfDiskSegmentation *halfDisk = new AliMFTHalfDiskSegmentation(diskUniqueID);
183 0 : halfDisk->SetPosition(pos);
184 0 : halfDisk->SetRotationAngles(ang);
185 0 : halfDisk->SetNLadders(nladder);
186 0 : halfDisk->CreateLadders(xml, node);
187 0 : if(halfDisk->GetNLaddersBuild() != halfDisk->GetNLadders()){
188 0 : AliFatal(Form("Number of ladder build (%d) does not correspond to the number declared (%d) : Check XML file",halfDisk->GetNLaddersBuild(), halfDisk->GetNLadders()));
189 : }
190 0 : new ((*fMFTHalfDisks)[idisk]) AliMFTHalfDiskSegmentation(*halfDisk);
191 0 : delete halfDisk;
192 : //GetHalfDisk(idisk)->Print("ls");
193 :
194 0 : }
195 :
196 : // display all child nodes
197 0 : XMLNodePointer_t child = xml->GetChild(node);
198 0 : while (child!=0) {
199 0 : CreateHalfDisks(xml, child);
200 0 : child = xml->GetNext(child);
201 : }
202 0 : }
203 : //====================================================================================
204 : /// Find Half-Disk in the XML file (private)
205 :
206 : void AliMFTHalfSegmentation::FindHalf(TXMLEngine* xml, XMLNodePointer_t node, XMLNodePointer_t &retnode){
207 : // Find in the XML Geometry File the node corresponding to the Half-MFT being build
208 : // Set Position and Orientation of the Half-MFT
209 : Int_t isTop;
210 : Int_t ndisk;
211 0 : Double_t pos[3] = {0., 0., 0.};
212 0 : Double_t ang[3] = {0., 0., 0.};
213 :
214 0 : TString nodeName = xml->GetNodeName(node);
215 0 : if (!nodeName.CompareTo("half")) {
216 0 : XMLAttrPointer_t attr = xml->GetFirstAttr(node);
217 0 : while (attr!=0) {
218 0 : TString attrName = xml->GetAttrName(attr);
219 0 : TString attrVal = xml->GetAttrValue(attr);
220 0 : if(!attrName.CompareTo("top")){
221 0 : isTop = attrVal.Atoi();
222 0 : if (isTop>1 || isTop<0) {
223 0 : AliFatal(Form(" Wrong Half MFT number : %d ",isTop));
224 : }
225 : } else
226 0 : if(!attrName.CompareTo("ndisk")){
227 0 : ndisk = attrVal.Atoi();
228 0 : if (ndisk>5 || ndisk<0) {
229 0 : AliError(Form(" Wrong number of disk : %d ",ndisk));
230 : }
231 :
232 : } else
233 0 : if(!attrName.CompareTo("xpos")){
234 0 : pos[0] = attrVal.Atof();
235 0 : } else
236 0 : if(!attrName.CompareTo("ypos")){
237 0 : pos[1] = attrVal.Atof();
238 0 : } else
239 0 : if(!attrName.CompareTo("zpos")){
240 0 : pos[2] = attrVal.Atof();
241 0 : } else
242 0 : if(!attrName.CompareTo("phi")){
243 0 : ang[0] = attrVal.Atof();
244 0 : } else
245 0 : if(!attrName.CompareTo("theta")){
246 0 : ang[1] = attrVal.Atof();
247 0 : } else
248 0 : if(!attrName.CompareTo("psi")){
249 0 : ang[2] = attrVal.Atof();
250 0 : } else{
251 0 : AliError(Form(" Unknwon Attribute name %s ",xml->GetAttrName(attr)));
252 : }
253 :
254 0 : attr = xml->GetNextAttr(attr);
255 0 : }
256 :
257 0 : AliMFTGeometry * mftGeom = AliMFTGeometry::Instance();
258 0 : if(isTop == mftGeom->GetHalfMFTID(GetUniqueID())) {
259 0 : AliDebug(1,Form("Setting up %s Half-MFT %d Disk(s) at the position (%.2f,%.2f,%.2f) with angles (%.2f,%.2f,%.2f)",(isTop?"Top":"Bottom"),ndisk,pos[0],pos[1],pos[2],ang[0],ang[1],ang[2]));
260 0 : SetPosition(pos);
261 0 : SetRotationAngles(ang);
262 0 : retnode = node;
263 0 : return;
264 : }
265 :
266 0 : }
267 :
268 : // display all child nodes
269 0 : XMLNodePointer_t child = xml->GetChild(node);
270 0 : while (child!=0) {
271 0 : FindHalf(xml, child, retnode);
272 0 : child = xml->GetNext(child);
273 : }
274 0 : }
275 :
|