]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveDet/AliEveMUONChamberData.cxx
Removing unnecessary and slightly misleading printout. Anyway we now in which event...
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveMUONChamberData.cxx
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel & Bogdan Vulpescu: 2006, 2007
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          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 #include "AliMpVSegmentation.h"
11 #include "AliEveMUONChamberData.h"
12
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>
19
20 #include <TVector2.h>
21
22 #include <EveBase/AliEveEventManager.h>
23
24 ///////////////////////////////////////////////////////////////////////////////
25 ///
26 /// AliEveMUONChamberData: geometry and digits
27 ///
28 ///////////////////////////////////////////////////////////////////////////////
29
30
31 ClassImp(AliEveMUONChamberData)
32
33 AliMUONGeometryTransformer* AliEveMUONChamberData::fgTransformer = 0;
34
35 //______________________________________________________________________________
36 AliEveMUONChamberData::AliEveMUONChamberData(Int_t chamber) :
37   TObject(),
38   fChamberID(0),
39   fNDetElem(0),
40   fNDigits(0),
41   fNClusters(0),
42   fNHits(0)
43 {
44   //
45   // constructor
46   //
47
48   fChamberID = chamber;
49   fNDetElem  = 0;
50   fNDigits   = 0;
51   fNClusters = 0;
52   fNHits     = 0;
53
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   }
62   for (Int_t i = 0; i < 5*256; i++) {
63     fClusterBuffer[i] = 0.0;
64   }
65   for (Int_t i = 0; i < 3*256; i++) {
66     fHitBuffer[i] = 0.0;
67   }
68
69   for (Int_t i = 0; i < 3; i++) {
70     fChamberBox[i*2  ] = +9999;
71     fChamberBox[i*2+1] = -9999;
72   }
73
74   if (fgTransformer == 0) {
75     AliEveEventManager::AssertGeometry();
76     fgTransformer = new AliMUONGeometryTransformer();
77     fgTransformer->LoadGeometryData();
78   }
79
80   Init(chamber);
81 }
82
83 //______________________________________________________________________________
84 AliEveMUONChamberData::~AliEveMUONChamberData()
85 {
86   //
87   // destructor
88   //
89
90 }
91
92 //______________________________________________________________________________
93 void AliEveMUONChamberData::DropData()
94 {
95   //
96   // release the chamber data
97   //
98
99   fNDigits   = 0;
100   fNClusters = 0;
101   fNHits     = 0;
102
103   return;
104
105 }
106
107 //______________________________________________________________________________
108 void AliEveMUONChamberData::Init(Int_t chamber)
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;
118   const AliMpSector *sector;
119   TVector2 position;
120   TVector2 dimension;
121
122   for ( it.First(chamber); ! it.IsDone(); it.Next() ) {
123
124     Int_t detElemId = it.CurrentDEId();
125
126     if (chamber < 4) {
127
128       sector = AliMpSegmentation::Instance()->GetSector(detElemId,AliMp::kCath0);
129
130       position  = TVector2(sector->GetPositionX(), sector->GetPositionY());
131       dimension = TVector2(sector->GetDimensionX(), sector->GetDimensionY()); // half length
132
133       locP[0] =  position.Px();
134       locP[1] =  position.Py();
135       locD[0] =  dimension.Px() * 2.;
136       locD[1] =  dimension.Py() * 2.;
137
138       locP[2] = 0.0;
139       locD[2] = 0.0;
140
141       fgTransformer->Local2Global(detElemId,
142                                   locP[0], locP[1], locP[2],
143                                   gloP[0], gloP[1], gloP[2]);
144
145       fgTransformer->Local2Global(detElemId,
146                                   locD[0], locD[1], locD[2],
147                                   gloD[0], gloD[1], gloD[2]);
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];
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]);
161
162     } else {
163
164 //      if (!fgSegmentation->HasDE(detElemId)) {
165 //      printf("Segmentation has no %d detElemId! \n",detElemId);
166 //      continue;
167 //      }
168
169       vseg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath0);
170
171       if (vseg == 0) {
172         printf("No MpVSegmentation for %d detElemId! \n",detElemId);
173         continue;
174       }
175
176       deltax = vseg->GetDimensionX();
177       deltay = vseg->GetDimensionY();
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
186       fgTransformer->Local2Global(detElemId,
187                                   locP[0], locP[1], locP[2],
188                                   gloP[0], gloP[1], gloP[2]);
189
190       fgTransformer->Local2Global(detElemId,
191                                   locD[0], locD[1], locD[2],
192                                   gloD[0], gloD[1], gloD[2]);
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];
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]);
210
211     }
212
213     fNDetElem++;
214
215   }  // end detElemId loop
216
217 }
218
219 //______________________________________________________________________________
220 void AliEveMUONChamberData::RegisterDigit(Int_t detElemId, Int_t cathode, Int_t ix, Int_t iy, Int_t charge)
221 {
222   //
223   // add a digit to this chamber
224   //
225
226   if ((fNDigits/7) == (4096-1)) return;
227
228   Float_t locP[3], gloP[3], locD[3], gloD[3];
229
230   const AliMpVSegmentation* vseg = AliMpSegmentation::Instance()
231     ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode));
232
233   AliMpPad pad = vseg->PadByIndices(ix,iy,kTRUE);
234
235   locP[0] = pad.GetPositionX();
236   locP[1] = pad.GetPositionY();
237   locD[0] = pad.GetDimensionX();
238   locD[1] = pad.GetDimensionY();
239
240   locP[2] = 0.0;
241   locD[2] = 0.0;
242
243   fgTransformer->Local2Global(detElemId,
244                               locP[0], locP[1], locP[2],
245                               gloP[0], gloP[1], gloP[2]);
246
247   gloD[0] = locD[0];
248   gloD[1] = locD[1];
249   gloD[2] = gloP[2];
250
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;
263
264 }
265
266 //______________________________________________________________________________
267 void AliEveMUONChamberData::RegisterCluster(Int_t /*detElemId*/, Int_t cathode, Float_t clsX, Float_t clsY, Float_t clsZ, Float_t charge)
268 {
269   //
270   // add a reconstructed point (cluster) to this chamber
271   //
272   // identical clusters are registered for both cathode planes ...
273   //
274
275   if ((fNClusters/5) == (256-1)) return;
276
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
285 }
286
287 //______________________________________________________________________________
288 void AliEveMUONChamberData::RegisterHit(Int_t /*detElemId*/, Float_t hitX, Float_t hitY, Float_t hitZ)
289 {
290   //
291   // add a simulation hit to this chamber
292   //
293
294   if ((fNHits/3) == (256-1)) return;
295
296   fHitBuffer[fNHits  ] = hitX;
297   fHitBuffer[fNHits+1] = hitY;
298   fHitBuffer[fNHits+2] = hitZ;
299
300   fNHits += 3;
301
302 }