10 #ifndef SKIMMINGUTILS_H 11 #define SKIMMINGUTILS_H 29 #include "Utilities/AssociationUtil.h" 63 std::map<
size_t, std::vector<T const*> > & ptrMap);
68 std::vector<T const*> & ptrMap);
76 std::vector<U const*> & otherPtrs,
77 std::vector<T const*> & fillPtrs);
81 std::vector<U const*> & otherPtrs,
82 std::vector<T const*> & fillPtrs);
92 std::vector<T> & objOut,
93 std::vector<rb::Cluster> & sliceOut,
97 std::vector<rb::Cluster> & sliceOut,
103 std::vector<rb::Vertex> & vertexOut,
104 std::vector<rb::Cluster> & sliceOut,
110 std::vector<rb::Shower> & showerOut,
111 std::vector<rb::Cluster> & sliceOut,
117 std::vector<rb::Track> & trackOut,
118 std::vector<rb::Cluster> & sliceOut,
126 std::vector<rb::Prong> & prongOut,
127 std::vector<rb::Cluster> & sliceOut,
132 size_t const& slcIdx,
133 std::vector<rb::Cluster> & sliceOut,
152 std::vector<rb::Cluster> & sliceOut,
157 <<
"CellId/TNS to art::Ptr<rb::CellHit> map is empty, no way to copy the slice";
161 auto allCells = sliceIn->
AllCells();
163 std::set<std::pair<geo::CellUniqueId, float> > cuid;
166 std::vector<double> slcWeights;
169 for(
size_t ch = 0; ch < allCells.size(); ++ch){
171 allCells[ch]->TNS());
174 if( !cuid.insert(
key).second ){
176 <<
"trying to insert a duplicate cell " << (*allCells[ch]);
182 slcWeights.emplace_back( sliceIn->
Weight(ch) );
187 sliceOut.emplace_back(sliceIn->
View(), sliceNum);
188 sliceOut.back().Add(slcCells, slcWeights);
196 std::map<
size_t, std::vector<T const*> > & ptrMap)
198 std::vector<T const*> ptrs;
210 std::vector<U const*> & otherPtrs,
211 std::vector<T const*> & fillPtrs)
224 std::vector<U const*> & otherPtrs,
225 std::vector<T const*> & fillPtrs)
233 fillPtrs.reserve(otherPtrs.size());
236 for(
size_t t = 0;
t < otherPtrs.size(); ++
t){
237 if(fo.at(
t).isValid()) fillPtrs.emplace_back(&(fo.at(
t).ref()));
240 fillPtrs.shrink_to_fit();
249 std::vector<T const*> & ptrVec)
251 if( fmp.isValid() ) fmp.
get(s, ptrVec);
260 std::vector<T> & objOut,
261 std::vector<rb::Cluster> & sliceOut,
265 for(
auto in : objIn){
266 objOut.push_back( *
in );
286 std::vector<rb::Vertex> & vertexOut,
287 std::vector<rb::Cluster> & sliceOut,
291 vertexOut.emplace_back(vertexIn->
GetXYZ(), vertexIn->
GetT() );
310 std::vector<rb::Shower> & showerOut,
311 std::vector<rb::Cluster> & sliceOut,
316 <<
"CellId to art::Ptr<rb::CellHit> map is empty, no way to copy the showers";
321 for(
auto shw : showerIn){
323 allCells = shw->AllCells();
325 std::vector<double> shwCellWt(shw->NCell(), 1.);
331 for(
size_t ch = 0; ch < allCells.
size(); ++ch){
333 allCells[ch]->TNS());
337 shwCellWt[ch] = shw->Weight(ch);
342 showerOut.emplace_back(shwHitPtrs,
369 std::vector<rb::Track> & trackOut,
370 std::vector<rb::Cluster> & sliceOut,
381 <<
"CellId to art::Ptr<rb::CellHit> map is empty, no way to copy the tracks";
386 for(
auto trk : trackIn){
391 allCells =
trk->AllCells();
393 std::vector<double> trkCellWt(
trk->NCell(), 1.);
399 for(
size_t ch = 0; ch < allCells.
size(); ++ch){
401 allCells[ch]->TNS());
405 trkCellWt[ch] =
trk->Weight(ch);
410 trackOut.emplace_back( trkHitPtrs,
439 std::vector<rb::Prong> & prongOut,
440 std::vector<rb::Cluster> & sliceOut,
445 <<
"CellId to art::Ptr<rb::CellHit> map is empty, no way to copy the prongs";
450 for(
auto png : prongIn){
452 allCells = png->AllCells();
454 std::vector<double> pngCellWt(png->NCell(), 1.);
460 for(
size_t ch = 0; ch < allCells.
size(); ++ch){
462 allCells[ch]->TNS());
466 pngCellWt[ch] = png->Weight(ch);
471 prongOut.emplace_back(pngHitPtrs,
495 size_t const& slcIdx,
496 std::vector<rb::Cluster> & sliceOut,
511 std::vector<rb::Cluster> slice({sliceOut[slcIdx]});
514 if(sliceTruthTable[0].
size() < 1){
516 <<
"Could not find MCTruth objects for this slice in backtracker, so " 517 <<
"return without setting MCTruth or MCFlux associations for this slice";
529 auto trueInt = sliceTruthTable[0][nuIdx[0]].neutrinoInt;
562 <<
"The FindOne for the FluxWeights is valid: " 565 << slcFlxWgtAssn.
size()
567 << fofw.at(0)->GetHadronProductionCentralValue();
583 #endif // SkimmingUtils
bool CopyProngs(art::EDProducer const &prod, art::Event &e, std::vector< art::Ptr< rb::Prong > > const &prongIn, std::vector< rb::Prong > &prongOut, std::vector< rb::Cluster > &sliceOut, art::Assns< rb::Cluster, rb::Prong > &slcPrgAssn)
virtual geo::View_t View() const
kXorY for 3D clusters.
bool CopyShowers(art::EDProducer const &prod, art::Event &e, std::vector< art::Ptr< rb::Shower > > const &showerIn, std::vector< rb::Shower > &showerOut, std::vector< rb::Cluster > &sliceOut, art::Assns< rb::Cluster, rb::Shower > &slcShwAssn)
back track the reconstruction to the simulation
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
void FillSliceMap(size_t const &s, art::FindMany< T > &fmp, std::map< size_t, std::vector< T const * > > &ptrMap)
Atom< std::string > generatorLabel
std::vector< NeutrinoWithIndex > allMCTruth() const
bool SliceMCTruthAssociation(art::EDProducer const &prod, art::Event &e, size_t const &slcIdx, std::vector< rb::Cluster > &sliceOut, art::Assns< rb::Cluster, simb::MCTruth > &slcTruAssn, art::Assns< rb::Cluster, simb::MCFlux > &slcFlxAssn, art::Assns< rb::Cluster, fxwgt::FluxWeights > &slcFlxWgtAssn, art::Assns< rb::Cluster, simb::GTruth > &slcGTruAssn, std::string const &generatorLabel, std::string const &fluxWeightLabel)
size_type get(size_type i, reference item, data_reference data) const
::xsd::cxx::tree::exception< char > exception
bool CopyProductAndSliceAssn(art::EDProducer const &prod, art::Event &e, std::vector< art::Ptr< T > > const &objIn, std::vector< T > &objOut, std::vector< rb::Cluster > &sliceOut, art::Assns< rb::Cluster, T > &slcCROAssn)
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
const PlaneGeo * Plane(unsigned int i) const
std::vector< std::vector< cheat::NeutrinoEffPur > > SlicesToMCTruthsTable(const std::vector< const rb::Cluster * > &sliceList) const
Given ALL the slices in an event, including the noise slice, returns a vector of vector of structures...
bool CopySlice(art::Ptr< rb::Cluster > const &sliceIn, std::vector< rb::Cluster > &sliceOut, size_t &sliceNum)
Module to create a summary of total POT seen in a job.
object containing MC flux information
art::PtrVector< rb::CellHit > AllCells() const
Get all cells from both views.
Give every cell in the geometry a unique ID number based on the TGeo path to the node.
std::vector< int > SliceToOrderedNuIds(const std::vector< cheat::NeutrinoWithIndex > &nusWithIdx, const std::vector< std::vector< cheat::NeutrinoEffPur >> &slTruthTable, std::function< double(const cheat::NeutrinoEffPur &)> slMetric, std::function< double(const cheat::NeutrinoEffPur &)> nuMetric) const
Given a vector of indexed neutrino interaction and a vector of slice truth tables, returns a vector of neutrino interaction indices ordered by best match to the corresponding slice. Here, best match is determined according to the given cheat::NeutrinoEffPur functions for the slice and the nu.
void FillSliceVector(size_t const &s, art::FindMany< T > &fmp, std::vector< T const * > &ptrMap)
Track finder for cosmic rays.
void push_back(Ptr< U > const &p)
double EnergyMetric(const cheat::NeutrinoEffPur &ep)
Function for NeutrinoEffPur's nu interaction to slice energy.
Vertex location in position and time.
T prod(const std::vector< T > &v)
#define LOG_WARNING(category)
art::ServiceHandle< geo::Geometry > fGeom
std::map< std::pair< geo::CellUniqueId, float >, art::Ptr< rb::CellHit > > fCellIdToHitPtr
bool CopyTracks(art::EDProducer const &prod, art::Event &e, std::vector< art::Ptr< rb::Track > > const &trackIn, std::vector< rb::Track > &trackOut, std::vector< rb::Cluster > &sliceOut, art::Assns< rb::Cluster, rb::Track > &slcTrkAssn, std::string const &slcInstance="", std::string const &trkInstance="")
#define LOG_VERBATIM(category)
bool CopyVertex(art::EDProducer const &prod, art::Event &e, art::Ptr< rb::Vertex > const &vertexIn, std::vector< rb::Vertex > &vertexOut, std::vector< rb::Cluster > &sliceOut, art::Assns< rb::Cluster, rb::Vertex > &slcVtxAssn)
double Weight(unsigned int globalIdx) const
Weight assigned to the cell.
Encapsulate the geometry of one entire detector (near, far, ndos)