Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

AlgFarDetEvent Class Reference

#include <AlgFarDetEvent.h>

Inheritance diagram for AlgFarDetEvent:

AlgBase List of all members.

Public Member Functions

 AlgFarDetEvent ()
virtual ~AlgFarDetEvent ()
virtual void RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void Trace (const char *c) const

Private Member Functions

void SetTrackProperties (FarDetEventHandle *evt, CandFitTrackHandle *fit, CandTrackHandle *trk)
void SetShowerProperties (FarDetEventHandle *evt, CandShowerHandle *shw)
bool Contained (const CandTrackHandle *track)
double DeDx (Float_t emu)
void GetShower (const CandShowerHandle *shower, const CandTrackHandle *track, vector< double > &TempShw, vector< double > &TempTrk)
void GetPulseHeight (vector< double > &TempShw, vector< double > &TempTrk, double &totph, const double &deweight)
double GetDeWeightFactor (const double &LinearEhad, AlgConfig &ac)
double CalibrateShowerEnergy (const double &totph, const double &deweight, AlgConfig &ac)

Constructor & Destructor Documentation

AlgFarDetEvent::AlgFarDetEvent  ) 
 

Definition at line 31 of file AlgFarDetEvent.cxx.

00032 {
00033 
00034 }   

AlgFarDetEvent::~AlgFarDetEvent  )  [virtual]
 

Definition at line 36 of file AlgFarDetEvent.cxx.

00037 {
00038 
00039 }


Member Function Documentation

double AlgFarDetEvent::CalibrateShowerEnergy const double &  totph,
const double &  deweight,
AlgConfig ac
[private]
 

Definition at line 596 of file AlgFarDetEvent.cxx.

References Registry::GetDouble(), Registry::KeyExists(), and MSG.

Referenced by RunAlg().

