2 // Main authors: Matevz Tadel & Alja Mrak-Tadel & Bogdan Vulpescu: 2006, 2007
4 /**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
10 #include "AliMpVSegmentation.h"
11 #include "AliEveMUONChamberData.h"
13 #include <AliMUONGeometryTransformer.h>
14 #include <mapping/AliMpDEIterator.h>
15 #include <mapping/AliMpSector.h>
16 #include <mapping/AliMpPad.h>
17 #include <mapping/AliMpSegmentation.h>
18 #include <mapping/AliMpVSegmentation.h>
22 #include <EveBase/AliEveEventManager.h>
24 ///////////////////////////////////////////////////////////////////////////////
26 /// AliEveMUONChamberData: geometry and digits
28 ///////////////////////////////////////////////////////////////////////////////
31 ClassImp(AliEveMUONChamberData)
33 AliMUONGeometryTransformer* AliEveMUONChamberData::fgTransformer = 0;
35 //______________________________________________________________________________
36 AliEveMUONChamberData::AliEveMUONChamberData(Int_t chamber) :
54 for (Int_t i = 0; i < 26; i++) {
55 for (Int_t j = 0; j < 4; j++) {
56 fFrameCoord[i][j] = 0.0;
59 for (Int_t i = 0; i < 7*4096; i++) {
60 fDigitBuffer[i] = 0.0;
62 for (Int_t i = 0; i < 5*256; i++) {
63 fClusterBuffer[i] = 0.0;
65 for (Int_t i = 0; i < 3*256; i++) {
69 for (Int_t i = 0; i < 3; i++) {
70 fChamberBox[i*2 ] = +9999;
71 fChamberBox[i*2+1] = -9999;
74 if (fgTransformer == 0) {
75 AliEveEventManager::AssertGeometry();
76 fgTransformer = new AliMUONGeometryTransformer();
77 fgTransformer->LoadGeometryData();
83 //______________________________________________________________________________
84 AliEveMUONChamberData::~AliEveMUONChamberData()
92 //______________________________________________________________________________
93 void AliEveMUONChamberData::DropData()
96 // release the chamber data
107 //______________________________________________________________________________
108 void AliEveMUONChamberData::Init(Int_t chamber)
111 // initialize the drawing coordinates of the chamber
114 Float_t locP[3], gloP[3], locD[3], gloD[3];
115 Float_t deltax, deltay;
117 const AliMpVSegmentation *vseg;
118 const AliMpSector *sector;
122 for ( it.First(chamber); ! it.IsDone(); it.Next() ) {
124 Int_t detElemId = it.CurrentDEId();
128 sector = AliMpSegmentation::Instance()->GetSector(detElemId,AliMp::kCath0);
130 position = TVector2(sector->GetPositionX(), sector->GetPositionY());
131 dimension = TVector2(sector->GetDimensionX(), sector->GetDimensionY()); // half length
133 locP[0] = position.Px();
134 locP[1] = position.Py();
135 locD[0] = dimension.Px() * 2.;
136 locD[1] = dimension.Py() * 2.;
141 fgTransformer->Local2Global(detElemId,
142 locP[0], locP[1], locP[2],
143 gloP[0], gloP[1], gloP[2]);
145 fgTransformer->Local2Global(detElemId,
146 locD[0], locD[1], locD[2],
147 gloD[0], gloD[1], gloD[2]);
149 fFrameCoord[fNDetElem][0] = gloP[0];
150 fFrameCoord[fNDetElem][1] = gloP[1];
151 fFrameCoord[fNDetElem][2] = gloD[0];
152 fFrameCoord[fNDetElem][3] = gloD[1];
153 fFrameCoord[fNDetElem][4] = gloP[2]; // Z position
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]);
164 // if (!fgSegmentation->HasDE(detElemId)) {
165 // printf("Segmentation has no %d detElemId! \n",detElemId);
169 vseg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath0);
172 printf("No MpVSegmentation for %d detElemId! \n",detElemId);
176 deltax = vseg->GetDimensionX();
177 deltay = vseg->GetDimensionY();
186 fgTransformer->Local2Global(detElemId,
187 locP[0], locP[1], locP[2],
188 gloP[0], gloP[1], gloP[2]);
190 fgTransformer->Local2Global(detElemId,
191 locD[0], locD[1], locD[2],
192 gloD[0], gloD[1], gloD[2]);
194 fFrameCoord[fNDetElem][0] = gloP[0];
195 fFrameCoord[fNDetElem][1] = gloP[1];
196 fFrameCoord[fNDetElem][2] = gloD[0];
197 fFrameCoord[fNDetElem][3] = gloD[1];
198 fFrameCoord[fNDetElem][4] = gloP[2]; // Z position
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]);
215 } // end detElemId loop
219 //______________________________________________________________________________
220 void AliEveMUONChamberData::RegisterDigit(Int_t detElemId, Int_t cathode, Int_t ix, Int_t iy, Int_t charge)
223 // add a digit to this chamber
226 if ((fNDigits/7) == (4096-1)) return;
228 Float_t locP[3], gloP[3], locD[3], gloD[3];
230 const AliMpVSegmentation* vseg = AliMpSegmentation::Instance()
231 ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode));
233 AliMpPad pad = vseg->PadByIndices(ix,iy,kTRUE);
235 locP[0] = pad.GetPositionX();
236 locP[1] = pad.GetPositionY();
237 locD[0] = pad.GetDimensionX();
238 locD[1] = pad.GetDimensionY();
243 fgTransformer->Local2Global(detElemId,
244 locP[0], locP[1], locP[2],
245 gloP[0], gloP[1], gloP[2]);
251 if (cathode == 0) gloP[2] += 0.1;
252 if (cathode == 1) gloP[2] -= 0.1;
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;
266 //______________________________________________________________________________
267 void AliEveMUONChamberData::RegisterCluster(Int_t /*detElemId*/, Int_t cathode, Float_t clsX, Float_t clsY, Float_t clsZ, Float_t charge)
270 // add a reconstructed point (cluster) to this chamber
272 // identical clusters are registered for both cathode planes ...
275 if ((fNClusters/5) == (256-1)) return;
277 fClusterBuffer[fNClusters ] = clsX;
278 fClusterBuffer[fNClusters+1] = clsY;
279 fClusterBuffer[fNClusters+2] = clsZ;
280 fClusterBuffer[fNClusters+3] = charge;
281 fClusterBuffer[fNClusters+4] = cathode;
287 //______________________________________________________________________________
288 void AliEveMUONChamberData::RegisterHit(Int_t /*detElemId*/, Float_t hitX, Float_t hitY, Float_t hitZ)
291 // add a simulation hit to this chamber
294 if ((fNHits/3) == (256-1)) return;
296 fHitBuffer[fNHits ] = hitX;
297 fHitBuffer[fNHits+1] = hitY;
298 fHitBuffer[fNHits+2] = hitZ;