4 : fLArPandoraShowerAlg(pset.
get<
fhicl::ParameterSet>(
"LArPandoraShowerAlg"))
5 , fHitModuleLabel(pset.
get<
art::InputTag>(
"HitModuleLabel"))
6 , fPFParticleLabel(pset.
get<
art::InputTag>(
"PFParticleLabel"))
7 , fShowerStartPositionInputLabel(pset.
get<
std::
string>(
"ShowerStartPositionInputLabel"))
8 , fShowerDirectionInputLabel(pset.
get<
std::
string>(
"ShowerDirectionInputLabel"))
9 , fInitialTrackSpacePointsInputLabel(pset.
get<
std::
string>(
"InitialTrackSpacePointsInputLabel"))
12 std::map<int, const simb::MCParticle*>
18 std::map<int, const simb::MCParticle*> trueParticles;
21 particleIt != particles.end();
24 trueParticles[particle->
TrackId()] = particle;
30 std::map<int, std::vector<int>>
32 std::map<int, const simb::MCParticle*>& trueParticles)
const 36 std::map<int, std::vector<int>> showerMothers;
39 for (
const auto& particleIt : trueParticles) {
47 while (mother->
Mother() != 0 && trueParticles.find(mother->
Mother()) != trueParticles.end()) {
49 int motherId = mother->
Mother();
54 mother = trueParticles[motherId];
70 std::cout <<
"Making Debug Event Display" <<
std::endl;
76 int subRun = Event.
subRun();
77 int event = Event.
event();
78 int PFPID = pfparticle->
Self();
81 TString canvasName = Form(
"canvas_%i_%i_%i_%i", run, subRun,
event, PFPID);
82 TCanvas* canvas =
tfs->make<TCanvas>(canvasName, canvasName);
89 std::vector<art::Ptr<recob::SpacePoint>> showerSpacePoints;
90 std::vector<art::Ptr<recob::SpacePoint>> otherSpacePoints;
93 std::vector<art::Ptr<recob::Hit>> hits;
97 const art::FindManyP<recob::SpacePoint> fmsph(hitHandle, Event,
fPFParticleLabel);
98 if (!fmsph.isValid()) {
100 <<
"Spacepoint and hit association not valid. Stopping.";
105 for (
auto hit : hits) {
107 std::vector<art::Ptr<recob::SpacePoint>> sps = fmsph.at(
hit.key());
108 if (sps.size() == 1) {
110 if (trueParticleID == trueParticle->
TrackId()) { showerSpacePoints.push_back(sp); }
112 otherSpacePoints.push_back(sp);
119 <<
"Start position not set, returning " <<
std::endl;
128 <<
"TrackSpacePoints not set, returning " <<
std::endl;
133 TVector3 showerStartPosition = {-999, -999, -999};
134 TVector3 showerDirection = {-999, -999, -999};
135 std::vector<art::Ptr<recob::SpacePoint>> trackSpacePoints;
142 double startXYZ[3] = {0, 0, 0};
143 auto startPoly = std::make_unique<TPolyMarker3D>(1, startXYZ);
158 auto showerPoly = std::make_unique<TPolyMarker3D>(showerSpacePoints.size());
159 for (
auto spacePoint : showerSpacePoints) {
172 showerPoly->SetPoint(point, x, y, z);
184 double xDirPoints[2] = {minProj * showerDirection.X(), maxProj * showerDirection.X()};
185 double yDirPoints[2] = {minProj * showerDirection.Y(), maxProj * showerDirection.Y()};
186 double zDirPoints[2] = {minProj * showerDirection.Z(), maxProj * showerDirection.Z()};
188 auto dirPoly = std::make_unique<TPolyLine3D>(2, xDirPoints, yDirPoints, zDirPoints);
191 auto trackPoly = std::make_unique<TPolyMarker3D>(trackSpacePoints.size());
192 for (
auto spacePoint : trackSpacePoints) {
197 trackPoly->SetPoint(point, x, y, z);
204 auto otherPoly = std::make_unique<TPolyMarker3D>(otherSpacePoints.size());
209 for (
auto const& sp : otherSpacePoints) {
220 otherPoly->SetPoint(point, x, y, z);
224 gStyle->SetOptStat(0);
225 TH3F axes(
"axes",
"", 1, x_min, x_max, 1, y_min, y_max, 1, z_min, z_max);
226 axes.SetDirectory(0);
227 axes.GetXaxis()->SetTitle(
"X");
228 axes.GetYaxis()->SetTitle(
"Y");
229 axes.GetZaxis()->SetTitle(
"Z");
232 otherPoly->SetMarkerStyle(20);
233 otherPoly->SetMarkerColor(4);
237 showerPoly->SetMarkerStyle(20);
239 trackPoly->SetMarkerStyle(20);
240 trackPoly->SetMarkerColor(2);
242 startPoly->SetMarkerStyle(21);
243 startPoly->SetMarkerSize(2);
244 startPoly->SetMarkerColor(3);
246 dirPoly->SetLineWidth(1);
247 dirPoly->SetLineColor(6);
260 double particleEnergy = 0;
261 int likelyTrackID = 0;
263 std::vector<sim::TrackIDE> trackIDs = bt_serv->
HitToTrackIDEs(clockData, hit);
264 for (
unsigned int idIt = 0; idIt < trackIDs.size(); ++idIt) {
265 if (trackIDs.at(idIt).energy > particleEnergy) {
266 particleEnergy = trackIDs.at(idIt).energy;
267 likelyTrackID = trackIDs.at(idIt).trackID;
270 return likelyTrackID;
273 std::pair<int, double>
276 std::map<
int, std::vector<int>>
const& ShowersMothers,
285 std::map<int, double> trackIDToEDepMap;
286 std::map<int, double> trackIDTo3EDepMap;
294 std::vector<sim::TrackIDE> trackIDs = bt_serv->
HitToTrackIDEs(clockData, hit);
295 for (
unsigned int idIt = 0; idIt < trackIDs.size(); ++idIt) {
296 trackIDTo3EDepMap[
std::abs(trackIDs[idIt].trackID)] += trackIDs[idIt].energy;
297 if (PlaneID == planeid) {
298 trackIDToEDepMap[
std::abs(trackIDs[idIt].trackID)] += trackIDs[idIt].energy;
304 std::map<int, double> MotherIDtoEMap;
305 std::map<int, double> MotherIDto3EMap;
306 for (std::map<
int, std::vector<int>>::
const_iterator showermother = ShowersMothers.begin();
307 showermother != ShowersMothers.end();
310 daughter != (showermother->second).
end();
312 MotherIDtoEMap[showermother->first] += trackIDToEDepMap[*daughter];
313 MotherIDto3EMap[showermother->first] += trackIDTo3EDepMap[*daughter];
318 double maxenergy = -1;
319 int objectTrack = -99999;
321 mapIt != MotherIDto3EMap.end();
323 double energy_three = mapIt->second;
324 double trackid = mapIt->first;
325 if (energy_three > maxenergy) {
326 maxenergy = energy_three;
327 objectTrack = trackid;
332 if (maxenergy == 0) {
return std::make_pair(-99999, -99999); }
334 return std::make_pair(objectTrack, MotherIDtoEMap[objectTrack]);
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
EventNumber_t event() const
shower::LArPandoraShowerAlg fLArPandoraShowerAlg
size_t Self() const
Returns the index of this particle.
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
std::map< int, const simb::MCParticle * > GetTrueParticleMap() const
LArPandoraShowerCheatingAlg(const fhicl::ParameterSet &pset)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
art::ServiceHandle< cheat::ParticleInventoryService > particleInventory
int PdgCode(Resonance_t res, int Q)
(resonance id, charge) -> PDG code
std::map< int, std::vector< int > > GetTrueChain(std::map< int, const simb::MCParticle * > &trueParticles) const
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
std::string fShowerDirectionInputLabel
bool CheckElement(const std::string &Name) const
SubRunNumber_t subRun() const
art::InputTag fHitModuleLabel
void CheatDebugEVD(detinfo::DetectorClocksData const &clockData, const simb::MCParticle *trueParticle, art::Event const &Event, reco::shower::ShowerElementHolder &ShowerEleHolder, const art::Ptr< recob::PFParticle > &pfparticle) const
double SpacePointProjection(art::Ptr< recob::SpacePoint > const &sp, TVector3 const &vertex, TVector3 const &direction) const
static int max(int a, int b)
PlaneID_t Plane
Index of the plane within its TPC.
int GetElement(const std::string &Name, T &Element) const
int TrueParticleID(detinfo::DetectorClocksData const &clockData, const art::Ptr< recob::Hit > &hit) const
std::string fShowerStartPositionInputLabel
Detector simulation of raw signals on wires.
const sim::ParticleList & ParticleList() const
std::string fInitialTrackSpacePointsInputLabel
std::pair< int, double > TrueParticleIDFromTrueChain(detinfo::DetectorClocksData const &clockData, std::map< int, std::vector< int >> const &ShowersMothers, std::vector< art::Ptr< recob::Hit >> const &hits, int planeid) const
art::ServiceHandle< art::TFileService > tfs
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Contains all timing reference information for the detector.
constexpr WireID()=default
Default constructor: an invalid TPC ID.
detail::Node< FrameID, bool > PlaneID
art::InputTag fPFParticleLabel
auto const & get(AssnsNode< L, R, D > const &r)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
Event finding and building.
TVector3 SpacePointPosition(art::Ptr< recob::SpacePoint > const &sp) const