00597 {
00598 
00599   // Initialize shower energy
00600   double cal_e(0.0);
00601 
00602   if( totph<=0 ) 
00603     {
00604       MSG("FarDetEvent",Msg::kVerbose) << " 0 MIPs -> 0 GeV" << endl;
00605       return cal_e;
00606     }
00607 
00608   // Get Calibration Constants from AlgConfig.
00609   if( deweight>=1.0 )
00610     {
00611       // USE LINEAR CONSTANTS
00612       // ====================
00613       double fCCLinLowScale(0.0); 
00614       double fCCLinLowC0(0.0); 
00615       double fCCLinLowC1(0.0); 
00616       double fCCLinLowC2(0.0); 
00617       double fCCLinHiC0(0.0); 
00618       double fCCLinHiC1(0.0);
00619  
00620       bool warn =false;
00621       TString errstring="AlgFarDetEvent::CalibrateShowerEnergy - Linear - Failed to get AlgConfig info for the following keys: ";
00622       
00623       if( ac.KeyExists("CCLinLowScale") ) fCCLinLowScale = ac.GetDouble("CCLinLowScale"); 
00624       else {errstring+="CCLinLowScale, "; warn =true; }
00625       if( ac.KeyExists("CCLinLowC0") )    fCCLinLowC0 = ac.GetDouble("CCLinLowC0");
00626       else {errstring+="CCLinLowC0, "; warn =true; }
00627       if( ac.KeyExists("CCLinLowC1") )    fCCLinLowC1 = ac.GetDouble("CCLinLowC1");
00628       else {errstring+="CCLinLowC1, "; warn =true; }
00629       if( ac.KeyExists("CCLinLowC2") )    fCCLinLowC2 = ac.GetDouble("CCLinLowC2");
00630       else {errstring+="CCLinLowC2, "; warn =true; }
00631       if( ac.KeyExists("CCLinHiC0") )     fCCLinHiC0 = ac.GetDouble("CCLinHiC0");
00632       else {errstring+="CCLinHiC0, "; warn =true; }
00633       if( ac.KeyExists("CCLinHiC1") )     fCCLinHiC1 = ac.GetDouble("CCLinHiC1"); 
00634       else {errstring+="CCLinHiC1"; warn =true; }
00635 
00636       if(warn) MSG("FarDetEvent",Msg::kWarning) << errstring.Data() <<endl;
00637 
00638       if( totph<fCCLinLowScale )
00639         {
00640           MSG("FarDetEvent",Msg::kVerbose) << "  using linear constants, low scale... " << endl;
00641           cal_e = fCCLinLowC0 + fCCLinLowC1*totph + fCCLinLowC2*totph*totph;
00642         }
00643       else
00644         {
00645           MSG("FarDetEvent",Msg::kVerbose) << "  using linear constants, high scale... " << endl;
00646           cal_e = fCCLinHiC0 + fCCLinHiC1*totph;
00647         }
00648     }
00649   else
00650     {
00651       // USE DEWEIGHTED CONSTANTS
00652       // ========================
00653       double fCCWtLowScale(0.0);
00654       double fCCWtMidScale(0.0);
00655       double fCCWtLowC0(0.0);
00656       double fCCWtLowC1(0.0);
00657       double fCCWtLowC2(0.0);
00658       double fCCWtLowC3(0.0);
00659       double fCCWtLowC4(0.0);
00660       double fCCWtMidC0(0.0);
00661       double fCCWtMidC1(0.0);
00662       double fCCWtHiC0(0.0);
00663       double fCCWtHiC1(0.0);
00664 
00665       bool warn =false;
00666       TString errstring="AlgFarDetEvent::CalibrateShowerEnergy - Deweight - Failed to get AlgConfig info for the following keys: ";
00667       
00668       if( ac.KeyExists("CCWtLowScale") ) fCCWtLowScale = ac.GetDouble("CCWtLowScale");  
00669       else {errstring+="CCWtLowScale, "; warn =true; }
00670       if( ac.KeyExists("CCWtMidScale") ) fCCWtMidScale = ac.GetDouble("CCWtMidScale");  
00671       else {errstring+="CCWtMidScale, "; warn =true; } 
00672       if( ac.KeyExists("CCWtLowC0") )    fCCWtLowC0 = ac.GetDouble("CCWtLowC0");
00673       else {errstring+="CCWtLowC0, "; warn =true; }
00674       if( ac.KeyExists("CCWtLowC1") )    fCCWtLowC1 = ac.GetDouble("CCWtLowC1");
00675       else {errstring+="CCWtLowC1, "; warn =true; }
00676       if( ac.KeyExists("CCWtLowC2") )    fCCWtLowC2 = ac.GetDouble("CCWtLowC2");
00677       else {errstring+="CCWtLowC2, "; warn =true; }
00678       if( ac.KeyExists("CCWtLowC3") )    fCCWtLowC3 = ac.GetDouble("CCWtLowC3");
00679       else {errstring+="CCWtLowC3, "; warn =true; }
00680       if( ac.KeyExists("CCWtLowC4") )    fCCWtLowC4 = ac.GetDouble("CCWtLowC4");
00681       else {errstring+="CCWtLowC4, "; warn =true; }
00682       if( ac.KeyExists("CCWtMidC0") )    fCCWtMidC0 = ac.GetDouble("CCWtMidC0");
00683       else {errstring+="CCWtMidC0, "; warn =true; }
00684       if( ac.KeyExists("CCWtMidC1") )     fCCWtMidC1 = ac.GetDouble("CCWtMidC1"); 
00685       else {errstring+="CCWtMidC1"; warn =true; }
00686       if( ac.KeyExists("CCWtHiC0") )     fCCWtHiC0 = ac.GetDouble("CCWtHiC0");
00687       else {errstring+="CCWtHiC0, "; warn =true; }
00688       if( ac.KeyExists("CCWtHiC1") )     fCCWtHiC1 = ac.GetDouble("CCWtHiC1"); 
00689       else {errstring+="CCWtHiC1"; warn =true; }
00690 
00691       if(warn) MSG("FarDetEvent",Msg::kWarning) << errstring.Data() <<endl;
00692 
00693       if( totph<fCCWtLowScale )
00694         {
00695           MSG("FarDetEvent",Msg::kVerbose) << "  using deweighted constants, low scale... " << endl;
00696           cal_e = fCCWtLowC0 +
00697                   fCCWtLowC1*totph + 
00698                   fCCWtLowC2*totph*totph +
00699                   fCCWtLowC3*totph*totph*totph +
00700                   fCCWtLowC4*totph*totph*totph*totph;
00701         }
00702       else if( totph<fCCWtMidScale )
00703         {
00704           MSG("FarDetEvent",Msg::kVerbose) << "  using deweighted constants, middle scale... " << endl;
00705           cal_e = fCCWtMidC0 + fCCWtMidC1*totph;
00706         }
00707       else 
00708         {
00709           MSG("FarDetEvent",Msg::kVerbose) << "  using deweighted constants, high scale... " << endl;
00710           cal_e = fCCWtHiC0 + fCCWtHiC1*totph;
00711         }
00712 
00713     }
00714 
00715   MSG("FarDetEvent",Msg::kVerbose) << "   " << totph << " MIPs -> " << cal_e << " GeV" << endl;
00716 
00717   return cal_e;
00718 }

bool AlgFarDetEvent::Contained const CandTrackHandle track  )  [private]
 

Definition at line 292 of file AlgFarDetEvent.cxx.

References CandRecoHandle::GetEndPlane(), CandRecoHandle::GetEndU(), CandRecoHandle::GetEndV(), CandRecoHandle::GetVtxPlane(), CandRecoHandle::GetVtxU(), and CandRecoHandle::GetVtxV().

Referenced by GetShower().

