13 #include "MCCheater/BackTracker.h" 20 #include "canvas/Persistency/Common/FindMany.h" 21 #include "canvas/Persistency/Common/FindManyP.h" 22 #include "canvas/Persistency/Common/FindOneP.h" 24 #include "nug4/ParticleNavigation/EmEveIdCalculator.h" 77 if (partCol.failedToGet()) {
81 <<
"failed to get handle to simb::MCParticle from " <<
fG4ModuleLabel 93 <<
"failed to associate MCTruth to MCParticle with " <<
fG4ModuleLabel 94 <<
"; all attempts to backtrack will fail\n";
99 for (
size_t iPart = 0; iPart < partCol->size(); ++iPart) {
126 <<
"unable to find MCTruth from ParticleList created in " 128 <<
"; all attempts to backtrack will fail\n" 129 <<
"message from caught exception:\n" << ex;
144 fParticleList.AdoptEveIdCalculator(
new sim::EmEveIdCalculator);
152 auto detProp = gar::providerFrom<detinfo::DetectorPropertiesService>();
154 detProp->Temperature());
156 auto garProp = gar::providerFrom<detinfo::GArPropertiesService>();
157 fLongDiffConst = std::sqrt(2.0 * garProp->LongitudinalDiffusion());
159 fGeo = gar::providerFrom<geo::GeometryGAr>();
165 fChannelToEDepCol.clear();
172 "; no backtracking in TPC will be possible" <<
173 "\n Well did you EXPECT RawDigits in this file?";
177 art::FindMany<sdp::EnergyDeposit, float> fmEnergyDep(digCol, evt,
fRawTPCDataLabel);
178 if (!fmEnergyDep.isValid()) {
182 <<
"Unable to find valid association between RawDigits and " 184 "; no backtracking in TPC will be possible" <<
185 "\n Well did you EXPECT those Assns in this file?";
189 fChannelToEDepCol.resize(fGeo->NChannels());
193 <<
"There are " << fChannelToEDepCol.size()
194 <<
" channels in the geometry";
197 std::vector<float const*> depweights;
198 std::vector<const sdp::EnergyDeposit*> eDeps;
199 for (
size_t iDig = 0; iDig < digCol->size(); ++iDig) {
202 fmEnergyDep.get(iDig, eDeps, depweights);
203 if (eDeps.size() < 1)
continue;
205 for(
size_t iDep=0; iDep<eDeps.size(); iDep++) {
208 fChannelToEDepCol[ (*digCol)[iDig].Channel() ].emplace_back(std::make_pair(eDeps[iDep],w));
210 MF_LOG_DEBUG(
"BackTracker_service::RebuildNoSC") <<
"eDep\t" << iDep <<
" from RawDigit \t" << iDig
211 <<
"\t TrkID, energy, dl, position:\t " << eDeps[iDep]->TrackID()
212 <<
"\t " << eDeps[iDep]->Energy() <<
"\t " << eDeps[iDep]->dX()
213 <<
"\t " << eDeps[iDep]->X() <<
"\t " << eDeps[iDep]->Y()
214 <<
"\t " << eDeps[iDep]->Z() <<
std::endl;
230 auto caloDigCol = evt.
getHandle<std::vector<raw::CaloRawDigit>>(ecalrawtag);
236 "; no backtracking in ECAL will be possible" <<
237 "\n Well did you EXPECT CaloRawDigits in this file?";
241 art::FindMany<sdp::CaloDeposit> fmCaloDep(caloDigCol, evt, ecalrawtag);
242 if (!fmCaloDep.isValid()) {
246 <<
"Unable to find valid association between CaloRawDigits and " 248 "; no backtracking in ECAL will be possible" <<
249 "\n Well did you EXPECT those Assns in this file?";
253 std::vector<const sdp::CaloDeposit*> CeDeps;
254 for (
size_t iCalDig = 0; iCalDig < caloDigCol->size(); ++iCalDig) {
256 fmCaloDep.get(iCalDig, CeDeps);
257 if (CeDeps.size() < 1)
continue;
276 <<
"Unable to find rec::Tracks in " <<
fTrackLabel <<
277 "; no backtracking of reconstructed tracks will be possible" <<
278 "\n Well did you EXPECT tracks in this file?";
282 art::FindMany<rec::TPCCluster> fmTPCClusts(recoTrackCol, evt,
fTrackLabel);
283 if (!fmTPCClusts.isValid()) {
287 <<
"Unable to find valid association between Tracks and " 289 "; no backtracking of reconstructed tracks will be possible" <<
290 "\n Well did you EXPECT those Assns in this file?";
295 std::vector<const rec::TPCCluster*> tpclusThisTrack;
296 for (
size_t iTrack = 0; iTrack < recoTrackCol->size(); ++iTrack) {
297 tpclusThisTrack.clear();
298 fmTPCClusts.get(iTrack, tpclusThisTrack);
299 if (tpclusThisTrack.size() < 1)
continue;
315 "; no backtracking of reconstructed tracks will be possible" <<
316 "\n Well did you EXPECT TPCClusters in this file?";
321 if (!fmHits.isValid()) {
325 <<
"Unable to find valid association between TPCClusters and " 327 "; no backtracking of reconstructed tracks will be possible" <<
328 "\n Well did you EXPECT those Assns in this file?";
332 std::vector<art::Ptr<rec::Hit>> hitsThisTPCCluster;
333 for (
size_t iTPClus = 0; iTPClus < tpclusCol->size(); ++iTPClus) {
334 hitsThisTPCCluster.clear();
335 fmHits.get(iTPClus, hitsThisTPCCluster);
336 if (hitsThisTPCCluster.size() < 1)
continue;
347 for (
auto aTrack : *recoTrackCol) {
348 std::vector<const rec::TPCCluster*> tpclusThisTrack =
352 std::vector<art::Ptr<rec::Hit>> hitsThisTrack;
355 std::vector<art::Ptr<rec::Hit>> hitsThisClus =
358 hitsThisTrack.insert( hitsThisTrack.end(),
359 hitsThisClus.begin(),hitsThisClus.end() );
372 auto recoClusterCol = evt.
getHandle<std::vector<rec::Cluster>>(ecalclustertag);
373 if (!recoClusterCol) {
377 <<
"Unable to find rec::Clusters in " <<
fClusterLabel <<
", " 379 <<
"clusters will be possible" <<
380 "\n Well did you EXPECT ECAL Clusters in this file?";
384 art::FindManyP<rec::CaloHit> fmCaloHits(recoClusterCol, evt, ecalclustertag);
385 if (!fmCaloHits.isValid()) {
389 <<
"Unable to find valid association between Clusters and " 391 <<
" instance; no backtracking of reconstructed tracks will be possible" <<
392 "\n Well did you EXPECT those Assns in this file?";
396 std::vector<art::Ptr<rec::CaloHit>> caloHitsThisCluster;
397 for (
size_t iCluster = 0; iCluster < recoClusterCol->size(); ++iCluster) {
398 caloHitsThisCluster.clear();
399 fmCaloHits.get(iCluster, caloHitsThisCluster);
400 if (caloHitsThisCluster.size() < 1)
continue;
double fLongDiffConst
longitudinal diffusion constant
std::vector< std::vector< std::pair< const sdp::EnergyDeposit *, float const > > > fChannelToEDepCol
convenience collections of EnergyDeposits for each channel
std::unordered_map< rec::IDNumber, std::vector< const rec::TPCCluster * > > fTrackIDToClusters
Reco track ID to track's clusters.
Handle< PROD > getHandle(SelectorBase const &) const
BackTracker(fhicl::ParameterSet const &pset, art::ActivityRegistry ®)
std::string fRawCaloDataECALInstance
instance name for the ECAL raw hits
std::string fClusterLabel
label for ECAL cluster producing module
std::unordered_map< raw::CellID_t, std::vector< const sdp::CaloDeposit * > > fCellIDToEDepCol
convenience collections of EnergyDeposit for each cell
const geo::GeometryCore * fGeo
pointer to the geometry
std::unordered_map< int, int > fTrackIDToMCTruthIndex
std::unordered_map< rec::IDNumber, std::vector< art::Ptr< rec::Hit > > > fTrackIDToHits
Reco track ID to track's hits.
void RebuildNoSC(art::Event const &evt)
std::string fClusterECALInstance
instance name for the ECAL clusters
void Rebuild(art::Event const &evt, art::ScheduleContext)
std::string fRawTPCDataLabel
label for TPC readout module
sim::ParticleList fParticleList
Maps MCParticle::TrackId() to same MCParticle.
std::string fTPCClusterLabel
label for TPCCluster producing module
std::string fTrackLabel
label for final track producing module
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
std::unordered_map< rec::IDNumber, std::vector< art::Ptr< rec::Hit > > > fTPCClusterIDToHits
Reco TPC cluster ID to cluster's hits.
std::unordered_map< rec::IDNumber, std::vector< art::Ptr< rec::CaloHit > > > fClusterIDToCaloHits
Reco ECAL cluster ID to CaloHits.
std::unordered_map< int, int > * fECALTrackToTPCTrack
results of previous FindTPCEve calls
GlobalSignal< detail::SignalResponseType::FIFO, void(Event const &, ScheduleContext)> sPreProcessEvent
std::string fG4ModuleLabel
label for geant4 module
General GArSoft Utilities.
#define DEFINE_ART_SERVICE(svc)
code to link reconstructed objects back to the MC truth information
bool fSplitEDeps
use weights from PRFs to break true energy deposits into channel specific contributions ...
std::string fRawCaloDataLabel
label for ECAL readout module
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for the event
#define MF_LOG_WARNING(category)
art framework interface to geometry description
double fInverseVelocity
inverse drift velocity
bool fDisableRebuild
for switching off backtracker's rebuild of the MCParticle tables
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)