17 #include "canvas/Persistency/Common/FindManyP.h" 21 #include "art_root_io/TFileService.h" 44 class CRTMatchTrackCaloAna;
134 auto const* SCE = lar::providerFrom<spacecharge::SpaceChargeService>();
137 std::vector < art::Ptr < recob::Track > > trackList;
138 auto trackListHandle = e.
getHandle < std::vector < recob::Track > >(
"pandoraTrack");
139 if (trackListHandle) {
145 art::FindManyP < recob::Hit > hitsFromTrack(trackListHandle, e,
"pandoraTrack");
148 auto pfpListHandle = e.
getHandle< std::vector<recob::PFParticle> >(
"pandora");
151 art::FindManyP<recob::PFParticle> fmpfp(trackListHandle, e,
"pandoraTrack");
154 art::FindManyP<anab::T0> fmt0pandora(pfpListHandle, e,
"pandora");
157 art::FindManyP<anab::T0> fmt0anodepiercer(pfpListHandle, e,
"anodepiercerst0");
160 art::FindManyP<anab::T0> fmt0crt2(trackListHandle, e,
"crtreco");
161 art::FindManyP<anab::CosmicTag> fmctcrt2(trackListHandle, e,
"crtreco");
162 art::FindManyP<anab::Calorimetry> fmcal(trackListHandle, e,
"pandoracalo");
165 std::vector<art::Ptr<recob::Hit>> hitlist;
166 auto hitListHandle = e.
getHandle< std::vector<recob::Hit> >(
"hitpdune");
172 for (
auto const& track : trackList){
203 int this_trackid = track.key();
204 double this_t0crt2 = -DBL_MAX;
205 double this_t0pandora = -DBL_MAX;
206 double this_t0anodep = -DBL_MAX;
207 double this_t0truth = -DBL_MAX;
208 double this_trackstartx = -DBL_MAX;
209 double this_trackstarty = -DBL_MAX;
210 double this_trackstartz = -DBL_MAX;
211 double this_trackendx = -DBL_MAX;
212 double this_trackendy = -DBL_MAX;
213 double this_trackendz = -DBL_MAX;
214 double this_trackstartx_sce = -DBL_MAX;
215 double this_trackstarty_sce = -DBL_MAX;
216 double this_trackstartz_sce = -DBL_MAX;
217 double this_trackendx_sce = -DBL_MAX;
218 double this_trackendy_sce = -DBL_MAX;
219 double this_trackendz_sce = -DBL_MAX;
220 double this_crt2x0 = -DBL_MAX;
221 double this_crt2y0 = -DBL_MAX;
222 double this_crt2z0 = -DBL_MAX;
223 double this_crt2x1 = -DBL_MAX;
224 double this_crt2y1 = -DBL_MAX;
225 double this_crt2z1 = -DBL_MAX;
226 if (!fmctcrt2.isValid())
continue;
227 if (fmt0crt2.isValid()){
228 auto const& vt0crt2 = fmt0crt2.at(track.key());
229 if (!vt0crt2.empty()) this_t0crt2 = vt0crt2[0]->Time();
233 if (fmctcrt2.isValid()){
234 auto const& vctcrt2 = fmctcrt2.at(track.key());
235 if (!vctcrt2.empty()){
236 this_crt2x0 = vctcrt2[0]->EndPoint1()[0];
237 this_crt2y0 = vctcrt2[0]->EndPoint1()[1];
238 this_crt2z0 = vctcrt2[0]->EndPoint1()[2];
239 this_crt2x1 = vctcrt2[0]->EndPoint2()[0];
240 this_crt2y1 = vctcrt2[0]->EndPoint2()[1];
241 this_crt2z1 = vctcrt2[0]->EndPoint2()[2];
247 if (this_t0crt2 > -DBL_MAX){
249 auto const & allHits = hitsFromTrack.at(track.key());
252 this_trackstartx = track->Vertex().X();
253 this_trackstarty = track->Vertex().Y();
254 this_trackstartz = track->Vertex().Z();
255 this_trackendx = track->End().X();
256 this_trackendy = track->End().Y();
257 this_trackendz = track->End().Z();
259 if (
std::abs(this_t0pandora+DBL_MAX)<1e-10){
261 double ticksOffset = 0;
262 if (this_t0crt2 > -DBL_MAX) ticksOffset = this_t0crt2/500.+detProp.GetXTicksOffset(allHits[0]->
WireID());
263 else if (this_t0anodep > -DBL_MAX) ticksOffset = this_t0anodep/500.+detProp.GetXTicksOffset(allHits[0]->
WireID());
264 double xOffset = detProp.ConvertTicksToX(ticksOffset,allHits[0]->
WireID());
265 this_trackstartx -= xOffset;
266 this_trackendx -= xOffset;
269 auto const & posOffsets = SCE->GetCalPosOffsets(
geo::Point_t(this_trackstartx, this_trackstarty, this_trackstartz), allHits[0]->
WireID().
TPC);
270 std::vector<art::Ptr<anab::Calorimetry>> calos=fmcal.at(track.key());
274 double trkHitX, trkHitY, trkHitZ;
275 for(
size_t ical = 0; ical<calos.size(); ++ical){
276 if (calos[ical]->
PlaneID().Plane!=2)
continue;
278 const size_t NHits=calos[ical]->dEdx().size();
279 for(
size_t iHit = 0; iHit < NHits; ++iHit){
281 const auto& TrkPos = (calos[ical] -> XYZ()[iHit]);
283 trkdqdx.push_back(calos[ical]->dQdx()[iHit]);
284 size_t tpIndex=(calos[ical]->TpIndices()[iHit]);
292 trkpitch.push_back(calos[ical]->TrkPitchVec()[iHit]);
303 this_trackstartx_sce = this_trackstartx - posOffsets.X();
304 this_trackstarty_sce = this_trackstarty + posOffsets.Y();
305 this_trackstartz_sce = this_trackstartz + posOffsets.Z();
306 this_trackendx_sce = this_trackendx - posOffsets.X();
307 this_trackendy_sce = this_trackendy + posOffsets.Y();
308 this_trackendz_sce = this_trackendz + posOffsets.Z();
310 trackid.push_back(this_trackid);
311 t0crt2.push_back(this_t0crt2);
312 t0truth.push_back(this_t0truth);
325 crt2x0.push_back(this_crt2x0);
326 crt2y0.push_back(this_crt2y0);
327 crt2z0.push_back(this_crt2z0);
328 crt2x1.push_back(this_crt2x1);
329 crt2y1.push_back(this_crt2y1);
330 crt2z1.push_back(this_crt2z1);
340 crtCalo = fileServiceHandle->make<TTree>(
"crtCalo",
"t0 info");
std::vector< double > crt2y0
std::vector< double > rdtimestamp_digits
std::vector< double > trackstartx
Handle< PROD > getHandle(SelectorBase const &) const
std::vector< double > t0truth
std::vector< double > trackendz
std::vector< double > crt2y1
std::vector< double > trackendy_sce
std::string fCalorimetryModuleLabel
std::vector< double > t0anodep
std::vector< double > trkdedx
std::vector< double > trkdedx_cali
EDAnalyzer(fhicl::ParameterSet const &pset)
std::vector< double > trkhitz
std::vector< double > trackstarty_sce
std::vector< double > TPCID
std::vector< double > trackendx_sce
std::vector< double > crt2z0
std::vector< double > t0pandora
protoana::ProtoDUNECalibration calibration
double dEdx(float dqdx, float Efield)
#define DEFINE_ART_MODULE(klass)
std::vector< int > trackid
std::vector< double > crt2x0
std::vector< double > crt2z1
std::vector< double > trackendz_sce
Definition of data types for geometry description.
std::vector< double > trackstartx_sce
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
CRTMatchTrackCaloAna & operator=(CRTMatchTrackCaloAna const &)=delete
std::vector< double > trkhity
std::vector< double > trkpitch
std::vector< double > crt2x1
Declaration of signal hit object.
std::vector< double > t0crt2
std::vector< double > trkresrange
Provides recob::Track data product.
std::vector< double > trkdqdx
fhicl::ParameterSet CalibrationPars
EventNumber_t event() const
std::vector< double > WireID
std::vector< double > trackendy
Declaration of basic channel signal object.
detail::Node< FrameID, bool > PlaneID
void analyze(art::Event const &e) override
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
std::vector< float > GetCalibratedCalorimetry(const recob::Track &track, art::Event const &evt, const std::string trackModule, const std::string caloModule, size_t planeID, double negativeZFix=0.)
CRTMatchTrackCaloAna(fhicl::ParameterSet const &p)
std::vector< double > trackstartz
std::vector< double > trkhitx
std::vector< double > trackstartz_sce
std::vector< double > trackstarty
std::vector< double > trackendx
Event finding and building.