EmcCluster.h

Go to the documentation of this file.
00001 #ifndef EMCCLUSTER_H
00002 #define EMCCLUSTER_H
00003 
00004 // Name: EmcCluster.h
00005 // Author: A. Bazilevsky (RIKEN-BNL)
00006 // Major modifications by M. Volkov (RRC KI) Jan 27 2000
00007 
00008 // Standard includes
00009 #include <cstdio>
00010 #include <cmath>
00011 #include <vector>
00012 #include "TObject.h"
00013 #include "TMath.h"
00014 
00015 // Forward declarations
00016 class EmcSectorRec;
00017 class EmcCluster;
00018 class EmcPeakarea;
00019 class EmcEmshower;
00020 
00025 struct EmcModule
00026 {
00027   EmcModule();
00028   EmcModule(int ich_, int softkey_, float amp_, float tof_,
00029             int deadmap_, int warnmap_, float adc_, float tac_);
00030 
00031   int ich;   // module id (linear)
00032   int softKey; /* software key = arm/sector/row/column =
00033                   100000 * iarm +
00034                   10000 * iS +
00035                   100 * iy +
00036                   iz                       */
00037   float amp; // module signal
00038   float tof; // module time-of-flight
00039   int deadmap; // module dead map: see emcCalibratedDataObject.h
00040   int warnmap; // MV 2001/12/06
00041   float adc; // ADC amplitude
00042   float tac; // TAC amplitude
00043 };
00044 
00045 // ///////////////////////////////////////////////////////////////////////////
00046 
00054 class EmcCluster : public TObject
00055 {
00056 
00057 public:
00058 
00060   EmcCluster()
00061   {}
00062 
00063   EmcCluster(EmcSectorRec *sector): fOwner(sector)
00064   {}
00065 
00067 #ifndef __CINT__
00068 
00069   EmcCluster(const std::vector<EmcModule>& hlist,
00070              EmcSectorRec *sector)
00071     : fOwner(sector)
00072   {
00073     fHitList = hlist;
00074   }
00075 #endif
00076 
00078   virtual ~EmcCluster()
00079   {}
00080 
00082 #ifndef __CINT__
00083 
00084   void ReInitialize( const std::vector<EmcModule>& hlist )
00085   {
00086     fHitList = hlist;
00087   }
00088 #endif
00089 
00090   int GetNofHits()
00091   {
00092     return fHitList.size();
00093   }
00095   void GetHits(EmcModule* phit, int n);
00097 #ifndef __CINT__
00098 
00099   void GetHitList(std::vector<EmcModule> *&plist)
00100   {
00101     plist = &fHitList;
00102   };
00103 #endif
00104 
00105   EmcModule GetMaxTower();
00107   EmcModule GetImpactTower();
00109   float GetTowerEnergy( int ich );
00111   float GetTowerEnergy( int ix, int iy );
00113   float GetTowerToF( int ich );
00115   int GetTowerDeadMap( int ich );
00117   int GetTowerWarnMap( int ich ); // MV 2002/02/18 bugfix
00118   float GetTowerADC( int ich ); // MV 2002/03/12 bugfix
00119   float GetTowerTAC( int ich ); // MV 2002/03/12 bugfix
00121   int GetNDead();
00122   int GetDeadMap(); // MV 2001/12/06
00123   int GetWarnMap(); // MV 2001/12/06
00125   float GetE4();
00127   float GetE9();
00129   float GetE9( int ich );
00131   float GetECore();
00133   float GetTotalEnergy();
00135   void GetMoments( float* pxcg, float* pycg,
00136                    float* pxx, float* pxy, float* pyy );
00138   void GetCorrPos( float* pxc, float* pyc );
00140   void GetGlobalPos( float* pxg, float* pyg, float* pzg );
00142   void GetErrors( float* pde, float* pdx, float* pdy, float* pdz);
00144   void GetChar( float* pe,
00145                 float* pxcg, float* pysg,
00146                 float* pxc, float* pyc,
00147                 float* pxg, float* pyg, float* pzg,
00148                 float* pxx, float* pxy, float* pyy,
00149                 float* pde, float* pdx, float* pdy, float* pdz );
00151   int GetPeaks(EmcPeakarea*, EmcModule*);
00152 
00153 protected:
00154 
00155 #ifndef __CINT__
00156 
00157   std::vector<EmcModule> fHitList;
00158 #endif
00159 
00160   EmcSectorRec *fOwner; // what sector it belongs to
00161 
00162   // static members
00163   static int const fgMaxNofPeaks;
00164   static int const fgPeakIter;
00165   static float const fgEmin;
00166   static float const fgChisq;
00167   static float const fgXABSURD;
00168   static float const fgYABSURD;
00169 
00170 public:
00171 
00172   // MV 2002/02/28 moved these functions here from #define's
00173 
00174   static int max(int a, int b)
00175   {
00176     return a > b ? a : b;
00177   }
00178   static float max(float a, float b)
00179   {
00180     return a > b ? a : b;
00181   }
00182   static double max(double a, double b)
00183   {
00184     return a > b ? a : b;
00185   }
00186 
00187   static int min(int a, int b)
00188   {
00189     return a < b ? a : b;
00190   }
00191   static float min(float a, float b)
00192   {
00193     return a < b ? a : b;
00194   }
00195   static double min(double a, double b)
00196   {
00197     return a < b ? a : b;
00198   }
00199 
00200   static int ABS(int x)
00201   {
00202     return abs(x);
00203   }
00204   static float ABS(float x)
00205   {
00206     return fabsf(x);
00207   }
00208   static double ABS(double x)
00209   {
00210     return fabs(x);
00211   }
00212 
00213   static int lowint(float x)
00214   {
00215     return x < 0. ? int(x - 1) : int(x);
00216   }
00217 
00218 };
00219 
00220 // ///////////////////////////////////////////////////////////////////////////
00221 
00227 class EmcPeakarea: public EmcCluster
00228 {
00229 
00230 public:
00231 
00233   EmcPeakarea(): fNdf(0), fCL(1.)
00234   {}
00235 
00236   EmcPeakarea(EmcSectorRec *sector):
00237     EmcCluster(sector), fNdf(0), fCL(1.)
00238   {}
00239 
00241 #ifndef __CINT__
00242 
00243   EmcPeakarea(const std::vector<EmcModule>& hlist, EmcSectorRec *sector):
00244     EmcCluster(hlist, sector), fNdf(0), fCL(1.)
00245   {}
00246 #endif
00247 
00248   virtual ~EmcPeakarea()
00249   {}
00250 
00252   float GetChi2();
00253   float GetChi2New();
00254   int GetNdf() const
00255   {
00256     return fNdf;
00257   } 
00258   // fetch number of degrees of freedom
00259   float GetCL() const
00260   {
00261     return fCL;
00262   } 
00263   // get CL (call only after GetChar())
00264   float GetCLNew();
00265 
00267   void GetCGmin( float* pxcgmin, float* pycgmin );
00268 
00270   void GetChar( float* pe, float* pec, float* pecore, float* pecorec,
00271                 float* pxcg, float* pysg,
00272                 float* pxcgmin, float* pysgmin,
00273                 float* pxc, float* pyc,
00274                 float* pxg, float* pyg, float* pzg,
00275                 float* pxx, float* pxy, float* pyy,
00276                 float* pchi,
00277                 float* pde, float* pdx, float* pdy, float* pdz );
00278 
00280   int GetGammas( EmcEmshower* );
00281 
00282 protected:
00283 
00284   int fNdf; // Number of degrees of freedom
00285   float fCL; // Confidence level
00286 
00287 };
00288 
00289 // ///////////////////////////////////////////////////////////////////////////
00290 
00295 class EmcEmshower
00296 {
00297 
00298 public:
00299 
00301   EmcEmshower();
00302   EmcEmshower(EmcSectorRec *sector);
00303 
00305   EmcEmshower(float e, float x, float y, float chi, int ndf,
00306               EmcSectorRec *sector);
00307 
00309   void ReInitialize(float e, float x, float y, float chi, int ndf)
00310   {
00311     fEnergy = e;
00312     fXcg = x;
00313     fYcg = y;
00314     fChisq = chi;
00315     fNdf = ndf;
00316   }
00317 
00319   float GetTotalEnergy()
00320   {
00321     return fEnergy;
00322   }
00323 
00325   void GetCG(float* px, float* py)
00326   {
00327     *px = fXcg;
00328     *py = fYcg;
00329   }
00330 
00332   void GetCorrPos(float*, float* );
00333 
00335   void GetGlobalPos(float*, float*, float*);
00336 
00338     float GetChi2() const
00339       {
00340         return fChisq;
00341       }
00342 
00344   float GetCL() const
00345   {
00346     return fCL;
00347   } 
00348   // get CL (call only after GetChar())
00349 
00351   void GetErrors( float* pde, float* pdx, float* pdy, float* pdz);
00352   
00354   void GetChar( float* pe,
00355                 float* pxcg, float* pysg,
00356                 float* pxc, float* pyc,
00357                 float* pxg, float* pyg, float* pzg,
00358                 float* pchi,
00359                 float* pde, float* pdx, float* pdy, float* pdz );
00360   
00361 protected:
00362 
00363     EmcSectorRec* fOwner; // what sector it belongs to
00364     int fNdf; // Number of degrees of freedom
00365     float fCL; // Confidence level
00366     float fEnergy;
00367     float fXcg;
00368     float fYcg;
00369     float fChisq;
00370 
00371 };
00372 
00373 #endif // #ifdef EMCCLUSTER_H