]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/OnlineAnalysis/AliHLTMUONTriggerReconstructor.cxx
Added test script of Bessel functions
[u/mrichter/AliRoot.git] / HLT / MUON / OnlineAnalysis / AliHLTMUONTriggerReconstructor.cxx
CommitLineData
6efe69e7 1/**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
4 * *
5 * Primary Authors: *
6 * Indranil Das <indra.das@saha.ac.in> *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17/* $Id$ */
18
19/**********************************************************************
20 Created on : 16/05/2007
21 Purpose : This class is supposed to read the tracker DDL files and
960d54ad 22 give the output AliMUONCoreTriggerRecord
6efe69e7 23 Author : Indranil Das, HEP Division, SINP
24 Email : indra.das@saha.ac.in | indra.ehep@gmail.com
25**********************************************************************/
26
27///*
28//
960d54ad 29// The trigger reconstructor class is designed to deal the rawdata inputfiles
30// to findout the the reconstructed hits at the trigger DDL. The output is send
31// to the output block for further processing.
6efe69e7 32//
33// Author : Indranil Das ( indra.das@saha.ac.in || indra.ehep@gmail.com )
34//
35//*/
36
6efe69e7 37#include "AliHLTMUONTriggerReconstructor.h"
7af42d4d 38#include "AliHLTMUONUtils.h"
39#include "AliHLTMUONConstants.h"
40#include "AliHLTMUONCalculations.h"
41#include <vector>
6efe69e7 42
6efe69e7 43const int AliHLTMUONTriggerReconstructor::fgkDetectorId = 0xB00;
44const int AliHLTMUONTriggerReconstructor::fgkDDLOffSet = 20 ;
45const int AliHLTMUONTriggerReconstructor::fgkNofDDL = 2 ;
46
47const int AliHLTMUONTriggerReconstructor::fgkDDLHeaderSize = 8;
960d54ad 48const int AliHLTMUONTriggerReconstructor::fgkEvenLutSize = 2602351 + 1;
49const int AliHLTMUONTriggerReconstructor::fgkOddLutSize = 2528735 + 1;
6efe69e7 50
51const int AliHLTMUONTriggerReconstructor::fgkLutLine = 10496;
52
960d54ad 53const int AliHLTMUONTriggerReconstructor::fgkMinIdManuChannel[2] = {819616, 862288};
54const int AliHLTMUONTriggerReconstructor::fgkMaxIdManuChannel[2] = {3421966, 3391022};
6efe69e7 55
56const float AliHLTMUONTriggerReconstructor::fgkHalfPadSizeXB[3] = {8.5, 17.0, 25.5};
57const float AliHLTMUONTriggerReconstructor::fgkHalfPadSizeYNB[2] = {25.5, 34.0};
58
59const int AliHLTMUONTriggerReconstructor::fgkDetElem = 9*4 ; // 9 detele per half chamber
60
960d54ad 61
62AliHLTMUONTriggerReconstructor::AliHLTMUONTriggerReconstructor()
63 :
6efe69e7 64 fPadData(NULL),
65 fLookUpTableData(NULL),
66 fRecPoints(NULL),
67 fRecPointsCount(NULL),
68 fMaxRecPointsCount(0),
960d54ad 69 fMaxFiredPerDetElem(),
70 fDetElemToDataId(),
6efe69e7 71 fDDLId(0),
7af42d4d 72 fIdOffSet(0),
73 fTrigRecId(0)
6efe69e7 74{
75 // ctor
76
77 if(AliHLTMUONTriggerReconstructor::fgkEvenLutSize > AliHLTMUONTriggerReconstructor::fgkOddLutSize){
78 fPadData = new AliHLTMUONHitReconstructor::DHLTPad[AliHLTMUONTriggerReconstructor::fgkEvenLutSize];
79 }
80 else{
81 fPadData = new AliHLTMUONHitReconstructor::DHLTPad[AliHLTMUONTriggerReconstructor::fgkOddLutSize];
82 }
83
6efe69e7 84 bzero(fGetIdTotalData,104*64*2*sizeof(int));
85}
86
87
88AliHLTMUONTriggerReconstructor::~AliHLTMUONTriggerReconstructor()
89{
90 // dtor
6efe69e7 91 delete []fPadData;
92 delete []fLookUpTableData;
960d54ad 93}
94
95bool AliHLTMUONTriggerReconstructor::SetRegToLocCardMap(RegToLoc* regToLoc)
96{
97 if(!memcpy(fRegToLocCard,regToLoc,128*sizeof(RegToLoc)))
98 return false;
99
100 for(int i=0;i<128;i++){
101 HLTDebug("DDL : %d, reg : %d, loc : %d",fRegToLocCard[i].fTrigDDL,
102 fRegToLocCard[i].fRegId,fRegToLocCard[i].fLocId);
103 }
104
105 return true;
6efe69e7 106}
107
108bool AliHLTMUONTriggerReconstructor::LoadLookUpTable(AliHLTMUONHitReconstructor::DHLTLut* lookUpTableData, int lookUpTableId)
109{
110 if(lookUpTableId<fgkDDLOffSet || lookUpTableId>= fgkDDLOffSet + fgkNofDDL){
111 HLTError("DDL number is out of range (must be %d<=iDDL<%d)",fgkDDLOffSet,fgkDDLOffSet+fgkNofDDL);
112 return false;
113 }
114
115 fDDLId = lookUpTableId;
116
117 int lutSize = ((lookUpTableId%2)==0) ? fgkEvenLutSize : fgkOddLutSize ;
118 int nofLutLine = fgkLutLine ;
119 fIdOffSet = fgkMinIdManuChannel[lookUpTableId%2];
120
121 int detManuChannelId;
122
123 fLookUpTableData = new AliHLTMUONHitReconstructor::DHLTLut[lutSize];
124
960d54ad 125 memset(fLookUpTableData,-1,lutSize*sizeof(AliHLTMUONHitReconstructor::DHLTLut));
6efe69e7 126
127 for(int i=0; i<nofLutLine; i++){
128
129 detManuChannelId = lookUpTableData[i].fIdManuChannel - fIdOffSet + 1;
130 fLookUpTableData[detManuChannelId].fIdManuChannel = lookUpTableData[i].fIdManuChannel - fIdOffSet;
131 fLookUpTableData[detManuChannelId].fIX = lookUpTableData[i].fIX ;
132 fLookUpTableData[detManuChannelId].fIY = lookUpTableData[i].fIY ;
133 fLookUpTableData[detManuChannelId].fRealX = lookUpTableData[i].fRealX ;
134 fLookUpTableData[detManuChannelId].fRealY = lookUpTableData[i].fRealY ;
135 fLookUpTableData[detManuChannelId].fRealZ = lookUpTableData[i].fRealZ ;
136 fLookUpTableData[detManuChannelId].fPcbZone = lookUpTableData[i].fPcbZone ;
137 fLookUpTableData[detManuChannelId].fPlane = lookUpTableData[i].fPlane ;
138 }
139 return true;
140
141 return true;
142}
143
227e7192 144bool AliHLTMUONTriggerReconstructor::Run(
145 const AliHLTUInt32_t* rawData,
146 AliHLTUInt32_t rawDataSize,
147 AliHLTMUONTriggerRecordStruct* trigRecord,
148 AliHLTUInt32_t& nofTrigRec
149 )
6efe69e7 150{
151
227e7192 152 fRecPoints = trigRecord;
153 fMaxRecPointsCount = nofTrigRec;
154 fRecPointsCount = &nofTrigRec;
6efe69e7 155 *fRecPointsCount = 0;
960d54ad 156 fMaxFiredPerDetElem.clear();
157 fDetElemToDataId.clear();
6efe69e7 158
159 fPadData[0].fDetElemId = 0;
160 fPadData[0].fBuspatchId = 0;
161 fPadData[0].fIdManuChannel = 0;
162 fPadData[0].fIX = 0 ;
163 fPadData[0].fIY = 0 ;
164 fPadData[0].fRealX = 0.0 ;
165 fPadData[0].fRealY = 0.0 ;
166 fPadData[0].fRealZ = 0.0 ;
167 fPadData[0].fPlane = -1 ;
168 fPadData[0].fPcbZone = -1 ;
169 fPadData[0].fCharge = 0 ;
170
227e7192 171 if(!ReadDDL(rawData, rawDataSize)){
6efe69e7 172 HLTError("Failed to read the complete DDL file\n");
173 return false;
174 }
175
176 if(!FindTrigHits()){
177 HLTError("Failed to generate RecHits\n");
178 return false;
179 }
180
181 return true;
182}
183
184
227e7192 185bool AliHLTMUONTriggerReconstructor::ReadDDL(
186 const AliHLTUInt32_t* rawData,
187 AliHLTUInt32_t rawDataSize
188 )
6efe69e7 189{
190
6efe69e7 191 int idManuChannel ;
192
193 int index = 0;
194 int dataCount = 0;
6efe69e7 195 int detElemId = 0 ;
960d54ad 196 int reg_output,reg_phys_trig_occur ;
197 int iLocIndex,loc,locDec,triggY,sign,loDev,triggX;
198 int iRegLoc, locId ;
199 short pattern[2][4]; // 2 stands for two cathode planes and 4 stands for 4 chambers
200
201 Int_t offset,ithSwitch,secondLocation,idetElemId;
6efe69e7 202
960d54ad 203 int shiftIndex = 10 - 6 - 1; // the one comes due to indexing from zero
6efe69e7 204
960d54ad 205 DataIdIndex dataIndex;
6efe69e7 206#ifdef DEBUG
207 int globalcard_data_occurance = (rawData[index]>>10)&0x1; //Set to 1 if global info present in DDL else set to 0
208 int version = (rawData[index]>>12)&0xFF; // software version
209 int serial_number = (rawData[index]>>20)&0xF; // serial number set to 0xF
210#endif
211 int phys_trig_occur = (rawData[index]>>30)&0x1; // 1 for physics trigger, 0 for software trigger
212
6efe69e7 213 HLTDebug("globalcard_data_occurance %d, version %d, serial_number %d, phys_trig_occur %d",
214 globalcard_data_occurance,version,serial_number,phys_trig_occur);
215
216 if(!phys_trig_occur) // for software trigger
217 index += 8 ;// corresponding to scalar words
218
219 index += 1 ; // To skip the separator 0xDEADFACE
220
221 index += 4 ; // corresponding to global input
222
223 index += 1 ; // reaches to global output
224
225 if((fDDLId - AliHLTMUONTriggerReconstructor::fgkDDLOffSet) == 0){ //if globalData is present in DDL 0 (presummed may be changed)
226#ifdef DEBUG
227 int singleLpt = rawData[index] & 0x1;
228 int singleHpt = (rawData[index] >> 1) & 0x1;
229
230 int pairUnlikeLpt = (rawData[index] >> 4) & 0x1;
231 int pairUnlikeHpt = (rawData[index] >> 5) & 0x1;
232
233 int pairLikeLpt = (rawData[index] >> 2) & 0x1;
234 int pairLikeHpt = (rawData[index] >> 3) & 0x1;
960d54ad 235#endif
6efe69e7 236 HLTDebug("singleLpt : %x, singleHpt : %x, pairUnlikeLpt : %x, pairUnlikeHpt : %x, pairLikeLpt : %x, pairLikeHpt : %x",
237 singleLpt,singleHpt,pairUnlikeLpt,pairUnlikeHpt,pairLikeLpt,pairLikeHpt);
238 }
239
240 if(!phys_trig_occur)
241 index += 10 ;// corresponds to scalar words
960d54ad 242
6efe69e7 243 index += 1; // separator 0xDEADBEEF
244
245 for (int iReg = 0; iReg < 8; iReg++) {
246 index += 1; // DARC Status Word
247 index += 1; // Regeional Word
960d54ad 248 reg_output = rawData[index] & 0xFF;
249 reg_phys_trig_occur = ( rawData[index] >> 31) & 0x1;
6efe69e7 250
251 index += 2; // 2 words for regional input
252
253 index += 1; // L0 counter
254
255 if(!reg_phys_trig_occur)
256 index += 10;
257
960d54ad 258 index += 1 ; // end of Regeonal header 0xBEEFFACE
6efe69e7 259
260 for(int iLoc = 0; iLoc < 16 ; iLoc++){
261
960d54ad 262 iLocIndex = index ;
6efe69e7 263
960d54ad 264 loc = (rawData[index+5] >> 19) & 0xF ;
6efe69e7 265
960d54ad 266 locDec = (rawData[index+5] >> 15) & 0xF;
267 triggY = (rawData[index+5] >> 14) & 0x1 ;
268 sign = (rawData[index+5] >> 9) & 0x1;
269 loDev = (rawData[index+5] >> 5) & 0xF ;
270 triggX = (loDev >> 4 & 0x1 ) && !(loDev & 0xF) ;
6efe69e7 271
960d54ad 272 if( locDec != 0x9 ){ // check for Dec
273
274 iRegLoc = iReg*16 + iLoc;
275 locId = fRegToLocCard[iRegLoc].fLocId ;
276
277 if(locId<=234){ // to avoid the copy locCards
6efe69e7 278
279 index += 1;
7af42d4d 280 pattern[0][0] = rawData[index] & 0xFFFF; // x-strip pattern for chamber 0
281 pattern[0][1] = (rawData[index] >> 16) & 0xFFFF; // x-strip pattern for chamber 1
960d54ad 282 index += 1;
283 pattern[0][2] = rawData[index] & 0xFFFF;
284 pattern[0][3] = (rawData[index] >> 16) & 0xFFFF;
6efe69e7 285
960d54ad 286 index += 1;
7af42d4d 287 pattern[1][0] = rawData[index] & 0xFFFF; // y-strip pattern for chamber 0
288 pattern[1][1] = (rawData[index] >> 16) & 0xFFFF; // y-strip pattern for chamber 0
960d54ad 289 index += 1;
290 pattern[1][2] = rawData[index] & 0xFFFF;
291 pattern[1][3] = (rawData[index] >> 16) & 0xFFFF;
6efe69e7 292
960d54ad 293 if(pattern[0][0] || pattern[0][1] || pattern[0][2] || pattern[0][3]
294 || pattern[1][0] || pattern[1][1] || pattern[1][2] || pattern[1][3]
295 ){
296
297 HLTDebug("iReg: %d, iLoc :%d, locId : %d,X : %x, %x, %x, %x ...Y : %x, %x, %x, %x",
298 iReg,iLoc,locId,pattern[0][0],pattern[0][1],pattern[0][2],pattern[0][3],
299 pattern[1][0],pattern[1][1],pattern[1][2],pattern[1][3]);
300
301 for(int iChamber = 0; iChamber < 4 ; iChamber++){ //4 chambers per DDL
302 for(int iPlane = 0; iPlane < 2 ; iPlane++){// 2 cathode plane
303 if(pattern[iPlane][iChamber]){
304 detElemId = fRegToLocCard[iRegLoc].fDetElemId[iChamber];
305 HLTDebug("\tdetElemId : %d\n",detElemId);
306 for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy) {
307 if ((pattern[iPlane][iChamber] >> ibitxy) & 0x1) {
6efe69e7 308
960d54ad 309 // not quite sure about this
310 offset = 0;
311 ithSwitch = (fRegToLocCard[iRegLoc].fSwitch >> shiftIndex) & 0x1;
312 if (iPlane && ithSwitch) offset = -8;
313
314 secondLocation = ibitxy + offset;
315
316 idetElemId = detElemId%1000;
317
318 idetElemId &= 0x1FF ;
319 iPlane &= 0x1 ;
320 locId &= 0xFF ;
321 secondLocation &= 0xF ;
322
323 idManuChannel &= 0x0;
324 idManuChannel = (idManuChannel|idetElemId)<<1;
325 idManuChannel = (idManuChannel|iPlane)<<8;
326 idManuChannel = (idManuChannel|locId)<<4 ;
327 idManuChannel |= secondLocation ;
328
329 idManuChannel -= fIdOffSet ;
330
331 if(fLookUpTableData[idManuChannel+1].fIdManuChannel == -1) //skip uninitialized values
332 continue;
333
334 fPadData[idManuChannel].fDetElemId = detElemId;
335 fPadData[idManuChannel].fIdManuChannel = idManuChannel;
336 fPadData[idManuChannel].fIX = fLookUpTableData[idManuChannel+1].fIX;
337 fPadData[idManuChannel].fIY = fLookUpTableData[idManuChannel+1].fIY;
338 fPadData[idManuChannel].fRealX = fLookUpTableData[idManuChannel+1].fRealX;
339 fPadData[idManuChannel].fRealY = fLookUpTableData[idManuChannel+1].fRealY;
340 fPadData[idManuChannel].fRealZ = fLookUpTableData[idManuChannel+1].fRealZ;
341 fPadData[idManuChannel].fPcbZone = fLookUpTableData[idManuChannel+1].fPcbZone;
342 fPadData[idManuChannel].fPlane = fLookUpTableData[idManuChannel+1].fPlane;
7af42d4d 343
344 // !!!!!!!!!!!! THIS IS A COMPLETE HACK !!!!!!!!!
345 // Have to use fBuspatchId to store the chamber number,
346 // and fCharge as the trigger records ID number.
347 // This must be fixed in the future by using more appropriate
348 // structures.
349 fPadData[idManuChannel].fBuspatchId = iChamber;
350 fPadData[idManuChannel].fCharge = fTrigRecId;
351 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
960d54ad 352 HLTDebug("\t Hit Found fo ich : %d, iPlane : %d, detelem %d, id : %d, at (%lf, %lf, %lf) cm"
353 ,iChamber,fLookUpTableData[idManuChannel+1].fPlane,detElemId,fLookUpTableData[idManuChannel+1].fIdManuChannel,
354 fPadData[idManuChannel].fRealX,
355 fPadData[idManuChannel].fRealY,fPadData[idManuChannel].fRealZ);
356
357 if(fMaxFiredPerDetElem[detElemId] == 0){
358 DataIdIndex first;
359 first.push_back(idManuChannel);
360 fDetElemToDataId[detElemId] = first;
361 }else{
362 dataIndex = fDetElemToDataId[detElemId];
363 dataIndex.push_back(idManuChannel);
364 fDetElemToDataId[detElemId] = dataIndex;
365 }
366
367 fMaxFiredPerDetElem[detElemId] = fMaxFiredPerDetElem[detElemId] + 1;
368
369 dataCount ++;
370
371 }//pattern maching is found
372 }// loop of ibitxy
373 }// if pattern
374 }// iplane
375 }// ichamber
376
7af42d4d 377 // Increment trigger record Id and keep it positive.
378 //TODO: handle the wrapparound better.
379 if (fTrigRecId < 0x7FFFFFFF)
380 fTrigRecId++;
381 else
382 fTrigRecId = 0;
383
960d54ad 384 }// if any non zero pattern found
385
386
6efe69e7 387 index += 1 ; // skipping the last word though it is important
388
960d54ad 389 }// if locId <=234
6efe69e7 390 }// Dec Condn
6efe69e7 391
6efe69e7 392
960d54ad 393 if(!reg_phys_trig_occur)
394 index += 45;
395
396 index += 1; // end of local Data 0xCAFEFADE
6efe69e7 397
960d54ad 398 HLTDebug("iReg %d, iLoc %d, locId : %d, trigY %x, triggX %x, loDev %x, dec %x, sign %x,rawData : %x",
399 iReg,iLoc,locId,triggY,triggX,loDev,dec,sign, rawData[index]);
6efe69e7 400
960d54ad 401 index = iLocIndex + 6 ; //important to reset the index counter for fake locids like 235
6efe69e7 402
960d54ad 403 }// iLoc loop
404
405 }// iReg Loop
6efe69e7 406
407 return true;
408}
409
7af42d4d 410
411// !!!!!!!!!!!! THIS IS A COMPLETE HACK !!!!!!!!!
412// The following intermediate structures should not be necessary
413// in a proper implementation. This will have to be fixed.
414struct HitInfo
415{
416 AliHLTMUONRecHitStruct fHit;
417 AliHLTInt32_t fChamber;
418 AliHLTInt32_t fTrigRecId;
419};
420
421// This array stores the reconstructed hits with extra chamber numbers
422// and trigger records numbers.
423std::vector<HitInfo> hitInfo;
424// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
425
426
6efe69e7 427bool AliHLTMUONTriggerReconstructor::FindTrigHits()
428{
6efe69e7 429
960d54ad 430 map<int,DataIdIndex>::iterator it;
6efe69e7 431
7af42d4d 432 hitInfo.clear();
960d54ad 433 for(it = fDetElemToDataId.begin(); it != fDetElemToDataId.end(); it++){
434 HLTDebug("Nof data found in Detelem : %d = %d",it->first,(it->second).size());
435 if(!MergeTrigHits(it->second))
436 return false;
6efe69e7 437 }// loop over detection element
7af42d4d 438
439// !!!!!!!!!!!! THIS IS A COMPLETE HACK !!!!!!!!!
440
441 // We now have to go through the list of reconstructed hits
442 // and collect all the ones that belong to a given trigger record.
443 while (hitInfo.size() > 0)
444 {
445 bool hitset[4] = {false, false, false, false};
446
447 // Choose the current trigger record we are collecting hits for.
448 AliHLTInt32_t currentTrig = hitInfo[0].fTrigRecId;
449
450 // Find the hits that belong to the current trigger record "currentTrig"
451 for (int n = (int)hitInfo.size() - 1; n >= 0; n--)
452 {
453 if (hitInfo[n].fTrigRecId != currentTrig) continue;
454
455 assert( 0 <= hitInfo[n].fChamber and hitInfo[n].fChamber < 4 );
456 fRecPoints[(*fRecPointsCount)].fHit[hitInfo[n].fChamber] = hitInfo[n].fHit;
457 hitset[hitInfo[n].fChamber] = true;
458 hitInfo.erase(hitInfo.end());
459 }
460
461 // Make sure the hits that are not set, get set to a nil value.
462 for (int i = 0; i < 4; i++)
463 {
464 if (not hitset[i])
465 {
466 fRecPoints[(*fRecPointsCount)].fHit[i]
467 = AliHLTMUONConstants::NilRecHitStruct();
468 }
469 }
470
471 fRecPoints[(*fRecPointsCount)].fId = currentTrig;
472
473 // Calculate the momentum and fill in the flags and momentum fields.
474 AliHLTMUONCalculations::ComputeMomentum(
475 fRecPoints[(*fRecPointsCount)].fHit[0].fX,
476 fRecPoints[(*fRecPointsCount)].fHit[0].fY,
477 fRecPoints[(*fRecPointsCount)].fHit[2].fY,
478 fRecPoints[(*fRecPointsCount)].fHit[0].fZ,
479 fRecPoints[(*fRecPointsCount)].fHit[2].fZ
480 );
481 fRecPoints[(*fRecPointsCount)].fPx = AliHLTMUONCalculations::Px();
482 fRecPoints[(*fRecPointsCount)].fPy = AliHLTMUONCalculations::Py();
483 fRecPoints[(*fRecPointsCount)].fPz = AliHLTMUONCalculations::Pz();
484
485 fRecPoints[(*fRecPointsCount)].fFlags =
486 AliHLTMUONUtils::PackTriggerRecordFlags(
487 AliHLTMUONCalculations::Sign(),
488 hitset
489 );
490
491 // Increment the counter for the number of trigger records found.
492 (*fRecPointsCount)++;
493 if((*fRecPointsCount) == fMaxRecPointsCount){
494 HLTFatal("Nof RecHit (i.e. %d) exceeds the max nof RecHit limit %d\n",(*fRecPointsCount),fMaxRecPointsCount);
495 return false;
496 }
497 }
498
499 hitInfo.clear();
500// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6efe69e7 501
7af42d4d 502 // Reseting the fPadData to zero for next call to Run.
960d54ad 503 DataIdIndex dataIndex;
504 for(it = fDetElemToDataId.begin(); it != fDetElemToDataId.end(); it++){
505 dataIndex = it->second;
506 for(size_t i=0;i<dataIndex.size();i++){
507 fPadData[dataIndex.at(i)].fDetElemId = 0;
508 fPadData[dataIndex.at(i)].fBuspatchId = 0;
509 fPadData[dataIndex.at(i)].fIdManuChannel = 0;
510 fPadData[dataIndex.at(i)].fIX = 0 ;
511 fPadData[dataIndex.at(i)].fIY = 0 ;
512 fPadData[dataIndex.at(i)].fRealX = 0.0 ;
513 fPadData[dataIndex.at(i)].fRealY = 0.0 ;
514 fPadData[dataIndex.at(i)].fRealZ = 0.0 ;
515 fPadData[dataIndex.at(i)].fPlane = -1 ;
516 fPadData[dataIndex.at(i)].fPcbZone = -1 ;
517 fPadData[dataIndex.at(i)].fCharge = 0 ;
518 }// data per detelem loop
519 }//detelem loop
520
6efe69e7 521 return true;
522}
523
7af42d4d 524
960d54ad 525bool AliHLTMUONTriggerReconstructor::MergeTrigHits(DataIdIndex& dataIndex)
6efe69e7 526{
527 int idManuChannelB, idManuChannelNB;
528 float halfPadLengthX,halfPadLengthY;
529 float diffX,diffY;
530
960d54ad 531 HLTDebug("\tThe bending plane hits are :");
532 for(size_t iPad=0;iPad<dataIndex.size();iPad++){
533 idManuChannelB = dataIndex.at(iPad);
534 if(fPadData[idManuChannelB].fPlane == 0){
535 HLTDebug("\t detelem :%d, pcbzone : %d, (%f, %f, %f) cm",fPadData[idManuChannelB].fDetElemId,fPadData[idManuChannelB].fPcbZone,fPadData[idManuChannelB].fRealX,
536 fPadData[idManuChannelB].fRealY,fPadData[idManuChannelB].fRealZ);
537 }
538 }
539
540 HLTDebug("\tThe non-bending plane hits are :");
541 for(size_t jPad=0;jPad<dataIndex.size();jPad++){
542 idManuChannelNB = dataIndex.at(jPad);
543 if(fPadData[idManuChannelNB].fPlane == 1){
544 HLTDebug("\t detelem :%d, pcbzone : %d,(%f, %f, %f) cm",fPadData[idManuChannelNB].fDetElemId,fPadData[idManuChannelNB].fPcbZone,fPadData[idManuChannelNB].fRealX,
545 fPadData[idManuChannelNB].fRealY,fPadData[idManuChannelNB].fRealZ);
546 }
547 }
548
960d54ad 549 for(size_t iPad=0;iPad<dataIndex.size();iPad++){
550 idManuChannelB = dataIndex.at(iPad);
6efe69e7 551 if(fPadData[idManuChannelB].fPlane == 0){
552
553 halfPadLengthX = AliHLTMUONTriggerReconstructor::fgkHalfPadSizeXB[fPadData[idManuChannelB].fPcbZone] ;
554
960d54ad 555 for(size_t jPad=0;jPad<dataIndex.size();jPad++){
556 idManuChannelNB = dataIndex.at(jPad);;
6efe69e7 557 if(fPadData[idManuChannelNB].fPlane == 1){
558
559 halfPadLengthY = AliHLTMUONTriggerReconstructor::fgkHalfPadSizeYNB[fPadData[idManuChannelNB].fPcbZone] ;
560
561 if(fabsf(fPadData[idManuChannelNB].fRealX) > fabsf(fPadData[idManuChannelB].fRealX))
562 diffX = fabsf(fPadData[idManuChannelNB].fRealX) - fabsf(fPadData[idManuChannelB].fRealX);
563 else
564 diffX = fabsf(fPadData[idManuChannelB].fRealX) - fabsf(fPadData[idManuChannelNB].fRealX) ;
565
566
567 if(fabsf(fPadData[idManuChannelNB].fRealY) > fabsf(fPadData[idManuChannelB].fRealY))
568 diffY = fabsf(fPadData[idManuChannelNB].fRealY) - fabsf(fPadData[idManuChannelB].fRealY);
569 else
570 diffY = fabsf(fPadData[idManuChannelB].fRealY) - fabsf(fPadData[idManuChannelNB].fRealY) ;
960d54ad 571 HLTDebug("\tdiffX %f, halfPadLengthX %f, diffY %f, halfPadLengthY %f\n",diffX,halfPadLengthX,diffY,halfPadLengthY);
6efe69e7 572
960d54ad 573 if(diffX < halfPadLengthX + 1.0 && diffY < halfPadLengthY + 1.0 ){// added redundancy of 1.0 cm due to the pb of geometrical segmentation
6efe69e7 574
7af42d4d 575 HitInfo hit;
576 hit.fHit.fX = fPadData[idManuChannelNB].fRealX;
577 hit.fHit.fY = fPadData[idManuChannelB].fRealY;
578 hit.fHit.fZ = fPadData[idManuChannelNB].fRealZ;
579 // !!!!!!!!!!!! THIS IS A COMPLETE HACK !!!!!!!!!
580 // Remember we had to use fBuspatchId to store the chamber number,
581 // and fCharge for the trigger record's ID number.
582 hit.fChamber = fPadData[idManuChannelNB].fBuspatchId;
583 hit.fTrigRecId = fPadData[idManuChannelNB].fCharge;
584 hitInfo.push_back(hit);
585 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
586
587 //fRecPoints[(*fRecPointsCount)].fHit[0] = hit;
588 //fRecPoints[(*fRecPointsCount)].fId = fPadData[idManuChannelB].fDetElemId ;
6efe69e7 589
7af42d4d 590 //(*fRecPointsCount)++;
591 //if((*fRecPointsCount) == fMaxRecPointsCount){
592 // HLTFatal("Nof RecHit (i.e. %d) exceeds the max nof RecHit limit %d\n",(*fRecPointsCount),fMaxRecPointsCount);
593 // return false;
594 //}
6efe69e7 595
960d54ad 596 HLTDebug("\t\t\tdetelem : %d, x %f, y %f, z %f\n",fPadData[idManuChannelB].fDetElemId,fPadData[idManuChannelNB].fRealX,
6efe69e7 597 fPadData[idManuChannelB].fRealY,fPadData[idManuChannelB].fRealZ);
598 }
599
6efe69e7 600 }//condn for non-bending plane
601 }//for loop for non-bending plane
602
603 }// condn for bending plane
604 }// for loop for bending plane
7af42d4d 605
6efe69e7 606 return true;
607}
608