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

AlgChopListPerfectMC.cxx

Go to the documentation of this file.
00001 
00002 // $Id: AlgChopListPerfectMC.cxx,v 1.2 2005/05/19 17:55:33 tagg Exp $
00003 //
00004 // AlgChopListPerfectMC.cxx
00005 //
00006 // A perfect slicer, that cheats by looking at MC truth info
00007 //
00009 
00010 #include <cassert>
00011 
00012 #include "CandChop/AlgChopListPerfectMC.h"
00013 #include "CandChop/CandChopListHandle.h"
00014 #include "CandChop/DigitVector.h"
00015 
00016 
00017 #include "Algorithm/AlgConfig.h"
00018 #include "Algorithm/AlgFactory.h"
00019 #include "Algorithm/AlgHandle.h"
00020 #include "CandData/CandHeader.h"
00021 #include "CandData/CandRecord.h"
00022 #include "CandDigit/CandDigitHandle.h"
00023 #include "CandDigit/CandDigitListHandle.h"
00024 #include "CandDigit/CandDigitList.h"
00025 #include "Candidate/CandContext.h"
00026 #include "MessageService/MsgService.h"
00027 #include "MinosObjectMap/MomNavigator.h"
00028 #include "RawData/RawHeader.h"
00029 #include "RawData/RawRecord.h"
00030 #include "RawData/RawDigitDataBlock.h"
00031 #include "UgliGeometry/UgliGeomHandle.h"
00032 #include "UgliGeometry/UgliStripHandle.h"
00033 #include "Validity/VldContext.h"
00034 #include "Calibrator/Calibrator.h"
00035 #include "DataUtil/Truthifier.h"
00036 
00037 ClassImp(AlgChopListPerfectMC)
00038 CVSID( " $Id: AlgChopListPerfectMC.cxx,v 1.2 2005/05/19 17:55:33 tagg Exp $ ");
00039 
00040 struct compareDigitTimes : public binary_function<const CandDigitHandle&, const CandDigitHandle&, bool> {
00041   bool operator()(const CandDigitHandle& d1, const CandDigitHandle& d2) {
00042     return (d1.GetTime() < d2.GetTime());
00043   }
00044 };
00045 
00046 const RawChannelId kQieRcid(DetectorType::kNear,ElecType::kQIE,0,0,false,false);
00047 
00048 
00049 //______________________________________________________________________
00050 AlgChopListPerfectMC::AlgChopListPerfectMC()
00051 {
00055 
00056 }
00057 
00058 //______________________________________________________________________
00059 AlgChopListPerfectMC::~AlgChopListPerfectMC()
00060 {
00061 }
00062 
00063 
00064 
00065 //______________________________________________________________________
00066 void AlgChopListPerfectMC::RunAlg(AlgConfig& /*algConfig*/, 
00067                            CandHandle &candHandle,  // thing to make
00068                            CandContext &candContext)
00069 {
00073 
00074   assert(candHandle.InheritsFrom("CandChopListHandle"));
00075   CandChopListHandle &sliceList = dynamic_cast<CandChopListHandle &>(candHandle);
00076 
00077    assert(candContext.GetDataIn());
00078    // Check for CandDigitListHandle input
00079    if (!(candContext.GetDataIn()->InheritsFrom("CandDigitListHandle"))) {
00080      MSG("Chop",Msg::kWarning ) << "Data into AlgChopListPerfectMC is not a digit list." << std::endl;
00081    }
00082    
00083    const CandDigitListHandle *cdlh_ptr = 
00084      dynamic_cast<const CandDigitListHandle*>(candContext.GetDataIn());
00085    
00086    const MomNavigator *mom = candContext.GetMom();
00087    RawRecord *rr = dynamic_cast<RawRecord *>(mom->GetFragment("RawRecord"));
00088    if (!rr) {
00089      MSG("Chop", Msg::kWarning) << "No RawRecord in MOM." << endl;
00090      return;
00091    }
00092    const RawDigitDataBlock *rddb = dynamic_cast<const RawDigitDataBlock *>
00093      (rr->FindRawBlock("RawDigitDataBlock"));
00094    if (!rddb) {
00095      MSG("Chop", Msg::kWarning) << "No RawDigitDataBlock in RawRecord." << endl;
00096      return;
00097    }
00098    
00099    // Get setup for the DigitList maker algorithm
00100    AlgFactory &af = AlgFactory::GetInstance();
00101    AlgHandle ah = af.GetAlgHandle("AlgChop","default");
00102    CandContext cxx(this,candContext.GetMom());
00103 
00104    const VldContext &context = *(candContext.GetCandRecord()->GetVldContext());
00105    if(context.GetDetector() != DetectorType::kNear) 
00106      MSG("Chop",Msg::kError) << "Running the PerfectMC algorithm on FD data is a no-no!" << endl;
00107 
00108    //Calibrator& cal = Calibrator::Instance();
00109    UgliGeomHandle ugli(context);
00110   
00111    // Now do the actual slicing.
00112 
00113    // First, make a nice stl vector of the digits.
00114    DigitVector digits(cdlh_ptr);
00115    UInt_t ndigits = digits.size();
00116    UInt_t nslice = 0;
00117 
00118    const Truthifier& truth = Truthifier::Instance(candContext.GetMom());
00119    std::vector<Int_t> neutrinos = truth.GetListOfNeutrinoIndecies();
00120 
00121    for(UInt_t inu=0; inu < neutrinos.size(); inu++) {
00122      // For each true neutrino in the event, make a slice:
00123      DigitVector slc;
00124 
00125      // Loop through digits and put the relevant ones in.
00126      for(UInt_t idig = 0; idig<ndigits; idig++) {
00127        float frac = truth.IsDigitFromNeutrino(neutrinos[inu],digits[idig]);
00128        if(frac>0.20) // Include the digit if more than 20% of it belongs to this neutrino.
00129          slc.push_back(digits[idig]);
00130      }
00131      if(slc.size()>0) { // there was at least one digit for this neutrino:
00132        // Store the slice.
00133        cxx.SetDataIn(&(slc));
00134        CandDigitListHandle sliceHandle = CandDigitList::MakeCandidate(ah,cxx);
00135        sliceHandle.SetName(Form("Chop %d",nslice++));
00136        sliceHandle.SetTitle(Form("Neutrino %d StdHepIndex %d",inu,neutrinos[inu]));
00137        sliceList.AddDaughterLink(sliceHandle);       
00138      }
00139    }
00140 
00141 }
00142 
00143 //______________________________________________________________________
00144 void AlgChopListPerfectMC::Trace(const char * /* c */) const
00145 {
00146 }
00147 

Generated on Thu Nov 1 15:51:40 2007 for loon by  doxygen 1.3.9.1