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

Last change on this file since 2911 was 2478, checked in by stamerra, 21 years ago
*** empty log message ***
File size: 25.4 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//
72// This correspondence is valid only for MAGIC-like geometries!
73//
74const 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//
116const 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//
127MMcTriggerLvl2::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//
149MMcTriggerLvl2::~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// "check"
168// Print a warning message when no starting pixel is found in the
169// CalcPseudoSize method.
170//
171// no option:
172// Print the value of the selection parameters
173//
174//
175void MMcTriggerLvl2::Print(Option_t *opt) const
176{
177 TString str(opt);
178
179 if (str.Contains("status", TString::kIgnoreCase))
180 {
181 *fLog << " Status of cells 1-9" <<endl;
182 for(int i=0; i<36; i++)
183 {
184 for(int j=0; j<9; j++)
185 {
186 // *fLog.width(3);
187 *fLog <<gsPixelsInCell[i][j]-1 << ":" << fPixels[i][j] << "\t ";
188 }
189 *fLog << endl;
190 }
191 }
192 else if (str.Contains("cell", TString::kIgnoreCase))
193 {
194 *fLog << " Pixel numbering in cells 1-9" <<endl;
195 for (int i=0;i<36;i++)
196 {
197 for(int j=0; j<9; j++)
198 {
199 *fLog << gsPixelsInCell[i][j]-1 << "\t";
200 }
201 *fLog << endl;
202 }
203 }
204 else if (str.Contains("check", TString::kIgnoreCase))
205 {
206 // check when no starting pixels was found (<<--to be fixed)
207 if (fPseudoSize < 0)
208 *fLog << " Warning: starting pixel not found. Pseudosize set to -1." << endl;
209 }
210 else
211 {
212 *fLog << " L2T selection parameters:" << endl;
213 *fLog << " - LutPseudoSize = " << fLutPseudoSize << endl;
214 *fLog << " - PseudoSize = " << fPseudoSize << endl;
215 *fLog << " - BiggerCellSize = " << fSizeBiggerCell << endl;
216 *fLog << " - TriggerPattern = " << fTriggerPattern << endl;
217 }
218
219}
220
221// --------------------------------------------------------------------------
222//
223// Take the information supplied by the Lvl1 (it reads from the object MMcTrig
224// the status of all pixels after Lvl1) and pass it to the Lvl2 (fill the
225// array fPixels)
226//
227//
228void MMcTriggerLvl2::SetLv1(MMcTrig *trig)
229{
230 if (!trig)
231 return;
232
233 fMcTrig = trig;
234
235 for(int i=0; i<36; i++)
236 {
237 for(int j=0; j<19; j++)
238 {
239 int pixel = gsPixelsInCell[i][j]-1;
240 fPixels[i][j] = (fMcTrig->IsPixelFired(pixel,0)) ? 1 : 0;
241 fFiredPixel[pixel]=(fMcTrig->IsPixelFired(pixel,0)) ? 1 : 0;
242 //if (fFiredPixel[pixel]==1)
243 //*fLog << pixel<<",";
244 }
245 }
246 //*fLog<<endl<<"Fine evento"<<endl;
247}
248
249
250// --------------------------------------------------------------------------
251//
252// Set the trigger status ( pixel fired(=1) or not(=0) ) manually for a given
253// pixel of a given cell
254//
255//
256void MMcTriggerLvl2::SetPixelFired(Int_t pixel, Int_t fired)
257{
258 for(int i=0; i<36; i++)
259 {
260 for(int j=0; j<19; j++)
261 {
262 if(gsPixelsInCell[i][j]-1==pixel) fPixels[i][j]=fired;
263 }
264 }
265
266}
267
268// --------------------------------------------------------------------------
269//
270// Calculate the Level 2 Trigger (L2T) parameters. They can be used
271// to select the events that have passed the L2T selection rule.
272//
273//
274void MMcTriggerLvl2::Calc()
275{
276
277 // Find the Lut and cell with the higher LutPseudoSize.
278 int lutcell = CalcBiggerLutPseudoSize();
279 int maxcell = lutcell/10;
280 int maxlut = lutcell-maxcell*10;
281 fLutPseudoSize = GetLutCompactPixel(maxcell,maxlut);
282
283 CalcPseudoSize();
284
285 fSizeBiggerCell = GetCellNumberFired(CalcBiggerFiredCell());
286
287 //*fLog << "fLPS="<<fLutPseudoSize<<endl;
288}
289
290
291
292// --------------------------------------------------------------------------
293//
294// For a given cell, just count how many pixels have been fired after Lvl1
295//
296Int_t MMcTriggerLvl2::GetCellNumberFired(int cell)
297{
298 int size=0;
299
300 for(int i=0; i<36; i++)
301 {
302 size += fPixels[i][cell];
303 }
304
305 return size;
306
307}
308
309
310// --------------------------------------------------------------------------
311//
312// Find the cell which the bigger number of fired pixels
313//
314//
315Int_t MMcTriggerLvl2::CalcBiggerFiredCell()
316{
317 int size=-1;
318 int cell=-1;
319
320 for(int j=0; j<19; j++)
321 {
322 if (GetCellNumberFired(j) > size)
323 {
324 size = GetCellNumberFired(j);
325 cell = j;
326 }
327 }
328
329 // *fLog << "size " <<size <<" in cell " << cell << endl;
330
331 return cell;
332
333}
334
335// --------------------------------------------------------------------------
336//
337// Calculate the higher LutPseudoSize of one event defined as the higher number
338// of compact pixel in the LUTs of the trigger cells.
339// neighpix is the number of Next-Neighbors which defines the compact pixel
340// topology (it can be 2-NN or 3-NN)
341//
342// It returns the cell and the LUT with the bigger LutPseudoSize, coded
343// accordingly to: cell*10 + LUT
344//
345Int_t MMcTriggerLvl2::CalcBiggerLutPseudoSize()
346{
347 int size=0;
348 int cell=-1;
349 int lut=-1;
350
351 for(int j=0; j<19; j++)
352 {
353 for(int i=0; i<3; i++)
354 {
355 if (GetLutCompactPixel(j,i) >= size)
356 {
357 size = GetLutCompactPixel(j,i);
358 cell = j;
359 lut = i;
360 }
361 }
362 }
363
364 //*fLog <<"Max cell: " << cell+1 << " Max Lut: " << lut+1 << " PseudoSize: " << size <<endl;
365
366 return cell*10+lut;
367}
368
369
370// --------------------------------------------------------------------------
371//
372// Identify compact pixels in one LUT and calculate the LutPseudoSize
373// (=number of compact pixels in one LUT)
374// neighpix is the number of Next-Neighbors which defines the compact pixel
375// topology.
376// Up to now only 2NN or 3NN are considered
377// <!if changed: change check made by Preprocess in MMcTriggerLvl2Calc>
378//
379// Returns:
380// -1 wrong neighpix
381// -2 wrong cell (<1 or >19)
382// -3 wrong lut (<1 or >3)
383// else:
384// the number of compact pixels in one LUT.
385//
386Int_t MMcTriggerLvl2::GetLutCompactPixel(int cell, int lut)
387{
388 int size=0;
389 int lutpix, a[12];
390 int neighpix= (*this).fCompactNN;
391
392 // check on input variables
393
394 if (neighpix >3 || neighpix < 2)
395 return(-1);
396
397 if (cell<0 || cell>18)
398 return(-2);
399
400 if (lut<0 || lut>2)
401 return(-3);
402
403
404 // LUT 1 and 2 are similar; LUT 3 differs
405
406 for(int j=0; j<12; j++)
407 {
408 lutpix = gsPixelsInLut[lut][j]-1;
409 // *fLog << "j=" <<j<<" lutpix="<<lutpix<<" Cell="<<cell<<endl;
410 a[j] = fPixels[lutpix][cell];
411 }
412
413 //
414 // Look for compact pixels 2NN
415 //
416 if (neighpix==2)
417 {
418 // case Lut 1 and 2
419 if (lut == 0 || lut == 1)
420 {
421 if (a[0] && a[1] && a[4])
422 size ++;
423 if (a[1] && ((a[0] && a[4]) ||
424 (a[4] && a[5]) ||
425 (a[5] && a[2]) ))
426 size ++;
427 if (a[2] && ((a[1] && a[5]) ||
428 (a[5] && a[6]) ||
429 (a[6] && a[3]) ))
430 size ++;
431 if (a[3] && ((a[2] && a[6]) ||
432 (a[6] && a[7]) ))
433 size ++;
434 if (a[4] && ((a[0] && a[1]) ||
435 (a[1] && a[5]) ||
436 (a[5] && a[8]) ))
437 size ++;
438 if (a[5] && ((a[1] && a[2]) ||
439 (a[2] && a[6]) ||
440 (a[6] && a[9]) ||
441 (a[9] && a[8]) ||
442 (a[8] && a[4]) ||
443 (a[4] && a[1]) ))
444 size ++;
445 if (a[6] && ((a[2] && a[3]) ||
446 (a[3] && a[7]) ||
447 (a[7] && a[10]) ||
448 (a[10] && a[9]) ||
449 (a[9] && a[5]) ||
450 (a[5] && a[2]) ))
451 size ++;
452 if (a[7] && ((a[3] && a[6]) ||
453 (a[6] && a[10]) ||
454 (a[10] && a[11]) ))
455 size ++;
456 if (a[8] && ((a[4] && a[5]) ||
457 (a[5] && a[9]) ))
458 size ++;
459 if (a[9] && ((a[8] && a[5]) ||
460 (a[5] && a[6]) ||
461 (a[6] && a[10]) ))
462 size ++;
463 if (a[10] && ((a[9] && a[6]) ||
464 (a[6] && a[7]) ||
465 (a[7] && a[11]) ))
466 size ++;
467 if (a[11] && a[7] && a[10])
468 size ++;
469 }
470
471 // case Lut 3
472 if (lut==2)
473 {
474 if (a[0] && a[1] && a[5])
475 size ++;
476 if (a[1] && ((a[0] && a[5]) ||
477 (a[5] && a[2]) ))
478 size ++;
479 if (a[2] && ((a[1] && a[5]) ||
480 (a[5] && a[6]) ||
481 (a[3] && a[4]) ||
482 (a[6] && a[3]) ))
483 size ++;
484 if (a[3] && ((a[2] && a[6]) ||
485 (a[6] && a[7]) ||
486 (a[2] && a[4]) ))
487 size ++;
488 if (a[4] && ((a[2] && a[3]) ))
489 size ++;
490 if (a[5] && ((a[1] && a[2]) ||
491 (a[2] && a[6]) ||
492 (a[6] && a[9]) ||
493 (a[9] && a[8]) ))
494 size ++;
495 if (a[6] && ((a[2] && a[3]) ||
496 (a[3] && a[7]) ||
497 (a[7] && a[10]) ||
498 (a[10] && a[9]) ||
499 (a[9] && a[5]) ||
500 (a[5] && a[2]) ))
501 size ++;
502 if (a[7] && ((a[3] && a[6]) ||
503 (a[6] && a[10]) ||
504 (a[10] && a[11]) ))
505 size ++;
506 if (a[8] && a[5] && a[9])
507 size ++;
508 if (a[9] && ((a[8] && a[5]) ||
509 (a[5] && a[6]) ||
510 (a[6] && a[10]) ))
511 size ++;
512 if (a[10] && ((a[9] && a[6]) ||
513 (a[6] && a[7]) ||
514 (a[7] && a[11]) ))
515 size ++;
516 if (a[11] && a[7] && a[10])
517 size ++;
518 }
519 }
520
521 //
522 // Look for compact pixels 3NN
523 //
524 if (neighpix==3)
525 {
526 // case Lut 1 and 2
527 if (lut == 0 || lut == 1)
528 {
529 if (a[0] && a[1] && a[4] && a[5]) // pix 0 is compact if there is a 4NN
530 size ++;
531 if (a[1] && ((a[0] && a[4] && a[5]) ||
532 (a[2] && a[4] && a[5]) ))
533 size ++;
534 if (a[2] && ((a[1] && a[5] && a[6]) ||
535 (a[5] && a[6] && a[3]) ))
536 size ++;
537 if (a[3] && (a[2] && a[6] && a[7] ))
538 size ++;
539 if (a[4] && ((a[0] && a[1] && a[5]) ||
540 (a[1] && a[5] && a[8]) ))
541 size ++;
542 if (a[5] && ((a[1] && a[2] && a[6]) ||
543 (a[2] && a[6] && a[9]) ||
544 (a[6] && a[9] && a[8]) ||
545 (a[9] && a[8] && a[4]) ||
546 (a[8] && a[4] && a[1]) ||
547 (a[4] && a[1] && a[2]) ))
548 size ++;
549 if (a[6] && ((a[2] && a[3] && a[7]) ||
550 (a[3] && a[7] && a[10]) ||
551 (a[7] && a[10] && a[9]) ||
552 (a[10] && a[9] && a[5]) ||
553 (a[9] && a[5] && a[2]) ||
554 (a[5] && a[2] && a[3]) ))
555 size ++;
556 if (a[7] && ((a[3] && a[6] && a[10]) ||
557 (a[6] && a[10] && a[11]) ))
558 size ++;
559 if (a[8] && (a[4] && a[5] && a[9] ))
560 size ++;
561 if (a[9] && ((a[8] && a[5] && a[6]) ||
562 (a[5] && a[6] && a[10]) ))
563 size ++;
564 if (a[10] && ((a[9] && a[6] && a[7]) ||
565 (a[6] && a[7] && a[11]) ))
566 size ++;
567 if (a[11] && a[7] && a[10] && a[6]) //pix 0 is compact if there is a 4NN
568 size ++;
569 }
570
571 // case Lut 3
572 if (lut==2)
573 {
574 if (a[0] && a[1] && a[5] && a[8]) // pix 0 is compact if there is a 4NN
575 size ++;
576 if (a[1] && (a[0] && a[5] && a[2])) //pix 0 is compact if there is a 4NN
577 size ++;
578 if (a[2] && ((a[1] && a[5] && a[6]) ||
579 (a[3] && a[5] && a[6]) ||
580 (a[6] && a[3] && a[4]) ))
581 size ++;
582 if (a[3] && ((a[2] && a[4] && a[6]) ||
583 (a[2] && a[6] && a[7]) ))
584 size ++;
585 if (a[4] && (a[2] && a[3] && a[6] ))
586 size ++;
587 if (a[5] && ((a[1] && a[2] && a[6]) ||
588 (a[2] && a[6] && a[9]) ||
589 (a[6] && a[9] && a[8]) ))
590 size ++;
591 if (a[6] && ((a[2] && a[3] && a[7]) ||
592 (a[3] && a[7] && a[10]) ||
593 (a[7] && a[10] && a[9]) ||
594 (a[10] && a[9] && a[5]) ||
595 (a[9] && a[5] && a[2]) ||
596 (a[5] && a[2] && a[3]) ))
597 size ++;
598 if (a[7] && ((a[3] && a[6] && a[10]) ||
599 (a[6] && a[10] && a[11]) ))
600 size ++;
601 if (a[8] && a[5] && a[9] && a[6]) //pix 0 is compact if there is a 4NN
602 size ++;
603 if (a[9] && ((a[8] && a[5] && a[6]) ||
604 (a[5] && a[6] && a[10]) ))
605 size ++;
606 if (a[10] && ((a[9] && a[6] && a[7]) ||
607 (a[6] && a[7] && a[11]) ))
608 size ++;
609 if (a[11] && a[7] && a[10] && a[6]) //pix 0 is compact if there is a 4NN
610 size ++;
611 }
612 }
613
614
615 if(size<0 ||size>12)
616 *fLog << "*" << size <<"-";
617
618 return size;
619}
620
621
622// --------------------------------------------------------------------------
623//
624// Look for clusters and calculate the PseudoSize of one event,
625// defined as the multiplicity of the bigger cluster.
626//
627//
628//
629void MMcTriggerLvl2::CalcPseudoSize()
630{
631 // Fill the fCompactPixel array with the compact pixels
632 CalcCompactPixels(fGeomCam);
633
634 // seek the LUT with higher number of compact pixels
635 //
636 int cellut = CalcBiggerLutPseudoSize();
637 int maxcell = cellut/10;
638 int maxlut = cellut - maxcell*10;
639 int startpix;
640 //if (GetLutCompactPixel(maxcell,maxlut)==0)
641 //*fLog << "Max lut size:" << GetLutCompactPixel(maxcell,maxlut) <<endl;
642
643 //
644 // seek a starting pixel in the lut for the iteration
645 //
646 int check=1;
647 for (int pixlut=0;pixlut<12;pixlut++)
648 {
649 int pixcell =gsPixelsInLut[maxlut][pixlut]-1;
650 startpix = gsPixelsInCell[pixcell][maxcell]-1;
651 //*fLog << "pix, compact:" << startpix << "@"<<fCompactPixel[startpix];
652 if (fCompactPixel[startpix]) // a starting pixel was found
653 break;
654 check++;
655 }
656
657 //*fLog << "check = " << check << endl;
658 // A LUT contains 12 pixels
659 if (check > 12)
660 {
661 check=1;
662 // A starting pixel was not found using the LutPseudoSize.
663 // We look for it in the BiggerCell
664 maxcell=CalcBiggerFiredCell();
665 for (int pixcell=0;pixcell<36;pixcell++)
666 {
667 startpix = gsPixelsInCell[pixcell][maxcell]-1;
668 //*fLog << "pix, compact:" << startpix << "@"<<fCompactPixel[startpix];
669 if (fCompactPixel[startpix]) // a starting pixel was found
670 break;
671 check++;
672 }
673 if (check > 36)
674 {
675 // *fLog <<"Warning: a starting pixel was not found! - PseudoSize = "<< fPseudoSize << endl;
676 fPseudoSize=-1;
677 return;
678 }
679 }
680 //
681 // Bulding cluster
682 //
683 Int_t cluster[397];
684 int pnt=0;
685 int pnt2=0; //pointer in the array fCluster_pix, needed for filling
686
687 memset (cluster,0,397*sizeof(Int_t));
688 memset (fCluster_pix,-1,397*sizeof(Int_t));
689
690 cluster[startpix]=1;
691 fCluster_pix[0]=startpix; //the starting pix is the first in cluster
692
693 // Look at neighbour pixs if they are compact (iterative search)
694 // until the array (fCluster_pix) has no more compact pixels.
695 // pnt points to the pixel in the array fCluster_pix whose neighbors are
696 // under study; pnt2 points to the last element of this array.
697 //
698 while (fCluster_pix[pnt] != -1)
699 {
700 const MGeomPix &pix=(*fGeomCam)[fCluster_pix[pnt]];
701
702 for (int i=0;i<pix.GetNumNeighbors();i++)
703 {
704 int pix_neigh = pix.GetNeighbor(i);
705 // check if pixel is fired and doesn't belong to cluster
706 if (fCompactPixel[pix_neigh] && !cluster[pix_neigh])
707 //if (fCompactPixel[pix_neigh])
708 {
709 cluster[pix_neigh] = 1;
710 fCluster_pix[++pnt2] = pix_neigh;
711 }
712 }
713 pnt++;
714 }
715
716 fPseudoSize = pnt;
717 //if (fPseudoSize < 4)
718 // *fLog << "fPseudoSize = " << fPseudoSize << endl;
719
720 // *fLog << "ClusterID:" <<(*clust).GetClusterId() << " Mult:" << (*clust).GetMultiplicity()<<endl;
721
722 // *fLog <<"PSize: "<< fPseudoSize << " in cell:" << maxcell << " lut:" <<maxlut <<endl;
723
724 return;
725}
726
727// --------------------------------------------------------------------------
728//
729// Fill the fCompactPixels array with the pixels which are compact
730//
731// neighpix is the number of Next-Neighbors which defines the compact pixel
732// topology (it can be 2-NN or 3-NN)
733//
734// Note: it is a *global* method; it looks in the all camera as a whole
735//
736//
737void MMcTriggerLvl2::CalcCompactPixels(MGeomCam *geom)
738{
739 memset (fCompactPixel,0,397*sizeof(Int_t));
740 // *fLog << endl << "NEW Event!";
741 for(UInt_t pixid=0;pixid<397;pixid++)
742 {
743 // Look if the pixel is fired, otherwise continue
744 if (!fFiredPixel[pixid])
745 continue;
746
747 const MGeomPix &pix=(*geom)[pixid];
748
749 // Look for compact pixels.
750 // A compact pixel must have at least fCompactNN adjacent neighbors
751 // It checks the 6 different configurations of neighbors pixels
752 int j=0;
753 for (int i=0;i<pix.GetNumNeighbors();i++)
754 {
755 //*fLog << pixid <<"->"<< pix.GetNeighbor(i+j) << endl;
756 while ((fFiredPixel[pix.GetNeighbor(i+j)]==1) && (j < fCompactNN))
757 j++;
758 if (j!=fCompactNN) continue; // configuration doesn't satisfy compact condition
759
760 fCompactPixel[pixid]=1; // pixel is compact
761
762 // *fLog << ","<<pixid;
763
764 break;
765 }
766 }
767}
768
769
770
771// --------------------------------------------------------------------------
772//
773// The Energy has to be given by this class to the Energy-PSSize correlation
774// histogram (MHMcTriggerLvl2)
775//
776void MMcTriggerLvl2::GetEnergy(MMcEvt *fMcEvt)
777{
778 const MMcEvt &h = *(MMcEvt *)fMcEvt;
779 fEnergy = h.GetEnergy();
780}
781
782
783// --------------------------------------------------------------------------
784//
785// Looks for a x-NN compact pattern in the whole camera
786// We have x-NN compact pattern when a triggered pix has
787// x-1 triggered neighbor pixels.
788// The variable fTriggerPattern = x is computed
789// (x= 2,3,4,5,6,7)
790//
791// x=2 * *
792//
793// x=3 * *
794// * *
795// x=4 * *
796// *
797// * *
798// x=5 * * *
799// *
800// x=6 * * *
801// * *
802// * *
803// x=7 * * *
804// * *
805//
806void MMcTriggerLvl2::CalcTriggerPattern(MGeomCam *geom)
807{
808 fTriggerPattern=0; //initialize
809
810 for(UInt_t pixid=0;pixid<397;pixid++)
811 {
812 // Look if the pixel is fired, otherwise continue
813 if (!fFiredPixel[pixid])
814 continue;
815
816 const MGeomPix &pix=(*geom)[pixid];
817
818 // Look for x-NN compact pattern
819 // If a x-NN pattern exists then a pixel must have
820 // at least x-1 adjacent neighbors (look at patterns)
821 // For each triggered pixel the number of adjacent triggered pixels
822 // is counted.
823 //
824 int j=1;
825 for (int i=0;i<pix.GetNumNeighbors();i++)
826 if (fFiredPixel[pix.GetNeighbor(i)]==1) j++;
827
828 if (j > fTriggerPattern)
829 fTriggerPattern=j;
830
831 if (fTriggerPattern==7)
832 break; // the 7-NN (max) pattern was found: exit
833
834 } // next pixel
835}
836
Note: See TracBrowser for help on using the repository browser.