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

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