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

AlgChopListPerfectMC.cxx

Go to the documentation of this file.
00001 
00002 // $Id: AlgChopListPerfectMC.cxx,v 1.4 2010/01/06 17:15:44 rhatcher 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 #include "DataUtil/GetRawBlock.h"
00037 
00038 ClassImp(AlgChopListPerfectMC)
00039 CVSID( " $Id: AlgChopListPerfectMC.cxx,v 1.4 2010/01/06 17:15:44 rhatcher Exp $ ");
00040 
00041 struct compareDigitTimes : public binary_function<const CandDigitHandle&, const CandDigitHandle&, bool> {
00042   bool operator()(const CandDigitHandle& d1, const CandDigitHandle& d2) {
00043     return (d1.GetTime() < d2.GetTime());
00044   }
00045 };
00046 
00047 const RawChannelId kQieRcid(Detector::kNear,ElecType::kQIE,0,0,false,false);
00048 
00049 
00050 //______________________________________________________________________
00051 AlgChopListPerfectMC::AlgChopListPerfectMC()
00052 {
00056 
00057 }
00058 
00059 //______________________________________________________________________
00060 AlgChopListPerfectMC::~AlgChopListPerfectMC()
00061 {
00062 }
00063 
00064 
00065 
00066 //______________________________________________________________________
00067 void AlgChopListPerfectMC::RunAlg(AlgConfig& /*algConfig*/, 
00068                            CandHandle &candHandle,  // thing to make
00069                            CandContext &candContext)
00070 {
00074 
00075   assert(candHandle.InheritsFrom("CandChopListHandle"));
00076   CandChopListHandle &sliceList = dynamic_cast<CandChopListHandle &>(candHandle);
00077 
00078    assert(candContext.GetDataIn());
00079    // Check for CandDigitListHandle input
00080    if (!(candContext.GetDataIn()->InheritsFrom("CandDigitListHandle"))) {
00081      MSG("Chop",Msg::kWarning ) << "Data into AlgChopListPerfectMC is not a digit list." << std::endl;
00082    }
00083    
00084    const CandDigitListHandle *cdlh_ptr = 
00085      dynamic_cast<const CandDigitListHandle*>(candContext.GetDataIn());
00086    
00087    const MomNavigator *mom = candContext.GetMom();
00088    const RawDigitDataBlock* rddb = DataUtil::GetRawBlock<RawDigitDataBlock>(mom);
00089    if (!rddb) {
00090      MSG("Chop", Msg::kWarning) << "No RawDigitDataBlock in RawRecord." << endl;
00091      return;
00092    }
00093    
00094    // Get setup for the DigitList maker algorithm
00095    AlgFactory &af = AlgFactory::GetInstance();
00096    AlgHandle ah = af.GetAlgHandle("AlgChop","default");
00097    CandContext cxx(this,candContext.GetMom());
00098 
00099    const VldContext &context = *(candContext.GetCandRecord()->GetVldContext());
00100    if(context.GetDetector() != Detector::kNear) 
00101      MSG("Chop",Msg::kError) << "Running the PerfectMC algorithm on FD data is a no-no!" << endl;
00102 
00103    //Calibrator& cal = Calibrator::Instance();
00104    UgliGeomHandle ugli(context);
00105   
00106    // Now do the actual slicing.
00107 
00108    // First, make a nice stl vector of the digits.
00109    DigitVector digits(cdlh_ptr);
00110    UInt_t ndigits = digits.size();
00111    UInt_t nslice = 0;
00112 
00113    const Truthifier& truth = Truthifier::Instance(candContext.GetMom());
00114    std::vector<Int_t> neutrinos = truth.GetListOfNeutrinoIndecies();
00115 
00116    for(UInt_t inu=0; inu < neutrinos.size(); inu++) {
00117      // For each true neutrino in the event, make a slice:
00118      DigitVector slc;
00119 
00120      // Loop through digits and put the relevant ones in.
00121      for(UInt_t idig = 0; idig<ndigits; idig++) {
00122        float frac = truth.IsDigitFromNeutrino(neutrinos[inu],digits[idig]);
00123        if(frac>0.20) // Include the digit if more than 20% of it belongs to this neutrino.
00124          slc.push_back(digits[idig]);
00125      }
00126      if(slc.size()>0) { // there was at least one digit for this neutrino:
00127        // Store the slice.
00128        cxx.SetDataIn(&(slc));
00129        CandDigitListHandle sliceHandle = CandDigitList::MakeCandidate(ah,cxx);
00130        sliceHandle.SetName(Form("Chop %d",nslice++));
00131        sliceHandle.SetTitle(Form("Neutrino %d StdHepIndex %d",inu,neutrinos[inu]));
00132        sliceList.AddDaughterLink(sliceHandle);       
00133      }
00134    }
00135 
00136 }
00137 
00138 //______________________________________________________________________
00139 void AlgChopListPerfectMC::Trace(const char * /* c */) const
00140 {
00141 }
00142 

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