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

ExtraHits.cxx

Go to the documentation of this file.
00001 // $Id: ExtraHits.cxx,v 1.5 2000/12/11 16:38:45 burnett Exp $
00002 // 
00003 //  Original author: Sawyer Gillespie
00004 //                   hgillesp@u.washington.edu
00005 //
00006 
00007 #include "reconstruction/ExtraHits.h"
00008 
00009 #include "reconstruction/GlastFit.h"
00010 #include "reconstruction/GlastRecon.h"
00011 #include "reconstruction/LbldData.h"
00012 #include "reconstruction/SiClusters.h"
00013 #include "reconstruction/TrackerRecon.h"
00014 
00015 //TODO: unhardwire this. It was SiTracker::convRadLen(ipln)
00016 static double conv_rad_len = 0.25000;
00017 
00018 
00019 // implementation of the ExtraHits class
00020 
00021 ExtraHits::ExtraHits (GlastRecon* r)
00022 : ReconAnalysis (r)
00023 {
00024 }
00025 
00026 ExtraHits::~ExtraHits ()
00027 {
00028 }
00029 
00030 void    ExtraHits::setUpData ()
00031 {
00032     i_1st_count = data()->addElement("fst_Hit_Count");
00033     i_srp_hit_rat = data()->addElement("Surplus_Hit_Ratio");
00034     i_out_hit_rat = data()->addElement("OutSide_Hit_Ratio");
00035     i_ShowerHits1 = data()->addElement("showerHits1");
00036     i_ShowerHits2 = data()->addElement("showerHits2");
00037     i_No_SHits = data()->addElement("Sum_Hits");
00038 }
00039 
00040 void    ExtraHits::compute ()
00041 {
00042     // get the TrackerRecon object which has reconstructed the
00043     // data within the silicon tracker
00044     TrackerRecon*   tr = recon()->getTracker();
00045     
00046     // declare local variables
00047 
00048     // get the gamma-ray fit from TrackerRecon
00049     GFgamma*    gamma = tr->gammaFit ();
00050 
00051     // get the instrument parameters from TrackerRecon
00052     const TrackerRecon::Parameters* parms = &tr->params ();
00053 
00054     // get parameters corresponding to the fit gamma-ray trajectory
00055     float t0x = tr->data.getData("Gamma_x_dir");
00056     float t0y = tr->data.getData("Gamma_y_dir");
00057     float t0z = tr->data.getData("Gamma_z_dir");
00058     Vector  t0 (t0x, t0y, t0z);
00059     Point   x0 = gamma->vertex();
00060 
00061     // get parameters corresponding to the track fit?
00062     float t1z = tr->data.getData("Fit_z_dir");
00063 
00064     // get the corrected CsI energy
00065     double   m_CsICorrEnergy = tr->getCsICorrEnergy();
00066 
00067     // get the silicon-strip cluster data
00068     SiClusters*   _mclsData = tr->getClusters();
00069 
00070     // native code - this code has been brought in from TrackerRecon
00071     // -------------------------------------------------------------
00072     double norma = 1.;
00073     double istHitCount = 0.;
00074     
00075     //  Find number of hits around first hit: 5 sigma out
00076     int firstLayer = gamma->firstLayer();
00077     Point firstHit = gamma->vertex();
00078     
00079     int diffXY = gamma->getXpair()->firstLayer()-gamma->getYpair()->firstLayer();
00080     float dz    =  gamma->getBest(SiData::X)->vertex().z() - 
00081         gamma->getBest(SiData::Y)->vertex().z();
00082     
00083     float hitRadFact = fabs(t0z) + sqrt(1. - t0z*t0z)/fabs(t0z);
00084     if(hitRadFact > 3.) hitRadFact = 3.;
00085     int ipln = parms->num_convs - firstLayer; 
00086     float radLenEff = (conv_rad_len + 2.*parms->si_thickness/9.36 +.003)/fabs(t1z);
00087     float thetaCone = .014/(m_CsICorrEnergy/2.)*sqrt(radLenEff)*(1.+.038*log(radLenEff));
00088     float minSprd  = 5.* thetaCone * parms->conv_gap; // 5 sigma cut
00089     float dltSprd  = minSprd;
00090     float norm = sqrt(t0.x()*t0.x() + t0.y()*t0.y());
00091     float xFact = 1., yFact = 1.;
00092     if(norm > 10000.*FLT_MIN) {
00093         xFact = 1. + (hitRadFact - 1.)*fabs(t0.x())/norm;
00094         yFact = 1. + (hitRadFact - 1.)*fabs(t0.y())/norm;
00095     }
00096     float dltX = dltSprd*xFact;
00097     float dltY = dltSprd*yFact;
00098     
00099     // Compute the First_hit_count variable
00100     istHitCount = _mclsData->numberOfHitsNear(firstLayer, dltX, dltY, firstHit);
00101     // separate the special case of 3 into 3 or 2.5
00102     if(istHitCount == 3 && diffXY == 0) { // Check if extra hits on the far side of the first gap
00103         SiData::Axis far_axis = SiData::X;
00104         double dR = dltX;
00105         if (dz>0) {
00106             far_axis = SiData::Y;
00107             dR = dltY;
00108         }
00109         int ihit_second = _mclsData->numberOfHitsNear(far_axis, firstLayer, dltX, firstHit);
00110         if (ihit_second == 2) istHitCount -=.5;
00111     }
00112     
00113     //  Find the number of hits around the rest of the gamma trajectory
00114     float deltaS = parms->conv_gap/fabs(t0.z());
00115     double disp = deltaS;
00116     int lastLayer = (int)(4+2.*log(m_CsICorrEnergy/.01) + firstLayer);
00117     if(lastLayer > parms->num_convs) lastLayer = parms->num_convs;
00118     
00119     float sumHits = _mclsData->numberOfHitsNear(firstLayer, .5*dltX, .5*dltY, firstHit);
00120     float shwHits1 = sumHits;
00121     float shwHits2 = 0; 
00122     if(firstLayer > 11){
00123         shwHits1 = 0; 
00124         shwHits2 = sumHits;
00125     }
00126     
00127     if(sumHits < 2.) sumHits = 2.;
00128     if(lastLayer - firstLayer < 5 && lastLayer == parms->num_convs) sumHits +=.5;
00129     float outHits = 0;
00130     
00131     xFact *= sqrt(t0.z() *t0.z() + t0.x()*t0.x());
00132     yFact *= sqrt(t0.z() *t0.z() + t0.y()*t0.y());
00133     
00134     int i;
00135     for(i=firstLayer+1; i<parms->num_convs; i++) {
00136         ipln = parms->num_convs - i;
00137         radLenEff +=  (conv_rad_len + 2.*parms->si_thickness/9.36 +.003)/fabs(t1z);
00138         float thetaMS = .014/(m_CsICorrEnergy/2.)*sqrt(radLenEff)*(1.+.038*log(radLenEff));
00139         float s_total = (i-firstLayer) * deltaS;
00140         float xSprd = thetaMS * s_total * xFact * 2.021; // = 3.5 sigma/sqrt(3)
00141         float ySprd = thetaMS * s_total * yFact * 2.021;
00142         Point trkHit((Point)(disp*t0 + x0));
00143         if (xSprd > 50) xSprd = 50.;
00144         if (ySprd > 50) ySprd = 50.;
00145         float nearHits = _mclsData->numberOfHitsNear(i, xSprd, ySprd, trkHit);
00146         if(i< 12) shwHits1 +=  nearHits;
00147         else      shwHits2 +=  nearHits; 
00148         if( i < lastLayer) {
00149             sumHits +=  nearHits;
00150             outHits +=  _mclsData->numberOfHitsNear(i, 50.,   50.,   trkHit) - nearHits;
00151         }
00152         disp += deltaS;
00153     }
00154     
00155     norma = (lastLayer - firstLayer);
00156     //-----------------------------------------------------------
00157     // end native code
00158         
00159     // set the state of this object to reflect the results of the
00160     // computation
00161     ReconAnalysis::result (new Result(sumHits, norma, istHitCount, outHits, shwHits1, shwHits2));
00162 
00163     // add the data to the list of archival data elements.
00164     tr->data.addData (i_1st_count, istHitCount);
00165     tr->data.addData (i_srp_hit_rat, sumHits/norma);
00166     tr->data.addData (i_out_hit_rat, outHits/norma);
00167     tr->data.addData (i_No_SHits, sumHits);
00168     tr->data.addData (i_ShowerHits1, shwHits1);
00169     tr->data.addData (i_ShowerHits2, shwHits2);
00170 }

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