181 if (wireReadoutGeom.Nplanes() > 3)
return;
186 std::vector<art::Ptr<recob::Hit>> allhits;
188 if (
empty(allhits))
return;
194 if (clusterListHandle->size() == 0)
return;
200 double xyz[3] = {0, 0, 0};
201 for (
unsigned int ii = 0; ii < vertexListHandle->size(); ++ii) {
211 for (
unsigned int ii = 0; ii < PFPListHandle->size(); ++ii) {
222 std::vector<const simb::MCParticle*> plist2;
224 std::vector<std::vector<art::Ptr<recob::Hit>>> hlist2;
226 std::vector<std::vector<short>> truToCl;
228 std::vector<std::vector<unsigned short>> nTruHitInCl;
230 std::vector<unsigned short> nRecHitInCl;
235 float aveNuEP2mu = 0.;
236 float numNuEP2mu = 0.;
237 float aveNuEP2nm = 0.;
238 float numNuEP2nm = 0.;
244 int neutTrackID = -1;
245 std::vector<int> tidlist;
246 float neutEnergy = -1.;
247 int neutIntType = -1;
262 << trackID <<
" PDG " << part->
PdgCode() <<
" E " << part->
E()
263 <<
" mass " << part->
Mass() <<
" Mother " 264 << part->
Mother() + neutTrackID <<
" Proc " << part->
Process();
269 neutTrackID = trackID;
271 neutEnergy = 1000. * theNeutrino.
Nu().
E();
273 neutCCNC = theNeutrino.
CCNC();
274 for (
unsigned short iv = 0; iv < recoVtxList.
size(); ++iv) {
275 recoVtxList[iv]->XYZ(xyz);
282 bool isCharged = (pdg == 11) || (pdg == 13) || (pdg == 211) || (pdg == 321) || (pdg == 2212);
284 if (!isCharged)
continue;
286 float KE = 1000 * (part->
E() - part->
Mass());
291 if (part->
Process() !=
"primary")
continue;
311 if (part->
Process() ==
"NeutronInelastic")
continue;
312 plist2.push_back(part);
313 tidlist.push_back(trackID);
315 std::vector<short> temp{-1, -1, -1};
316 truToCl.push_back(temp);
318 std::vector<unsigned short> temp2(3);
319 nTruHitInCl.push_back(temp2);
323 <<
" trackID " << trackID <<
" PDG " << part->
PdgCode() <<
" KE " 324 << (int)KE <<
" Mother " << part->
Mother() + neutTrackID
325 <<
" Proc " << part->
Process();
328 if (
empty(plist2))
return;
332 if (hlist2.size() != plist2.size()) {
333 mf::LogError(
"PFPAna") <<
"MC particle list size " << plist2.size()
334 <<
" != size of MC particle true hits lists " << hlist2.size();
340 std::vector<std::pair<unsigned short, unsigned short>> moda;
345 for (
unsigned short dpl = plist2.size() - 1; dpl > 0; --dpl) {
347 if (plist2[dpl]->Mother() == 0)
continue;
349 if (
abs(plist2[dpl]->PdgCode()) == 11)
continue;
351 int motherID = neutTrackID + plist2[dpl]->Mother() - 1;
353 if (motherID < 0)
continue;
356 for (
unsigned short kpl = 0; kpl < plist2.size(); ++kpl) {
357 if (plist2[kpl]->Mother() == motherID) ++ndtr;
360 if (ndtr > 1)
continue;
363 for (
unsigned short jpl = dpl - 1; jpl > 0; --jpl) {
364 if (plist2[jpl]->TrackId() == motherID) {
370 if (mpl < 0)
continue;
372 if (plist2[dpl]->PdgCode() != plist2[mpl]->PdgCode())
continue;
373 moda.push_back(std::make_pair(mpl, dpl));
379 for (
unsigned int ii = 0; ii < clusterListHandle->size(); ++ii) {
385 nRecHitInCl.resize(clusters.
size());
389 std::map<geo::View_t, unsigned int> ViewToPlane;
392 ViewToPlane[view] = plane.ID().Plane;
394 for (
size_t icl = 0; icl < clusters.
size(); ++icl) {
395 unsigned int plane = ViewToPlane[clusters[icl]->View()];
396 std::vector<art::Ptr<recob::Hit>> cluhits = fmh.at(icl);
398 nRecHitInCl[icl] = cluhits.size();
400 std::vector<unsigned short> nHitInPl2(plist2.size());
401 for (
size_t iht = 0; iht < cluhits.size(); ++iht) {
404 for (
unsigned short ipl = 0; ipl < plist2.size(); ++ipl) {
405 unsigned short imat = 0;
406 for (imat = 0; imat < hlist2[ipl].size(); ++imat) {
407 if (cluhits[iht] == hlist2[ipl][imat])
break;
409 if (imat < hlist2[ipl].
size()) {
414 if (hitInPl2 < 0)
continue;
418 for (
unsigned short imd = 0; imd < moda.size(); ++imd) {
419 if (moda[imd].
second == hitInPl2) hitInPl2 = moda[imd].first;
422 ++nHitInPl2[hitInPl2];
426 unsigned short nhit = 0;
428 for (
unsigned int ipl = 0; ipl < nHitInPl2.size(); ++ipl) {
429 if (nHitInPl2[ipl] > nhit) {
430 nhit = nHitInPl2[ipl];
438 if (nhit > nTruHitInCl[imtru][plane]) {
439 truToCl[imtru][plane] = icl;
440 nTruHitInCl[imtru][plane] = nhit;
446 for (
unsigned short ipl = 0; ipl < plist2.size(); ++ipl) {
449 for (
unsigned short ii = 0; ii < moda.size(); ++ii) {
450 if (moda[ii].
second == ipl) {
455 if (skipit)
continue;
458 if (hlist2[ipl].
size() < 3)
continue;
460 int trackID = plist2[ipl]->TrackId();
463 float KE = 1000 * (plist2[ipl]->E() - plist2[ipl]->Mass());
464 int PDG =
abs(plist2[ipl]->PdgCode());
466 std::vector<short> nTru(wireReadoutGeom.Nplanes());
467 std::vector<short> nRec(wireReadoutGeom.Nplanes());
468 std::vector<short> nTruRec(wireReadoutGeom.Nplanes());
469 std::vector<float> eff(wireReadoutGeom.Nplanes());
470 std::vector<float> pur(wireReadoutGeom.Nplanes());
471 std::vector<float> ep(wireReadoutGeom.Nplanes());
472 for (
unsigned int plane = 0; plane < wireReadoutGeom.Nplanes(); ++plane) {
475 for (
unsigned short ii = 0; ii < hlist2[ipl].size(); ++ii) {
476 if (ViewToPlane[hlist2[ipl][ii]->View()] == plane) ++nTru[plane];
479 unsigned short mom = ipl;
480 std::vector<std::pair<unsigned short, unsigned short>>::reverse_iterator rit =
482 while (rit != moda.rend()) {
483 if ((*rit).first == mom) {
484 unsigned short dau = (*rit).second;
485 for (
unsigned short jj = 0; jj < hlist2[dau].size(); ++jj) {
486 if (ViewToPlane[hlist2[dau][jj]->View()] == plane) ++nTru[plane];
495 if (nTru[plane] == 0) {
continue; }
496 short icl = truToCl[ipl][plane];
497 nRec[plane] = nRecHitInCl[icl];
498 nTruRec[plane] = nTruHitInCl[ipl][plane];
499 if (nTru[plane] > 0) eff[plane] = (float)nTruRec[plane] / (
float)nTru[plane];
500 if (nRec[plane] > 0) pur[plane] = (float)nTruRec[plane] / (
float)nRec[plane];
501 ep[plane] = eff[plane] * pur[plane];
504 std::vector<float> temp;
506 std::sort(temp.begin(), temp.end());
508 unsigned short ii = temp.size() - 2;
509 float ep2 = temp[ii];
512 short ep2Cluster = 0;
513 for (
unsigned short jj = 0; jj < temp.size(); ++jj) {
516 ep2Cluster = truToCl[ipl][ep2Plane];
521 std::array<double, 2> clBeg, clEnd;
522 if (ep2Cluster >= 0) {
523 clBeg[0] = clusters[ep2Cluster]->StartWire();
524 clBeg[1] = clusters[ep2Cluster]->StartTick();
525 clEnd[0] = clusters[ep2Cluster]->EndWire();
526 clEnd[1] = clusters[ep2Cluster]->EndTick();
535 fCRE->Fill(eff[ep2Plane]);
536 fCRP->Fill(pur[ep2Plane]);
541 <<
">>>CREP2 " << std::fixed << std::setprecision(2) << ep2 <<
" E " << eff[ep2Plane]
542 << std::setprecision(2) <<
" P " << pur[ep2Plane] <<
" P:W:T " << ep2Plane <<
":" 543 << (int)clBeg[0] <<
":" << (
int)clBeg[1] << "-" << ep2Plane << ":" << (
int)clEnd[0]
544 << ":" << (
int)clEnd[1] << " PDG " << PDG << " KE " << (
int)KE << " MeV";
551 aveNuEP2mu += ep2 * wght;
555 aveNuEP2nm += ep2 * wght;
565 else if (PDG == 13) {
572 else if (PDG == 211) {
579 else if (PDG == 321) {
586 else if (PDG == 2212) {
595 <<
">>>NuEP2 " << std::fixed << std::setprecision(2) << ep2 <<
" E " << eff[ep2Plane]
596 << std::setprecision(2) <<
" P " << pur[ep2Plane] <<
" P:W:T " << ep2Plane <<
":" 597 << (int)clBeg[0] <<
":" << (
int)clBeg[1] << "-" << ep2Plane << ":" << (
int)clEnd[0]
598 << ":" << (
int)clEnd[1] << " PDG " << PDG << " KE " << (
int)KE << " MeV ";
602 mfp <<
" Truth P:W:T ";
603 for (
unsigned int plane = 0; plane < wireReadoutGeom.Nplanes(); ++plane) {
604 unsigned short loW = 9999;
605 unsigned short loT = 0;
606 unsigned short hiW = 0;
607 unsigned short hiT = 0;
608 for (
unsigned short ii = 0; ii < hlist2[ipl].size(); ++ii) {
609 if (ViewToPlane[hlist2[ipl][ii]->View()] == plane) {
621 mfp << plane <<
":" << loW <<
":" << loT <<
"-" << plane <<
":" << hiW <<
":" << hiT
629 if (numNuEP2mu > 0.) ave1 = aveNuEP2mu / numNuEP2mu;
632 if (numNuEP2nm > 0.) ave2 = aveNuEP2nm / numNuEP2nm;
635 if (numCREP2 > 0.) ave3 = aveCREP2 / numCREP2;
637 if (fPrintLevel > 0) {
638 std::string nuType =
"Other";
640 if (neutIntType == 1001) nuType =
"CCQE";
641 if (neutIntType == 1091) nuType =
"DIS";
642 if (neutIntType == 1097) nuType =
"COH";
643 if (neutIntType > 1002 && neutIntType < 1091) nuType =
"RES";
652 << std::fixed << std::setprecision(0) << neutEnergy <<
std::right 653 << std::fixed << std::setprecision(2) <<
" NuMuons " << ave1
654 <<
" NuPiKp " << ave2 <<
" CosmicRays " << ave3 <<
" CCNC " 655 << neutCCNC <<
" IntType " << neutIntType;
double E(const int i=0) const
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::vector< float > fElecKERange
const simb::MCNeutrino & GetNeutrino() const
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
std::string fVertexModuleLabel
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
const simb::MCParticle & Nu() const
list_type::const_iterator const_iterator
simb::Origin_t Origin() const
std::string fHitsModuleLabel
std::vector< float > fProtKERange
constexpr auto abs(T v)
Returns the absolute value of the argument.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
WireID_t Wire
Index of the wire within its plane.
geo::WireID const & WireID() const
Initial tdc tick for hit.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::string Process() const
std::string fClusterModuleLabel
std::vector< float > fPionKERange
TProfile * fNuEP2_KE_kaon
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
int InteractionType() const
TProfile * fNuEP2_KE_elec
void push_back(Ptr< U > const &p)
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int id) const
TProfile * fNuEP2_KE_pion
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
std::string fPFParticleModuleLabel
std::vector< std::vector< art::Ptr< recob::Hit > > > TrackIdsToHits_Ps(detinfo::DetectorClocksData const &clockData, std::vector< int > const &tkIds, std::vector< art::Ptr< recob::Hit >> const &hitsIn) const
The data type to uniquely identify a TPC.
const sim::ParticleList & ParticleList() const
TProfile * fNuEP2_KE_prot
double Vx(const int i=0) const
float PeakTime() const
Time of the signal peak, in tick units.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
TProfile * fNuEP2_KE_muon
double Vz(const int i=0) const
EventNumber_t event() const
std::vector< float > fMuonKERange
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
second_as<> second
Type of time stored in seconds, in double precision.
Event generator information.
double Vy(const int i=0) const
std::vector< float > fKaonKERange
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.