00293 {
00294   // vertex containment
00295   double VtxU = track->GetVtxU();
00296   double VtxV = track->GetVtxV();
00297   double VtxR = sqrt(VtxU*VtxU+VtxV*VtxV);
00298   bool VtxContained = (VtxR<3.75 && VtxR>0.4) && ((track->GetVtxPlane()>5 && track->GetVtxPlane()<243) || (track->GetVtxPlane()>254 && track->GetVtxPlane()<480));
00299 
00300   // end containment
00301   double EndU = track->GetEndU();
00302   double EndV = track->GetEndV();
00303   double EndR = sqrt(EndU*EndU+EndV*EndV);
00304   bool EndContained = (EndR<3.75 && EndR>0.4) && ((track->GetEndPlane()>5 && track->GetEndPlane()<243) || (track->GetEndPlane()>254 && track->GetEndPlane()<480));
00305 
00306   return (VtxContained && EndContained);
00307 }

double AlgFarDetEvent::DeDx Float_t  emu  )  [private]
 

Definition at line 309 of file AlgFarDetEvent.cxx.

References pow().

Referenced by GetShower().

00310 {
00311   double dedx = 0.;
00312   double mm = 105.658389;
00313   double mm_2 = mm*mm;
00314   
00315   if(emu*emu-mm_2<0.){return 0.;}
00316   double a_2     = 1./(137.036*137.036);
00317   double pi = 3.141;
00318   double Na = 6.023;
00319   double lamda_2 = 3.8616*3.8616;
00320   double Z_A = 0.5377;
00321   double me  = 0.51099906;
00322   double me_2 = me*me; 
00323   double beta = sqrt(emu*emu-mm_2)/emu;
00324   double beta_2 = beta*beta;
00325   double gamma = emu/105.658389;
00326   double gamma_2 = gamma*gamma;
00327   double I = 68.7e-6;
00328   double I_2 = I*I;
00329   double p = sqrt(emu*emu-mm_2);
00330   double p_2 = p*p;
00331   double Em = 2 * me * p_2 / ( me_2 + mm_2 + 2*me*emu );
00332   double Em_2= Em*Em;
00333   double emu_2 = emu*emu;
00334   double X0 = 0.165;
00335   double X1 = 2.503;
00336   double X = log10(beta*gamma);
00337   double a = 0.165;
00338   double C = -3.3;
00339   double m = 3.222;
00340   double d = 0;
00341   if(X0 < X && X < X1){d = 4.6052 * X + a * pow(X1-X,m) + C;}
00342   if(X > X1){d = 4.6052 * X + C;}
00343 
00344   dedx =  a_2 * 2*pi * Na * lamda_2 * Z_A * (me / beta_2) *( log( 2*me*beta_2*gamma_2*Em/I_2 ) - 2*beta_2 + 0.25*(Em_2/emu_2) - d );
00345 
00346   return 10*dedx;
00347 }

double AlgFarDetEvent::GetDeWeightFactor const double &  LinearEhad,
AlgConfig ac
[private]
 

Definition at line 508 of file AlgFarDetEvent.cxx.

References Registry::GetDouble(), Registry::KeyExists(), and MSG.

Referenced by RunAlg().

00509 {
00510   double deweightfactorCC(1.0);
00511 
00512   double fdeweightLowScale(0.0);
00513   double fdeweightC0(0.0);
00514   double fdeweightC1(0.0);
00515   double fdeweightC2(0.0);
00516   double fdeweightC3(0.0);
00517 
00518   bool warn =false;
00519   TString errstring="AlgFarDetEvent::GetDeWeightFactor - Failed to get AlgConfig info for the following keys: ";
00520   
00521   if( ac.KeyExists("deweightLowScale") ) fdeweightLowScale = ac.GetDouble("deweightLowScale");
00522   else {errstring+="deweightLowScale, "; warn =true; }
00523   if( ac.KeyExists("deweightC0") )fdeweightC0 = ac.GetDouble("deweightC0");
00524   else {errstring+="deweightC0, "; warn =true; }
00525   if( ac.KeyExists("deweightC1") )fdeweightC1 = ac.GetDouble("deweightC1");
00526   else {errstring+="deweightC1, "; warn =true; }
00527   if( ac.KeyExists("deweightC2") )fdeweightC2 = ac.GetDouble("deweightC2");
00528   else {errstring+="deweightC2, "; warn =true; }
00529   if( ac.KeyExists("deweightC3") )fdeweightC3 = ac.GetDouble("deweightC3");
00530   else {errstring+="deweightC3"; warn =true; }
00531   if(warn) MSG("FarDetEvent",Msg::kWarning) << errstring.Data() <<endl;
00532 
00533   if(LinearEhad < fdeweightLowScale)
00534     {
00535       deweightfactorCC = fdeweightC0 + 
00536                          fdeweightC1*LinearEhad +
00537                          fdeweightC2*LinearEhad*LinearEhad +
00538                          fdeweightC3*LinearEhad*LinearEhad*LinearEhad;
00539     }
00540   
00541   MSG("FarDetEvent",Msg::kVerbose) << " LinearEnergy=" << LinearEhad << " DeweightFactor=" << deweightfactorCC << endl;
00542 
00543   return deweightfactorCC;
00544 }

void AlgFarDetEvent::GetPulseHeight vector< double > &  TempShw,
vector< double > &  TempTrk,
double &  totph,
const double &  deweight
[private]
 

