Changeset 1746 for trunk/MagicSoft/Mars/manalysis/MTrigLvl2.cc
- Timestamp:
- 02/07/03 11:43:09 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/manalysis/MTrigLvl2.cc
r1740 r1746 1 /*########################################################################### 2 # 3 # This file is part of MTrigLvl2 simulation toolkit for simulating the 4 # MAGIC Second Level Trigger 5 # e-mail: stamerra@pi.infn.it 6 # marcos@gae.ucm.es # 7 # date: January 2003 # 8 # version: 0.1 # 9 ###########################################################################*/ 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 // MTrigLvl2 // 29 // Storage container for the 2nd level trigger selection parameters // 30 // as part of the 2nd level trigger simulation // 31 // // 32 // (preliminary version) // 33 // // 34 // Basic L2T Selection Parameters: // 35 // // 36 // LutPseudoSize number of compact pixels in one LUT // 37 // // 38 ///////////////////////////////////////////////////////////////////////////// 10 39 11 40 #include "MTrigLvl2.h" 12 #include <iostream.h> 41 13 42 #include "MGeomCamMagic.h" 14 43 #include "MCamDisplay.h" 44 15 45 #include "MMcTrig.hxx" 46 47 #include <fstream.h> 48 #include "MLog.h" 49 16 50 #include <TCanvas.h> 17 51 … … 21 55 22 56 // 23 // Correspondence TABLE between pixel numbering in the trigger cel ss and57 // Correspondence TABLE between pixel numbering in the trigger cells and 24 58 // the standard spiral counting 25 // (Not ice: Pixels start to count from 1 instead of 0)26 // 27 const Float_t pixels_in_cell[36][19] = {59 // (Note: Pixels start to count from 1 instead of 0) 60 // 61 static const Int_t pixels_in_cell[36][19] = { 28 62 {26, 91, 66, 71, 76, 81, 86, 269, 224, 233, 242, 251, 260, 391, 336, 347, 358, 369, 380}, 29 63 {25, 61, 41, 45, 49, 53, 57, 215, 175, 183, 191, 199, 207, 325, 275, 285, 295, 305, 315}, … … 64 98 }; 65 99 66 67 /****************************************************************************** 68 * Default constructor 69 * 70 *****************************************************************************/ 100 // 101 // corrispondence between pixels in cell and lut (pix numbering starts from 1) 102 // 103 static const Int_t pixels_in_lut[3][12] = { 104 { 1, 2, 3, 4, 6, 7, 8, 9, 12, 13, 14, 15}, 105 {34, 29, 23, 16, 30, 24, 17, 10, 25, 18, 11, 5}, 106 {35, 31, 26, 20, 19, 32, 27, 21, 36, 33, 28, 22}, 107 }; 108 109 // -------------------------------------------------------------------------- 110 // 111 // Default constructor 112 // 71 113 MTrigLvl2::MTrigLvl2(const char *name, const char *title) 72 114 { … … 74 116 fTitle = title; 75 117 76 cout << "created MTrigLvl2" << endl; 77 78 // 79 // Initialization of the fPixels array to cero 80 // 81 for(int i=0; i<36; i++){ 82 for(int j=0; j<19; j++){ 83 fPixels[i][j]=0; 84 } 85 } 86 } 87 88 89 90 /////////////////////////////////////////////////////////////////////////////// 91 // 92 // Print Functions 93 // 94 /////////////////////////////////////////////////////////////////////////////// 95 96 /****************************************************************************** 97 * Just print out the pixels containg in a given trigger cell 98 * 99 *****************************************************************************/ 100 void MTrigLvl2::PrintCell(Int_t cell) 101 { 102 for (int i=0;i<36;i++) 103 { 104 cout << pixels_in_cell[i][cell]-1 << endl; 105 } 106 } 107 108 /****************************************************************************** 109 * Print a table with the staus (pixel is fired or not after Lvl1) for all 110 * the pixels in all the trigger cells 111 * 112 *****************************************************************************/ 113 void MTrigLvl2::PrintStatus() 114 { 115 for(int i=0; i<36; i++){ 116 for(int j=0; j<9; j++){ 117 cout.width(3); 118 cout << pixels_in_cell[i][j]-1 << ":" << fPixels[i][j] << " "; 119 } 120 cout << endl; 121 } 122 } 123 124 125 126 127 128 129 /////////////////////////////////////////////////////////////////////////////// 130 // 131 // Set Functions 132 // 133 /////////////////////////////////////////////////////////////////////////////// 134 135 /****************************************************************************** 136 * 137 * Take the information supplied by the Lvl1 (it reads from the object MMcTrig 138 * i the status of all pixels after Lvl1) and pass it to the Lvl2 (fill the 139 * array fPixels) 140 * 141 *****************************************************************************/ 118 *fLog << "created MTrigLvl2" << endl; 119 120 // 121 // Initialization of the fPixels array to zero 122 // 123 memset (fPixels,0,36*19); 124 125 } 126 127 // -------------------------------------------------------------------------- 128 // 129 // Print functions for debugging and testing 130 // 131 // 132 // Print out the pixel number of a given trigger cell 133 // 134 // Print a table with the status (pixel is fired or not after Lvl1) for all 135 // the pixels in all the trigger cells 136 // 137 void MTrigLvl2::Print(Int_t cell) const 138 { 139 if (cell >-1) { 140 for (int i=0;i<36;i++) 141 { 142 *fLog << pixels_in_cell[i][cell]-1 << endl; 143 } 144 } 145 else { 146 for(int i=0; i<36; i++){ 147 for(int j=0; j<9; j++){ 148 // *fLog.width(3); 149 *fLog << pixels_in_cell[i][j]-1 << ":" << fPixels[i][j] << "\t "; 150 } 151 *fLog << endl; 152 } 153 } 154 } 155 156 // -------------------------------------------------------------------------- 157 // 158 // Take the information supplied by the Lvl1 (it reads from the object MMcTrig 159 // i the status of all pixels after Lvl1) and pass it to the Lvl2 (fill the 160 // array fPixels) 161 // 162 // 142 163 void MTrigLvl2::SetLv1(MMcTrig *trig) 143 164 { 165 if (!trig) 166 return; 167 144 168 fMcTrig = trig; 145 169 … … 155 179 156 180 157 /****************************************************************************** 158 * Set the trigger status ( pixel fired(=1) or not(=0) ) manually for a given 159 * pixel of a given cell 160 * 161 *****************************************************************************/ 181 // -------------------------------------------------------------------------- 182 // 183 // Set the trigger status ( pixel fired(=1) or not(=0) ) manually for a given 184 // pixel of a given cell 185 // 186 // 162 187 void MTrigLvl2::SetPixelFired(Int_t pixel, Int_t fired) 163 188 { … … 170 195 171 196 172 173 174 /////////////////////////////////////////////////////////////////////////////// 175 // 176 // Graphical display Functions 177 // 178 /////////////////////////////////////////////////////////////////////////////// 179 180 /****************************************************************************** 181 * Display the MAGIC Camera a draw the pixels corresponding to a given cell 182 * 183 *****************************************************************************/ 197 // -------------------------------------------------------------------------- 198 // 199 // Display the MAGIC Camera a draw the pixels corresponding to a given cell 200 // (preliminary) <to be fixed> 201 // 184 202 void MTrigLvl2::DrawCell(Int_t cell) 185 203 { … … 220 238 221 239 222 /****************************************************************************** 223 * Display the MAGIC camera and draw all the pixel fired after Lvl1 224 * 225 *****************************************************************************/ 240 // -------------------------------------------------------------------------- 241 // 242 // Display the MAGIC camera and draw all the pixel fired after Lvl1 243 // (preliminary) <to be fixed> 244 // 245 // 226 246 void MTrigLvl2::DrawLv1() 227 247 { … … 263 283 } 264 284 265 266 267 /////////////////////////////////////////////////////////////////////////////// 268 // 269 // Implementation of the Lv2l selection strategies 270 // 271 /////////////////////////////////////////////////////////////////////////////// 272 273 /****************************************************************************** 274 * For a given cell, just count how many pixels have been fired after Lvl1 275 * 276 *****************************************************************************/ 285 // -------------------------------------------------------------------------- 286 // 287 // For a given cell, just count how many pixels have been fired after Lvl1 288 // 277 289 Int_t MTrigLvl2::GetCellNumberFired(int cell) 278 290 { … … 288 300 289 301 290 /****************************************************************************** 291 * Find the cell which the bigger number of fired pixels 292 * 293 *****************************************************************************/ 302 // -------------------------------------------------------------------------- 303 // 304 // Find the cell which the bigger number of fired pixels 305 // 306 // 294 307 Int_t MTrigLvl2::GetBiggerFiredCell() 295 308 { … … 304 317 } 305 318 306 cout<< "size " <<size <<" in cell " << cell << endl;319 *fLog << "size " <<size <<" in cell " << cell << endl; 307 320 308 321 return cell; … … 310 323 } 311 324 312 313 325 // -------------------------------------------------------------------------- 326 // 327 // Calculate the 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 // 333 Int_t MTrigLvl2::GetLutPseudoSize(int neighpix) 334 { 335 int size=0; 336 int cell=-1; 337 int lut=-1; 338 339 if (neighpix >3 || neighpix < 2) return(0); 340 341 for(int j=0; j<19; j++){ 342 for(int i=0; i<3; i++){ 343 if (GetLutCompactPixel(j,i,neighpix) > size) { 344 size = GetLutCompactPixel(j,i,neighpix); 345 cell = j; 346 lut = i; 347 } 348 } 349 } 350 351 *fLog <<"Max cell: " << cell+1 << " Max Lut: " << lut+1 << " PseudoSize: " << size <<endl; 352 353 fLutPseudoSize = size; 354 355 return fLutPseudoSize; 356 } 357 358 359 // -------------------------------------------------------------------------- 360 // 361 // Identify compact pixels in one LUT and calculate the LutPseudoSize 362 // (=number of compact pixels in one LUT) 363 // neighpix is the number of Next-Neighbors which defines the compact pixel 364 // topology (it can be 2NN or 3NN) 365 // 366 Int_t MTrigLvl2::GetLutCompactPixel(int cell, int lut, int neighpix) 367 { 368 int size=0; 369 int lutpix, a[12]; 370 371 if (neighpix >3 || neighpix < 2) return(0); 372 373 // LUT 1 and 2 are similar; LUT 3 differs 374 375 for(int j=0; j<12; j++){ 376 lutpix = pixels_in_lut[lut][j]-1; 377 // *fLog << "j=" <<j<<" lutpix="<<lutpix<<" Cell="<<cell<<endl; 378 a[j] = fPixels[lutpix][cell]; 379 } 380 381 // 382 // Look for compact pixels 2NN 383 // 384 if (neighpix==2){ 385 386 // case Lut 1 and 2 387 if (lut == 0 || lut == 1){ 388 if (a[0] && a[1] && a[4]) 389 size ++; 390 if (a[1] && ((a[0] && a[4]) || 391 (a[4] && a[5]) || 392 (a[5] && a[2]) )) 393 size ++; 394 if (a[2] && ((a[1] && a[5]) || 395 (a[5] && a[6]) || 396 (a[6] && a[3]) )) 397 size ++; 398 if (a[3] && ((a[2] && a[6]) || 399 (a[6] && a[7]) )) 400 size ++; 401 if (a[4] && ((a[0] && a[1]) || 402 (a[1] && a[5]) || 403 (a[5] && a[8]) )) 404 size ++; 405 if (a[5] && ((a[1] && a[2]) || 406 (a[2] && a[6]) || 407 (a[6] && a[9]) || 408 (a[9] && a[8]) || 409 (a[8] && a[4]) || 410 (a[4] && a[1]) )) 411 size ++; 412 if (a[6] && ((a[2] && a[3]) || 413 (a[3] && a[7]) || 414 (a[7] && a[10]) || 415 (a[10] && a[9]) || 416 (a[9] && a[5]) || 417 (a[5] && a[2]) )) 418 size ++; 419 if (a[7] && ((a[3] && a[6]) || 420 (a[6] && a[10]) || 421 (a[10] && a[11]) )) 422 size ++; 423 if (a[8] && ((a[4] && a[5]) || 424 (a[5] && a[9]) )) 425 size ++; 426 if (a[9] && ((a[8] && a[5]) || 427 (a[5] && a[6]) || 428 (a[6] && a[10]) )) 429 size ++; 430 if (a[10] && ((a[9] && a[6]) || 431 (a[6] && a[7]) || 432 (a[7] && a[11]) )) 433 size ++; 434 if (a[11] && a[7] && a[10]) 435 size ++; 436 } 437 438 // case Lut 3 439 if (lut==2) { 440 if (a[0] && a[1] && a[5]) 441 size ++; 442 if (a[1] && ((a[0] && a[5]) || 443 (a[5] && a[2]) )) 444 size ++; 445 if (a[2] && ((a[1] && a[5]) || 446 (a[5] && a[6]) || 447 (a[3] && a[4]) || 448 (a[6] && a[3]) )) 449 size ++; 450 if (a[3] && ((a[2] && a[6]) || 451 (a[6] && a[7]) || 452 (a[2] && a[4]) )) 453 size ++; 454 if (a[4] && ((a[2] && a[3]) )) 455 size ++; 456 if (a[5] && ((a[1] && a[2]) || 457 (a[2] && a[6]) || 458 (a[6] && a[9]) || 459 (a[9] && a[8]) )) 460 size ++; 461 if (a[6] && ((a[2] && a[3]) || 462 (a[3] && a[7]) || 463 (a[7] && a[10]) || 464 (a[10] && a[9]) || 465 (a[9] && a[5]) || 466 (a[5] && a[2]) )) 467 size ++; 468 if (a[7] && ((a[3] && a[6]) || 469 (a[6] && a[10]) || 470 (a[10] && a[11]) )) 471 size ++; 472 if (a[8] && a[5] && a[9]) 473 size ++; 474 if (a[9] && ((a[8] && a[5]) || 475 (a[5] && a[6]) || 476 (a[6] && a[10]) )) 477 size ++; 478 if (a[10] && ((a[9] && a[6]) || 479 (a[6] && a[7]) || 480 (a[7] && a[11]) )) 481 size ++; 482 if (a[11] && a[7] && a[10]) 483 size ++; 484 } 485 } 486 487 // 488 // Look for compact pixels 3NN 489 // 490 if (neighpix==3){ 491 492 // case Lut 1 and 2 493 if (lut == 0 || lut == 1){ 494 if (a[0] && a[1] && a[4] && a[5]) // pix 0 is compact if there is a 4NN 495 size ++; 496 if (a[1] && ((a[0] && a[4] && a[5]) || 497 (a[2] && a[4] && a[5]) )) 498 size ++; 499 if (a[2] && ((a[1] && a[5] && a[6]) || 500 (a[5] && a[6] && a[3]) )) 501 size ++; 502 if (a[3] && (a[2] && a[6] && a[7] )) 503 size ++; 504 if (a[4] && ((a[0] && a[1] && a[5]) || 505 (a[1] && a[5] && a[8]) )) 506 size ++; 507 if (a[5] && ((a[1] && a[2] && a[6]) || 508 (a[2] && a[6] && a[9]) || 509 (a[6] && a[9] && a[8]) || 510 (a[9] && a[8] && a[4]) || 511 (a[8] && a[4] && a[1]) || 512 (a[4] && a[1] && a[2]) )) 513 size ++; 514 if (a[6] && ((a[2] && a[3] && a[7]) || 515 (a[3] && a[7] && a[10]) || 516 (a[7] && a[10] && a[9]) || 517 (a[10] && a[9] && a[5]) || 518 (a[9] && a[5] && a[2]) || 519 (a[5] && a[2] && a[3]) )) 520 size ++; 521 if (a[7] && ((a[3] && a[6] && a[10]) || 522 (a[6] && a[10] && a[11]) )) 523 size ++; 524 if (a[8] && (a[4] && a[5] && a[9] )) 525 size ++; 526 if (a[9] && ((a[8] && a[5] && a[6]) || 527 (a[5] && a[6] && a[10]) )) 528 size ++; 529 if (a[10] && ((a[9] && a[6] && a[7]) || 530 (a[6] && a[7] && a[11]) )) 531 size ++; 532 if (a[11] && a[7] && a[10] && a[6]) //pix 0 is compact if there is a 4NN 533 size ++; 534 } 535 536 // case Lut 3 537 if (lut==2) { 538 if (a[0] && a[1] && a[5] && a[8]) // pix 0 is compact if there is a 4NN 539 size ++; 540 if (a[1] && (a[0] && a[5] && a[2])) //pix 0 is compact if there is a 4NN 541 size ++; 542 if (a[2] && ((a[1] && a[5] && a[6]) || 543 (a[3] && a[5] && a[6]) || 544 (a[6] && a[3] && a[4]) )) 545 size ++; 546 if (a[3] && ((a[2] && a[4] && a[6]) || 547 (a[2] && a[6] && a[7]) )) 548 size ++; 549 if (a[4] && (a[2] && a[3] && a[6] )) 550 size ++; 551 if (a[5] && ((a[1] && a[2] && a[6]) || 552 (a[2] && a[6] && a[9]) || 553 (a[6] && a[9] && a[8]) )) 554 size ++; 555 if (a[6] && ((a[2] && a[3] && a[7]) || 556 (a[3] && a[7] && a[10]) || 557 (a[7] && a[10] && a[9]) || 558 (a[10] && a[9] && a[5]) || 559 (a[9] && a[5] && a[2]) || 560 (a[5] && a[2] && a[3]) )) 561 size ++; 562 if (a[7] && ((a[3] && a[6] && a[10]) || 563 (a[6] && a[10] && a[11]) )) 564 size ++; 565 if (a[8] && a[5] && a[9] && a[6]) //pix 0 is compact if there is a 4NN 566 size ++; 567 if (a[9] && ((a[8] && a[5] && a[6]) || 568 (a[5] && a[6] && a[10]) )) 569 size ++; 570 if (a[10] && ((a[9] && a[6] && a[7]) || 571 (a[6] && a[7] && a[11]) )) 572 size ++; 573 if (a[11] && a[7] && a[10] && a[6]) //pix 0 is compact if there is a 4NN 574 size ++; 575 } 576 } 577 578 579 return size; 580 } 581 582
Note:
See TracChangeset
for help on using the changeset viewer.