4 //----------------------------------------------------------------
6 const bool PhotonBackTracker::CanRun(Evt const& evt) {
7 return ! ( evt.isRealData() ) ;
11 //----------------------------------------------------------------
12 template<typename Evt>
13 void PhotonBackTracker::PrepOpDetBTRs(Evt const& evt)
15 if(this->BTRsReady()){ return;}
16 auto const& btrHandle = evt.template getValidHandle < std::vector < sim::OpDetBacktrackerRecord > > (fG4ModuleLabel);
17 if(btrHandle.failedToGet()){
18 /* mf::LogWarning("PhotonBackTracker") << "failed to get handle to simb::MCParticle from "
20 * << ", return";*/ //This is now silent as it is expected to happen every generation run. It is also temporary while we wait for
24 art::fill_ptr_vector(priv_OpDetBTRs, btrHandle);
26 auto compareBTRlambda = [](art::Ptr<sim::OpDetBacktrackerRecord> a, art::Ptr<sim::OpDetBacktrackerRecord> b) {return(a->OpDetNum()<b->OpDetNum());};
27 if (!std::is_sorted(priv_OpDetBTRs.begin(),priv_OpDetBTRs.end(),compareBTRlambda)) std::sort(priv_OpDetBTRs.begin(),priv_OpDetBTRs.end(),compareBTRlambda);
32 //----------------------------------------------------------------
33 template<typename Evt>
34 void PhotonBackTracker::PrepOpFlashToOpHits( Evt const& evt)
36 if(this->OpFlashToOpHitsReady()){ return;}
37 auto const& flashHandle = evt.template getValidHandle < std::vector < recob::OpFlash > > (fOpFlashLabel);
38 std::vector<art::Ptr<recob::OpFlash>> tmpVec;
39 art::fill_ptr_vector(tmpVec, flashHandle);
41 if(flashHandle.failedToGet()){
42 mf::LogWarning("PhotonBackTracker")<<" failed to get handle to recob::OpFlash. Has reco run yet?";
45 auto const& fmp = art::FindManyP<recob::OpHit>(flashHandle, evt, fOpHitLabel.label());
46 for ( size_t i=0; i<flashHandle->size(); i++)
47 fOpFlashToOpHits[tmpVec.at(i)] = fmp.at(i);
50 //----------------------------------------------------------------
51 template<typename Evt>
52 void PhotonBackTracker::PrepEvent( Evt const& evt)
54 if( !(this->CanRun( evt ) ) ){
55 throw cet::exception("PhotonBackTracker")
56 <<"PhotonBackTracker cannot function."
57 <<"Is this file real data?";
59 priv_OpDetBTRs.clear();
60 this->PrepOpDetBTRs(evt);
61 this->PrepOpFlashToOpHits(evt);