Definition at line 550 of file AlgFarDetEvent.cxx.

References MSG, and pow().

Referenced by RunAlg().

00551 {
00552 
00553   // zero pulse height
00554   totph=0.0;
00555   
00556   double ph;
00557   double pulseheight_check_1(0);
00558   double pulseheight_check_2(0);
00559   double pulseheight_check_3(0);
00560 
00561   unsigned int nstrips = TempShw.size();
00562   if( nstrips<1 ) return;
00563 
00564   if( deweight>=1.0 )
00565     {
00566       for(unsigned int i=0; i<nstrips; ++i)
00567         {
00568           ph = TempShw[i]-TempTrk[i];
00569           pulseheight_check_1 += TempShw[i];
00570           pulseheight_check_2 += TempTrk[i];
00571           totph += ph;
00572         }
00573       MSG("FarDetEvent",Msg::kVerbose) << "    ... linear check: ShwPH=" << pulseheight_check_1 << ", TrkPH=" << pulseheight_check_2 << endl;
00574     }
00575   else
00576     {
00577       for(unsigned int i=0; i<nstrips; ++i)
00578         {
00579           if( TempShw[i]-1.4*TempTrk[i]>0.0 )
00580             {
00581               ph = TempShw[i]-1.4*TempTrk[i];
00582               pulseheight_check_3 += ph;
00583               totph += pow(ph,deweight);
00584             }
00585         }
00586         MSG("FarDetEvent",Msg::kVerbose) << "    ... deweight check: ShwPH-TrkPH=" << pulseheight_check_3 << endl;   
00587     }
00588 
00589   return;
00590 }

void AlgFarDetEvent::GetShower const CandShowerHandle shower,
const CandTrackHandle track,
vector< double > &  TempShw,
vector< double > &  TempTrk
[private]
 

Definition at line 356 of file AlgFarDetEvent.cxx.

References Contained(), DeDx(), Calibrator::GetAttenCorrected(), CandStripHandle::GetCharge(), CandHandle::GetDaughterIterator(), Calibrator::GetMIP(), CandTrackHandle::GetMomentum(), CandFitTrackHandle::GetMomentumCurve(), CandFitTrackHandle::GetMomentumRange(), CandStripHandle::GetPlane(), CandStripHandle::GetPlaneView(), CandStripHandle::GetStrip(), CandStripHandle::GetStripEndId(), CandShowerHandle::GetU(), CandShowerHandle::GetV(), CandRecoHandle::GetVtxDirCosZ(), Calibrator::Instance(), and MSG.

Referenced by RunAlg().

