27 #include "art_root_io/TFileService.h" 69 bool operator() (std::pair<geo::WireID,float> i, std::pair<geo::WireID,float> j)
71 float dw_i = ((
int)(i.first.Wire) - (
int)(
hit->WireID().Wire))*geom->WirePitch(i.first.Plane);
72 float dw_j = ((
int)(j.first.Wire) - (
int)(
hit->WireID().Wire))*geom->WirePitch(j.first.Plane);
73 float dt_i = i.second -
hit->PeakTime();
74 float dt_j = j.second -
hit->PeakTime();
75 return (std::sqrt(dw_i*dw_i + dt_i*dt_i) < std::sqrt(dw_j*dw_j + dt_j*dt_j));
188 <<
" is not support\n";
195 const string myname =
"pddpana::CosmicsdQdx::analyze: ";
202 cout<<myname<<
"The event contains "<< Tracks->size() <<
" tracks\n";
209 for (
unsigned itrk = 0; itrk < Tracks->size(); ++itrk) {
236 cout<<myname<<
"Skipping track ID "<<
fTrackId 237 <<
" due to hit plane mismatch "<<
endl;
246 cout<<myname<<
"Skipping track ID "<<
fTrackId<<
" has " 255 cout<<myname<<
"Track ID "<<
fTrackId<<
" has " 257 <<
"\n start at: ( " << track.
Vertex().X()
258 <<
" ; " << track.
Vertex().Y()
259 <<
" ; " << track.
Vertex().Z()
260 <<
"\n end at: ( " << track.
End().X()
261 <<
" ; " << track.
End().Y()
262 <<
" ; " << track.
End().Z()<<
" )"<<
endl;
267 for(
size_t i_plane=0; i_plane<
fGeom->
Nplanes(); i_plane++) {
274 cout<<myname<<
"Hits in plane "<<i_plane<<
" "<<hits.size()<<
endl;
279 vector< unsigned > traj_points_idx;
280 vector< pair<geo::WireID,float> > traj_points_in_plane;
285 cerr<<
"track point "<<i_trjpt<<
" has position (" 286 <<pnt.X()<<
", "<<pnt.Y()<<
", "<<pnt.Z()<<
") \n" 292 double x_pos = pnt.X();
293 float tick = detProp.ConvertXToTicks(x_pos,(
int)i_plane,0,0);
307 traj_points_in_plane.push_back( std::make_pair(wid, tick) );
308 traj_points_idx.push_back( i_trjpt );
320 for(
auto const &
hit: hits ){
325 size_t traj_iter =
std::distance( traj_points_in_plane.begin(),
326 std::min_element( traj_points_in_plane.begin(),
327 traj_points_in_plane.end(),
329 size_t traj_pnt_idx = traj_points_idx[traj_iter];
383 fTree = tfs->make<TTree>(
"cranaTree",
"Check cosmics dQdx");
410 fTree->Branch(
"X", &
fX,
"X/F");
411 fTree->Branch(
"Y", &
fY,
"Y/F");
412 fTree->Branch(
"Z", &
fZ,
"Z/F");
418 const string myname =
"pddpana::CosmicsdQdx::endJob: ";
430 const string myname =
"pddpana::CosmicsdQdx::checkCutsAndGetT0: ";
437 cout<<myname<<
"Failed to pass length cut "<<track.
Length()<<
endl;
442 auto tstart = track.
Vertex();
443 auto tend = track.
End();
446 if( tstart.X() < tend.X() ){
451 if( not crp_geo_info.valid )
return false;
457 cout<<myname<<
"Failed to pass T0 cut "<<T0<<
endl;
465 cout<<myname<<
"Failed to pass wall cut (" 466 <<tstart.X()<<
", "<<tstart.Y()<<
", "<<tstart.Z()<<
")"<<
endl;
475 cout<<myname<<
"Failed to pass LEM edge cut (" 476 <<tstart.X()<<
", "<<tstart.Y()<<
", "<<tstart.Z()<<
")"<<
endl;
488 const string myname =
"pddpana::CosmicsdQdx::checkTrackHitInfo: ";
491 unsigned EventId = e.
id().
event();
495 for(
size_t i_plane = 0; i_plane<
fGeom->
Nplanes(); i_plane++) {
507 v0 +=
h->SummedADC();
511 for(
auto const &
h: fPlaneHits[1] ){
512 v1 +=
h->SummedADC();
515 fQAsym = (v0 - v1)/(v0 + v1);
522 for(
size_t i_plane = 0; i_plane<
fGeom->
Nplanes(); i_plane++) {
523 auto hits = fPlaneHits[i_plane];
525 vector<unsigned> plane_hits_tpcid( hits.size() );
527 for(
size_t i_hit = 0; i_hit<hits.size(); i_hit++ ){
528 plane_hits_tpcid[i_hit] = hits[i_hit]->WireID().TPC;
532 auto start = plane_hits_tpcid.begin();
533 auto end = plane_hits_tpcid.end();
534 if( std::equal(start + 1,
end, start)) {
535 this_tpcid = (
int)(*start);
539 cout<<myname<<
"hits for the same plane have mixed TPC IDs. Skipping...\n";
542 if( this_tpcid < 0 ){
547 hitsTpcId[i_plane] = (unsigned)this_tpcid;
551 if( hitsTpcId.empty() )
return true;
553 auto start = hitsTpcId.begin();
554 auto end = hitsTpcId.end();
555 if( !std::equal(start + 1,
end, start)) {
557 cout<<myname<<
"mismatch in TPC ID for the initial hits: ";
558 cout<<
" event ID "<<EventId<<
"; hit TPC IDs ";
559 for(
auto const &v: hitsTpcId ){ cout<<v<<
" ";}
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
CosmicsdQdx & operator=(CosmicsdQdx const &)=delete
bool checkTrackHitInfo(const recob::Track &track, art::Event const &e)
unsigned fMaxHitMultiplicity
static constexpr double g
Point_t const & LocationAtPoint(size_t i) const
The data type to uniquely identify a Plane.
bool HasValidPoint(size_t i) const
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Vector_t VertexDirection() const
geo::TPCID PositionToTPCID(geo::Point_t const &point) const
Returns the ID of the TPC at specified location.
EDAnalyzer(fhicl::ParameterSet const &pset)
art framework interface to geometry description
crpgeoinfo GetCRPGeoInfo(geo::Point_t const &pnt) const
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
double Length(size_t p=0) const
Access to various track properties.
#define DEFINE_ART_MODULE(klass)
protoana::ProtoDUNETrackUtils trackUtil
Point_t const & Vertex() const
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
The geometry of one entire detector, as served by art.
vector< vector< const recob::Hit * > > fPlaneHits
Detector simulation of raw signals on wires.
const std::vector< const recob::Hit * > GetRecoTrackHitsFromPlane(const recob::Track &track, art::Event const &evt, const std::string trackModule, unsigned int planeID) const
Get the hits from a given reco track from a specific plane.
void analyze(art::Event const &e) override
Declaration of signal hit object.
bool checkCutsAndGetT0(const recob::Track &track, float &T0)
short int DetectDriftDirection() const
Returns the expected drift direction based on geometry.
Vector_t EndDirection() const
protoana::ProtoDUNEDPCRPGeo crpGeoUtil
double TrackPitchInView(recob::Track const &track, geo::View_t view, size_t trajectory_point=0U)
Returns the projected length of track on a wire pitch step [cm].
Provides recob::Track data product.
CosmicsdQdx(fhicl::ParameterSet const &p)
EventNumber_t event() const
Point_t const & End() const
geo::WireID NearestWireID(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the ID of wire closest to position in the specified TPC.
Declaration of basic channel signal object.
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
2D representation of charge deposited in the TDC/wire plane
Utility functions to extract information from recob::Track
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
cet::coded_exception< error, detail::translate > exception
const geo::Geometry * fGeom
QTextStream & endl(QTextStream &s)