Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

CalModules.cxx

Go to the documentation of this file.
00001 // $Id: CalModules.cxx,v 1.4 2000/12/11 16:38:44 burnett Exp $
00002 //
00003 // Implementation for  access to CsI  data organized by Towers
00004 //
00005 
00006 #include "reconstruction/CalModules.h"
00007 
00008 #include "data/CsIData.h"
00009 
00010 
00011 CalModules::CalModules ()
00012 {
00013 }
00014 
00015 
00016 CalModules::~CalModules ()
00017 {
00018    clear();
00019 }
00020 
00021 
00022 
00023 float CalModules::energy (unsigned int n) const
00024 {
00025   return calorList[n].energy;
00026 }
00027 
00028 int CalModules::nMods () const
00029 {
00030   return (int)calorList.size();
00031 }
00032 
00033 Point CalModules::calPos (unsigned int n) const
00034 {
00035   return  calorList[n].pos;
00036 }
00037 
00038 enum CalModules::ShowerType CalModules::responseType (unsigned int n) const
00039 {
00040   return (ShowerType)calorList[n].type;
00041 }
00042 
00043 idents::ModuleId CalModules::moduleId (unsigned int n) const
00044 {
00045   return calorList[n].module;
00046 }
00047 
00048 void CalModules::load (const CsIData& data)
00049 {
00050     using namespace idents;
00051 
00052     static double energyThreshold = .001; // 1 Mev...
00053 
00054     int numXtals = data.nHits(0);  // Hardwired for 1 layer...
00055     ModuleId lastMod(0,999999);
00056     Point pos;
00057     int sum =0;
00058     float xsum = 0., xxsum = 0., ysum = 0., yysum = 0., xysum = 0., zsum= 0.; 
00059     //, xCenter, yCenter;
00060     float esum = 0, xtalEnergy, corlCoef;
00061     ShowerType eventType;
00062     for(int i=0; i<numXtals; i++) {
00063        if(lastMod != data.moduleId(0, i)) {
00064           if(sum > 0) {
00065              float detx   =  esum*xxsum - xsum*xsum;
00066              float dety   =  esum*yysum - ysum*ysum;
00067              float denom = detx * dety;
00068              float esumsq= esum*esum;
00069              float numer = (esum*xysum - xsum*ysum);
00070              if(denom/(esumsq*esumsq) > .1)
00071                 corlCoef = numer/sqrt(denom);
00072              else
00073                 corlCoef = 1;
00074 
00075   // Following formula drived by plotting corlCoef vs numTowers for mu's
00076             double minCorr = .95 - .04*(sum -5)/(1.+exp(sum-10.));
00077             if(minCorr > .92) minCorr = .92;
00078             if(fabs(corlCoef) > minCorr && sum > 4)  eventType = MIP;
00079             else if(sum > 2)                         eventType = QED_SHOWER;
00080             else                                     eventType = SPATTER;
00081 
00082   // Added data to list
00083             calorList.push_back(CalModules_Data(Point(xsum/esum, ysum/esum, zsum/esum),
00084                                  esum, sum, lastMod, corlCoef, eventType));
00085          }
00086          eventType = NOT_HIT;
00087          xsum  = 0.; xxsum = 0.;
00088          ysum  = 0.; yysum = 0.;
00089          zsum  = 0.;
00090          xysum = 0.;
00091          esum  = 0;
00092          sum   = 0;
00093          lastMod = data.moduleId(0, i);
00094       }
00095     xtalEnergy = data.energy(0, i);
00096     if(xtalEnergy >= energyThreshold) {
00097        sum += 1;
00098        esum += xtalEnergy;
00099        pos = data.xtalPos(0, i);
00100        xsum  += pos.x() * xtalEnergy;
00101        ysum  += pos.y() * xtalEnergy;
00102        zsum  += pos.z() * xtalEnergy;
00103        xxsum += pos.x() * pos.x() * xtalEnergy;
00104        xysum += pos.x() * pos.y() * xtalEnergy;
00105        yysum += pos.y() * pos.y() * xtalEnergy;
00106     }
00107   }
00108  // Pick up the last module..
00109   if(sum > 0) {
00110      float detx   =  esum*xxsum - xsum*xsum;
00111      float dety   =  esum*yysum - ysum*ysum;
00112      float denom = detx * dety;
00113      float esumsq= esum*esum;
00114      float numer = (esum*xysum - xsum*ysum);
00115      if(denom/(esumsq*esumsq) > .1)
00116         corlCoef = numer/sqrt(denom);
00117      else
00118         corlCoef = 1;
00119 
00120      double minCorr = .95 - .04*(sum -5)/(1.+exp(sum-10.));
00121      if(minCorr > .92) minCorr = .92;
00122      if(fabs(corlCoef) > minCorr && sum > 4)  eventType = MIP;
00123      else if(sum > 2)                         eventType = QED_SHOWER;
00124      else                                     eventType = SPATTER;
00125 
00126      calorList.push_back(CalModules_Data(Point(xsum/esum, ysum/esum, zsum/esum),
00127                                  esum, sum, lastMod, corlCoef, eventType));
00128   }
00129 }
00130 
00131 void CalModules::clear ()
00132 {
00133    calorList.clear();
00134 }
00135 
00136 void CalModules::printOn (std::ostream& cout) const
00137 {
00138   cout << "\nCalModules: "<< calorList.size() << " Towers \n";
00139   for(unsigned i=0; i < calorList.size(); i++)
00140   {
00141       cout << '\t' << energy(i) << '\t' << calPos(i) << '\n';
00142   }
00143 }
00144 
00145 // Additional Declarations
00146 
00147 
00148 

Generated at Wed Nov 21 12:20:43 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000