00360 {
00361 
00362   Calibrator& cal = Calibrator::Instance();
00363   int indx(-1),pln(-1),strp(-1);
00364 
00365 
00366   // make map of shower strips
00367   // ========================
00368   map<int,int> isShowerStrip;
00369   if( shower ) 
00370     {
00371       TIter shwitr(shower->GetDaughterIterator());
00372       while(CandStripHandle* strip = (CandStripHandle*)(shwitr()))
00373         { 
00374           if( strip )
00375             {
00376               pln = strip->GetPlane();
00377               strp = strip->GetStrip();
00378               indx = strp + 192*pln;
00379               isShowerStrip[indx] = 1;
00380             }
00381         }
00382     }
00383 
00384 
00385   // make map of track strips
00386   // ========================
00387   map<int,int> isTrackStrip;
00388   
00389   double sharedplanes(0.0);
00390   if( track ) 
00391     {
00392       int minpln(-999),maxpln(-999);
00393       TIter trkitr(track->GetDaughterIterator());
00394       while(CandStripHandle* strip = (CandStripHandle*)(trkitr()))
00395         { 
00396           if( strip )
00397             {
00398               pln = strip->GetPlane();
00399               strp = strip->GetStrip();
00400               indx = strp + 192*pln;
00401               isTrackStrip[indx] = 1;
00402 
00403               if( isShowerStrip[indx]==1 )
00404                 {
00405                   if(minpln<0 || pln<minpln) minpln=pln;
00406                   if(maxpln<0 || pln>maxpln) maxpln=pln;
00407                 }
00408             }
00409         }
00410     
00411       if( maxpln>=0 && minpln>=0 && maxpln-minpln>=0 )
00412         {
00413           sharedplanes = 1+maxpln-minpln;
00414         }
00415     }
00416 
00417   MSG("FarDetEvent",Msg::kVerbose) << "    ... shared planes = " << sharedplanes << endl;    
00418 
00419 
00420   // Calculate track correction (MIPs per strip) to remove from shower
00421   // =================================================================
00422   double trackcorrection = 0.0;
00423   if(track)
00424     { 
00425        double pmu = track->GetMomentum();
00426        double trackdircosZ = fabs(1.0/(track->GetVtxDirCosZ())); 
00427        MSG("FarDetEvent",Msg::kVerbose) << "    ... track direction = " << trackdircosZ << endl;
00428 
00429        const CandFitTrackHandle* fit = dynamic_cast<const CandFitTrackHandle*>(track);
00430        if( fit )
00431          {
00432            if( this->Contained(track) ) pmu = fit->GetMomentumRange(); 
00433            else pmu = fit->GetMomentumCurve();
00434          }
00435 
00436        // (Note: alternative dEdX calculation)
00437        // Material  poly(MinosMaterial::ePolystyreneMinos);
00438        // BetheBlochModel bbmodel(poly);
00439        // double dedx = bbmodel.dE_dx(emu*1000.)/1.985; 
00440 
00441        double dedx = DeDx(1000.0*pmu)/1.985;
00442        double dedx_end = dedx;
00443        double pmuend = pmu - sharedplanes/(30.*trackdircosZ);
00444        MSG("FarDetEvent",Msg::kVerbose) << "    ... muon momentum: vtx = " << pmu << " end = " << pmuend << endl;
00445        if( pmuend>0.3 ) // beta*gamma~3 => p~300MeV
00446          {
00447            dedx_end = DeDx(1000.0*pmuend)/1.985;
00448          }
00449        
00450        double avg_dedx = 0.5*(dedx+dedx_end);
00451        MSG("FarDetEvent",Msg::kVerbose) << "    ... average dedx per strip (MIPs) = " << avg_dedx << endl;
00452 
00453        double temp_trackdircosZ = fabs(trackdircosZ);
00454        if( temp_trackdircosZ<0.5 ) temp_trackdircosZ = 0.5;
00455        trackcorrection = avg_dedx/temp_trackdircosZ;
00456     }
00457   
00458   MSG("FarDetEvent",Msg::kVerbose) << "    ... track correction = " << trackcorrection << endl;
00459 
00460   // Calculate the MIP values for each strip in the shower
00461   // =====================================================
00462   
00463   if(shower)
00464     {
00465       double opos(0.0);
00466       double sigmapN(0.0),sigmapP(0.0);
00467       double shwMIP(0.0),trkMIP(0.0); 
00468       TIter shwitr(shower->GetDaughterIterator());
00469       while(CandStripHandle* strip = (CandStripHandle*)(shwitr()))
00470         { 
00471           if( strip )
00472             {
00473               pln = strip->GetPlane();
00474               strp = strip->GetStrip();
00475               indx = strp + 192*pln;
00476 
00477               shwMIP = 0.0; 
00478               trkMIP = 0.0;
00479               opos = 0.0;
00480 
00481               if(strip->GetPlaneView()==PlaneView::kU) opos = -1.0*shower->GetV(pln); 
00482               if(strip->GetPlaneView()==PlaneView::kV) opos =  1.0*shower->GetU(pln); 
00483               if( fabs(opos)<999.9 )
00484                 {
00485                   sigmapN=cal.GetAttenCorrected(strip->GetCharge(StripEnd::kNegative,CalDigitType::kSigCorr), opos, strip->GetStripEndId(StripEnd::kNegative) );
00486                   shwMIP+=cal.GetMIP(sigmapN, strip->GetStripEndId(StripEnd::kNegative) );
00487                   sigmapP=cal.GetAttenCorrected(strip->GetCharge(StripEnd::kPositive,CalDigitType::kSigCorr), opos, strip->GetStripEndId(StripEnd::kPositive) );
00488                   shwMIP+=cal.GetMIP(sigmapP, strip->GetStripEndId(StripEnd::kPositive) );
00489                 }
00490               
00491               if( isTrackStrip[indx]==1 )
00492                 {
00493                   trkMIP = trackcorrection;
00494                 }
00495               TempShw.push_back(shwMIP);
00496               TempTrk.push_back(trkMIP);
00497             }   
00498         }  
00499     }
00500   
00501   return;
00502 }

void AlgFarDetEvent::RunAlg AlgConfig ac,
CandHandle ch,
CandContext cx
[virtual]
 

Implements AlgBase.

Definition at line 53 of file AlgFarDetEvent.cxx.

References CalibrateShowerEnergy(), CandContext::GetCandRecord(), CandContext::GetDataIn(), GetDeWeightFactor(), CandStripHandle::GetPlane(), CandEventHandle::GetPrimaryShower(), CandEventHandle::GetPrimaryTrack(), GetPulseHeight(), GetShower(), RecMinos::GetVldContext(), CandStripHandle::GetZPos(), Calibrator::Instance(), MSG, Calibrator::ReInitialise(), CandEventHandle::SetEnergy(), FarDetEventHandle::SetMaxPlane(), FarDetEventHandle::SetMaxZ(), FarDetEventHandle::SetMinPlane(), FarDetEventHandle::SetMinZ(), SetShowerProperties(), FarDetEventHandle::SetShwEnergyGeV(), FarDetEventHandle::SetShwEnergyGeVDeweighted(), FarDetEventHandle::SetShwEnergyGeVLinear(), FarDetEventHandle::SetShwMipsDeweighted(), FarDetEventHandle::SetShwMipsLinear(), and SetTrackProperties().

