CMake: removing qpythia from the depedencies
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveMUONChamberData.cxx
CommitLineData
d810d0de 1// $Id$
fafff680 2// Main authors: Matevz Tadel & Alja Mrak-Tadel & Bogdan Vulpescu: 2006, 2007
d810d0de 3
4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
cb4245bb 9
812e34d8 10#include "AliMpVSegmentation.h"
d810d0de 11#include "AliEveMUONChamberData.h"
3626c858 12
3626c858 13#include <AliMUONGeometryTransformer.h>
b9df0156 14#include <AliMpDEIterator.h>
15#include <AliMpSector.h>
16#include <AliMpPad.h>
17#include <AliMpSegmentation.h>
18#include <AliMpVSegmentation.h>
3626c858 19
3626c858 20#include <TVector2.h>
21
b9df0156 22#include <AliEveEventManager.h>
2674c15a 23
3626c858 24///////////////////////////////////////////////////////////////////////////////
25///
d810d0de 26/// AliEveMUONChamberData: geometry and digits
3626c858 27///
28///////////////////////////////////////////////////////////////////////////////
3626c858 29
3626c858 30
d810d0de 31ClassImp(AliEveMUONChamberData)
32
33AliMUONGeometryTransformer* AliEveMUONChamberData::fgTransformer = 0;
3626c858 34
57ffa5fb 35//______________________________________________________________________________
fd31e9de 36AliEveMUONChamberData::AliEveMUONChamberData(Int_t chamber) :
37 TObject(),
c76ea574 38 fChamberID(0),
39 fNDetElem(0),
40 fNDigits(0),
41 fNClusters(0),
fd31e9de 42 fNHits(0)
3626c858 43{
44 //
45 // constructor
46 //
47
48 fChamberID = chamber;
49 fNDetElem = 0;
50 fNDigits = 0;
eadce74d 51 fNClusters = 0;
52 fNHits = 0;
53
3626c858 54 for (Int_t i = 0; i < 26; i++) {
55 for (Int_t j = 0; j < 4; j++) {
56 fFrameCoord[i][j] = 0.0;
57 }
58 }
59 for (Int_t i = 0; i < 7*4096; i++) {
60 fDigitBuffer[i] = 0.0;
61 }
cef26510 62 for (Int_t i = 0; i < 5*256; i++) {
eadce74d 63 fClusterBuffer[i] = 0.0;
64 }
cef26510 65 for (Int_t i = 0; i < 3*256; i++) {
eadce74d 66 fHitBuffer[i] = 0.0;
67 }
3626c858 68
69 for (Int_t i = 0; i < 3; i++) {
70 fChamberBox[i*2 ] = +9999;
71 fChamberBox[i*2+1] = -9999;
72 }
73
8d33d1c2 74 if (fgTransformer == 0) {
b642f9a5 75 AliEveEventManager::AssertGeometry();
66e5f12c 76 fgTransformer = new AliMUONGeometryTransformer();
b642f9a5 77 fgTransformer->LoadGeometryData();
3626c858 78 }
79
80 Init(chamber);
3626c858 81}
82
57ffa5fb 83//______________________________________________________________________________
d810d0de 84AliEveMUONChamberData::~AliEveMUONChamberData()
3626c858 85{
86 //
87 // destructor
88 //
89
90}
91
57ffa5fb 92//______________________________________________________________________________
d810d0de 93void AliEveMUONChamberData::DropData()
3626c858 94{
95 //
96 // release the chamber data
97 //
98
eadce74d 99 fNDigits = 0;
100 fNClusters = 0;
101 fNHits = 0;
102
3626c858 103 return;
104
105}
106
57ffa5fb 107//______________________________________________________________________________
d810d0de 108void AliEveMUONChamberData::Init(Int_t chamber)
3626c858 109{
110 //
111 // initialize the drawing coordinates of the chamber
112 //
113
114 Float_t locP[3], gloP[3], locD[3], gloD[3];
115 Float_t deltax, deltay;
116 AliMpDEIterator it;
117 const AliMpVSegmentation *vseg;
3626c858 118 const AliMpSector *sector;
119 TVector2 position;
120 TVector2 dimension;
121
122 for ( it.First(chamber); ! it.IsDone(); it.Next() ) {
123
361fa326 124 Int_t detElemId = it.CurrentDEId();
3626c858 125
126 if (chamber < 4) {
127
9f147efe 128 sector = AliMpSegmentation::Instance()->GetSector(detElemId,AliMp::kCath0);
51346b82 129
6e97fbb8 130 position = TVector2(sector->GetPositionX(), sector->GetPositionY());
131 dimension = TVector2(sector->GetDimensionX(), sector->GetDimensionY()); // half length
51346b82 132
3626c858 133 locP[0] = position.Px();
134 locP[1] = position.Py();
135 locD[0] = dimension.Px() * 2.;
136 locD[1] = dimension.Py() * 2.;
51346b82 137
3626c858 138 locP[2] = 0.0;
139 locD[2] = 0.0;
140
51346b82 141 fgTransformer->Local2Global(detElemId,
142 locP[0], locP[1], locP[2],
3626c858 143 gloP[0], gloP[1], gloP[2]);
51346b82 144
3626c858 145 fgTransformer->Local2Global(detElemId,
51346b82 146 locD[0], locD[1], locD[2],
3626c858 147 gloD[0], gloD[1], gloD[2]);
51346b82 148
149 fFrameCoord[fNDetElem][0] = gloP[0];
150 fFrameCoord[fNDetElem][1] = gloP[1];
151 fFrameCoord[fNDetElem][2] = gloD[0];
152 fFrameCoord[fNDetElem][3] = gloD[1];
3626c858 153 fFrameCoord[fNDetElem][4] = gloP[2]; // Z position
154
155 fChamberBox[0] = TMath::Min(fChamberBox[0],gloP[0]-gloD[0]);
156 fChamberBox[1] = TMath::Max(fChamberBox[1],gloP[0]+gloD[0]);
157 fChamberBox[2] = TMath::Min(fChamberBox[2],gloP[1]-gloD[1]);
158 fChamberBox[3] = TMath::Max(fChamberBox[3],gloP[1]+gloD[1]);
159 fChamberBox[4] = TMath::Min(fChamberBox[4],gloP[2]);
160 fChamberBox[5] = TMath::Max(fChamberBox[5],gloP[2]);
51346b82 161
3626c858 162 } else {
163
8d33d1c2 164// if (!fgSegmentation->HasDE(detElemId)) {
165// printf("Segmentation has no %d detElemId! \n",detElemId);
166// continue;
167// }
3626c858 168
361fa326 169 vseg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath0);
3626c858 170
171 if (vseg == 0) {
172 printf("No MpVSegmentation for %d detElemId! \n",detElemId);
173 continue;
174 }
175
6e97fbb8 176 deltax = vseg->GetDimensionX();
177 deltay = vseg->GetDimensionY();
3626c858 178 locP[0] = -deltax;
179 locP[1] = -deltay;
180 locD[0] = +deltax;
181 locD[1] = +deltay;
182
183 locP[2] = 0.0;
184 locD[2] = 0.0;
185
51346b82 186 fgTransformer->Local2Global(detElemId,
187 locP[0], locP[1], locP[2],
3626c858 188 gloP[0], gloP[1], gloP[2]);
51346b82 189
3626c858 190 fgTransformer->Local2Global(detElemId,
51346b82 191 locD[0], locD[1], locD[2],
3626c858 192 gloD[0], gloD[1], gloD[2]);
51346b82 193
194 fFrameCoord[fNDetElem][0] = gloP[0];
195 fFrameCoord[fNDetElem][1] = gloP[1];
196 fFrameCoord[fNDetElem][2] = gloD[0];
197 fFrameCoord[fNDetElem][3] = gloD[1];
3626c858 198 fFrameCoord[fNDetElem][4] = gloP[2]; // Z position
199
200 fChamberBox[0] = TMath::Min(fChamberBox[0],gloP[0]);
201 fChamberBox[0] = TMath::Min(fChamberBox[0],gloD[0]);
202 fChamberBox[1] = TMath::Max(fChamberBox[1],gloP[0]);
203 fChamberBox[1] = TMath::Max(fChamberBox[1],gloD[0]);
204 fChamberBox[2] = TMath::Min(fChamberBox[0],gloP[1]);
205 fChamberBox[2] = TMath::Min(fChamberBox[0],gloD[1]);
206 fChamberBox[3] = TMath::Max(fChamberBox[1],gloP[1]);
207 fChamberBox[3] = TMath::Max(fChamberBox[1],gloD[1]);
208 fChamberBox[4] = TMath::Min(fChamberBox[4],gloP[2]);
209 fChamberBox[5] = TMath::Max(fChamberBox[5],gloP[2]);
51346b82 210
3626c858 211 }
212
213 fNDetElem++;
214
215 } // end detElemId loop
216
3626c858 217}
218
57ffa5fb 219//______________________________________________________________________________
d810d0de 220void AliEveMUONChamberData::RegisterDigit(Int_t detElemId, Int_t cathode, Int_t ix, Int_t iy, Int_t charge)
3626c858 221{
222 //
223 // add a digit to this chamber
224 //
225
cef26510 226 if ((fNDigits/7) == (4096-1)) return;
227
3626c858 228 Float_t locP[3], gloP[3], locD[3], gloD[3];
229
361fa326 230 const AliMpVSegmentation* vseg = AliMpSegmentation::Instance()
231 ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode));
3626c858 232
168e9c4d 233 AliMpPad pad = vseg->PadByIndices(ix,iy,kTRUE);
51346b82 234
6e97fbb8 235 locP[0] = pad.GetPositionX();
236 locP[1] = pad.GetPositionY();
237 locD[0] = pad.GetDimensionX();
238 locD[1] = pad.GetDimensionY();
51346b82 239
3626c858 240 locP[2] = 0.0;
241 locD[2] = 0.0;
242
51346b82 243 fgTransformer->Local2Global(detElemId,
244 locP[0], locP[1], locP[2],
3626c858 245 gloP[0], gloP[1], gloP[2]);
51346b82 246
3626c858 247 gloD[0] = locD[0];
248 gloD[1] = locD[1];
249 gloD[2] = gloP[2];
250
3626c858 251 if (cathode == 0) gloP[2] += 0.1;
252 if (cathode == 1) gloP[2] -= 0.1;
253
254 fDigitBuffer[fNDigits ] = gloP[0];
255 fDigitBuffer[fNDigits+1] = gloP[1];
256 fDigitBuffer[fNDigits+2] = gloD[0];
257 fDigitBuffer[fNDigits+3] = gloD[1];
258 fDigitBuffer[fNDigits+4] = gloP[2];
259 fDigitBuffer[fNDigits+5] = charge;
260 fDigitBuffer[fNDigits+6] = cathode;
261
262 fNDigits += 7;
cef26510 263
eadce74d 264}
265
57ffa5fb 266//______________________________________________________________________________
d810d0de 267void AliEveMUONChamberData::RegisterCluster(Int_t /*detElemId*/, Int_t cathode, Float_t clsX, Float_t clsY, Float_t clsZ, Float_t charge)
eadce74d 268{
269 //
270 // add a reconstructed point (cluster) to this chamber
271 //
272 // identical clusters are registered for both cathode planes ...
273 //
274
cef26510 275 if ((fNClusters/5) == (256-1)) return;
276
eadce74d 277 fClusterBuffer[fNClusters ] = clsX;
278 fClusterBuffer[fNClusters+1] = clsY;
279 fClusterBuffer[fNClusters+2] = clsZ;
280 fClusterBuffer[fNClusters+3] = charge;
281 fClusterBuffer[fNClusters+4] = cathode;
282
283 fNClusters += 5;
284
eadce74d 285}
286
57ffa5fb 287//______________________________________________________________________________
d810d0de 288void AliEveMUONChamberData::RegisterHit(Int_t /*detElemId*/, Float_t hitX, Float_t hitY, Float_t hitZ)
eadce74d 289{
290 //
291 // add a simulation hit to this chamber
292 //
293
cef26510 294 if ((fNHits/3) == (256-1)) return;
295
eadce74d 296 fHitBuffer[fNHits ] = hitX;
297 fHitBuffer[fNHits+1] = hitY;
298 fHitBuffer[fNHits+2] = hitZ;
299
eadce74d 300 fNHits += 3;
3626c858 301
302}