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