00054 {
00055   MSG("FarDetEvent",Msg::kDebug) << " AlgFarDetEvent::RunAlg(....) " << endl;
00056 
00057   FarDetEventHandle& myevent = dynamic_cast<FarDetEventHandle&>(ch);
00058 
00059   Calibrator& cal = Calibrator::Instance();
00060   cal.ReInitialise(*(cx.GetCandRecord()->GetVldContext()));
00061 
00062   // Unpack CandContext
00063   // ==================
00064   const TObjArray* eventArray = dynamic_cast<const TObjArray*>(cx.GetDataIn());
00065 
00066   CandFitTrackHandle* fit = (CandFitTrackHandle*)(eventArray->At(0));
00067   CandTrackHandle* trk = (CandTrackHandle*)(eventArray->At(1));
00068   CandShowerHandle* shw = (CandShowerHandle*)(eventArray->At(2));
00069   // TObjArray* HadronicShowers = (TObjArray*)(eventArray->At(3));
00070   // TObjArray* BremsAndDeltas = (TObjArray*)(eventArray->At(4));
00071   // TObjArray* AssociatedStrips = (TObjArray*)(eventArray->At(5));
00072   TObjArray* AllStrips = (TObjArray*)(eventArray->At(6));
00073   
00074   // Set primary track and shower properties
00075   // =======================================
00076   MSG("FarDetEvent",Msg::kDebug) << " Setting track properties " << endl;
00077   this->SetTrackProperties(&myevent, fit, trk);
00078 
00079   MSG("FarDetEvent",Msg::kDebug) << " Setting shower properties " << endl;
00080   this->SetShowerProperties(&myevent, shw);
00081 
00082   if( myevent.GetPrimaryTrack()==0 && myevent.GetPrimaryShower()==0 )
00083     {
00084       MSG("FarDetEvent",Msg::kWarning) << " AlgFarDetEvent: Event has no primary track or shower!" << endl; 
00085     }
00086 
00087   // Calculate other event properties
00088   // ================================
00089   MSG("FarDetEvent",Msg::kDebug) << " Setting event properties " << endl;
00090 
00091   int minplane(-999), maxplane(-999);
00092   double minz(-999.9), maxz(-999.9);
00093 
00094   for(Int_t i=0; i<AllStrips->GetEntries(); i++)
00095     {
00096       CandStripHandle* strip = (CandStripHandle*)(AllStrips->At(i));
00097     
00098       if( minplane<0 || strip->GetPlane()<minplane ){
00099         minplane = strip->GetPlane(); 
00100         minz = strip->GetZPos();
00101       }
00102  
00103       if( maxplane<0 || strip->GetPlane()>maxplane ){
00104         maxplane = strip->GetPlane();  
00105         maxz = strip->GetZPos();
00106       }
00107 
00108     }
00109 
00110   myevent.SetMinPlane(minplane); 
00111   myevent.SetMaxPlane(maxplane);
00112   myevent.SetMinZ(minz); 
00113   myevent.SetMaxZ(maxz);
00114 
00115   // Calculate event kinematics
00116   // ==========================
00117   MSG("FarDetEvent",Msg::kDebug) << " Calculating event kinematics " << endl;
00118 
00119   double EhadLinear(0.), EhadDeweight(0.);
00120 
00121   // (1) get MIP values for each shower strip
00122   // ========================================
00123   // input: primary shower, primary track
00124   // output: list of MIPs, track correction, shared planes 
00125 
00126   MSG("FarDetEvent",Msg::kDebug) << " (1) calculate MIP values for each strip " << endl;
00127 
00128   vector<double> TempShw;
00129   vector<double> TempTrk;
00130 
00131   this->GetShower( myevent.GetPrimaryShower(), myevent.GetPrimaryTrack(), TempShw, TempTrk );
00132 
00133   MSG("FarDetEvent",Msg::kDebug) << "    ... shower strips = " << TempShw.size() << endl;
00134 
00135   // (2) calculate pulse height and energy
00136   // =====================================
00137   // input: list of MIPs, track correction, shared planes, deweight factor
00138   // output: corrected pulse height, then shower energy
00139 
00140   MSG("FarDetEvent",Msg::kDebug) << " (2) calculate pulse height and energy " << endl;
00141 
00142   // linear pulse height and energy
00143   double linearfactor(1.0), linearph(0.0);
00144 
00145   this->GetPulseHeight( TempShw, TempTrk, linearph, linearfactor );
00146 
00147   EhadLinear = this->CalibrateShowerEnergy( linearph, linearfactor, ac );
00148 
00149   MSG("FarDetEvent",Msg::kDebug) << "    ... linear pulse height = " << linearph << endl;
00150   MSG("FarDetEvent",Msg::kDebug) << "        linear energy = " << EhadLinear << endl;
00151 
00152   // deweighted pulse height and energy
00153   double deweightfactor(1.0), deweightph(0.0);
00154 
00155   deweightfactor = this->GetDeWeightFactor( EhadLinear, ac );
00156 
00157   this->GetPulseHeight( TempShw, TempTrk, deweightph, deweightfactor );
00158 
00159   EhadDeweight = this->CalibrateShowerEnergy( deweightph, deweightfactor, ac );
00160 
00161   MSG("FarDetEvent",Msg::kDebug) << "    ... deweighted pulse height = " << deweightph << endl;
00162   MSG("FarDetEvent",Msg::kDebug) << "        deweighted energy = " << EhadDeweight << endl;
00163 
00164   // set reconstructed shower energy
00165   myevent.SetShwMipsLinear(linearph);            
00166   myevent.SetShwMipsDeweighted(deweightph);        
00167   myevent.SetShwEnergyGeVLinear(EhadLinear); 
00168   myevent.SetShwEnergyGeVDeweighted(EhadDeweight); 
00169   myevent.SetShwEnergyGeV(EhadLinear); 
00170 
00171   // (3) calculate overall energy
00172   // ============================
00173   double Enu(0.0);
00174   
00175   myevent.SetEnergy(Enu);
00176 
00177   return;
00178 }

