Changeset 1998 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
04/24/03 09:23:11 (22 years ago)
Author:
stamerra
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1993 r1998  
    11                                                 -*-*- END OF LINE -*-*-
    22
     3 2003/04/24: Antonio Stamerra
     4
     5    * mhistmc/MHMcTriggerLvl2.[h,cc]
     6      - renamed some variable (hf->fHist)
     7      - added fHist*Norm and fFNorm in the destructor
     8
     9    * manalysis/MMcTriggerLvl2.[h,cc]
     10      - added CalcCompactPixel() public method
     11      - implemented CalcPseudoSize method (still under construction...)
     12      - added inline method SetNewCamera(), used in the costructor
     13      - renamed global variables pixels_in_cell->gsPixelsInCell
     14        and pixels_in_lut->gsPixelsInLut
     15      - added destructor
     16     
    317
    418 2003/04/23: Thomas Bretz
  • trunk/MagicSoft/Mars/manalysis/MMcTriggerLvl2.cc

    r1920 r1998  
    2424\* ======================================================================== */
    2525
     26
    2627/////////////////////////////////////////////////////////////////////////////
    2728//                                                                         //
     
    3132//                                                                         //
    3233// input parameter:                                                        //
    33 //    fCompactNN   number of next neighboors that define a compact pixel   //
     34//    fCompactNN number of next neighboors that define a compact pixel     //
    3435//                                                                         //
    3536//                                                                         //
    3637// Basic L2T Selection Parameters:                                         //
    3738//                                                                         //
    38 //    fLutPseudoSize       number of compact pixels in one LUT             //
    39 //    fPseudoSize          Multiplicity of the bigger cluster              //
    40 //    fSizeBiggerCell      higher number of fired pixel in cell            //
     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                 //
    4142//                                                                         //
    4243/////////////////////////////////////////////////////////////////////////////
     
    4445#include "MMcTriggerLvl2.h"
    4546
     47#include "MGeomCam.h"
     48#include "MGeomPix.h"
    4649#include "MGeomCamMagic.h"
    4750#include "MCamDisplay.h"
     51
     52#include "MCluster.h"
    4853
    4954#include "MMcTrig.hxx"
     
    6469// (Note: Pixels start to count from 1 instead of 0)
    6570//
    66 const  Int_t  MMcTriggerLvl2::pixels_in_cell[36][19] = {
     71const  Int_t  MMcTriggerLvl2::gsPixelsInCell[36][19] = {
    6772    {26,  91,  66,  71,  76,  81,  86,  269,  224,  233,  242,  251,  260,  391,  336,  347,  358,      369,  380},
    6873    {25,  61,  41,  45,  49,  53,  57,  215,  175,  183,  191,  199,  207,  325,  275,  285,  295,  305,  315},
     
    106111// corrispondence between pixels in cell and lut (pix numbering starts from 1)
    107112//
    108 const Int_t MMcTriggerLvl2::pixels_in_lut[3][12] = {
     113const Int_t MMcTriggerLvl2::gsPixelsInLut[3][12] = {
    109114    { 1,  2,  3,  4,  6,  7,  8,  9, 12, 13, 14, 15},
    110115    {34, 29, 23, 16, 30, 24, 17, 10, 25, 18, 11,  5},
     
    127132  // Initialization of the fPixels array to zero
    128133  //
    129 
    130134  memset (fPixels,0,36*19*sizeof(Int_t));
    131 
     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;
    132149}
    133150
     
    161178            {
    162179              //      *fLog.width(3);
    163               *fLog <<pixels_in_cell[i][j]-1 << ":" << fPixels[i][j]  << "\t ";
     180              *fLog <<gsPixelsInCell[i][j]-1 << ":" << fPixels[i][j]  << "\t ";
    164181            }
    165182          *fLog << endl;
     
    173190          for(int j=0; j<9; j++)
    174191            {
    175               *fLog << pixels_in_cell[i][j]-1 << "\t";
     192              *fLog << gsPixelsInCell[i][j]-1 << "\t";
    176193            }
    177194          *fLog << endl;
     
    208225      for(int j=0; j<19; j++)
    209226        {
    210           int pixel = pixels_in_cell[i][j]-1;
     227          int pixel = gsPixelsInCell[i][j]-1;
    211228          fPixels[i][j] = (fMcTrig->IsPixelFired(pixel,0)) ? 1 : 0;
     229          fFiredPixel[pixel]=(fMcTrig->IsPixelFired(pixel,0)) ? 1 : 0;
    212230        }
    213231    }
     
    227245      for(int j=0; j<19; j++)
    228246        {
    229           if(pixels_in_cell[i][j]-1==pixel) fPixels[i][j]=fired;
     247          if(gsPixelsInCell[i][j]-1==pixel) fPixels[i][j]=fired;
    230248        }
    231249    }
     
    241259void MMcTriggerLvl2::Calc()
    242260{
     261
     262  // MCluster temp;
     263  //MCluster &clust = (temp).FindCluster();
     264  //  temp=*clust;
     265
    243266  // Reads the number of NN that define a compact pixel
    244   int neighpix=(*this).fCompactNN;
    245267
    246268  // Find the Lut and cell with the higher LutPseudoSize.
    247   int lutcell = CalcBiggerLutPseudoSize(neighpix);
     269  int lutcell = CalcBiggerLutPseudoSize();
    248270  int maxcell = lutcell/10;
    249271  int maxlut = lutcell-maxcell*10;
    250   fLutPseudoSize = GetLutCompactPixel(maxcell,maxlut,neighpix);
    251 
    252   fPseudoSize = CalcPseudoSize(neighpix);
     272  fLutPseudoSize = GetLutCompactPixel(maxcell,maxlut);
     273
     274  CalcPseudoSize();
    253275
    254276  fSizeBiggerCell = GetCellNumberFired(CalcBiggerFiredCell());
     
    272294  // the same camera pad
    273295  //
    274   if (!fGeomcam)
    275     fGeomcam = new MGeomCamMagic; 
     296  if (!fGeomCam)
     297    fGeomCam = new MGeomCamMagic; 
    276298  if (!fCam)
    277299    {
    278       fCam = new MCamDisplay(fGeomcam);
     300      fCam = new MCamDisplay(fGeomCam);
    279301      fCam->Draw();
    280302      fCam->DrawPixelNumbers();
     
    289311    {
    290312      color = (fPixels[i][cell]) ? 5 : 3;
    291       fCam->SetPix( pixels_in_cell[i][cell]-1, color, 1, 5 );
     313      fCam->SetPix( gsPixelsInCell[i][cell]-1, color, 1, 5 );
    292314    }
    293315 
     
    316338  //  !FixMe! Delete this method when the trigger display is available!
    317339  //
    318   if (!fGeomcam)
    319     fGeomcam = new MGeomCamMagic; 
     340  if (!fGeomCam)
     341    fGeomCam = new MGeomCamMagic; 
    320342  if (!fCam)
    321343    {
    322       fCam = new MCamDisplay(fGeomcam);
     344      fCam = new MCamDisplay(fGeomCam);
    323345      fCam->Draw(); 
    324346      fCam->DrawPixelNumbers();
     
    401423//      accordingly to:   cell*10 + LUT
    402424//
    403 Int_t MMcTriggerLvl2::CalcBiggerLutPseudoSize(int neighpix)
     425Int_t MMcTriggerLvl2::CalcBiggerLutPseudoSize()
    404426{
    405427  int size=0;
     
    411433      for(int i=0; i<3; i++)
    412434        {
    413           if (GetLutCompactPixel(j,i,neighpix) > size)
     435          if (GetLutCompactPixel(j,i) >= size)
    414436            {
    415               size = GetLutCompactPixel(j,i,neighpix);
     437              size = GetLutCompactPixel(j,i);
    416438              cell = j;
    417439              lut = i;
     
    421443 
    422444  //  *fLog <<"Max cell: " << cell+1 << "  Max Lut: " << lut+1 << "  PseudoSize: " << size <<endl;
    423  
    424  
     445   
    425446  return cell*10+lut;
    426447}
     
    443464//      the number of compact pixels in one LUT.
    444465//     
    445 Int_t MMcTriggerLvl2::GetLutCompactPixel(int cell, int lut, int neighpix)
     466Int_t MMcTriggerLvl2::GetLutCompactPixel(int cell, int lut)
    446467{
    447468  int size=0;
    448469  int lutpix, a[12];
     470  int neighpix= (*this).fCompactNN;
     471
     472  // check on input variables
    449473
    450474  if (neighpix >3 || neighpix < 2)
     
    462486  for(int j=0; j<12; j++)
    463487    {
    464       lutpix = pixels_in_lut[lut][j]-1;
     488      lutpix = gsPixelsInLut[lut][j]-1;
    465489      //    *fLog << "j=" <<j<<"  lutpix="<<lutpix<<"  Cell="<<cell<<endl;
    466490      a[j] = fPixels[lutpix][cell];
     
    668692    }
    669693 
     694
     695  if(size<0 ||size>12)
     696    *fLog << "*" << size <<"-";
    670697 
    671698  return size;
     
    678705//   defined as the multiplicity of the bigger cluster.
    679706//
     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//
    680788//  neighpix is the number of Next-Neighbors which defines the compact pixel
    681789//    topology (it can be 2-NN or 3-NN)
    682790//
    683 //    !Not yet implemented!!
    684 //
    685 Int_t MMcTriggerLvl2::CalcPseudoSize(int neighpix)
    686 {
    687   int size=0;
    688  
    689   return size;
    690 }
    691 
     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
  • trunk/MagicSoft/Mars/manalysis/MMcTriggerLvl2.h

    r1920 r1998  
    77
    88class MMcTrig;
     9
     10class MCamDisplay;
    911class MGeomCamMagic;
    10 class MCamDisplay;
     12
     13class MGeomCam;
     14class MGeomPix;
     15
     16class MCluster;
    1117
    1218class MMcTriggerLvl2 : public MParContainer
     
    1521 private:
    1622
    17   Int_t fPixels[36][19];  // Array with the triggered pixels. 1st idx:pixels in trigger cell; 2nd idx:trigger cell number 
     23  Int_t fPixels[36][19];  // Array with flag for triggered pixels. 1st idx:pixels in trigger cell; 2nd idx:trigger cell number 
    1824
    19   static const Int_t pixels_in_cell[36][19];
    20   static const Int_t pixels_in_lut[3][12];
     25  Int_t fFiredPixel[397]; // Array with flag for triggered pixel. idx: pixel id
     26
     27  static const Int_t gsPixelsInCell[36][19];
     28  static const Int_t gsPixelsInLut[3][12];
    2129
    2230  Int_t fLutPseudoSize;  // number of compact pixels in one lut
     
    2634  Int_t fCompactNN;  //Number of NN pixels that define a compact pixel
    2735
     36  Int_t fCompactPixel[397]; //Array with flag for compact pixels
     37
     38  Int_t fCluster_pix[397]; //Array with pixel in cluster
     39
    2840  MMcTrig *fMcTrig;
    29   MGeomCamMagic *fGeomcam; 
     41  MGeomCam *fGeomCam; 
    3042  MCamDisplay *fCam;
     43  //  MCluster *fClust;
    3144
    3245  Int_t CalcBiggerFiredCell();
    33   Int_t CalcBiggerLutPseudoSize(int neighpix);
    34   Int_t CalcPseudoSize(int neighpix);
     46  Int_t CalcBiggerLutPseudoSize();
     47  void CalcPseudoSize();
    3548   
     49  void SetNewCamera(MGeomCam *geom) {fGeomCam = geom;}
     50
    3651 public:
    3752
    3853  MMcTriggerLvl2(const char* name = NULL, const char* title = NULL);
    39  
     54  ~MMcTriggerLvl2(); 
    4055 
    4156  void DrawCell(Int_t cell); 
     
    5166  void SetCompactNN(Int_t neighpix)     {fCompactNN=neighpix;}
    5267
    53   Int_t GetPseudoSize()     const {return fPseudoSize;}
    54   Int_t GetLutPseudoSize()  const {return fLutPseudoSize;}
     68  Int_t GetPseudoSize() const    {return fPseudoSize;}
     69  Int_t GetLutPseudoSize() const {return fLutPseudoSize;}
    5570  Int_t GetSizeBiggerCell() const {return fSizeBiggerCell;}
    56   Int_t GetCompactNN()      const {return fCompactNN;}
     71  Int_t GetCompactNN() const      {return fCompactNN;}
    5772
    5873  Int_t GetCellNumberFired(int cell);
    59   Int_t GetLutCompactPixel(int cell, int lut, int neighpix);
     74  Int_t GetLutCompactPixel(int cell, int lut);
     75
     76  void CalcCompactPixels(MGeomCam *fCam);
     77
    6078
    6179  ClassDef(MMcTriggerLvl2,0) // Container for 2nd Level Trigger selection parameters
Note: See TracChangeset for help on using the changeset viewer.