167 if(
evt.isRealData())
return;
170 auto recoTracks =
evt.getValidHandle<std::vector<recob::Track> >(
fTrackerTag);
173 const art::FindManyP<recob::Hit> findTrackHits(recoTracks,
evt,
fTrackerTag);
176 const art::FindManyP<anab::CosmicTag> findCosmicTags(recoTracks,
evt,
fTrackerTag);
182 unsigned int local_TrueCosmicMuon = 0;
183 unsigned int local_TaggedCosmicMuon = 0;
184 unsigned int local_TrueOther = 0;
185 unsigned int local_TaggedOther = 0;
186 unsigned int local_TrueCosmicOrigin = 0;
187 unsigned int local_TaggedCosmicOrigin = 0;
188 unsigned int local_TrueOtherOrigin = 0;
189 unsigned int local_TaggedOtherOrigin = 0;
192 std::vector<int> matchedTruths;
196 for(
unsigned int t = 0;
t < recoTracks->size(); ++
t){
199 auto const& trackHits = findTrackHits.at(
t);
204 if(trueMatch == 0x0)
continue;
206 bool alreadyMatched =
false;
207 if(std::find(matchedTruths.begin(),matchedTruths.end(),trueMatch->
TrackId())==matchedTruths.end()){
208 matchedTruths.push_back(trueMatch->
TrackId());
211 alreadyMatched =
true;
215 bool isCosmic =
false;
216 bool isCosmicMuon =
false;
221 if(fabs(trueMatch->
PdgCode()) == 13){
222 ++local_TrueCosmicMuon;
229 ++local_TrueCosmicOrigin;
235 ++local_TrueOtherOrigin;
239 auto const& trackCosmicTag = findCosmicTags.at(
t);
257 if(trackCosmicTag.size() == 0){
260 std::cout <<
"We've found a cosmic muon but we don't have a tag for it" <<
std::endl;
265 std::cout <<
" - Track length = " << ((*recoTracks)[
t].Vertex()-(*recoTracks)[
t].End()).
R() <<
std::endl;
266 if((*recoTracks)[
t].Vertex().Y() < (*recoTracks)[
t].End().Y()){
267 std::cout <<
" - Track reconstructed with the vertex lower than the end point" <<
std::endl;
269 if((*recoTracks)[
t].Vertex().Y() < 550 && (*recoTracks)[
t].End().Y() < 550){
270 std::cout <<
" - This track was reconstructed away from the top of the detector... no way to tag it. " <<
std::endl;
273 std::cout <<
" - This true particle " << trueMatch->
TrackId() <<
"was already matched" <<
std::endl;
281 ++local_TaggedCosmicMuon;
289 ++local_TaggedCosmicOrigin;
292 ++local_TaggedOtherOrigin;
294 if(correctProcess ==
"primary"){
295 std::cout <<
" - Oops! Tagged a good beam particle (" << trueMatch->
PdgCode() <<
") as a cosmic (" <<
ConvertCosmicType(trackCosmicTag[0]->CosmicType()) <<
")" <<
std::endl;
297 else if(correctProcess ==
"primaryBackground"){
298 std::cout <<
" - Oops! Tagged a background beam particle (" << trueMatch->
PdgCode() <<
") as a cosmic (" <<
ConvertCosmicType(trackCosmicTag[0]->CosmicType()) <<
")" <<
std::endl;
301 std::cout <<
" - Oops! Tagged a non-primary beam particle (" << trueMatch->
PdgCode() <<
") as a cosmic (" <<
ConvertCosmicType(trackCosmicTag[0]->CosmicType()) <<
")" <<
std::endl;
303 (*recoTracks)[
t].Vertex<TVector3>().Print();
304 (*recoTracks)[
t].End<TVector3>().Print();
305 trueMatch->
Position().Vect().Print();
318 if(local_TrueCosmicMuon > 0){
319 hCosmicMuonEff->Fill(local_TaggedCosmicMuon/static_cast<float>(local_TrueCosmicMuon));
321 if(local_TaggedCosmicMuon+local_TaggedOther > 0){
322 hCosmicMuonPur->Fill(local_TaggedCosmicMuon/static_cast<float>(local_TaggedCosmicMuon + local_TaggedOther));
324 if(local_TrueCosmicOrigin > 0){
325 hCosmicEff->Fill(local_TaggedCosmicOrigin/static_cast<float>(local_TrueCosmicOrigin));
327 if(local_TaggedCosmicOrigin+local_TaggedOtherOrigin > 0){
328 hCosmicPur->Fill(local_TaggedCosmicOrigin/static_cast<float>(local_TaggedCosmicOrigin + local_TaggedOtherOrigin));
const TLorentzVector & Position(const int i=0) const
const TLorentzVector & EndPosition() const
simb::Origin_t Origin() const
art::InputTag fTrackerTag
const particleType ConvertPDGCode(int pdg) const
std::string Process() const
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int id) const
unsigned int fTaggedOther
int ConvertCosmicType(anab::CosmicTagID_t tag) const
unsigned int fTrueCosmicMuon
unsigned int fTaggedCosmicOrigin
const simb::MCParticle & GetParticle(int i) const
unsigned int fTaggedOtherOrigin
unsigned int fTaggedCosmicMuon
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
unsigned int fTrueCosmicOrigin
const simb::MCParticle * GetTruthParticle(detinfo::DetectorClocksData const &clockData, const std::vector< art::Ptr< recob::Hit > > &hits) const
QTextStream & endl(QTextStream &s)
unsigned int fTrueOtherOrigin