void AlgFarDetEvent::SetShowerProperties FarDetEventHandle evt,
CandShowerHandle shw
[private]
 

Definition at line 249 of file AlgFarDetEvent.cxx.

References CandEventHandle::AddShower(), CandRecoHandle::GetDirCosU(), CandRecoHandle::GetDirCosV(), CandRecoHandle::GetDirCosZ(), FarDetEventHandle::GetMuReco(), FarDetEventHandle::GetShwDirCosU(), FarDetEventHandle::GetShwDirCosV(), FarDetEventHandle::GetShwDirCosZ(), FarDetEventHandle::GetShwReco(), FarDetEventHandle::GetVtxPlane(), CandRecoHandle::GetVtxPlane(), CandRecoHandle::GetVtxT(), FarDetEventHandle::GetVtxTime(), FarDetEventHandle::GetVtxU(), CandRecoHandle::GetVtxU(), FarDetEventHandle::GetVtxV(), CandRecoHandle::GetVtxV(), FarDetEventHandle::GetVtxZ(), CandRecoHandle::GetVtxZ(), MSG, CandEventHandle::SetPrimaryShower(), FarDetEventHandle::SetShwDirCosU(), FarDetEventHandle::SetShwDirCosV(), FarDetEventHandle::SetShwDirCosZ(), FarDetEventHandle::SetShwReco(), FarDetEventHandle::SetVtxPlane(), FarDetEventHandle::SetVtxTime(), FarDetEventHandle::SetVtxU(), FarDetEventHandle::SetVtxV(), and FarDetEventHandle::SetVtxZ().

Referenced by RunAlg().

00250 {
00251   MSG("FarDetEvent",Msg::kVerbose) << " AlgFarDetEvent::SetShowerProperties(....) " << endl;
00252 
00253   if( shw )
00254     {
00255       // set primary shower properties
00256       MSG("FarDetEvent",Msg::kVerbose) << "   (found primary shower) " << endl;
00257       evt->SetShwReco(1);
00258       evt->AddShower(shw);
00259       evt->SetPrimaryShower(shw);
00260       evt->SetShwDirCosU(shw->GetDirCosU()); 
00261       evt->SetShwDirCosV(shw->GetDirCosV()); 
00262       evt->SetShwDirCosZ(shw->GetDirCosZ());
00263       if( evt->GetMuReco()==0 )
00264         {
00265           evt->SetVtxTime(shw->GetVtxT());
00266           evt->SetVtxU(shw->GetVtxU()); 
00267           evt->SetVtxV(shw->GetVtxV()); 
00268           evt->SetVtxZ(shw->GetVtxZ());
00269           evt->SetVtxPlane(shw->GetVtxPlane()); 
00270         }
00271     }
00272 
00273   MSG("FarDetEvent",Msg::kVerbose) << endl
00274     << " Shower properties: " << endl
00275     << "  ShwReco = " << evt->GetShwReco() << endl
00276     << "  ShwDirCosU = " << evt->GetShwDirCosU() << endl
00277     << "  ShwDirCosV = " << evt->GetShwDirCosV() << endl
00278     << "  ShwDirCosZ = " << evt->GetShwDirCosZ() << endl   
00279     << "  (VtxTime = " << evt->GetVtxTime() << ")" << endl
00280     << "  (VtxU = " << evt->GetVtxU() << ")" << endl
00281     << "  (VtxV = " << evt->GetVtxV() << ")" << endl
00282     << "  (VtxZ = " << evt->GetVtxZ() << ")" << endl
00283     << "  (VtxPlane = " << evt->GetVtxPlane() << ")" << endl;
00284 
00285   return;
00286 }

void AlgFarDetEvent::SetTrackProperties FarDetEventHandle evt,
CandFitTrackHandle fit,
CandTrackHandle trk
[private]
 

Definition at line 183 of file AlgFarDetEvent.cxx.

