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

FillShower.cxx

Go to the documentation of this file.
00001 // $Id: FillShower.cxx,v 1.15 2008/01/31 22:18:17 rustem Exp $
00002 
00003 // ROOT
00004 #include "TClonesArray.h"
00005 
00006 // MINOS
00007 #include "CandNtupleSR/NtpSRShower.h"
00008 #include "DataUtil/EnergyCorrections.h"
00009 #include "MessageService/MsgService.h"
00010 #include "MinosObjectMap/MomNavigator.h"
00011 #include "RecoBase/CandShowerHandle.h"
00012 #include "Registry/Registry.h"
00013 #include "StandardNtuple/NtpStRecord.h"
00014 
00015 // Local
00016 #include "PhysicsNtuple/Default.h"
00017 #include "PhysicsNtuple/Factory.h"
00018 
00019 // Local
00020 #include "FillShower.h"
00021 
00022 CVSID("$Id: FillShower.cxx,v 1.15 2008/01/31 22:18:17 rustem Exp $");
00023 
00024 REGISTER_ANP_OBJECT(AlgStore,FillShower)
00025 
00026 namespace EnergyCorrections{}
00027 using namespace EnergyCorrections;
00028 using namespace std;
00029 
00030 //-------------------------------------------------------------------
00031 Anp::FillShower::FillShower()
00032    :fCorr(true)
00033 {    
00034 }
00035 
00036 //----------------------------------------------------------------------
00037 Anp::FillShower::~FillShower()
00038 {
00039 }
00040 
00041 //----------------------------------------------------------------------
00042 bool Anp::FillShower::Run(Record& record, TObject *ptr)
00043 {
00044    //
00045    // Fill reconstructed shower information for PhysicsNtuple/Shower.h
00046    //
00047 
00048    if(!record.GetHeader().IsValid())
00049    {
00050       MSG("FillAlg", Msg::kError) << "Header is not valid" << endl;
00051       return false;
00052    }
00053 
00054    NtpStRecord *ntprec = dynamic_cast<NtpStRecord *>(ptr);
00055    if(!ntprec)
00056    {
00057       const MomNavigator *mom = dynamic_cast<const MomNavigator *> (ptr);
00058       if(mom)
00059       {
00060          ntprec = dynamic_cast<NtpStRecord *>(mom -> GetFragment("NtpStRecord")); 
00061       }
00062       else
00063       {
00064          MSG("FillAlg", Msg::kError) << "Failed to find MomNavigator pointer" << endl;
00065          return false;
00066       }      
00067    }
00068 
00069    if(!ntprec)
00070    {
00071       MSG("FillAlg", Msg::kError) << "Failed to get NtpStRecord pointer" << endl;
00072       return false;
00073    }
00074 
00075    const TClonesArray *shower_array = ntprec -> shw;
00076    if(!shower_array)
00077    {
00078       MSG("FillAlg", Msg::kError) << "NtpStRecord does not have valid shower array." <<endl;
00079       return true;
00080    }
00081 
00082    const VldContext vldc = ntprec -> GetHeader().GetVldContext();
00083    const int nshowers = shower_array -> GetEntries();
00084 
00085    for(int i = 0; i < nshowers; ++i)
00086    {
00087       NtpSRShower *ntpshw  = dynamic_cast<NtpSRShower *>(shower_array -> At(i));
00088       if(!ntpshw)
00089       {
00090          MSG("FillAlg", Msg::kWarning) << "No shower at " << i << endl;
00091          continue;
00092       }
00093 
00094       if(ntpshw -> index != i)
00095       {
00096          MSG("FillAlg", Msg::kWarning) << "Mismatched shower index" << endl;
00097          continue;
00098       }
00099 
00100       if(!fBasic.Fill(*ntprec, *ntpshw))
00101       {
00102          MSG("FillAlg", Msg::kError) << "Failed to fill basic shower information" << endl;
00103          continue;
00104       }
00105 
00106       Shower shower;
00107       
00108       shower.index      = ntpshw -> index;
00109       shower.lin_cc_def = ntpshw -> shwph.linCCgev;
00110       shower.lin_nc_def = ntpshw -> shwph.linNCgev;
00111       shower.wt_cc_def  = ntpshw -> shwph.wtCCgev;
00112       shower.wt_nc_def  = ntpshw -> shwph.wtNCgev;
00113       shower.em         = ntpshw -> shwph.EMgev;
00114 
00115       if(fCorr)
00116       {
00117          shower.lin_cc = FullyCorrectShowerEnergy(ntpshw -> shwph.linCCgev,
00118                                                   CandShowerHandle::kCC,
00119                                                   vldc,
00120                                                   ntprec -> GetRelease());
00121          
00122          shower.wt_cc = FullyCorrectShowerEnergy(ntpshw -> shwph.wtCCgev,
00123                                                  CandShowerHandle::kWtCC,
00124                                                  vldc,
00125                                                  ntprec -> GetRelease());
00126          
00127          shower.lin_nc = FullyCorrectShowerEnergy(ntpshw -> shwph.linNCgev,
00128                                                   CandShowerHandle::kNC,
00129                                                   vldc,
00130                                                   ntprec -> GetRelease());
00131          
00132          shower.wt_nc = FullyCorrectShowerEnergy(ntpshw -> shwph.wtNCgev,
00133                                                  CandShowerHandle::kWtNC,
00134                                                  vldc,
00135                                                  ntprec -> GetRelease());
00136       }
00137       else
00138       {
00139          shower.lin_cc = ntpshw -> shwph.linCCgev;
00140          shower.lin_nc = ntpshw -> shwph.linNCgev;
00141          shower.wt_cc  = ntpshw -> shwph.wtCCgev;
00142          shower.wt_nc  = ntpshw -> shwph.wtNCgev;
00143       }
00144       
00145       shower.fBasic = fBasic.GetBasic();
00146       shower.fVtx   = fBasic.GetBegVtx();
00147       
00148       record.Add(shower);
00149    }
00150    
00151    return true;
00152 }
00153 
00154 //----------------------------------------------------------------------
00155 void Anp::FillShower::Config(const Registry &reg)
00156 {
00157    //
00158    // Configure self
00159    //
00160    
00161    Anp::Read(reg, "FillShowerCorr", fCorr);
00162 
00163    fBasic.Config(reg);
00164 
00165    if(reg.KeyExists("PrintConfig"))
00166    {
00167       cout << "FillShower::Config" << endl
00168            << "   Corr = " << fCorr << endl;
00169    }
00170 }

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