StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
L2eemcGamma2012.h
1 #ifndef L2eemcGamma2012_H
2 #define L2eemcGamma2012_H
3 /*********************************************************************
4  * $Id: L2eemcGamma2012.h,v 1.3 2011/10/19 16:12:11 jml Exp $
5  * \author Jan Balewski, MIT, 2008
6  *********************************************************************
7  * Descripion:
8  * example algo finding list of 2x2 ETOW clusters based on ET-seed list produced by L2-etow-calib algo
9  * features: uses 2D array (ieta vs. iphi )
10  * Limitations:
11  * - ignores seeds at the edges
12  * - double counts for neighbours seeds
13  * - no provision for wrap up in phi
14  *********************************************************************
15  */
16 
17 
18 #ifdef IS_REAL_L2 //in l2-ana environment
19  #include "L2VirtualAlgo2012.h"
20 #else
21  #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2VirtualAlgo2012.h"
22 #endif
23 
24 #include "L2gammaResult2012.h"
25 
26 class L2eemcGamma2012 ;
27 class L2Histo;
28 class L2EmcGeom2012;
29 
30 // remember to clear in initRun() to avoid stale data
31 class L2eemcGammaEvent2012 {// WARN : all is in RAM x 4096 tokens!
32  public:
33  enum {mxClust=50}; // keep the size down
34  enum {kDataFresh=0}; // if used 1 or more times data are stale
35  private:
36  friend class L2eemcGamma2012 ;
37  int isFresh; // for QA
38  int size;// size of used data in the array below
39  float clusterET[mxClust]; //above seed thresholds, not cleared
40  float clusterEta[mxClust]; //Eta bin of cluster
41  float clusterPhi[mxClust]; //Phi bin of cluster
42  unsigned short int clusterSeedTow[mxClust]; //Seed Tower number
43  unsigned short int clusterQuad[mxClust]; //Quadrant of cluster relative to seed tower [0,3]
44  unsigned short int clusterSeedRank[mxClust]; //Rank of Seed for this cluster
45  L2gammaResult2012 resultBlob;
46 };
47 
49  /* this class fills the folowing bins
50  of counter histo (mhN), see also L2VirtualAlgo2009.h
51  5 - # of eve w/ overflow # of clusters, on input
52  6 - # of eve w/ STALE data - very bad, on input
53 
54  15 - # of eve w/ overflow # of clusters, accepted
55  */
56  public:
57  enum {mxEtow=(EtowGeom::mxEtaBin) * (EtowGeom::mxPhiBin)}; // shortcut
58  private:
59 
60  //..................... params set in initRun
61  int par_dbg;
62  float par_seedEtThres;
63  float par_clusterEtThres;
64  float par_eventEtThres;
65 
66 
67  //.............run-long, token independent variables
68  L2EmcGeom2012 *mGeom;// avaliable but not used in this example
69  int mRdo2tower[mxEtow];
70  int mTower2rdo[mxEtow];
71 
72  //---- event-long variables changed by COMPUTE() -----
73  //............... working, token independent
74  float wrkEtow_et[mxEtow]; // full event
75  int wrkEtow_tower_index[mxEtow]; // Tower numbers indexed by hit number
76  int wrkEtow_tower_seed[mxEtow]; // above seed thresholds, not cleared
77  int wrkEtow_tower_seed_size;
78  //............... preserved for Decision(),
79  L2eemcGammaEvent2012 mEtow[L2eventStream2012::mxToken]; //it is a lot of RAM!
80  //............... event-long variables
81  float etow_et[mxEtow]; // full event
82  int etow_used[mxEtow]; // flag set to 1 when tower has been "used" in a cluster
83  int etow_tower_seed[mxEtow]; // above seed thresholds, not cleared
84  int etow_tower_seed_size;
85  float etow_clusterET[mxEtow]; // above seed thresholds, not cleared
86  int etow_clusterET_size;
87 
88  //............... cluster data type
89  struct mCluster {
90  int seedTower;
91  int seedRank;
92  int quadrant;
93  float ETsum;
94  };
95 
96  mCluster towerCluster[mxEtow];
97 
98 
99 
100  // utility methods
101  void createHisto();
102  void clearEvent(int token);
103  void clearEvent();
104  int countNonZeroTow(int phi, int eta);
105  float sumET(int phi, int eta);
106  void flagUsed(int phi, int eta);
107  void averageEtaPhi(int phi, int eta, float *avePhi, float *aveEta);
108  void quickSort(int array[], int start, int end);
109  void swap(int array[], int index1, int index2);
110 
111  public:
112  L2eemcGamma2012(const char* name, const char *uid, L2EmcDb2012* db, L2EmcGeom2012 *geo, char* outDir, int resOff);
113  int initRunUser( int runNo, int *rc_ints, float *rc_floats);
114  void finishRunUser();// at the end of each run
115  void computeUser(int token);
116  bool decisionUser(int token, int *myL2Result);
117 
118  void print1(int token);
119  void print2();
120  void print3();
121  void print4(int token, int hitSize);
122 
123 };
124 
125 #endif
126 
127 /**********************************************************************
128  $Log: L2eemcGamma2012.h,v $
129  Revision 1.3 2011/10/19 16:12:11 jml
130  more 2012 stuff
131 
132  Revision 1.2 2011/10/19 15:39:43 jml
133  2012
134 
135  Revision 1.1 2011/10/18 15:11:42 jml
136  adding 2012 algorithms
137 
138  Revision 1.1 2011/03/09 16:29:07 pibero
139  Added L2gamma2009
140 
141  Revision 1.5 2008/01/30 00:47:17 balewski
142  Added L2-Etow-calib
143 
144  Revision 1.4 2008/01/18 23:29:13 balewski
145  now L2result is exported
146 
147  Revision 1.3 2008/01/17 23:15:52 balewski
148  bug in token-addressed memory fixed
149 
150  Revision 1.2 2008/01/16 23:32:36 balewski
151  toward token dependent compute()
152 
153  Revision 1.1 2007/12/19 02:30:19 balewski
154  new L2-etow-calib-2008
155 
156 
157 
158 */
159 
void computeUser(int token)