References CandEventHandle::AddTrack(), CandRecoHandle::GetDirCosU(), CandRecoHandle::GetDirCosV(), CandRecoHandle::GetDirCosZ(), FarDetEventHandle::GetEMCharge(), CandFitTrackHandle::GetEMCharge(), CandTrackHandle::GetMomentum(), CandFitTrackHandle::GetMomentumCurve(), CandFitTrackHandle::GetMomentumRange(), FarDetEventHandle::GetMuDirCosU(), FarDetEventHandle::GetMuDirCosV(), FarDetEventHandle::GetMuDirCosZ(), FarDetEventHandle::GetMuMomentumCurve(), FarDetEventHandle::GetMuMomentumRange(), FarDetEventHandle::GetMuReco(), FarDetEventHandle::GetVtxPlane(), CandRecoHandle::GetVtxPlane(), CandRecoHandle::GetVtxT(), FarDetEventHandle::GetVtxTime(), FarDetEventHandle::GetVtxU(), CandRecoHandle::GetVtxU(), FarDetEventHandle::GetVtxV(), CandRecoHandle::GetVtxV(), FarDetEventHandle::GetVtxZ(), CandRecoHandle::GetVtxZ(), MSG, FarDetEventHandle::SetEMCharge(), FarDetEventHandle::SetMuDirCosU(), FarDetEventHandle::SetMuDirCosV(), FarDetEventHandle::SetMuDirCosZ(), FarDetEventHandle::SetMuMomentumCurve(), FarDetEventHandle::SetMuMomentumRange(), FarDetEventHandle::SetMuReco(), CandEventHandle::SetPrimaryTrack(), FarDetEventHandle::SetVtxPlane(), FarDetEventHandle::SetVtxTime(), FarDetEventHandle::SetVtxU(), FarDetEventHandle::SetVtxV(), and FarDetEventHandle::SetVtxZ().

Referenced by RunAlg().

00184 {
00185   MSG("FarDetEvent",Msg::kVerbose) << " AlgFarDetEvent::SetTrackProperties(....) " << endl;
00186 
00187   CandTrackHandle* track = 0; 
00188 
00189   double erange,ecurve,emcharge;
00190   // Use the fitted track if we have one...
00191   if(fit) 
00192     {
00193       track = fit;
00194       erange = fit->GetMomentumRange();
00195       ecurve = fabs(fit->GetMomentumCurve());
00196       emcharge = fit->GetEMCharge();
00197     }  
00198   // ...or else fall back to found track
00199   else if( trk ) 
00200     {
00201       track = trk;
00202       erange = trk->GetMomentum();
00203       ecurve = 0.0;
00204       emcharge = 0.0;
00205     }
00206   
00207   if( track )
00208     {
00209       // set primary track properties
00210       MSG("FarDetEvent",Msg::kVerbose) << "   (found primary track) " << endl;
00211       evt->AddTrack(track);
00212       evt->SetPrimaryTrack(track);
00213       evt->SetMuReco(1);
00214       evt->SetMuMomentumRange(erange);
00215       evt->SetMuMomentumCurve(ecurve);
00216       evt->SetEMCharge(emcharge);
00217       evt->SetMuDirCosU(track->GetDirCosU()); 
00218       evt->SetMuDirCosV(track->GetDirCosV()); 
00219       evt->SetMuDirCosZ(track->GetDirCosZ());
00220       evt->SetVtxTime(track->GetVtxT());
00221       evt->SetVtxU(track->GetVtxU()); 
00222       evt->SetVtxV(track->GetVtxV()); 
00223       evt->SetVtxZ(track->GetVtxZ());
00224       evt->SetVtxPlane(track->GetVtxPlane()); 
00225     }
00226 
00227   MSG("FarDetEvent",Msg::kVerbose) << endl
00228     << " Track Properties: " << endl
00229     << "  MuReco = " << evt->GetMuReco() << endl
00230     << "  MuMomentumRange = " << evt->GetMuMomentumRange() << endl
00231     << "  MuMomentumCurve = " << evt->GetMuMomentumCurve() << endl
00232     << "  EMCharge = " << evt->GetEMCharge() << endl
00233     << "  MuDirCosU = " << evt->GetMuDirCosU() << endl
00234     << "  MuDirCosV = " << evt->GetMuDirCosV() << endl
00235     << "  MuDirCosZ = " << evt->GetMuDirCosZ() << endl   
00236     << "  (VtxTime = " << evt->GetVtxTime() << ")" << endl
00237     << "  (VtxU = " << evt->GetVtxU() << ")" << endl
00238     << "  (VtxV = " << evt->GetVtxV() << ")" << endl
00239     << "  (VtxZ = " << evt->GetVtxZ() << ")" << endl
00240     << "  (VtxPlane = " << evt->GetVtxPlane() << ")" << endl;
00241 
00242   return;
00243 }

void AlgFarDetEvent::Trace const char *  c  )  const [virtual]
 

Reimplemented from AlgBase.

Definition at line 720 of file AlgFarDetEvent.cxx.

00721 {
00722 
00723 }


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:00:07 2008 for loon by  doxygen 1.3.9.1