17 #include "canvas/Persistency/Common/FindManyP.h" 21 #include "art_root_io/TFileService.h" 145 auto const* SCE = lar::providerFrom<spacecharge::SpaceChargeService>();
148 std::vector < art::Ptr < recob::Track > > trackList;
149 auto trackListHandle = e.
getHandle< std::vector < recob::Track > >(
"pandoraTrack");
150 if (trackListHandle) {
156 art::FindManyP < recob::Hit > hitsFromTrack(trackListHandle, e,
"pandoraTrack");
159 auto pfpListHandle = e.
getHandle< std::vector<recob::PFParticle> >(
"pandora");
162 art::FindManyP<recob::PFParticle> fmpfp(trackListHandle, e,
"pandoraTrack");
165 art::FindManyP<anab::T0> fmt0pandora(pfpListHandle, e,
"pandora");
168 art::FindManyP<anab::T0> fmt0anodepiercer(pfpListHandle, e,
"anodepiercerst0");
171 art::FindManyP<anab::T0> fmt0crt2(trackListHandle, e,
"crtreco");
172 art::FindManyP<anab::CosmicTag> fmctcrt2(trackListHandle, e,
"crtreco");
175 art::FindManyP<anab::T0> fmt0crt1(trackListHandle, e,
"crttag");
176 art::FindManyP<anab::CosmicTag> fmctcrt1(trackListHandle, e,
"crttag");
181 for (
auto const& track : trackList){
182 int this_trackid = track.key();
183 double this_t0crt2 = -DBL_MAX;
184 double this_t0crt1 = -DBL_MAX;
185 double this_t0pandora = -DBL_MAX;
186 double this_t0anodep = -DBL_MAX;
187 double this_t0truth = -DBL_MAX;
188 double this_trackstartx = -DBL_MAX;
189 double this_trackstarty = -DBL_MAX;
190 double this_trackstartz = -DBL_MAX;
191 double this_trackendx = -DBL_MAX;
192 double this_trackendy = -DBL_MAX;
193 double this_trackendz = -DBL_MAX;
194 double this_trackstartx_sce = -DBL_MAX;
195 double this_trackstarty_sce = -DBL_MAX;
196 double this_trackstartz_sce = -DBL_MAX;
197 double this_trackendx_sce = -DBL_MAX;
198 double this_trackendy_sce = -DBL_MAX;
199 double this_trackendz_sce = -DBL_MAX;
200 double this_crt1x = -DBL_MAX;
201 double this_crt1y = -DBL_MAX;
202 double this_crt1z = -DBL_MAX;
203 double this_crt2x0 = -DBL_MAX;
204 double this_crt2y0 = -DBL_MAX;
205 double this_crt2z0 = -DBL_MAX;
206 double this_crt2x1 = -DBL_MAX;
207 double this_crt2y1 = -DBL_MAX;
208 double this_crt2z1 = -DBL_MAX;
210 if (fmt0crt2.isValid()){
211 auto const& vt0crt2 = fmt0crt2.at(track.key());
212 if (!vt0crt2.empty()) this_t0crt2 = vt0crt2[0]->Time();
215 if (fmt0crt1.isValid()){
216 auto const& vt0crt1 = fmt0crt1.at(track.key());
217 if (!vt0crt1.empty()) this_t0crt1 = vt0crt1[0]->Time();
220 if (fmctcrt2.isValid()){
221 auto const& vctcrt2 = fmctcrt2.at(track.key());
222 if (!vctcrt2.empty()){
223 this_crt2x0 = vctcrt2[0]->EndPoint1()[0];
224 this_crt2y0 = vctcrt2[0]->EndPoint1()[1];
225 this_crt2z0 = vctcrt2[0]->EndPoint1()[2];
226 this_crt2x1 = vctcrt2[0]->EndPoint2()[0];
227 this_crt2y1 = vctcrt2[0]->EndPoint2()[1];
228 this_crt2z1 = vctcrt2[0]->EndPoint2()[2];
232 if (fmctcrt1.isValid()){
233 auto const& vctcrt1 = fmctcrt1.at(track.key());
234 if (!vctcrt1.empty()){
235 this_crt1x = vctcrt1[0]->EndPoint1()[0];
236 this_crt1y = vctcrt1[0]->EndPoint1()[1];
237 this_crt1z = vctcrt1[0]->EndPoint1()[2];
241 if (fmpfp.isValid()){
242 auto const &pfps = fmpfp.at(track.key());
245 if (fmt0pandora.isValid()){
246 auto const &t0s = fmt0pandora.at(pfps[0].
key());
248 this_t0pandora = t0s[0]->Time();
251 if (fmt0anodepiercer.isValid()){
252 auto const &t0aps = fmt0anodepiercer.at(pfps[0].
key());
254 this_t0anodep = t0aps[0]->Time();
259 if (this_t0crt2 > -DBL_MAX ||
260 this_t0crt1 > -DBL_MAX ||
261 this_t0pandora > -DBL_MAX ||
262 this_t0anodep > -DBL_MAX){
264 auto const & allHits = hitsFromTrack.at(track.key());
269 std::map<int,double> trkide;
270 for(
size_t h = 0;
h < allHits.size(); ++
h){
273 for(
size_t e = 0; e < TrackIDs.size(); ++
e){
274 trkide[TrackIDs[
e].trackID] += TrackIDs[
e].energy;
282 if ((ii->second)>maxe){
290 this_t0truth = particle->
T();
294 this_trackstartx = track->Vertex().X();
295 this_trackstarty = track->Vertex().Y();
296 this_trackstartz = track->Vertex().Z();
297 this_trackendx = track->End().X();
298 this_trackendy = track->End().Y();
299 this_trackendz = track->End().Z();
301 if (
std::abs(this_t0pandora+DBL_MAX)<1e-10){
303 double ticksOffset = 0;
304 if (this_t0crt2 > -DBL_MAX) ticksOffset = this_t0crt2/500.+detProp.GetXTicksOffset(allHits[0]->
WireID());
305 else if (this_t0crt1 > -DBL_MAX) ticksOffset = this_t0crt1/500.+detProp.GetXTicksOffset(allHits[0]->
WireID());
306 else if (this_t0anodep > -DBL_MAX) ticksOffset = this_t0anodep/500.+detProp.GetXTicksOffset(allHits[0]->
WireID());
307 double xOffset = detProp.ConvertTicksToX(ticksOffset,allHits[0]->
WireID());
308 this_trackstartx -= xOffset;
309 this_trackendx -= xOffset;
312 auto const & posOffsets = SCE->GetCalPosOffsets(
geo::Point_t(this_trackstartx, this_trackstarty, this_trackstartz), allHits[0]->
WireID().
TPC);
313 this_trackstartx_sce = this_trackstartx - posOffsets.X();
314 this_trackstarty_sce = this_trackstarty + posOffsets.Y();
315 this_trackstartz_sce = this_trackstartz + posOffsets.Z();
316 this_trackendx_sce = this_trackendx - posOffsets.X();
317 this_trackendy_sce = this_trackendy + posOffsets.Y();
318 this_trackendz_sce = this_trackendz + posOffsets.Z();
320 trackid.push_back(this_trackid);
321 t0crt2.push_back(this_t0crt2);
322 t0crt1.push_back(this_t0crt1);
325 t0truth.push_back(this_t0truth);
338 crt1x.push_back(this_crt1x);
339 crt1y.push_back(this_crt1y);
340 crt1z.push_back(this_crt1z);
341 crt2x0.push_back(this_crt2x0);
342 crt2y0.push_back(this_crt2y0);
343 crt2z0.push_back(this_crt2z0);
344 crt2x1.push_back(this_crt2x1);
345 crt2y1.push_back(this_crt2y1);
346 crt2z1.push_back(this_crt2z1);
351 std::vector < art::Ptr < raw::RDTimeStamp > > rdtsevtList;
353 auto rdts_evt = e.
getHandle< std::vector < raw::RDTimeStamp > >(itag);
358 if (!rdtsevtList.empty()){
364 std::vector < art::Ptr < raw::RDTimeStamp > > rdtsdigitList;
365 auto rdts_digit = e.
getHandle < std::vector < raw::RDTimeStamp > >(itag2);
370 for (
const auto & rdts : rdtsdigitList){
379 t0tree = fileServiceHandle->make<TTree>(
"t0tree",
"t0 info");
std::vector< double > crt2z1
std::vector< double > crt1y
std::vector< double > trackstartx
std::vector< double > trackendy_sce
CheckT0 & operator=(CheckT0 const &)=delete
std::vector< double > crt2y0
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
std::vector< double > t0crt2
Handle< PROD > getHandle(SelectorBase const &) const
std::vector< TrackID > TrackIDs
const simb::MCParticle * TrackIdToParticle_P(int id) const
std::vector< double > crt2y1
std::vector< double > trackendx
EDAnalyzer(fhicl::ParameterSet const &pset)
std::vector< double > crt1x
CheckT0(fhicl::ParameterSet const &p)
std::vector< double > trackendy
std::vector< double > rdtimestamp_digits
std::vector< double > crt1z
std::vector< double > trackstarty_sce
std::vector< double > crt2z0
std::vector< double > t0crt1
#define DEFINE_ART_MODULE(klass)
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
std::vector< double > trackendz
void analyze(art::Event const &e) override
double T(const int i=0) const
std::vector< double > trackendx_sce
std::vector< double > trackendz_sce
std::vector< double > trackstartz
Detector simulation of raw signals on wires.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
std::vector< double > trackstartx_sce
std::vector< int > trackid
Declaration of signal hit object.
std::vector< double > t0truth
std::vector< double > t0pandora
std::vector< double > trackstartz_sce
Provides recob::Track data product.
EventNumber_t event() const
std::vector< double > crt2x1
std::vector< double > trackstarty
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
std::vector< double > t0anodep
Event finding and building.
std::vector< double > crt2x0