1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Antonio Stamerra 1/2003 <mailto:antono.stamerra@pi.infn.it>
|
---|
19 | ! Author(s): Marcos Lopez 1/2003 <mailto:marcos@gae.ucm.es>
|
---|
20 | ! Author(s): Nicola Galante 7/2003 <mailto:nicola.galante@pi.infn.it>
|
---|
21 | !
|
---|
22 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
23 | !
|
---|
24 | !
|
---|
25 | \* ======================================================================== */
|
---|
26 |
|
---|
27 |
|
---|
28 | /////////////////////////////////////////////////////////////////////////////
|
---|
29 | // //
|
---|
30 | // MMcTriggerLvl2 //
|
---|
31 | // Storage container for the 2nd level trigger selection parameters //
|
---|
32 | // as part of the 2nd level trigger simulation //
|
---|
33 | // //
|
---|
34 | // input parameter: //
|
---|
35 | // fCompactNN number of next neighboors that define a compact pixel //
|
---|
36 | // //
|
---|
37 | // //
|
---|
38 | // Basic L2T Selection Parameters: //
|
---|
39 | // //
|
---|
40 | // fLutPseudoSize number of compact pixels in one LUT //
|
---|
41 | // fPseudoSize Multiplicity of the bigger cluster //
|
---|
42 | // fSizeBiggerCell higher number of fired pixel in cell //
|
---|
43 | // //
|
---|
44 | /////////////////////////////////////////////////////////////////////////////
|
---|
45 |
|
---|
46 | #include "MMcTriggerLvl2.h"
|
---|
47 |
|
---|
48 | #include "MGeomCam.h"
|
---|
49 | #include "MGeomPix.h"
|
---|
50 | #include "MGeomCamMagic.h"
|
---|
51 |
|
---|
52 | #include "MMcTrig.hxx"
|
---|
53 |
|
---|
54 | #include "MMcEvt.hxx"
|
---|
55 |
|
---|
56 | #include "MLog.h"
|
---|
57 |
|
---|
58 | #include <TCanvas.h>
|
---|
59 |
|
---|
60 | ClassImp(MMcTriggerLvl2);
|
---|
61 |
|
---|
62 | using namespace std;
|
---|
63 |
|
---|
64 | // ---------------------------
|
---|
65 | // Initialization of static const data members pixel_in_cell and pixel_in_lut
|
---|
66 |
|
---|
67 | //
|
---|
68 | // Correspondence TABLE between pixel numbering in the trigger cells and
|
---|
69 | // the standard spiral counting
|
---|
70 | // (Note: Pixels start to count from 1 instead of 0)
|
---|
71 | //
|
---|
72 | // This correspondence is valid only for MAGIC-like geometries!
|
---|
73 | //
|
---|
74 | const Int_t MMcTriggerLvl2::gsPixelsInCell[36][19] = {
|
---|
75 | {26, 91, 66, 71, 76, 81, 86, 269, 224, 233, 242, 251, 260, 391, 336, 347, 358, 369, 380},
|
---|
76 | {25, 61, 41, 45, 49, 53, 57, 215, 175, 183, 191, 199, 207, 325, 275, 285, 295, 305, 315},
|
---|
77 | {24, 37, 22, 25, 28, 31, 34, 167, 132, 139, 146, 153, 160, 265, 220, 229, 238, 247, 256},
|
---|
78 | {23, 19, 9, 11, 13, 15, 17, 125, 95, 101, 107, 113, 119, 211, 171, 179, 187, 195, 203},
|
---|
79 | {27, 62, 67, 72, 77, 82, 87, 270, 225, 234, 243, 252, 261, 392, 337, 348, 359, 370, 381},
|
---|
80 | {12, 38, 42, 46, 50, 54, 58, 216, 176, 184, 192, 200, 208, 326, 276, 286, 296, 306, 316},
|
---|
81 | {11, 20, 23, 26, 29, 32, 35, 168, 133, 140, 147, 154, 161, 266, 221, 230, 239, 248, 257},
|
---|
82 | {10, 8, 10, 12, 14, 16, 18, 126, 96, 102, 108, 114, 120, 212, 172, 180, 188, 196, 204},
|
---|
83 | {22, 2, 3, 4, 5, 6, 7, 90, 65, 70, 75, 80, 85, 164, 129, 136, 143, 150, 157},
|
---|
84 | {28, 93, 99, 105, 111, 117, 123, 271, 226, 235, 244, 253, 262, 393, 338, 349, 360, 371, 382},
|
---|
85 | {13, 63, 68, 73, 78, 83, 88, 217, 177, 185, 193, 201, 209, 327, 277, 287, 297, 307, 317},
|
---|
86 | { 4, 39, 43, 47, 51, 55, 59, 169, 134, 141, 148, 155, 162, 267, 222, 231, 240, 249, 258},
|
---|
87 | { 3, 21, 24, 27, 30, 33, 36, 127, 97, 103, 109, 115, 121, 213, 173, 181, 189, 197, 205},
|
---|
88 | { 9, 9, 11, 13, 15, 17, 19, 91, 66, 71, 76, 81, 86, 165, 130, 137, 144, 151, 158},
|
---|
89 | {21, 3, 4, 5, 6, 7, 2, 61, 41, 45, 49, 53, 57, 123, 93, 99, 105, 111, 117},
|
---|
90 | {29, 130, 137, 144, 151, 158, 165, 218, 227, 236, 245, 254, 263, 394, 339, 350, 361, 372, 383},
|
---|
91 | {14, 94, 100, 106, 112, 118, 124, 170, 178, 186, 194, 202, 210, 328, 278, 288, 298, 308, 318},
|
---|
92 | { 5, 64, 69, 74, 79, 84, 89, 128, 135, 142, 149, 156, 163, 268, 223, 232, 241, 250, 259},
|
---|
93 | { 1, 40, 44, 48, 52, 56, 60, 92, 98, 104, 110, 116, 122, 214, 174, 182, 190, 198, 206},
|
---|
94 | { 2, 22, 25, 28, 31, 34, 37, 62, 67, 72, 77, 82, 87, 166, 131, 138, 145, 152, 159},
|
---|
95 | { 8, 10, 12, 14, 16, 18, 8, 38, 42, 46, 50, 54, 58, 124, 94, 100, 106, 112, 118},
|
---|
96 | {20, 11, 13, 15, 17, 19, 9, 20, 23, 26, 29, 32, 35, 88, 63, 68, 73, 78, 83},
|
---|
97 | {30, 131, 138, 145, 152, 159, 166, 219, 228, 237, 246, 255, 264, 329, 279, 289, 299, 309, 319},
|
---|
98 | {15, 95, 101, 107, 113, 119, 125, 171, 179, 187, 195, 203, 211, 269, 224, 233, 242, 251, 260},
|
---|
99 | { 6, 65, 70, 75, 80, 85, 90, 129, 136, 143, 150, 157, 164, 215, 175, 183, 191, 199, 207},
|
---|
100 | { 7, 41, 45, 49, 53, 57, 61, 93, 99, 105, 111, 117, 123, 167, 132, 139, 146, 153, 160},
|
---|
101 | {19, 23, 26, 29, 32, 35, 20, 63, 68, 73, 78, 83, 88, 125, 95, 101, 107, 113, 119},
|
---|
102 | {37, 24, 27, 30, 33, 36, 21, 39, 43, 47, 51, 55, 59, 89, 64, 69, 74, 79, 84},
|
---|
103 | {31, 132, 139, 146, 153, 160, 167, 220, 229, 238, 247, 256, 265, 270, 225, 234, 243, 252, 261},
|
---|
104 | {16, 96, 102, 108, 114, 120, 126, 172, 180, 188, 196, 204, 212, 216, 176, 184, 192, 200, 208},
|
---|
105 | {17, 66, 71, 76, 81, 86, 91, 130, 137, 144, 151, 158, 165, 168, 133, 140, 147, 154, 161},
|
---|
106 | {18, 42, 46, 50, 54, 58, 38, 94, 100, 106, 112, 118, 124, 126, 96, 102, 108, 114, 120},
|
---|
107 | {36, 43, 47, 51, 55, 59, 39, 64, 69, 74, 79, 84, 89, 90, 65, 70, 75, 80, 85},
|
---|
108 | {32, 133, 140, 147, 154, 161, 168, 221, 230, 239, 248, 257, 266, 217, 177, 185, 193, 201, 209},
|
---|
109 | {33, 97, 103, 109, 115, 121, 127, 173, 181, 189, 197, 205, 213, 169, 134, 141, 148, 155, 162},
|
---|
110 | {35, 68, 73, 78, 83, 88, 63, 95, 101, 107, 113, 119, 125, 91, 66, 71, 76, 81, 86}
|
---|
111 | };
|
---|
112 |
|
---|
113 | //
|
---|
114 | // corrispondence between pixels in cell and lut (pix numbering starts from 1)
|
---|
115 | //
|
---|
116 | const Int_t MMcTriggerLvl2::gsPixelsInLut[3][12] = {
|
---|
117 | { 1, 2, 3, 4, 6, 7, 8, 9, 12, 13, 14, 15},
|
---|
118 | {34, 29, 23, 16, 30, 24, 17, 10, 25, 18, 11, 5},
|
---|
119 | {35, 31, 26, 20, 19, 32, 27, 21, 36, 33, 28, 22},
|
---|
120 | };
|
---|
121 |
|
---|
122 |
|
---|
123 | // --------------------------------------------------------------------------
|
---|
124 | //
|
---|
125 | // Default constructor
|
---|
126 | //
|
---|
127 | MMcTriggerLvl2::MMcTriggerLvl2(const char *name, const char *title):fCompactNN(2),fTriggerPattern(0)
|
---|
128 | {
|
---|
129 | fName = name ? name : ClassName();
|
---|
130 | fTitle = title;
|
---|
131 |
|
---|
132 | *fLog << "created MMcTriggerLvl2" << endl;
|
---|
133 |
|
---|
134 | //
|
---|
135 | // Initialization of the fPixels array to zero
|
---|
136 | //
|
---|
137 | memset (fPixels,0,36*19*sizeof(Int_t));
|
---|
138 | memset (fFiredPixel,0,397*sizeof(Int_t));
|
---|
139 |
|
---|
140 | // create a new camera
|
---|
141 | SetNewCamera(new MGeomCamMagic);
|
---|
142 |
|
---|
143 | }
|
---|
144 |
|
---|
145 | // --------------------------------------------------------------------------
|
---|
146 | //
|
---|
147 | // Destructor
|
---|
148 | //
|
---|
149 | MMcTriggerLvl2::~MMcTriggerLvl2()
|
---|
150 | {
|
---|
151 | delete fGeomCam;
|
---|
152 | }
|
---|
153 |
|
---|
154 | // --------------------------------------------------------------------------
|
---|
155 | //
|
---|
156 | // Print functions for debugging and testing
|
---|
157 | //
|
---|
158 | // Options available:
|
---|
159 | //
|
---|
160 | // "cell":
|
---|
161 | // Print out the pixel number of a given trigger cell
|
---|
162 | //
|
---|
163 | // "status":
|
---|
164 | // Print a table with the status (pixel is fired or not after Lvl1) for
|
---|
165 | // all the pixels in all the trigger cells
|
---|
166 | //
|
---|
167 | // no option:
|
---|
168 | // Print the value of the selection parameters
|
---|
169 | //
|
---|
170 | //
|
---|
171 | void MMcTriggerLvl2::Print(Option_t *opt) const
|
---|
172 | {
|
---|
173 | TString str(opt);
|
---|
174 |
|
---|
175 | if (str.Contains("status", TString::kIgnoreCase))
|
---|
176 | {
|
---|
177 | *fLog << " Status of cells 1-9" <<endl;
|
---|
178 | for(int i=0; i<36; i++)
|
---|
179 | {
|
---|
180 | for(int j=0; j<9; j++)
|
---|
181 | {
|
---|
182 | // *fLog.width(3);
|
---|
183 | *fLog <<gsPixelsInCell[i][j]-1 << ":" << fPixels[i][j] << "\t ";
|
---|
184 | }
|
---|
185 | *fLog << endl;
|
---|
186 | }
|
---|
187 | }
|
---|
188 | else if (str.Contains("cell", TString::kIgnoreCase))
|
---|
189 | {
|
---|
190 | *fLog << " Pixel numbering in cells 1-9" <<endl;
|
---|
191 | for (int i=0;i<36;i++)
|
---|
192 | {
|
---|
193 | for(int j=0; j<9; j++)
|
---|
194 | {
|
---|
195 | *fLog << gsPixelsInCell[i][j]-1 << "\t";
|
---|
196 | }
|
---|
197 | *fLog << endl;
|
---|
198 | }
|
---|
199 | }
|
---|
200 | else
|
---|
201 | {
|
---|
202 | *fLog << " L2T selection parameters:" << endl;
|
---|
203 | *fLog << " - LutPseudoSize = " << fLutPseudoSize << endl;
|
---|
204 | *fLog << " - PseudoSize = " << fPseudoSize << endl;
|
---|
205 | *fLog << " - BiggerCellSize = " << fSizeBiggerCell << endl;
|
---|
206 | *fLog << " - TriggerPattern = " << fTriggerPattern << endl;
|
---|
207 | }
|
---|
208 |
|
---|
209 | }
|
---|
210 |
|
---|
211 | // --------------------------------------------------------------------------
|
---|
212 | //
|
---|
213 | // Take the information supplied by the Lvl1 (it reads from the object MMcTrig
|
---|
214 | // the status of all pixels after Lvl1) and pass it to the Lvl2 (fill the
|
---|
215 | // array fPixels)
|
---|
216 | //
|
---|
217 | //
|
---|
218 | void MMcTriggerLvl2::SetLv1(MMcTrig *trig)
|
---|
219 | {
|
---|
220 | if (!trig)
|
---|
221 | return;
|
---|
222 |
|
---|
223 | fMcTrig = trig;
|
---|
224 |
|
---|
225 | for(int i=0; i<36; i++)
|
---|
226 | {
|
---|
227 | for(int j=0; j<19; j++)
|
---|
228 | {
|
---|
229 | int pixel = gsPixelsInCell[i][j]-1;
|
---|
230 | fPixels[i][j] = (fMcTrig->IsPixelFired(pixel,0)) ? 1 : 0;
|
---|
231 | fFiredPixel[pixel]=(fMcTrig->IsPixelFired(pixel,0)) ? 1 : 0;
|
---|
232 | //if (fFiredPixel[pixel]==1)
|
---|
233 | //*fLog << pixel<<",";
|
---|
234 | }
|
---|
235 | }
|
---|
236 | //*fLog<<endl<<"Fine evento"<<endl;
|
---|
237 | }
|
---|
238 |
|
---|
239 |
|
---|
240 | // --------------------------------------------------------------------------
|
---|
241 | //
|
---|
242 | // Set the trigger status ( pixel fired(=1) or not(=0) ) manually for a given
|
---|
243 | // pixel of a given cell
|
---|
244 | //
|
---|
245 | //
|
---|
246 | void MMcTriggerLvl2::SetPixelFired(Int_t pixel, Int_t fired)
|
---|
247 | {
|
---|
248 | for(int i=0; i<36; i++)
|
---|
249 | {
|
---|
250 | for(int j=0; j<19; j++)
|
---|
251 | {
|
---|
252 | if(gsPixelsInCell[i][j]-1==pixel) fPixels[i][j]=fired;
|
---|
253 | }
|
---|
254 | }
|
---|
255 |
|
---|
256 | }
|
---|
257 |
|
---|
258 | // --------------------------------------------------------------------------
|
---|
259 | //
|
---|
260 | // Calculate the Level 2 Trigger (L2T) parameters. They can be used
|
---|
261 | // to select the events that have passed the L2T selection rule.
|
---|
262 | //
|
---|
263 | //
|
---|
264 | void MMcTriggerLvl2::Calc()
|
---|
265 | {
|
---|
266 |
|
---|
267 | // Find the Lut and cell with the higher LutPseudoSize.
|
---|
268 | int lutcell = CalcBiggerLutPseudoSize();
|
---|
269 | int maxcell = lutcell/10;
|
---|
270 | int maxlut = lutcell-maxcell*10;
|
---|
271 | fLutPseudoSize = GetLutCompactPixel(maxcell,maxlut);
|
---|
272 |
|
---|
273 | CalcPseudoSize();
|
---|
274 |
|
---|
275 | fSizeBiggerCell = GetCellNumberFired(CalcBiggerFiredCell());
|
---|
276 |
|
---|
277 | //*fLog << "fLPS="<<fLutPseudoSize<<endl;
|
---|
278 | }
|
---|
279 |
|
---|
280 |
|
---|
281 |
|
---|
282 | // --------------------------------------------------------------------------
|
---|
283 | //
|
---|
284 | // For a given cell, just count how many pixels have been fired after Lvl1
|
---|
285 | //
|
---|
286 | Int_t MMcTriggerLvl2::GetCellNumberFired(int cell)
|
---|
287 | {
|
---|
288 | int size=0;
|
---|
289 |
|
---|
290 | for(int i=0; i<36; i++)
|
---|
291 | {
|
---|
292 | size += fPixels[i][cell];
|
---|
293 | }
|
---|
294 |
|
---|
295 | return size;
|
---|
296 |
|
---|
297 | }
|
---|
298 |
|
---|
299 |
|
---|
300 | // --------------------------------------------------------------------------
|
---|
301 | //
|
---|
302 | // Find the cell which the bigger number of fired pixels
|
---|
303 | //
|
---|
304 | //
|
---|
305 | Int_t MMcTriggerLvl2::CalcBiggerFiredCell()
|
---|
306 | {
|
---|
307 | int size=-1;
|
---|
308 | int cell=-1;
|
---|
309 |
|
---|
310 | for(int j=0; j<19; j++)
|
---|
311 | {
|
---|
312 | if (GetCellNumberFired(j) > size)
|
---|
313 | {
|
---|
314 | size = GetCellNumberFired(j);
|
---|
315 | cell = j;
|
---|
316 | }
|
---|
317 | }
|
---|
318 |
|
---|
319 | // *fLog << "size " <<size <<" in cell " << cell << endl;
|
---|
320 |
|
---|
321 | return cell;
|
---|
322 |
|
---|
323 | }
|
---|
324 |
|
---|
325 | // --------------------------------------------------------------------------
|
---|
326 | //
|
---|
327 | // Calculate the higher LutPseudoSize of one event defined as the higher number
|
---|
328 | // of compact pixel in the LUTs of the trigger cells.
|
---|
329 | // neighpix is the number of Next-Neighbors which defines the compact pixel
|
---|
330 | // topology (it can be 2-NN or 3-NN)
|
---|
331 | //
|
---|
332 | // It returns the cell and the LUT with the bigger LutPseudoSize, coded
|
---|
333 | // accordingly to: cell*10 + LUT
|
---|
334 | //
|
---|
335 | Int_t MMcTriggerLvl2::CalcBiggerLutPseudoSize()
|
---|
336 | {
|
---|
337 | int size=0;
|
---|
338 | int cell=-1;
|
---|
339 | int lut=-1;
|
---|
340 |
|
---|
341 | for(int j=0; j<19; j++)
|
---|
342 | {
|
---|
343 | for(int i=0; i<3; i++)
|
---|
344 | {
|
---|
345 | if (GetLutCompactPixel(j,i) >= size)
|
---|
346 | {
|
---|
347 | size = GetLutCompactPixel(j,i);
|
---|
348 | cell = j;
|
---|
349 | lut = i;
|
---|
350 | }
|
---|
351 | }
|
---|
352 | }
|
---|
353 |
|
---|
354 | //*fLog <<"Max cell: " << cell+1 << " Max Lut: " << lut+1 << " PseudoSize: " << size <<endl;
|
---|
355 |
|
---|
356 | return cell*10+lut;
|
---|
357 | }
|
---|
358 |
|
---|
359 |
|
---|
360 | // --------------------------------------------------------------------------
|
---|
361 | //
|
---|
362 | // Identify compact pixels in one LUT and calculate the LutPseudoSize
|
---|
363 | // (=number of compact pixels in one LUT)
|
---|
364 | // neighpix is the number of Next-Neighbors which defines the compact pixel
|
---|
365 | // topology.
|
---|
366 | // Up to now only 2NN or 3NN are considered
|
---|
367 | // <!if changed: change check made by Preprocess in MMcTriggerLvl2Calc>
|
---|
368 | //
|
---|
369 | // Returns:
|
---|
370 | // -1 wrong neighpix
|
---|
371 | // -2 wrong cell (<1 or >19)
|
---|
372 | // -3 wrong lut (<1 or >3)
|
---|
373 | // else:
|
---|
374 | // the number of compact pixels in one LUT.
|
---|
375 | //
|
---|
376 | Int_t MMcTriggerLvl2::GetLutCompactPixel(int cell, int lut)
|
---|
377 | {
|
---|
378 | int size=0;
|
---|
379 | int lutpix, a[12];
|
---|
380 | int neighpix= (*this).fCompactNN;
|
---|
381 |
|
---|
382 | // check on input variables
|
---|
383 |
|
---|
384 | if (neighpix >3 || neighpix < 2)
|
---|
385 | return(-1);
|
---|
386 |
|
---|
387 | if (cell<0 || cell>18)
|
---|
388 | return(-2);
|
---|
389 |
|
---|
390 | if (lut<0 || lut>2)
|
---|
391 | return(-3);
|
---|
392 |
|
---|
393 |
|
---|
394 | // LUT 1 and 2 are similar; LUT 3 differs
|
---|
395 |
|
---|
396 | for(int j=0; j<12; j++)
|
---|
397 | {
|
---|
398 | lutpix = gsPixelsInLut[lut][j]-1;
|
---|
399 | // *fLog << "j=" <<j<<" lutpix="<<lutpix<<" Cell="<<cell<<endl;
|
---|
400 | a[j] = fPixels[lutpix][cell];
|
---|
401 | }
|
---|
402 |
|
---|
403 | //
|
---|
404 | // Look for compact pixels 2NN
|
---|
405 | //
|
---|
406 | if (neighpix==2)
|
---|
407 | {
|
---|
408 | // case Lut 1 and 2
|
---|
409 | if (lut == 0 || lut == 1)
|
---|
410 | {
|
---|
411 | if (a[0] && a[1] && a[4])
|
---|
412 | size ++;
|
---|
413 | if (a[1] && ((a[0] && a[4]) ||
|
---|
414 | (a[4] && a[5]) ||
|
---|
415 | (a[5] && a[2]) ))
|
---|
416 | size ++;
|
---|
417 | if (a[2] && ((a[1] && a[5]) ||
|
---|
418 | (a[5] && a[6]) ||
|
---|
419 | (a[6] && a[3]) ))
|
---|
420 | size ++;
|
---|
421 | if (a[3] && ((a[2] && a[6]) ||
|
---|
422 | (a[6] && a[7]) ))
|
---|
423 | size ++;
|
---|
424 | if (a[4] && ((a[0] && a[1]) ||
|
---|
425 | (a[1] && a[5]) ||
|
---|
426 | (a[5] && a[8]) ))
|
---|
427 | size ++;
|
---|
428 | if (a[5] && ((a[1] && a[2]) ||
|
---|
429 | (a[2] && a[6]) ||
|
---|
430 | (a[6] && a[9]) ||
|
---|
431 | (a[9] && a[8]) ||
|
---|
432 | (a[8] && a[4]) ||
|
---|
433 | (a[4] && a[1]) ))
|
---|
434 | size ++;
|
---|
435 | if (a[6] && ((a[2] && a[3]) ||
|
---|
436 | (a[3] && a[7]) ||
|
---|
437 | (a[7] && a[10]) ||
|
---|
438 | (a[10] && a[9]) ||
|
---|
439 | (a[9] && a[5]) ||
|
---|
440 | (a[5] && a[2]) ))
|
---|
441 | size ++;
|
---|
442 | if (a[7] && ((a[3] && a[6]) ||
|
---|
443 | (a[6] && a[10]) ||
|
---|
444 | (a[10] && a[11]) ))
|
---|
445 | size ++;
|
---|
446 | if (a[8] && ((a[4] && a[5]) ||
|
---|
447 | (a[5] && a[9]) ))
|
---|
448 | size ++;
|
---|
449 | if (a[9] && ((a[8] && a[5]) ||
|
---|
450 | (a[5] && a[6]) ||
|
---|
451 | (a[6] && a[10]) ))
|
---|
452 | size ++;
|
---|
453 | if (a[10] && ((a[9] && a[6]) ||
|
---|
454 | (a[6] && a[7]) ||
|
---|
455 | (a[7] && a[11]) ))
|
---|
456 | size ++;
|
---|
457 | if (a[11] && a[7] && a[10])
|
---|
458 | size ++;
|
---|
459 | }
|
---|
460 |
|
---|
461 | // case Lut 3
|
---|
462 | if (lut==2)
|
---|
463 | {
|
---|
464 | if (a[0] && a[1] && a[5])
|
---|
465 | size ++;
|
---|
466 | if (a[1] && ((a[0] && a[5]) ||
|
---|
467 | (a[5] && a[2]) ))
|
---|
468 | size ++;
|
---|
469 | if (a[2] && ((a[1] && a[5]) ||
|
---|
470 | (a[5] && a[6]) ||
|
---|
471 | (a[3] && a[4]) ||
|
---|
472 | (a[6] && a[3]) ))
|
---|
473 | size ++;
|
---|
474 | if (a[3] && ((a[2] && a[6]) ||
|
---|
475 | (a[6] && a[7]) ||
|
---|
476 | (a[2] && a[4]) ))
|
---|
477 | size ++;
|
---|
478 | if (a[4] && ((a[2] && a[3]) ))
|
---|
479 | size ++;
|
---|
480 | if (a[5] && ((a[1] && a[2]) ||
|
---|
481 | (a[2] && a[6]) ||
|
---|
482 | (a[6] && a[9]) ||
|
---|
483 | (a[9] && a[8]) ))
|
---|
484 | size ++;
|
---|
485 | if (a[6] && ((a[2] && a[3]) ||
|
---|
486 | (a[3] && a[7]) ||
|
---|
487 | (a[7] && a[10]) ||
|
---|
488 | (a[10] && a[9]) ||
|
---|
489 | (a[9] && a[5]) ||
|
---|
490 | (a[5] && a[2]) ))
|
---|
491 | size ++;
|
---|
492 | if (a[7] && ((a[3] && a[6]) ||
|
---|
493 | (a[6] && a[10]) ||
|
---|
494 | (a[10] && a[11]) ))
|
---|
495 | size ++;
|
---|
496 | if (a[8] && a[5] && a[9])
|
---|
497 | size ++;
|
---|
498 | if (a[9] && ((a[8] && a[5]) ||
|
---|
499 | (a[5] && a[6]) ||
|
---|
500 | (a[6] && a[10]) ))
|
---|
501 | size ++;
|
---|
502 | if (a[10] && ((a[9] && a[6]) ||
|
---|
503 | (a[6] && a[7]) ||
|
---|
504 | (a[7] && a[11]) ))
|
---|
505 | size ++;
|
---|
506 | if (a[11] && a[7] && a[10])
|
---|
507 | size ++;
|
---|
508 | }
|
---|
509 | }
|
---|
510 |
|
---|
511 | //
|
---|
512 | // Look for compact pixels 3NN
|
---|
513 | //
|
---|
514 | if (neighpix==3)
|
---|
515 | {
|
---|
516 | // case Lut 1 and 2
|
---|
517 | if (lut == 0 || lut == 1)
|
---|
518 | {
|
---|
519 | if (a[0] && a[1] && a[4] && a[5]) // pix 0 is compact if there is a 4NN
|
---|
520 | size ++;
|
---|
521 | if (a[1] && ((a[0] && a[4] && a[5]) ||
|
---|
522 | (a[2] && a[4] && a[5]) ))
|
---|
523 | size ++;
|
---|
524 | if (a[2] && ((a[1] && a[5] && a[6]) ||
|
---|
525 | (a[5] && a[6] && a[3]) ))
|
---|
526 | size ++;
|
---|
527 | if (a[3] && (a[2] && a[6] && a[7] ))
|
---|
528 | size ++;
|
---|
529 | if (a[4] && ((a[0] && a[1] && a[5]) ||
|
---|
530 | (a[1] && a[5] && a[8]) ))
|
---|
531 | size ++;
|
---|
532 | if (a[5] && ((a[1] && a[2] && a[6]) ||
|
---|
533 | (a[2] && a[6] && a[9]) ||
|
---|
534 | (a[6] && a[9] && a[8]) ||
|
---|
535 | (a[9] && a[8] && a[4]) ||
|
---|
536 | (a[8] && a[4] && a[1]) ||
|
---|
537 | (a[4] && a[1] && a[2]) ))
|
---|
538 | size ++;
|
---|
539 | if (a[6] && ((a[2] && a[3] && a[7]) ||
|
---|
540 | (a[3] && a[7] && a[10]) ||
|
---|
541 | (a[7] && a[10] && a[9]) ||
|
---|
542 | (a[10] && a[9] && a[5]) ||
|
---|
543 | (a[9] && a[5] && a[2]) ||
|
---|
544 | (a[5] && a[2] && a[3]) ))
|
---|
545 | size ++;
|
---|
546 | if (a[7] && ((a[3] && a[6] && a[10]) ||
|
---|
547 | (a[6] && a[10] && a[11]) ))
|
---|
548 | size ++;
|
---|
549 | if (a[8] && (a[4] && a[5] && a[9] ))
|
---|
550 | size ++;
|
---|
551 | if (a[9] && ((a[8] && a[5] && a[6]) ||
|
---|
552 | (a[5] && a[6] && a[10]) ))
|
---|
553 | size ++;
|
---|
554 | if (a[10] && ((a[9] && a[6] && a[7]) ||
|
---|
555 | (a[6] && a[7] && a[11]) ))
|
---|
556 | size ++;
|
---|
557 | if (a[11] && a[7] && a[10] && a[6]) //pix 0 is compact if there is a 4NN
|
---|
558 | size ++;
|
---|
559 | }
|
---|
560 |
|
---|
561 | // case Lut 3
|
---|
562 | if (lut==2)
|
---|
563 | {
|
---|
564 | if (a[0] && a[1] && a[5] && a[8]) // pix 0 is compact if there is a 4NN
|
---|
565 | size ++;
|
---|
566 | if (a[1] && (a[0] && a[5] && a[2])) //pix 0 is compact if there is a 4NN
|
---|
567 | size ++;
|
---|
568 | if (a[2] && ((a[1] && a[5] && a[6]) ||
|
---|
569 | (a[3] && a[5] && a[6]) ||
|
---|
570 | (a[6] && a[3] && a[4]) ))
|
---|
571 | size ++;
|
---|
572 | if (a[3] && ((a[2] && a[4] && a[6]) ||
|
---|
573 | (a[2] && a[6] && a[7]) ))
|
---|
574 | size ++;
|
---|
575 | if (a[4] && (a[2] && a[3] && a[6] ))
|
---|
576 | size ++;
|
---|
577 | if (a[5] && ((a[1] && a[2] && a[6]) ||
|
---|
578 | (a[2] && a[6] && a[9]) ||
|
---|
579 | (a[6] && a[9] && a[8]) ))
|
---|
580 | size ++;
|
---|
581 | if (a[6] && ((a[2] && a[3] && a[7]) ||
|
---|
582 | (a[3] && a[7] && a[10]) ||
|
---|
583 | (a[7] && a[10] && a[9]) ||
|
---|
584 | (a[10] && a[9] && a[5]) ||
|
---|
585 | (a[9] && a[5] && a[2]) ||
|
---|
586 | (a[5] && a[2] && a[3]) ))
|
---|
587 | size ++;
|
---|
588 | if (a[7] && ((a[3] && a[6] && a[10]) ||
|
---|
589 | (a[6] && a[10] && a[11]) ))
|
---|
590 | size ++;
|
---|
591 | if (a[8] && a[5] && a[9] && a[6]) //pix 0 is compact if there is a 4NN
|
---|
592 | size ++;
|
---|
593 | if (a[9] && ((a[8] && a[5] && a[6]) ||
|
---|
594 | (a[5] && a[6] && a[10]) ))
|
---|
595 | size ++;
|
---|
596 | if (a[10] && ((a[9] && a[6] && a[7]) ||
|
---|
597 | (a[6] && a[7] && a[11]) ))
|
---|
598 | size ++;
|
---|
599 | if (a[11] && a[7] && a[10] && a[6]) //pix 0 is compact if there is a 4NN
|
---|
600 | size ++;
|
---|
601 | }
|
---|
602 | }
|
---|
603 |
|
---|
604 |
|
---|
605 | if(size<0 ||size>12)
|
---|
606 | *fLog << "*" << size <<"-";
|
---|
607 |
|
---|
608 | return size;
|
---|
609 | }
|
---|
610 |
|
---|
611 |
|
---|
612 | // --------------------------------------------------------------------------
|
---|
613 | //
|
---|
614 | // Look for clusters and calculate the PseudoSize of one event,
|
---|
615 | // defined as the multiplicity of the bigger cluster.
|
---|
616 | //
|
---|
617 | //
|
---|
618 | //
|
---|
619 | void MMcTriggerLvl2::CalcPseudoSize()
|
---|
620 | {
|
---|
621 | // Fill the fCompactPixel array with the compact pixels
|
---|
622 | CalcCompactPixels(fGeomCam);
|
---|
623 |
|
---|
624 | // seek the LUT with higher number of compact pixels
|
---|
625 | //
|
---|
626 | int cellut = CalcBiggerLutPseudoSize();
|
---|
627 | int maxcell = cellut/10;
|
---|
628 | int maxlut = cellut - maxcell*10;
|
---|
629 | int startpix;
|
---|
630 | //if (GetLutCompactPixel(maxcell,maxlut)==0)
|
---|
631 | //*fLog << "Max lut size:" << GetLutCompactPixel(maxcell,maxlut) <<endl;
|
---|
632 |
|
---|
633 | //
|
---|
634 | // seek a starting pixel in the lut for the iteration
|
---|
635 | //
|
---|
636 | int check=1;
|
---|
637 | for (int pixlut=0;pixlut<12;pixlut++)
|
---|
638 | {
|
---|
639 | int pixcell =gsPixelsInLut[maxlut][pixlut]-1;
|
---|
640 | startpix = gsPixelsInCell[pixcell][maxcell]-1;
|
---|
641 | //*fLog << "pix, compact:" << startpix << "@"<<fCompactPixel[startpix];
|
---|
642 | if (fCompactPixel[startpix]) // a starting pixel was found
|
---|
643 | break;
|
---|
644 | check++;
|
---|
645 | }
|
---|
646 |
|
---|
647 | //*fLog << "check = " << check << endl;
|
---|
648 | // A LUT contains 12 pixels
|
---|
649 | if (check > 12)
|
---|
650 | {
|
---|
651 | check=1;
|
---|
652 | // A starting pixel was not found using the LutPseudoSize.
|
---|
653 | // We look for it in the BiggerCell
|
---|
654 | maxcell=CalcBiggerFiredCell();
|
---|
655 | for (int pixcell=0;pixcell<36;pixcell++)
|
---|
656 | {
|
---|
657 | startpix = gsPixelsInCell[pixcell][maxcell]-1;
|
---|
658 | //*fLog << "pix, compact:" << startpix << "@"<<fCompactPixel[startpix];
|
---|
659 | if (fCompactPixel[startpix]) // a starting pixel was found
|
---|
660 | break;
|
---|
661 | check++;
|
---|
662 | }
|
---|
663 | if (check > 36)
|
---|
664 | {
|
---|
665 | *fLog <<"Error: a starting pixels was not found! - PseudoSize = "<< fPseudoSize << endl;
|
---|
666 | fPseudoSize=0;
|
---|
667 | return;
|
---|
668 | }
|
---|
669 | }
|
---|
670 | //
|
---|
671 | // Bulding cluster
|
---|
672 | //
|
---|
673 | Int_t cluster[397];
|
---|
674 | int pnt=0;
|
---|
675 | int pnt2=0; //pointer in the array fCluster_pix, needed for filling
|
---|
676 |
|
---|
677 | memset (cluster,0,397*sizeof(Int_t));
|
---|
678 | memset (fCluster_pix,-1,397*sizeof(Int_t));
|
---|
679 |
|
---|
680 | cluster[startpix]=1;
|
---|
681 | fCluster_pix[0]=startpix; //the starting pix is the first in cluster
|
---|
682 |
|
---|
683 | // Look at neighbour pixs if they are compact (iterative search)
|
---|
684 | // until the array (fCluster_pix) has no more compact pixels.
|
---|
685 | // pnt points to the pixel in the array fCluster_pix whose neighbors are
|
---|
686 | // under study; pnt2 points to the last element of this array.
|
---|
687 | //
|
---|
688 | while (fCluster_pix[pnt] != -1)
|
---|
689 | {
|
---|
690 | const MGeomPix &pix=(*fGeomCam)[fCluster_pix[pnt]];
|
---|
691 |
|
---|
692 | for (int i=0;i<pix.GetNumNeighbors();i++)
|
---|
693 | {
|
---|
694 | int pix_neigh = pix.GetNeighbor(i);
|
---|
695 | // check if pixel is fired and doesn't belong to cluster
|
---|
696 | if (fCompactPixel[pix_neigh] && !cluster[pix_neigh])
|
---|
697 | //if (fCompactPixel[pix_neigh])
|
---|
698 | {
|
---|
699 | cluster[pix_neigh] = 1;
|
---|
700 | fCluster_pix[++pnt2] = pix_neigh;
|
---|
701 | }
|
---|
702 | }
|
---|
703 | pnt++;
|
---|
704 | }
|
---|
705 |
|
---|
706 | fPseudoSize = pnt;
|
---|
707 | //if (fPseudoSize < 4)
|
---|
708 | // *fLog << "fPseudoSize = " << fPseudoSize << endl;
|
---|
709 |
|
---|
710 | // *fLog << "ClusterID:" <<(*clust).GetClusterId() << " Mult:" << (*clust).GetMultiplicity()<<endl;
|
---|
711 |
|
---|
712 | // *fLog <<"PSize: "<< fPseudoSize << " in cell:" << maxcell << " lut:" <<maxlut <<endl;
|
---|
713 |
|
---|
714 | return;
|
---|
715 | }
|
---|
716 |
|
---|
717 | // --------------------------------------------------------------------------
|
---|
718 | //
|
---|
719 | // Fill the fCompactPixels array with the pixels which are compact
|
---|
720 | //
|
---|
721 | // neighpix is the number of Next-Neighbors which defines the compact pixel
|
---|
722 | // topology (it can be 2-NN or 3-NN)
|
---|
723 | //
|
---|
724 | // Note: it is a *global* method; it looks in the all camera as a whole
|
---|
725 | //
|
---|
726 | //
|
---|
727 | void MMcTriggerLvl2::CalcCompactPixels(MGeomCam *geom)
|
---|
728 | {
|
---|
729 | memset (fCompactPixel,0,397*sizeof(Int_t));
|
---|
730 | // *fLog << endl << "NEW Event!";
|
---|
731 | for(UInt_t pixid=0;pixid<397;pixid++)
|
---|
732 | {
|
---|
733 | // Look if the pixel is fired, otherwise continue
|
---|
734 | if (!fFiredPixel[pixid])
|
---|
735 | continue;
|
---|
736 |
|
---|
737 | const MGeomPix &pix=(*geom)[pixid];
|
---|
738 |
|
---|
739 | // Look for compact pixels.
|
---|
740 | // A compact pixel must have at least fCompactNN adjacent neighbors
|
---|
741 | // It checks the 6 different configurations of neighbors pixels
|
---|
742 | int j=0;
|
---|
743 | for (int i=0;i<pix.GetNumNeighbors();i++)
|
---|
744 | {
|
---|
745 | //*fLog << pixid <<"->"<< pix.GetNeighbor(i+j) << endl;
|
---|
746 | while ((fFiredPixel[pix.GetNeighbor(i+j)]==1) && (j < fCompactNN))
|
---|
747 | j++;
|
---|
748 | if (j!=fCompactNN) continue; // configuration doesn't satisfy compact condition
|
---|
749 |
|
---|
750 | fCompactPixel[pixid]=1; // pixel is compact
|
---|
751 |
|
---|
752 | // *fLog << ","<<pixid;
|
---|
753 |
|
---|
754 | break;
|
---|
755 | }
|
---|
756 | }
|
---|
757 | }
|
---|
758 |
|
---|
759 |
|
---|
760 |
|
---|
761 | // --------------------------------------------------------------------------
|
---|
762 | //
|
---|
763 | // The Energy has to be given by this class to the Energy-PSSize correlation
|
---|
764 | // histogram (MHMcTriggerLvl2)
|
---|
765 | //
|
---|
766 | void MMcTriggerLvl2::GetEnergy(MMcEvt *fMcEvt)
|
---|
767 | {
|
---|
768 | const MMcEvt &h = *(MMcEvt *)fMcEvt;
|
---|
769 | fEnergy = h.GetEnergy();
|
---|
770 | }
|
---|
771 |
|
---|
772 |
|
---|
773 | // --------------------------------------------------------------------------
|
---|
774 | //
|
---|
775 | // Looks for a x-NN compact pattern in the whole camera
|
---|
776 | // We have x-NN compact pattern when a triggered pix has
|
---|
777 | // x-1 triggered neighbor pixels.
|
---|
778 | // The variable fTriggerPattern = x is computed
|
---|
779 | // (x= 3,4,5,6,7)
|
---|
780 | //
|
---|
781 | // x=3 * *
|
---|
782 | // * *
|
---|
783 | // x=4 * *
|
---|
784 | // *
|
---|
785 | // * *
|
---|
786 | // x=5 * * *
|
---|
787 | // *
|
---|
788 | // x=6 * * *
|
---|
789 | // * *
|
---|
790 | // * *
|
---|
791 | // x=7 * * *
|
---|
792 | // * *
|
---|
793 | //
|
---|
794 | void MMcTriggerLvl2::CalcTriggerPattern(MGeomCam *geom)
|
---|
795 | {
|
---|
796 | fTriggerPattern=0; //initialize
|
---|
797 |
|
---|
798 | for(UInt_t pixid=0;pixid<397;pixid++)
|
---|
799 | {
|
---|
800 | // Look if the pixel is fired, otherwise continue
|
---|
801 | if (!fFiredPixel[pixid])
|
---|
802 | continue;
|
---|
803 |
|
---|
804 | const MGeomPix &pix=(*geom)[pixid];
|
---|
805 |
|
---|
806 | // Look for x-NN compact pattern
|
---|
807 | // If a x-NN pattern exists then a pixel must have
|
---|
808 | // at least x-1 adjacent neighbors (look at patterns)
|
---|
809 | // For each triggered pixel the number of adjacent triggered pixels is counted.
|
---|
810 | //
|
---|
811 | int j=1;
|
---|
812 | for (int i=0;i<pix.GetNumNeighbors();i++)
|
---|
813 | if (fFiredPixel[pix.GetNeighbor(i)]==1) j++;
|
---|
814 |
|
---|
815 | if (j > fTriggerPattern)
|
---|
816 | fTriggerPattern=j;
|
---|
817 |
|
---|
818 | if (fTriggerPattern==7)
|
---|
819 | break; // the 7-NN (max) pattern was found: exit
|
---|
820 |
|
---|
821 | } // next pixel
|
---|
822 | }
|
---|
823 |
|
---|