source: trunk/MagicSoft/Mars/manalysis/MMcTriggerLvl2.cc@ 2419

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