401 std::cout <<
"\n\n************* New Event / Module running - Run " <<
Run <<
", Event " <<
Event <<
", NEvent " <<
NEvent <<
" *************\n\n" <<
std::endl;
404 auto const*
geo = lar::providerFrom<geo::Geometry>();
413 auto truth =
evt.getHandle<std::vector<simb::MCParticle> >(
"largeant");
415 for (
size_t i=0; i<truth->size(); i++) {
416 truthmap[truth->at(i).TrackId()]=&((*truth)[i]);
417 if (truth->at(i).Mother() == 0) {
423 std::cout <<
"The primary particle in this event was a " <<
PrimPDG[
nPrim-1]<<
" with Energy " <<
PrimEn[
nPrim-1]
429 std::cout <<
"There were " <<
nPrim <<
" primary particles." <<
std::endl;
432 auto simchannels =
evt.getHandle<std::vector<sim::SimChannel> >(
"largeant");
435 std::vector<int> MuonVec, PionVec, Pi0Vec, KaonVec, ElecVec, ProtVec;
441 std::vector< sim::IDE > UnAssignVec;
444 for (
auto const& simchannel:*simchannels) {
450 for (
auto const& tdcide:simchannel.TDCIDEMap()) {
451 unsigned int tdc = tdcide.first;
452 auto const& idevec=tdcide.second;
454 std::cout <<
"TDC IDE " << tdcideIt <<
" of " << simchannel.TDCIDEMap().size() <<
", has tdc " << tdc <<
", and idevec of size " << idevec.size() <<
std::endl;
457 for (
auto const& ide:idevec) {
458 int ideTrackID = ide.trackID;
459 float ideEnergy = ide.energy;
474 int OrigPdgCode = Origpart.
PdgCode();
477 if (!(
geo->HasTPC(tpcid)) ) {
479 std::cout <<
"Outside the Active volume I found at the top!" <<
std::endl;
549 bool isDecay =
false;
550 bool WrittenOut =
false;
551 bool OrigPart =
true;
553 std::cout <<
"\nLooking at IDE " << ideIt <<
", ideTrackID is " << ideTrackID <<
", it was due to a " 556 while ( ideTrackID != 0 && !WrittenOut ) {
559 if ( PdgCode != OrigPdgCode || ideTrackID < 0 )
562 if ( (PdgCode == -13 || PdgCode == 13) )
563 FillVars( MuonVec,
nMuon,
MuonEDep,
MuonDaughtersEDep,
MuonDecayEDep,
MuonStart,
MuonEnd,
nParentMuon,
MuonParents,
MuonParTrID,
MuonPDG,
MuonTrID,
MuonCont,
MuonFromDecay,
564 ideTrackID, tdc, ide, part, OrigPart, isDecay, WrittenOut );
566 else if ( (PdgCode == -211 || PdgCode == 211) && part.
Process() !=
"pi+Inelastic" && part.
Process() !=
"pi-Inelastic" )
567 FillVars( PionVec,
nPion,
PionEDep,
PionDaughtersEDep,
PionDecayEDep,
PionStart,
PionEnd,
nParentPion,
PionParents,
PionParTrID,
PionPDG,
PionTrID,
PionCont,
PionFromDecay,
568 ideTrackID, tdc, ide, part, OrigPart, isDecay, WrittenOut);
570 else if ( PdgCode == 111 )
571 FillVars( Pi0Vec ,
nPi0 ,
Pi0EDep ,
Pi0DaughtersEDep ,
Pi0DecayEDep ,
Pi0Start ,
Pi0End ,
nParentPi0 ,
Pi0Parents ,
Pi0ParTrID ,
Pi0PDG ,
Pi0TrID ,
Pi0Cont ,
Pi0FromDecay ,
572 ideTrackID, tdc, ide, part, OrigPart, isDecay, WrittenOut );
574 else if ( (PdgCode == 321 || PdgCode == -321) && part.
Process() !=
"kaon+Inelastic" && part.
Process() !=
"kaon-Inelastic" )
575 FillVars( KaonVec,
nKaon,
KaonEDep,
KaonDaughtersEDep,
KaonDecayEDep,
KaonStart,
KaonEnd,
nParentKaon,
KaonParents,
KaonParTrID,
KaonPDG,
KaonTrID,
KaonCont,
KaonFromDecay,
576 ideTrackID, tdc, ide, part, OrigPart, isDecay, WrittenOut );
578 else if ( (PdgCode == -11 || PdgCode == 11) ) {
581 FillVars( ElecVec,
nElec,
ElecEDep,
ElecDaughtersEDep,
ElecDecayEDep,
ElecStart,
ElecEnd,
nParentElec,
ElecParents,
ElecParTrID,
ElecPDG,
ElecTrID,
ElecCont,
ElecFromDecay,
582 ideTrackID, tdc, ide, part, OrigPart, isDecay, WrittenOut );
584 }
else if ( PdgCode == 2212 )
585 FillVars( ProtVec,
nProt,
ProtEDep,
ProtDaughtersEDep,
ProtDecayEDep,
ProtStart,
ProtEnd,
nParentProt,
ProtParents,
ProtParTrID,
ProtPDG,
ProtTrID,
ProtCont,
ProtFromDecay,
586 ideTrackID, tdc, ide, part, OrigPart, isDecay, WrittenOut );
589 ideTrackID = part.
Mother();
592 int ThrowIDE = ide.trackID;
593 std::cout <<
"None of the particles in this chain are interesting, so skipping. It was due to TrackID " << ThrowIDE <<
", PdGCode " <<
truthmap[
abs(ThrowIDE) ]->PdgCode()
594 <<
", energy " << ide.energy <<
", and pos ("<<ide.x<<
", "<<ide.y<<
", "<<ide.z<<
").\n" 595 <<
" The ide parentage was PdG (TrackID) " <<
truthmap[
abs(ThrowIDE) ]->PdgCode() <<
" (" << ThrowIDE <<
") ";
596 while ( ThrowIDE != 0 ) {
601 std::cout <<
" <-- " <<
truthmap[
abs(ThrowIDE) ]->PdgCode() <<
" (" << ThrowIDE <<
") ";
604 UnAssignVec.push_back( ide );
610 if ( ideTrackID > 0 && part.
Process() ==
"Decay" &&
611 ( PdgCode == -13 || PdgCode == 13 || PdgCode == -211 || PdgCode == 211 ||
612 PdgCode == 321 || PdgCode == -321 || PdgCode == -11 || PdgCode == 11 ||
622 std::cout <<
"Not something interesting so moving backwards. The parent of that particle had trackID " << ideTrackID
623 <<
", was from a " << PdgCode <<
", from a decay? " << isDecay <<
std::endl;
629 std::cout <<
"Had too many of one particle type, voiding this event now...nKaon " <<
nKaon <<
", nElec " <<
nElec <<
", nMuon " <<
nMuon 642 std::cout <<
"\nLooked through all of my IDEs, my UnAssignVec has size " << UnAssignVec.size() <<
std::endl;
643 int StillUnassign = 0;
644 for (
auto const& ide:UnAssignVec) {
646 std::cout <<
"Going through my uninteresting particles...this IDE was due to TrackID " << ide.trackID <<
", energy " << ide.energy
647 <<
", and pos ("<<ide.x<<
", "<<ide.y<<
", "<<ide.z<<
"). " <<
std::endl;
648 int ideTrId = ide.trackID;
649 std::cout <<
" The ide parentage was PdG (TrackID) " <<
truthmap[
abs(ideTrId) ]->PdgCode() <<
" (" << ideTrId <<
") ";
650 while ( ideTrId != 0 ) {
655 std::cout <<
" <-- " <<
truthmap[
abs(ideTrId) ]->PdgCode() <<
" (" << ideTrId <<
") ";
658 bool FoundDep =
false;
661 if (FoundDep)
continue;
664 if (FoundDep)
continue;
667 if (FoundDep)
continue;
670 if (FoundDep)
continue;
673 if (FoundDep)
continue;
676 if (FoundDep)
continue;
678 if (
Verbosity > 1) std::cout <<
"!!!This IDE was nowhere near anything...." <<
std::endl;
681 std::cout <<
"There were still " << StillUnassign <<
" unassigned IDEs." <<
std::endl;
687 std::cout <<
"\nThere are kaons in this event!!" <<
std::endl;
688 for (
int KL=0; KL<
nKaon; ++KL) {
689 std::cout <<
"Kaon " << KL <<
" had properties: PDG " <<
KaonPDG[KL] <<
", TrackID " <<
KaonTrID[KL] <<
", EDep " <<
KaonEDep[KL]
694 std::cout <<
"There are electrons in this event!!" <<
std::endl;
695 for (
int EL=0; EL<
nElec; ++EL) {
696 std::cout <<
"Elec " << EL <<
" had properties: PDG " <<
ElecPDG[EL] <<
", TrackID " <<
ElecTrID[EL] <<
", EDep " <<
ElecEDep[EL]
700 <<
"\nThe parents of this electron were: ";
708 std::cout <<
"There are " <<
nMuon <<
" muons in this event!!" <<
std::endl;
711 std::cout <<
"There are " <<
nPion <<
" pions in this event!!" <<
std::endl;
714 std::cout <<
"There are " <<
nPi0 <<
" pi0's in this event!!" <<
std::endl;
717 std::cout <<
"There are " <<
nProt <<
" protons in this event!!" <<
std::endl;
727 std::cout <<
"There were Kaons in the detector so writing out this event." <<
std::endl;
int ProtParTrID[MaxPart][MaxParent]
float ProtDecayEDep[MaxPart]
int ElecParents[MaxPart][MaxParent]
float ElecDecayEDep[MaxPart]
int ElecParTrID[MaxPart][MaxParent]
float MuonDecayEDep[MaxPart]
float PionDecayEDep[MaxPart]
int MuonParents[MaxPart][MaxParent]
float Pi0DaughtersEDep[MaxPart]
float KaonDecayEDep[MaxPart]
float ElecStart[MaxPart][4]
int ProtFromDecay[MaxPart]
float Pi0DecayEDep[MaxPart]
std::string Process() const
std::vector< int > AllTrackIDs
float ProtNearEDep[MaxPart]
int ElecFromDecay[MaxPart]
int KaonParTrID[MaxPart][MaxParent]
int PdgCode(Resonance_t res, int Q)
(resonance id, charge) -> PDG code
bool UnAssignLoop(int nPart, float St[MaxPart][4], sim::IDE thisIDE, float NearE[MaxPart])
float MuonEnd[MaxPart][4]
float MuonDaughtersEDep[MaxPart]
float KaonEnd[MaxPart][4]
int MuonParTrID[MaxPart][MaxParent]
float ProtDaughtersEDep[MaxPart]
int PionParTrID[MaxPart][MaxParent]
float Pi0Start[MaxPart][4]
float ProtEnd[MaxPart][4]
float ElecDaughtersEDep[MaxPart]
float PionNearEDep[MaxPart]
float PionEnd[MaxPart][4]
float KaonDaughtersEDep[MaxPart]
The data type to uniquely identify a TPC.
int Pi0Parents[MaxPart][MaxParent]
std::map< int, const simb::MCParticle * > truthmap
float PionDaughtersEDep[MaxPart]
int ProtParents[MaxPart][MaxParent]
float ElecEnd[MaxPart][4]
int KaonFromDecay[MaxPart]
int MuonFromDecay[MaxPart]
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
float KaonStart[MaxPart][4]
int Pi0ParTrID[MaxPart][MaxParent]
int KaonParents[MaxPart][MaxParent]
float ProtStart[MaxPart][4]
int PionFromDecay[MaxPart]
float ElecNearEDep[MaxPart]
void FillVars(std::vector< int > &TrackIDVec, int &numParts, float EDep[MaxPart], float DaughtEDep[MaxPart], float DecayEDep[MaxPart], float Start[MaxPart][4], float End[MaxPart][4], int nParents[MaxPart], int Parent[MaxPart][MaxParent], int ParTrID[MaxPart][MaxParent], int PDG[MaxPart], int TrID[MaxPart], int Cont[MaxPart], int FromDecay[MaxPart], int ThisID, unsigned int ThisTDC, sim::IDE ThisIDE, const simb::MCParticle &MCPart, bool Decay, bool OrigParticle, bool &Written)
float MuonStart[MaxPart][4]
float MuonNearEDep[MaxPart]
float Pi0NearEDep[MaxPart]
LArSoft geometry interface.
float KaonNearEDep[MaxPart]
int PionParents[MaxPart][MaxParent]
int Pi0FromDecay[MaxPart]
float PionStart[MaxPart][4]
QTextStream & endl(QTextStream &s)
Signal from collection planes.