1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
6 * Indranil Das <indra.das@saha.ac.in> *
7 * Artur Szostak <artursz@iafrica.com> *
9 * Permission to use, copy, modify and distribute this software and its *
10 * documentation strictly for non-commercial purposes is hereby granted *
11 * without fee, provided that the above copyright notice appears in all *
12 * copies and that both the copyright notice and this permission notice *
13 * appear in the supporting documentation. The authors make no claims *
14 * about the suitability of this software for any purpose. It is *
15 * provided "as is" without express or implied warranty. *
16 **************************************************************************/
20 /**********************************************************************
21 Created on : 16/05/2007
22 Purpose : This class reads the tracker DDL files and gives the output
23 as AliMUONTriggerRecordStruct structures.
24 Author : Indranil Das, HEP Division, SINP
25 Email : indra.das@saha.ac.in | indra.ehep@gmail.com
27 Artur Szostak <artursz@iafrica.com>:
28 Completely reimplemented the lookup table to a simplified format.
29 **********************************************************************/
33 // The trigger reconstructor class is designed to deal the rawdata inputfiles
34 // to findout the the reconstructed hits at the trigger DDL. The output is send
35 // to the output block for further processing.
37 // Author : Indranil Das ( indra.das@saha.ac.in || indra.ehep@gmail.com )
41 #include "AliHLTMUONTriggerReconstructor.h"
42 #include "AliHLTMUONUtils.h"
43 #include "AliHLTMUONConstants.h"
44 #include "AliHLTMUONCalculations.h"
49 AliHLTMUONTriggerReconstructor::AliHLTMUONTriggerReconstructor() :
50 fMaxRecPointsCount(0),
55 for (Int_t i = 0; i < 8; i++)
56 for (Int_t j = 0; j < 16; j++)
57 for (Int_t k = 0; k < 4; k++)
58 for (Int_t n = 0; n < 2; n++)
59 for (Int_t m = 0; m < 16; m++)
61 fLookupTable[i][j][k][n][m].fX = 0;
62 fLookupTable[i][j][k][n][m].fY = 0;
63 fLookupTable[i][j][k][n][m].fZ = 0;
68 AliHLTMUONTriggerReconstructor::~AliHLTMUONTriggerReconstructor()
74 bool AliHLTMUONTriggerReconstructor::Run(
75 const AliHLTUInt32_t* rawData,
76 // TODO: if we are not checking rawDataSize then it means we are
77 // not parsing the raw data safely or checking for corruption carefully.
78 // This must be fixed at some point.
79 AliHLTUInt32_t /*rawDataSize*/,
80 AliHLTMUONTriggerRecordStruct* trigRecord,
81 AliHLTUInt32_t& nofTrigRec,
82 bool suppressPartialTrigs
85 fMaxRecPointsCount = nofTrigRec;
87 // nofTrigRec now becomes the output of how many trigger records were found.
91 int reg_output, reg_phys_trig_occur;
92 int iLocIndex,loc,locDec,triggY,sign,loDev,triggX;
93 short pattern[2][4]; // 2 stands for two cathode planes and 4 stands for 4 chambers
95 int phys_trig_occur = (rawData[index]>>30)&0x1; // 1 for physics trigger, 0 for software trigger
97 if (not phys_trig_occur) // for software trigger
98 index += 8 ;// corresponding to scalar words
100 index += 1 ; // To skip the separator 0xDEADFACE
102 index += 4 ; // corresponding to global input
104 index += 1 ; // reaches to global output
106 if (not phys_trig_occur) index += 10; // corresponds to scalar words
108 index += 1; // separator 0xDEADBEEF
110 for (int iReg = 0; iReg < 8; iReg++)
112 index += 1; // DARC Status Word
113 index += 1; // Regeional Word
114 reg_output = rawData[index] & 0xFF;
115 reg_phys_trig_occur = ( rawData[index] >> 31) & 0x1;
117 index += 2; // 2 words for regional input
119 index += 1; // L0 counter
121 if (not reg_phys_trig_occur) index += 10;
123 index += 1; // end of Regeonal header 0xBEEFFACE
125 for(int iLoc = 0; iLoc < 16 ; iLoc++)
129 loc = (rawData[index+5] >> 19) & 0xF ;
131 locDec = (rawData[index+5] >> 15) & 0xF;
132 triggY = (rawData[index+5] >> 14) & 0x1;
133 sign = (rawData[index+5] >> 9) & 0x1;
134 loDev = (rawData[index+5] >> 5) & 0xF ;
135 triggX = (loDev >> 4 & 0x1 ) && !(loDev & 0xF);
141 pattern[0][0] = rawData[index] & 0xFFFF; // x-strip pattern for chamber 0
142 pattern[0][1] = (rawData[index] >> 16) & 0xFFFF; // x-strip pattern for chamber 1
144 pattern[0][2] = rawData[index] & 0xFFFF;
145 pattern[0][3] = (rawData[index] >> 16) & 0xFFFF;
148 pattern[1][0] = rawData[index] & 0xFFFF; // y-strip pattern for chamber 0
149 pattern[1][1] = (rawData[index] >> 16) & 0xFFFF; // y-strip pattern for chamber 0
151 pattern[1][2] = rawData[index] & 0xFFFF;
152 pattern[1][3] = (rawData[index] >> 16) & 0xFFFF;
154 if (pattern[0][0] || pattern[0][1] || pattern[0][2] || pattern[0][3]
155 || pattern[1][0] || pattern[1][1] || pattern[1][2] || pattern[1][3]
158 if (nofTrigRec == fMaxRecPointsCount)
160 HLTError("Output buffer is overflowed maximum assiged arraysize : %d, present array index : %d",
161 fMaxRecPointsCount, nofTrigRec
166 bool Xset[4] = {false, false, false, false};
167 bool Yset[4] = {false, false, false, false};
169 for (int iChamber = 0; iChamber < 4 ; iChamber++) //4 chambers per DDL
170 for (int iPlane = 0; iPlane < 2 ; iPlane++) // 2 cathode plane
172 for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy)
174 if (((pattern[iPlane][iChamber] >> ibitxy) & 0x1) != 0x1)
179 trigRecord[nofTrigRec].fHit[iChamber].fX =
180 fLookupTable[iReg][iLoc][iChamber][iPlane][ibitxy].fX;
181 Xset[iChamber] = true;
185 trigRecord[nofTrigRec].fHit[iChamber].fY =
186 fLookupTable[iReg][iLoc][iChamber][iPlane][ibitxy].fY;
187 trigRecord[nofTrigRec].fHit[iChamber].fZ =
188 fLookupTable[iReg][iLoc][iChamber][iPlane][ibitxy].fZ;
189 Yset[iChamber] = true;
195 // hitset indicates which hits on chambers 7 to 10 have been found and filled.
196 bool hitset[4] = {false, false, false, false};
198 // Fill the hitset flags and make sure the hit structures that were not
199 // filled (set) get set to a nil value.
200 for (int i = 0; i < 4; i++)
202 hitset[i] = Xset[i] and Yset[i];
206 trigRecord[nofTrigRec].fHit[i]
207 = AliHLTMUONConstants::NilRecHitStruct();
211 trigRecord[nofTrigRec].fId = fTrigRecId;
213 // Increment trigger record Id and keep it positive.
214 //TODO: handle the wrapparound better.
215 if (fTrigRecId < 0x7FFFFFFF)
220 AliHLTMUONRecHitStruct* hit1 = NULL;
222 hit1 = &trigRecord[nofTrigRec].fHit[0];
224 hit1 = &trigRecord[nofTrigRec].fHit[1];
225 AliHLTMUONRecHitStruct* hit2 = NULL;
227 hit2 = &trigRecord[nofTrigRec].fHit[2];
229 hit2 = &trigRecord[nofTrigRec].fHit[3];
231 if (hit1 != NULL and hit2 != NULL)
233 // Calculate the momentum and fill in the flags and momentum fields.
234 AliHLTMUONCalculations::ComputeMomentum(
239 trigRecord[nofTrigRec].fPx = AliHLTMUONCalculations::Px();
240 trigRecord[nofTrigRec].fPy = AliHLTMUONCalculations::Py();
241 trigRecord[nofTrigRec].fPz = AliHLTMUONCalculations::Pz();
243 trigRecord[nofTrigRec].fFlags =
244 AliHLTMUONUtils::PackTriggerRecordFlags(
245 AliHLTMUONCalculations::Sign(),
251 else if ((hit1 != NULL or hit2 != NULL) and not suppressPartialTrigs)
253 trigRecord[nofTrigRec].fPx = 0;
254 trigRecord[nofTrigRec].fPy = 0;
255 trigRecord[nofTrigRec].fPz = 0;
257 trigRecord[nofTrigRec].fFlags =
258 AliHLTMUONUtils::PackTriggerRecordFlags(
266 }// if any non zero pattern found
268 index += 1 ; // the last word, important one
271 if (not reg_phys_trig_occur)
274 index += 1; // end of local Data 0xCAFEFADE
276 index = iLocIndex + 6; //important to reset the index counter for fake locids like 235