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

FillTrack.cxx

Go to the documentation of this file.
00001 // $Id: FillTrack.cxx,v 1.16 2008/02/09 19:15:19 rustem Exp $
00002 
00003 // ROOT
00004 #include "TClonesArray.h"
00005 
00006 // MINOS
00007 #include "CandNtupleSR/NtpSRTrack.h"
00008 #include "DataUtil/EnergyCorrections.h"
00009 #include "MessageService/MsgService.h"
00010 #include "MinosObjectMap/MomNavigator.h"
00011 #include "Registry/Registry.h"
00012 #include "StandardNtuple/NtpStRecord.h"
00013 
00014 // Local
00015 #include "PhysicsNtuple/Default.h"
00016 #include "PhysicsNtuple/Factory.h"
00017 
00018 // Local
00019 #include "FillTrack.h"
00020 
00021 CVSID("$Id: FillTrack.cxx,v 1.16 2008/02/09 19:15:19 rustem Exp $");
00022 
00023 REGISTER_ANP_OBJECT(AlgStore,FillTrack)
00024 
00025 namespace EnergyCorrections{}
00026 using namespace EnergyCorrections;
00027 using namespace std;
00028 
00029 //-----------------------------------------------------------------------------
00030 Anp::FillTrack::FillTrack()
00031    :fCorr(true)
00032 {    
00033 }
00034 
00035 //-----------------------------------------------------------------------------
00036 Anp::FillTrack::~FillTrack()
00037 {
00038 }
00039 
00040 //----------------------------------------------------------------------
00041 bool Anp::FillTrack::Run(Record& record, TObject *ptr)
00042 {
00043    //
00044    // Extract data from NtpSRTrack and save to Anp::Track
00045    //
00046 
00047    NtpStRecord *ntprec = dynamic_cast<NtpStRecord *>(ptr);
00048    if(!ntprec)
00049    {
00050       const MomNavigator *mom = dynamic_cast<const MomNavigator *> (ptr);
00051       if(mom)
00052       {
00053          ntprec = dynamic_cast<NtpStRecord *>(mom -> GetFragment("NtpStRecord")); 
00054       }
00055       else
00056       {
00057          MSG("FillAlg", Msg::kError) << "Failed to find MomNavigator pointer" << endl;
00058          return false;
00059       }      
00060    }
00061 
00062    if(!ntprec)
00063    {
00064       MSG("FillAlg", Msg::kError) << "Failed to get NtpStRecord pointer" << endl;
00065       return false;
00066    }
00067 
00068    const TClonesArray *track_array = ntprec -> trk;
00069    if(!track_array)
00070    {
00071       MSG("FillAlg", Msg::kWarning) << "NtpStRecord does not have valid track array." <<endl;
00072       return true;
00073    }
00074    
00075    const VldContext vldc = ntprec -> GetHeader().GetVldContext();
00076    const int ntrack = track_array -> GetEntries();
00077 
00078    for(int i = 0; i < ntrack; ++i)
00079    {
00080       NtpSRTrack *ntptrk  = dynamic_cast<NtpSRTrack *>(track_array -> At(i));
00081       if(!ntptrk)
00082       {
00083          MSG("FillAlg", Msg::kWarning) << "Failed to find NtpSRTrack at index " << i << endl;
00084          continue;
00085       }
00086       
00087       if(ntptrk -> index != i)
00088       {
00089          MSG("FillAlg", Msg::kWarning) << "Mismatched track index" << endl;
00090          continue;
00091       }
00092       
00093       if(!fBasic.Fill(*ntprec, *ntptrk))
00094       {
00095          MSG("FillAlg", Msg::kWarning) << "Failed to fill basic track information" << endl;
00096       }
00097 
00098       //
00099       // Fill variables for PhysicsNtuple/Track.h data class 
00100       //
00101       Track track;
00102 
00103       track.index       = ntptrk -> index;
00104       track.tracen      = ntptrk -> fidend.nplane;
00105       track.tracet      = ntptrk -> fidend.dr;
00106       track.fit_qp      = ntptrk -> momentum.qp;
00107       track.fit_eqp     = ntptrk -> momentum.eqp;
00108       track.fit_chi2    = ntptrk -> fit.chi2;
00109       track.fit_ndof    = ntptrk -> fit.ndof;
00110       track.pass_fit    = ntptrk -> fit.pass;
00111       track.range       = ntptrk -> range;
00112       track.p_range_def = ntptrk -> momentum.range;
00113 
00114       if(fCorr)
00115       {
00116          track.p_range = FullyCorrectMomentumFromRange(ntptrk -> momentum.range,
00117                                                        vldc,
00118                                                        ntprec -> GetRelease());
00119       }
00120       else
00121       {
00122          track.p_range = ntptrk -> momentum.range;
00123       }
00124 
00125       //
00126       // Fill vertex info
00127       //
00128       track.fBasic  = fBasic.GetBasic();
00129       track.fBegVtx = fBasic.GetBegVtx();
00130       track.fEndVtx = fBasic.GetEndVtx();
00131       
00132       //
00133       // Use default containment cut      
00134       //
00135       if(ntptrk -> contained == 1)
00136       {
00137          track.stopping = true;
00138       }
00139       else
00140       {
00141          track.stopping = false;
00142       }     
00143 
00144       record.Add(track);
00145    }
00146 
00147    return true;
00148 }
00149 
00150 //-----------------------------------------------------------------------------
00151 void Anp::FillTrack::Config(const Registry &reg)
00152 {
00153    //
00154    // Configure self
00155    //
00156    
00157    Anp::Read(reg, "FillTrackCorr", fCorr);
00158 
00159    fBasic.Config(reg);
00160 
00161    if(reg.KeyExists("PrintConfig"))
00162    {
00163       cout << "FillTrack::Config" << endl
00164            << "   Corr = " << fCorr << endl;
00165    }
00166 }

Generated on Mon Feb 15 11:06:42 2010 for loon by  doxygen 1.3.9.1