78 #ifndef ANALYSISTREE_H
79 #define ANALYSISTREE_H
82 #include "art/Framework/Core/ModuleMacros.h"
83 #include "art/Framework/Core/EDAnalyzer.h"
84 #include "art/Framework/Principal/Event.h"
85 #include "art/Framework/Principal/SubRun.h"
86 #include "art/Framework/Principal/Handle.h"
87 #include "art/Framework/Principal/View.h"
88 #include "canvas/Persistency/Common/Ptr.h"
89 #include "canvas/Persistency/Common/PtrVector.h"
90 #include "art/Framework/Services/Registry/ServiceHandle.h"
91 #include "art_root_io/TFileService.h"
92 #include "art_root_io/TFileDirectory.h"
93 #include "canvas/Persistency/Common/FindMany.h"
94 #include "canvas/Persistency/Common/FindManyP.h"
95 #include "canvas/Persistency/Common/FindOneP.h"
96 #include "fhiclcpp/ParameterSet.h"
97 #include "messagefacility/MessageLogger/MessageLogger.h"
100 #include "nusimdata/SimulationBase/GTruth.h"
101 #include "nusimdata/SimulationBase/MCTruth.h"
102 #include "nusimdata/SimulationBase/MCFlux.h"
147 #include <functional>
152 #include "TTimeStamp.h"
164 template <
typename T>
181 template <
typename Array_t>
192 { std::memcpy((
char*) &(
data()), (
char*) &(from.
data()),
sizeof(Array_t)); }
218 operator decltype(&
array[0]) ()
const {
return &
array[0]; }
236 template <
typename T>
238 template <
typename T>
240 template <
typename T>
241 using HitData_t = std::vector<BoxedArray<T[kNplanes][kMaxTrackHits]>>;
242 template <
typename T>
324 void Resize(
size_t nTracks);
344 template <
typename T>
374 void Resize(
size_t nShowers);
375 void SetShowerAddresses(TTree* pTree, std::string showerLabel,
bool saveHierarchyInfo);
392 template <
typename T>
394 template <
typename T>
411 void Resize(
size_t nVertices);
412 void SetAddresses(TTree* pTree, std::string vertexLabel,
bool saveHierarchyInfo);
577 std::vector<Float_t>
Px;
578 std::vector<Float_t>
Py;
579 std::vector<Float_t>
Pz;
580 std::vector<Float_t>
P;
619 template <
typename T>
667 void SetBits(
unsigned int setbits,
bool unset =
false)
668 {
if (unset)
bits &= ~setbits;
else bits |= setbits; }
710 void SetAddresses(TTree* pTree,
const std::vector<std::string>& trackers, std::string showerLabel,
const std::vector< std::string> &vertexLabels,
bool isCosmics,
const std::vector<bool>& saveHierarchyInfo,
bool saveShowerHierarchyInfo);
713 void SetShowerAddresses(TTree* pTree, std::string showerLabel,
bool saveHierarchyInfo);
741 (std::string
name,
void* address, std::string leaflist )
744 TBranch* pBranch =
pTree->GetBranch(
name.c_str());
746 pTree->Branch(
name.c_str(), address, leaflist.c_str() );
747 MF_LOG_DEBUG(
"AnalysisTreeStructure")
748 <<
"Creating branch '" <<
name <<
" with leaf '" << leaflist <<
"'";
750 else if (pBranch->GetAddress() != address) {
751 pBranch->SetAddress(address);
752 MF_LOG_DEBUG(
"AnalysisTreeStructure")
753 <<
"Reassigning address to branch '" <<
name <<
"'";
756 MF_LOG_DEBUG(
"AnalysisTreeStructure")
757 <<
"Branch '" <<
name <<
"' is fine";
761 (std::string
name,
void* address,
const std::stringstream& leaflist )
763 template <
typename T>
765 (std::string
name, std::vector<T>& data, std::string leaflist )
766 {
return this->
operator() (
name, (
void*) data.data(), leaflist ); }
768 template <
typename T>
777 TBranch* pBranch =
pTree->GetBranch(name.c_str());
779 pTree->Branch(name.c_str(), &data);
782 MF_LOG_DEBUG(
"AnalysisTreeStructure")
783 <<
"Creating object branch '" << name
784 <<
" with " << TClass::GetClass(
typeid(T))->ClassName();
787 (*(
reinterpret_cast<std::vector<T>**
>(pBranch->GetAddress())) != &data)
794 pBranch->SetObject(&data);
795 MF_LOG_DEBUG(
"AnalysisTreeStructure")
796 <<
"Reassigning object to branch '" << name <<
"'";
799 MF_LOG_DEBUG(
"AnalysisTreeStructure")
800 <<
"Branch '" << name <<
"' is fine";
834 std::vector< art::Ptr<recob::Hit> >
const& hits, Int_t& trackid, Float_t& purity,
double& maxe);
836 Int_t& truthid, Float_t& frac, Float_t& energy, Float_t& numElectrons);
838 bool TrackIdToMCTruth( Int_t
const trkID, art::Ptr<simb::MCTruth>& mctruth );
839 bool DoesHitHaveSimChannel( std::vector<const sim::SimChannel*> chans, art::Ptr<recob::Hit>
const& hit);
841 double length(
const simb::MCParticle& part, TVector3& start, TVector3&
end);
892 art::ServiceHandle<cheat::ParticleInventoryService>
pi_serv;
895 art::ServiceHandle<cheat::BackTrackerService>
bt_serv;
935 throw art::Exception(art::errors::LogicError)
936 <<
"AnalysisTree::SetTrackerAddresses(): no tracker #" << iTracker
947 throw art::Exception(art::errors::LogicError)
948 <<
"AnalysisTree::SetVerticesAddresses(): no tracker #" << iTracker
972 throw art::Exception(art::errors::LogicError)
973 <<
"AnalysisTree::" << caller <<
": no data";
979 throw art::Exception(art::errors::LogicError)
980 <<
"AnalysisTree::" << caller <<
": no tree";
988 class AutoResettingStringSteam:
public std::ostringstream {
990 AutoResettingStringSteam& operator() () { str(
"");
return *
this; }
994 template <
typename ITER,
typename TYPE>
995 inline void FillWith(ITER
from, ITER to, TYPE
value)
999 template <
typename ITER,
typename TYPE>
1000 inline void FillWith(ITER
from,
size_t n, TYPE
value)
1004 template <
typename CONT,
typename V>
1005 inline void FillWith(CONT& data,
const V&
value)
1094 FillWith(trkId , -9999 );
1095 FillWith(trkncosmictags_tagger, -9999 );
1096 FillWith(trkcosmicscore_tagger, -99999.);
1097 FillWith(trkcosmictype_tagger, -9999 );
1098 FillWith(trkncosmictags_flashmatch, -9999 );
1099 FillWith(trkcosmicscore_flashmatch, -99999.);
1100 FillWith(trkcosmictype_flashmatch, -9999 );
1101 FillWith(trkstartx , -99999.);
1102 FillWith(trkstarty , -99999.);
1103 FillWith(trkstartz , -99999.);
1104 FillWith(trkstartd , -99999.);
1105 FillWith(trkendx , -99999.);
1106 FillWith(trkendy , -99999.);
1107 FillWith(trkendz , -99999.);
1108 FillWith(trkendd , -99999.);
1109 FillWith(trktheta , -99999.);
1110 FillWith(trkphi , -99999.);
1111 FillWith(trkstartdcosx, -99999.);
1112 FillWith(trkstartdcosy, -99999.);
1113 FillWith(trkstartdcosz, -99999.);
1114 FillWith(trkenddcosx , -99999.);
1115 FillWith(trkenddcosy , -99999.);
1116 FillWith(trkenddcosz , -99999.);
1117 FillWith(trkthetaxz , -99999.);
1118 FillWith(trkthetayz , -99999.);
1119 FillWith(trkmom , -99999.);
1120 FillWith(trkmomrange , -99999.);
1121 FillWith(trkmommschi2 , -99999.);
1122 FillWith(trkmommsllhd , -99999.);
1123 FillWith(trklen , -99999.);
1124 FillWith(trksvtxid , -1);
1125 FillWith(trkevtxid , -1);
1126 FillWith(trkpidbestplane, -1);
1127 FillWith(trkisprimary, -9999);
1128 FillWith(trkndaughters, -9999);
1129 FillWith(trkpfpid, -9999);
1130 FillWith(trkparentpfpid, -9999);
1133 for (
size_t iTrk = 0; iTrk < MaxTracks; ++iTrk){
1137 FillWith(trkke[iTrk] , -99999.);
1138 FillWith(trkrange[iTrk] , -99999.);
1139 FillWith(trkidtruth_recoutils_totaltrueenergy[iTrk] , -99999 );
1140 FillWith(trkidtruth_recoutils_totalrecocharge[iTrk] , -99999 );
1141 FillWith(trkidtruth_recoutils_totalrecohits[iTrk] , -99999 );
1142 FillWith(trkidtruth[iTrk] , -99999 );
1143 FillWith(trkorigin[iTrk] , -1 );
1144 FillWith(trkpdgtruth[iTrk], -99999 );
1145 FillWith(trkefftruth[iTrk], -99999.);
1146 FillWith(trksimIDEenergytruth[iTrk], -99999.);
1147 FillWith(trksimIDExtruth[iTrk], -99999.);
1148 FillWith(trksimIDEytruth[iTrk], -99999.);
1149 FillWith(trksimIDEztruth[iTrk], -99999.);
1150 FillWith(trkpurtruth[iTrk], -99999.);
1151 FillWith(trkpitchc[iTrk] , -99999.);
1152 FillWith(ntrkhits[iTrk] , -9999 );
1154 FillWith(trkdedx[iTrk], 0.);
1155 FillWith(trkdqdx[iTrk], 0.);
1156 FillWith(trkresrg[iTrk], 0.);
1158 FillWith(trkxyz[iTrk], 0.);
1160 FillWith(trkpidpdg[iTrk] , -1);
1161 FillWith(trkpidchi[iTrk] , -99999.);
1162 FillWith(trkpidchipr[iTrk] , -99999.);
1163 FillWith(trkpidchika[iTrk] , -99999.);
1164 FillWith(trkpidchipi[iTrk] , -99999.);
1165 FillWith(trkpidchimu[iTrk] , -99999.);
1166 FillWith(trkpidpida[iTrk] , -99999.);
1174 TTree* pTree, std::string tracker,
bool isCosmics,
bool saveHierarchyInfo
1176 if (MaxTracks == 0)
return;
1180 AutoResettingStringSteam sstr;
1182 std::string MaxTrackHitsIndexStr(
"[" + sstr.str() +
"]");
1184 std::string TrackLabel = tracker;
1185 std::string BranchName;
1187 BranchName =
"ntracks_" + TrackLabel;
1188 CreateBranch(BranchName, &ntracks, BranchName +
"/S");
1189 std::string NTracksIndexStr =
"[" + BranchName +
"]";
1191 BranchName =
"trkId_" + TrackLabel;
1192 CreateBranch(BranchName, trkId, BranchName + NTracksIndexStr +
"/S");
1194 BranchName =
"trkncosmictags_tagger_" + TrackLabel;
1195 CreateBranch(BranchName, trkncosmictags_tagger, BranchName + NTracksIndexStr +
"/S");
1197 BranchName =
"trkcosmicscore_tagger_" + TrackLabel;
1198 CreateBranch(BranchName, trkcosmicscore_tagger, BranchName + NTracksIndexStr +
"/F");
1200 BranchName =
"trkcosmictype_tagger_" + TrackLabel;
1201 CreateBranch(BranchName, trkcosmictype_tagger, BranchName + NTracksIndexStr +
"/S");
1203 BranchName =
"trkncosmictags_flashmatch_" + TrackLabel;
1204 CreateBranch(BranchName, trkncosmictags_flashmatch, BranchName + NTracksIndexStr +
"/S");
1206 BranchName =
"trkcosmicscore_flashmatch_" + TrackLabel;
1207 CreateBranch(BranchName, trkcosmicscore_flashmatch, BranchName + NTracksIndexStr +
"/F");
1209 BranchName =
"trkcosmictype_flashmatch_" + TrackLabel;
1210 CreateBranch(BranchName, trkcosmictype_flashmatch, BranchName + NTracksIndexStr +
"/S");
1212 BranchName =
"trkke_" + TrackLabel;
1213 CreateBranch(BranchName, trkke, BranchName + NTracksIndexStr +
"[3]/F");
1215 BranchName =
"trkrange_" + TrackLabel;
1216 CreateBranch(BranchName, trkrange, BranchName + NTracksIndexStr +
"[3]/F");
1218 BranchName =
"trkidtruth_recoutils_totaltrueenergy_" + TrackLabel;
1219 CreateBranch(BranchName, trkidtruth_recoutils_totaltrueenergy, BranchName + NTracksIndexStr +
"[3]/I");
1221 BranchName =
"trkidtruth_recoutils_totalrecocharge_" + TrackLabel;
1222 CreateBranch(BranchName, trkidtruth_recoutils_totalrecocharge, BranchName + NTracksIndexStr +
"[3]/I");
1224 BranchName =
"trkidtruth_recoutils_totalrecohits_" + TrackLabel;
1225 CreateBranch(BranchName, trkidtruth_recoutils_totalrecohits, BranchName + NTracksIndexStr +
"[3]/I");
1227 BranchName =
"trkidtruth_" + TrackLabel;
1228 CreateBranch(BranchName, trkidtruth, BranchName + NTracksIndexStr +
"[3]/I");
1230 BranchName =
"trkorigin_" + TrackLabel;
1231 CreateBranch(BranchName, trkorigin, BranchName + NTracksIndexStr +
"[3]/S");
1233 BranchName =
"trkpdgtruth_" + TrackLabel;
1234 CreateBranch(BranchName, trkpdgtruth, BranchName + NTracksIndexStr +
"[3]/I");
1236 BranchName =
"trkefftruth_" + TrackLabel;
1237 CreateBranch(BranchName, trkefftruth, BranchName + NTracksIndexStr +
"[3]/F");
1239 BranchName =
"trksimIDEenergytruth_" + TrackLabel;
1240 CreateBranch(BranchName, trksimIDEenergytruth, BranchName + NTracksIndexStr +
"[3]/F");
1242 BranchName =
"trksimIDExtruth_" + TrackLabel;
1243 CreateBranch(BranchName, trksimIDExtruth, BranchName + NTracksIndexStr +
"[3]/F");
1245 BranchName =
"trksimIDEytruth_" + TrackLabel;
1246 CreateBranch(BranchName, trksimIDEytruth, BranchName + NTracksIndexStr +
"[3]/F");
1248 BranchName =
"trksimIDEztruth_" + TrackLabel;
1249 CreateBranch(BranchName, trksimIDEztruth, BranchName + NTracksIndexStr +
"[3]/F");
1251 BranchName =
"trkpurtruth_" + TrackLabel;
1252 CreateBranch(BranchName, trkpurtruth, BranchName + NTracksIndexStr +
"[3]/F");
1254 BranchName =
"trkpitchc_" + TrackLabel;
1255 CreateBranch(BranchName, trkpitchc, BranchName + NTracksIndexStr +
"[3]/F");
1257 BranchName =
"ntrkhits_" + TrackLabel;
1258 CreateBranch(BranchName, ntrkhits, BranchName + NTracksIndexStr +
"[3]/S");
1261 BranchName =
"trkdedx_" + TrackLabel;
1262 CreateBranch(BranchName, trkdedx, BranchName + NTracksIndexStr +
"[3]" + MaxTrackHitsIndexStr +
"/F");
1264 BranchName =
"trkdqdx_" + TrackLabel;
1265 CreateBranch(BranchName, trkdqdx, BranchName + NTracksIndexStr +
"[3]" + MaxTrackHitsIndexStr +
"/F");
1267 BranchName =
"trkresrg_" + TrackLabel;
1268 CreateBranch(BranchName, trkresrg, BranchName + NTracksIndexStr +
"[3]" + MaxTrackHitsIndexStr +
"/F");
1270 BranchName =
"trkxyz_" + TrackLabel;
1271 CreateBranch(BranchName, trkxyz, BranchName + NTracksIndexStr +
"[3]" + MaxTrackHitsIndexStr +
"/F");
1274 BranchName =
"trkstartx_" + TrackLabel;
1275 CreateBranch(BranchName, trkstartx, BranchName + NTracksIndexStr +
"/F");
1277 BranchName =
"trkstarty_" + TrackLabel;
1278 CreateBranch(BranchName, trkstarty, BranchName + NTracksIndexStr +
"/F");
1280 BranchName =
"trkstartz_" + TrackLabel;
1281 CreateBranch(BranchName, trkstartz, BranchName + NTracksIndexStr +
"/F");
1283 BranchName =
"trkstartd_" + TrackLabel;
1284 CreateBranch(BranchName, trkstartd, BranchName + NTracksIndexStr +
"/F");
1286 BranchName =
"trkendx_" + TrackLabel;
1287 CreateBranch(BranchName, trkendx, BranchName + NTracksIndexStr +
"/F");
1289 BranchName =
"trkendy_" + TrackLabel;
1290 CreateBranch(BranchName, trkendy, BranchName + NTracksIndexStr +
"/F");
1292 BranchName =
"trkendz_" + TrackLabel;
1293 CreateBranch(BranchName, trkendz, BranchName + NTracksIndexStr +
"/F");
1295 BranchName =
"trkendd_" + TrackLabel;
1296 CreateBranch(BranchName, trkendd, BranchName + NTracksIndexStr +
"/F");
1298 BranchName =
"trktheta_" + TrackLabel;
1299 CreateBranch(BranchName, trktheta, BranchName + NTracksIndexStr +
"/F");
1301 BranchName =
"trkphi_" + TrackLabel;
1302 CreateBranch(BranchName, trkphi, BranchName + NTracksIndexStr +
"/F");
1304 BranchName =
"trkstartdcosx_" + TrackLabel;
1305 CreateBranch(BranchName, trkstartdcosx, BranchName + NTracksIndexStr +
"/F");
1307 BranchName =
"trkstartdcosy_" + TrackLabel;
1308 CreateBranch(BranchName, trkstartdcosy, BranchName + NTracksIndexStr +
"/F");
1310 BranchName =
"trkstartdcosz_" + TrackLabel;
1311 CreateBranch(BranchName, trkstartdcosz, BranchName + NTracksIndexStr +
"/F");
1313 BranchName =
"trkenddcosx_" + TrackLabel;
1314 CreateBranch(BranchName, trkenddcosx, BranchName + NTracksIndexStr +
"/F");
1316 BranchName =
"trkenddcosy_" + TrackLabel;
1317 CreateBranch(BranchName, trkenddcosy, BranchName + NTracksIndexStr +
"/F");
1319 BranchName =
"trkenddcosz_" + TrackLabel;
1320 CreateBranch(BranchName, trkenddcosz, BranchName + NTracksIndexStr +
"/F");
1322 BranchName =
"trkthetaxz_" + TrackLabel;
1323 CreateBranch(BranchName, trkthetaxz, BranchName + NTracksIndexStr +
"/F");
1325 BranchName =
"trkthetayz_" + TrackLabel;
1326 CreateBranch(BranchName, trkthetayz, BranchName + NTracksIndexStr +
"/F");
1328 BranchName =
"trkmom_" + TrackLabel;
1329 CreateBranch(BranchName, trkmom, BranchName + NTracksIndexStr +
"/F");
1331 BranchName =
"trkmomrange_" + TrackLabel;
1332 CreateBranch(BranchName, trkmomrange, BranchName + NTracksIndexStr +
"/F");
1334 BranchName =
"trkmommschi2_" + TrackLabel;
1335 CreateBranch(BranchName, trkmommschi2, BranchName + NTracksIndexStr +
"/F");
1337 BranchName =
"trkmommsllhd_" + TrackLabel;
1338 CreateBranch(BranchName, trkmommsllhd, BranchName + NTracksIndexStr +
"/F");
1340 BranchName =
"trklen_" + TrackLabel;
1341 CreateBranch(BranchName, trklen, BranchName + NTracksIndexStr +
"/F");
1343 BranchName =
"trksvtxid_" + TrackLabel;
1344 CreateBranch(BranchName, trksvtxid, BranchName + NTracksIndexStr +
"/S");
1346 BranchName =
"trkevtxid_" + TrackLabel;
1347 CreateBranch(BranchName, trkevtxid, BranchName + NTracksIndexStr +
"/S");
1349 BranchName =
"trkpidpdg_" + TrackLabel;
1350 CreateBranch(BranchName, trkpidpdg, BranchName + NTracksIndexStr +
"[3]/I");
1352 BranchName =
"trkpidchi_" + TrackLabel;
1353 CreateBranch(BranchName, trkpidchi, BranchName + NTracksIndexStr +
"[3]/F");
1355 BranchName =
"trkpidchipr_" + TrackLabel;
1356 CreateBranch(BranchName, trkpidchipr, BranchName + NTracksIndexStr +
"[3]/F");
1358 BranchName =
"trkpidchika_" + TrackLabel;
1359 CreateBranch(BranchName, trkpidchika, BranchName + NTracksIndexStr +
"[3]/F");
1361 BranchName =
"trkpidchipi_" + TrackLabel;
1362 CreateBranch(BranchName, trkpidchipi, BranchName + NTracksIndexStr +
"[3]/F");
1364 BranchName =
"trkpidchimu_" + TrackLabel;
1365 CreateBranch(BranchName, trkpidchimu, BranchName + NTracksIndexStr +
"[3]/F");
1367 BranchName =
"trkpidpida_" + TrackLabel;
1368 CreateBranch(BranchName, trkpidpida, BranchName + NTracksIndexStr +
"[3]/F");
1370 BranchName =
"trkpidbestplane_" + TrackLabel;
1371 CreateBranch(BranchName, trkpidbestplane, BranchName + NTracksIndexStr +
"/S");
1373 if(saveHierarchyInfo){
1374 BranchName =
"trkisprimary_" + TrackLabel;
1375 CreateBranch(BranchName, trkisprimary, BranchName + NTracksIndexStr +
"/O");
1377 BranchName =
"trkndaughters_" + TrackLabel;
1378 CreateBranch(BranchName, trkndaughters, BranchName + NTracksIndexStr +
"/I");
1380 BranchName =
"trkpfpid_" + TrackLabel;
1381 CreateBranch(BranchName, trkpfpid, BranchName + NTracksIndexStr +
"/I");
1383 BranchName =
"trkparentpfpid_" + TrackLabel;
1384 CreateBranch(BranchName, trkparentpfpid, BranchName + NTracksIndexStr +
"/I");
1394 MaxShowers = nShowers;
1396 shwId.resize(MaxShowers);
1397 shwbestplane.resize(MaxShowers);
1398 shwlength.resize(MaxShowers);
1399 shwopenangle.resize(MaxShowers);
1400 shwstartx.resize(MaxShowers);
1401 shwstarty.resize(MaxShowers);
1402 shwstartz.resize(MaxShowers);
1403 shwdirx.resize(MaxShowers);
1404 shwdiry.resize(MaxShowers);
1405 shwdirz.resize(MaxShowers);
1406 shwisprimary.resize(MaxShowers);
1407 shwndaughters.resize(MaxShowers);
1408 shwpfpid.resize(MaxShowers);
1409 shwparentpfpid.resize(MaxShowers);
1418 FillWith(shwId, -9999);
1419 FillWith(shwbestplane, -9999);
1420 FillWith(shwlength, -9999.);
1421 FillWith(shwopenangle, -9999.);
1422 FillWith(shwstartx, -9999.);
1423 FillWith(shwstarty, -9999.);
1424 FillWith(shwstartz, -9999.);
1425 FillWith(shwdirx, -9999.);
1426 FillWith(shwdiry, -9999.);
1427 FillWith(shwdirz, -9999.);
1428 FillWith(shwisprimary, -9999);
1429 FillWith(shwndaughters, -9999);
1430 FillWith(shwpfpid, -9999);
1431 FillWith(shwparentpfpid, -9999);
1436 TTree* pTree, std::string showerLabel,
bool saveHierarchyInfo
1438 if (MaxShowers == 0)
return;
1442 std::string ShowerLabel = showerLabel;
1443 std::string BranchName;
1445 BranchName =
"nshowers_" + ShowerLabel;
1446 CreateBranch(BranchName, &nshowers, BranchName +
"/S");
1447 std::string NShowersIndexStr =
"[" + BranchName +
"]";
1449 BranchName =
"shwId_" + ShowerLabel;
1450 CreateBranch(BranchName, shwId, BranchName + NShowersIndexStr +
"/I");
1452 BranchName =
"shwbestplane_" + ShowerLabel;
1453 CreateBranch(BranchName, shwbestplane, BranchName + NShowersIndexStr +
"/I");
1455 BranchName =
"shwlength_" + ShowerLabel;
1456 CreateBranch(BranchName, shwlength, BranchName + NShowersIndexStr +
"/F");
1458 BranchName =
"shwlength_" + ShowerLabel;
1459 CreateBranch(BranchName, shwlength, BranchName + NShowersIndexStr +
"/F");
1461 BranchName =
"shwopenangle_" + ShowerLabel;
1462 CreateBranch(BranchName, shwopenangle, BranchName + NShowersIndexStr +
"/F");
1464 BranchName =
"shwstartx_" + ShowerLabel;
1465 CreateBranch(BranchName, shwstartx, BranchName + NShowersIndexStr +
"/F");
1467 BranchName =
"shwstarty_" + ShowerLabel;
1468 CreateBranch(BranchName, shwstarty, BranchName + NShowersIndexStr +
"/F");
1470 BranchName =
"shwstartz_" + ShowerLabel;
1471 CreateBranch(BranchName, shwstartz, BranchName + NShowersIndexStr +
"/F");
1473 BranchName =
"shwdirx_" + ShowerLabel;
1474 CreateBranch(BranchName, shwdirx, BranchName + NShowersIndexStr +
"/F");
1476 BranchName =
"shwdiry_" + ShowerLabel;
1477 CreateBranch(BranchName, shwdiry, BranchName + NShowersIndexStr +
"/F");
1479 BranchName =
"shwdirz_" + ShowerLabel;
1480 CreateBranch(BranchName, shwdirz, BranchName + NShowersIndexStr +
"/F");
1482 if(saveHierarchyInfo){
1483 BranchName =
"shwisprimary_" + ShowerLabel;
1484 CreateBranch(BranchName, shwisprimary, BranchName + NShowersIndexStr +
"/O");
1486 BranchName =
"shwndaughters_" + ShowerLabel;
1487 CreateBranch(BranchName, shwndaughters, BranchName + NShowersIndexStr +
"/I");
1489 BranchName =
"shwpfpid_" + ShowerLabel;
1490 CreateBranch(BranchName, shwpfpid, BranchName + NShowersIndexStr +
"/I");
1492 BranchName =
"shwparentpfpid_" + ShowerLabel;
1493 CreateBranch(BranchName, shwparentpfpid, BranchName + NShowersIndexStr +
"/I");
1503 MaxVertices = nVertices;
1505 vtx.resize(MaxVertices);
1506 primaryvtx.resize(MaxVertices);
1510 Resize(MaxVertices);
1513 for (
size_t iVtx = 0; iVtx < MaxVertices; ++iVtx){
1514 FillWith(vtx[iVtx], -9999.);
1516 FillWith(primaryvtx, -9999);
1520 TTree* pTree, std::string vertices,
bool saveHierarchyInfo
1522 if (MaxVertices == 0)
return;
1526 std::string VertexLabel = vertices;
1527 std::string BranchName;
1529 BranchName =
"nvtx_" + VertexLabel;
1530 CreateBranch(BranchName, &nvtx, BranchName +
"/S");
1531 std::string NVertexIndexStr =
"[" + BranchName +
"]";
1533 if(saveHierarchyInfo){
1534 BranchName =
"primaryvtx_" + VertexLabel;
1535 CreateBranch(BranchName, primaryvtx, BranchName + NVertexIndexStr +
"/I");
1538 BranchName =
"vtx_" + VertexLabel;
1539 CreateBranch(BranchName, vtx, BranchName + NVertexIndexStr +
"[3]/F");
1611 FillWith(
pdg, -99999);
1612 FillWith(
status, -99999);
1613 FillWith(
Mass, -99999.);
1614 FillWith(
Eng, -99999.);
1615 FillWith(
EndE, -99999.);
1616 FillWith(
Px, -99999.);
1617 FillWith(
Py, -99999.);
1618 FillWith(
Pz, -99999.);
1619 FillWith(
P, -99999.);
1623 FillWith(
StartT, -9999999.);
1624 FillWith(
EndT, -9999999.);
1628 FillWith(
EndT, -99999.);
1629 FillWith(
theta, -99999.);
1630 FillWith(
phi, -99999.);
1642 FillWith(
Mother, -99999);
1665 FillWith(
cry_Px, -99999.);
1666 FillWith(
cry_Py, -99999.);
1667 FillWith(
cry_Pz, -99999.);
1668 FillWith(
cry_P, -99999.);
1675 FillWith(
cry_ND, -99999);
1683 for (
auto& partInfo:
AuxDetID) FillWith(partInfo, -9999);
1693 for (
auto& partInfo: *cont) FillWith(partInfo, -99999.);
1846 cry_Px.resize(nPrimaries);
1847 cry_Py.resize(nPrimaries);
1848 cry_Pz.resize(nPrimaries);
1849 cry_P.resize(nPrimaries);
1856 cry_ND.resize(nPrimaries);
1863 const std::vector<std::string>& trackers,
1864 const std::string showerLabel,
1865 const std::vector<std::string>& vertexLabels,
1867 const std::vector<bool>& saveHierarchyInfo,
1868 bool saveShowerHierarchyInfo
1872 CreateBranch(
"run",&
run,
"run/I");
1873 CreateBranch(
"subrun",&
subrun,
"subrun/I");
1874 CreateBranch(
"event",&
event,
"event/I");
1875 CreateBranch(
"evttime",&
evttime,
"evttime/D");
1876 CreateBranch(
"beamtime",&
beamtime,
"beamtime/D");
1879 CreateBranch(
"isdata",&
isdata,
"isdata/B");
1880 CreateBranch(
"taulife",&
taulife,
"taulife/F");
1882 CreateBranch(
"no_hits",&
no_hits,
"no_hits/I");
1884 CreateBranch(
"hit_tpc",
hit_tpc,
"hit_tpc[no_hits]/S");
1885 CreateBranch(
"hit_plane",
hit_plane,
"hit_plane[no_hits]/S");
1886 CreateBranch(
"hit_wire",
hit_wire,
"hit_wire[no_hits]/S");
1887 CreateBranch(
"hit_channel",
hit_channel,
"hit_channel[no_hits]/S");
1888 CreateBranch(
"hit_peakT",
hit_peakT,
"hit_peakT[no_hits]/F");
1889 CreateBranch(
"hit_charge",
hit_charge,
"hit_charge[no_hits]/F");
1890 CreateBranch(
"hit_ph",
hit_ph,
"hit_ph[no_hits]/F");
1891 CreateBranch(
"hit_startT",
hit_startT,
"hit_startT[no_hits]/F");
1892 CreateBranch(
"hit_endT",
hit_endT,
"hit_endT[no_hits]/F");
1893 CreateBranch(
"hit_width",
hit_width,
"hit_width[no_hits]/F");
1894 CreateBranch(
"hit_trkid",
hit_trkid,
"hit_trkid[no_hits]/S");
1895 CreateBranch(
"hit_mcid",
hit_mcid,
"hit_mcid[no_hits]/I");
1896 CreateBranch(
"hit_frac",
hit_frac,
"hit_frac[no_hits]/F");
1897 CreateBranch(
"hit_energy",
hit_energy,
"hit_energy[no_hits]/F");
1898 CreateBranch(
"hit_nelec",
hit_nelec,
"hit_nelec[no_hits]/F");
1899 CreateBranch(
"hit_reconelec",
hit_reconelec,
"hit_reconelec[no_hits]/F");
1912 std::string VertexLabel = vertexLabels[i];
1916 VertexData[i].SetAddresses(pTree, VertexLabel, saveHierarchyInfo[i]);
1921 AutoResettingStringSteam sstr;
1923 std::string MaxTrackHitsIndexStr(
"[" + sstr.str() +
"]");
1926 CreateBranch(
"kNTracker",&kNTracker,
"kNTracker/B");
1928 std::string TrackLabel = trackers[i];
1929 std::string BranchName;
1933 TrackData[i].SetAddresses(pTree, TrackLabel, isCosmics, saveHierarchyInfo[i]);
1938 std::string ShowerLabel = showerLabel;
1943 CreateBranch(
"num_pfps",&
num_pfps,
"num_pfps/I");
1944 CreateBranch(
"pfp_sliceid",&
pfp_sliceid,
"pfp_sliceid[num_pfps]/I");
1945 CreateBranch(
"pfp_pdg",&
pfp_pdg,
"pfp_pdg[num_pfps]/I");
1946 CreateBranch(
"num_slices",&
num_slices,
"num_slices/I");
1947 CreateBranch(
"num_nuslices",&
num_nuslices,
"num_nuslices/I");
1960 CreateBranch(
"mcevts_truth",&
mcevts_truth,
"mcevts_truth/I");
1961 CreateBranch(
"nuScatterCode_truth",
nuScatterCode_truth,
"nuScatterCode_truth[mcevts_truth]/I");
1962 CreateBranch(
"nuID_truth",
nuID_truth,
"nuID_truth[mcevts_truth]/I");
1963 CreateBranch(
"nuPDG_truth",
nuPDG_truth,
"nuPDG_truth[mcevts_truth]/I");
1964 CreateBranch(
"ccnc_truth",
ccnc_truth,
"ccnc_truth[mcevts_truth]/I");
1965 CreateBranch(
"mode_truth",
mode_truth,
"mode_truth[mcevts_truth]/I");
1966 CreateBranch(
"enu_truth",
enu_truth,
"enu_truth[mcevts_truth]/F");
1967 CreateBranch(
"Q2_truth",
Q2_truth,
"Q2_truth[mcevts_truth]/F");
1968 CreateBranch(
"W_truth",
W_truth,
"W_truth[mcevts_truth]/F");
1969 CreateBranch(
"hitnuc_truth",
hitnuc_truth,
"hitnuc_truth[mcevts_truth]/I");
1970 CreateBranch(
"nuvtxx_truth",
nuvtxx_truth,
"nuvtxx_truth[mcevts_truth]/F");
1971 CreateBranch(
"nuvtxy_truth",
nuvtxy_truth,
"nuvtxy_truth[mcevts_truth]/F");
1972 CreateBranch(
"nuvtxz_truth",
nuvtxz_truth,
"nuvtxz_truth[mcevts_truth]/F");
1973 CreateBranch(
"nu_dcosx_truth",
nu_dcosx_truth,
"nu_dcosx_truth[mcevts_truth]/F");
1974 CreateBranch(
"nu_dcosy_truth",
nu_dcosy_truth,
"nu_dcosy_truth[mcevts_truth]/F");
1975 CreateBranch(
"nu_dcosz_truth",
nu_dcosz_truth,
"nu_dcosz_truth[mcevts_truth]/F");
1976 CreateBranch(
"lep_mom_truth",
lep_mom_truth,
"lep_mom_truth[mcevts_truth]/F");
1977 CreateBranch(
"lep_dcosx_truth",
lep_dcosx_truth,
"lep_dcosx_truth[mcevts_truth]/F");
1978 CreateBranch(
"lep_dcosy_truth",
lep_dcosy_truth,
"lep_dcosy_truth[mcevts_truth]/F");
1979 CreateBranch(
"lep_dcosz_truth",
lep_dcosz_truth,
"lep_dcosz_truth[mcevts_truth]/F");
1981 CreateBranch(
"tpx_flux",
tpx_flux,
"tpx_flux[mcevts_truth]/F");
1982 CreateBranch(
"tpy_flux",
tpy_flux,
"tpy_flux[mcevts_truth]/F");
1983 CreateBranch(
"tpz_flux",
tpz_flux,
"tpz_flux[mcevts_truth]/F");
1984 CreateBranch(
"tptype_flux",
tptype_flux,
"tptype_flux[mcevts_truth]/I");
1987 CreateBranch(
"genie_primaries_pdg",
genie_primaries_pdg,
"genie_primaries_pdg[genie_no_primaries]/I");
1988 CreateBranch(
"genie_Eng",
genie_Eng,
"genie_Eng[genie_no_primaries]/F");
1989 CreateBranch(
"genie_Px",
genie_Px,
"genie_Px[genie_no_primaries]/F");
1990 CreateBranch(
"genie_Py",
genie_Py,
"genie_Py[genie_no_primaries]/F");
1991 CreateBranch(
"genie_Pz",
genie_Pz,
"genie_Pz[genie_no_primaries]/F");
1992 CreateBranch(
"genie_P",
genie_P,
"genie_P[genie_no_primaries]/F");
1993 CreateBranch(
"genie_status_code",
genie_status_code,
"genie_status_code[genie_no_primaries]/I");
1994 CreateBranch(
"genie_mass",
genie_mass,
"genie_mass[genie_no_primaries]/F");
1995 CreateBranch(
"genie_trackID",
genie_trackID,
"genie_trackID[genie_no_primaries]/I");
1996 CreateBranch(
"genie_ND",
genie_ND,
"genie_ND[genie_no_primaries]/I");
1997 CreateBranch(
"genie_mother",
genie_mother,
"genie_mother[genie_no_primaries]/I");
2003 CreateBranch(
"cry_primaries_pdg",
cry_primaries_pdg,
"cry_primaries_pdg[cry_no_primaries]/I");
2004 CreateBranch(
"cry_Eng",
cry_Eng,
"cry_Eng[cry_no_primaries]/F");
2005 CreateBranch(
"cry_Px",
cry_Px,
"cry_Px[cry_no_primaries]/F");
2006 CreateBranch(
"cry_Py",
cry_Py,
"cry_Py[cry_no_primaries]/F");
2007 CreateBranch(
"cry_Pz",
cry_Pz,
"cry_Pz[cry_no_primaries]/F");
2008 CreateBranch(
"cry_P",
cry_P,
"cry_P[cry_no_primaries]/F");
2009 CreateBranch(
"cry_StartPointx",
cry_StartPointx,
"cry_StartPointx[cry_no_primaries]/F");
2010 CreateBranch(
"cry_StartPointy",
cry_StartPointy,
"cry_StartPointy[cry_no_primaries]/F");
2011 CreateBranch(
"cry_StartPointz",
cry_StartPointz,
"cry_StartPointz[cry_no_primaries]/F");
2012 CreateBranch(
"cry_status_code",
cry_status_code,
"cry_status_code[cry_no_primaries]/I");
2013 CreateBranch(
"cry_mass",
cry_mass,
"cry_mass[cry_no_primaries]/F");
2014 CreateBranch(
"cry_trackID",
cry_trackID,
"cry_trackID[cry_no_primaries]/I");
2015 CreateBranch(
"cry_ND",
cry_ND,
"cry_ND[cry_no_primaries]/I");
2016 CreateBranch(
"cry_mother",
cry_mother,
"cry_mother[cry_no_primaries]/I");
2020 CreateBranch(
"no_primaries",&
no_primaries,
"no_primaries/I");
2023 CreateBranch(
"pdg",
pdg,
"pdg[geant_list_size]/I");
2024 CreateBranch(
"status",
status,
"status[geant_list_size]/I");
2025 CreateBranch(
"Mass",
Mass,
"Mass[geant_list_size]/F");
2026 CreateBranch(
"Eng",
Eng,
"Eng[geant_list_size]/F");
2027 CreateBranch(
"EndE",
EndE,
"EndE[geant_list_size]/F");
2028 CreateBranch(
"Px",
Px,
"Px[geant_list_size]/F");
2029 CreateBranch(
"Py",
Py,
"Py[geant_list_size]/F");
2030 CreateBranch(
"Pz",
Pz,
"Pz[geant_list_size]/F");
2031 CreateBranch(
"P",
P,
"P[geant_list_size]/F");
2032 CreateBranch(
"StartPointx",
StartPointx,
"StartPointx[geant_list_size]/F");
2033 CreateBranch(
"StartPointy",
StartPointy,
"StartPointy[geant_list_size]/F");
2034 CreateBranch(
"StartPointz",
StartPointz,
"StartPointz[geant_list_size]/F");
2035 CreateBranch(
"StartT",
StartT,
"StartT[geant_list_size]/F");
2036 CreateBranch(
"EndPointx",
EndPointx,
"EndPointx[geant_list_size]/F");
2037 CreateBranch(
"EndPointy",
EndPointy,
"EndPointy[geant_list_size]/F");
2038 CreateBranch(
"EndPointz",
EndPointz,
"EndPointz[geant_list_size]/F");
2039 CreateBranch(
"EndT",
EndT,
"EndT[geant_list_size]/F");
2040 CreateBranch(
"theta",
theta,
"theta[geant_list_size]/F");
2041 CreateBranch(
"phi",
phi,
"phi[geant_list_size]/F");
2042 CreateBranch(
"theta_xz",
theta_xz,
"theta_xz[geant_list_size]/F");
2043 CreateBranch(
"theta_yz",
theta_yz,
"theta_yz[geant_list_size]/F");
2044 CreateBranch(
"pathlen",
pathlen,
"pathlen[geant_list_size]/F");
2045 CreateBranch(
"inTPCActive",
inTPCActive,
"inTPCActive[geant_list_size]/I");
2046 CreateBranch(
"StartPointx_tpcAV",
StartPointx_tpcAV,
"StartPointx_tpcAV[geant_list_size]/F");
2047 CreateBranch(
"StartPointy_tpcAV",
StartPointy_tpcAV,
"StartPointy_tpcAV[geant_list_size]/F");
2048 CreateBranch(
"StartPointz_tpcAV",
StartPointz_tpcAV,
"StartPointz_tpcAV[geant_list_size]/F");
2049 CreateBranch(
"EndPointx_tpcAV",
EndPointx_tpcAV,
"EndPointx_tpcAV[geant_list_size]/F");
2050 CreateBranch(
"EndPointy_tpcAV",
EndPointy_tpcAV,
"EndPointy_tpcAV[geant_list_size]/F");
2051 CreateBranch(
"EndPointz_tpcAV",
EndPointz_tpcAV,
"EndPointz_tpcAV[geant_list_size]/F");
2052 CreateBranch(
"NumberDaughters",
NumberDaughters,
"NumberDaughters[geant_list_size]/I");
2053 CreateBranch(
"Mother",
Mother,
"Mother[geant_list_size]/I");
2054 CreateBranch(
"TrackId",
TrackId,
"TrackId[geant_list_size]/I");
2055 CreateBranch(
"MergedId",
MergedId,
"MergedId[geant_list_size]/I");
2056 CreateBranch(
"MotherNuId",
MotherNuId,
"MotherNuId[geant_list_size]/I");
2057 CreateBranch(
"process_primary",
process_primary,
"process_primary[geant_list_size]/I");
2059 CreateBranch(
"DepEnergy",
DepEnergy,
"DepEnergy[geant_list_size]/F");
2060 CreateBranch(
"NumElectrons",
NumElectrons,
"NumElectrons[geant_list_size]/F");
2061 CreateBranch(
"total_DepEnergy", &
total_DepEnergy,
"total_DepEnergy/F");
2069 throw art::Exception(art::errors::Configuration)
2070 <<
"Saving Auxiliary detector information requies saving GEANT information, "
2071 <<
"please set fSaveGeantInfo flag to true in your fhicl file and rerun.\n";
2073 std::ostringstream sstr;
2075 std::string MaxAuxDetIndexStr = sstr.str();
2076 CreateBranch(
"NAuxDets",
NAuxDets,
"NAuxDets[geant_list_size]/s");
2077 CreateBranch(
"AuxDetID",
AuxDetID,
"AuxDetID[geant_list_size]" + MaxAuxDetIndexStr +
"/S");
2078 CreateBranch(
"AuxDetEntryX",
entryX,
"AuxDetEntryX[geant_list_size]" + MaxAuxDetIndexStr +
"/F");
2079 CreateBranch(
"AuxDetEntryY",
entryY,
"AuxDetEntryY[geant_list_size]" + MaxAuxDetIndexStr +
"/F");
2080 CreateBranch(
"AuxDetEntryZ",
entryZ,
"AuxDetEntryZ[geant_list_size]" + MaxAuxDetIndexStr +
"/F");
2081 CreateBranch(
"AuxDetEntryT",
entryT,
"AuxDetEntryT[geant_list_size]" + MaxAuxDetIndexStr +
"/F");
2082 CreateBranch(
"AuxDetExitX",
exitX,
"AuxDetExitX[geant_list_size]" + MaxAuxDetIndexStr +
"/F");
2083 CreateBranch(
"AuxDetExitY",
exitY,
"AuxDetExitY[geant_list_size]" + MaxAuxDetIndexStr +
"/F");
2084 CreateBranch(
"AuxDetExitZ",
exitZ,
"AuxDetExitZ[geant_list_size]" + MaxAuxDetIndexStr +
"/F");
2085 CreateBranch(
"AuxDetExitT",
exitT,
"AuxDetExitT[geant_list_size]" + MaxAuxDetIndexStr +
"/F");
2086 CreateBranch(
"AuxDetExitPx",
exitPx,
"AuxDetExitPx[geant_list_size]" + MaxAuxDetIndexStr +
"/F");
2087 CreateBranch(
"AuxDetExitPy",
exitPy,
"AuxDetExitPy[geant_list_size]" + MaxAuxDetIndexStr +
"/F");
2088 CreateBranch(
"AuxDetExitPz",
exitPz,
"AuxDetExitPz[geant_list_size]" + MaxAuxDetIndexStr +
"/F");
2090 "CombinedEnergyDep[geant_list_size]" + MaxAuxDetIndexStr +
"/F");
2102 fTree(nullptr), fData(nullptr),
2103 fDigitModuleLabel (pset.
get<
std::string >(
"DigitModuleLabel") ),
2104 fHitsModuleLabel (pset.
get<
std::string >(
"HitsModuleLabel") ),
2105 fLArG4ModuleLabel (pset.
get<
std::string >(
"LArGeantModuleLabel") ),
2106 fTPCSimChannelModuleLabel (pset.
get<
std::string >(
"TPCSimChannelModuleLabel") ),
2107 fCalDataModuleLabel (pset.
get<
std::string >(
"CalDataModuleLabel") ),
2108 fGenieGenModuleLabel (pset.
get<
std::string >(
"GenieGenModuleLabel") ),
2109 fCryGenModuleLabel (pset.
get<
std::string >(
"CryGenModuleLabel") ),
2110 fG4ModuleLabel (pset.
get<
std::string >(
"G4ModuleLabel") ),
2111 fPFParticleModuleLabel (pset.
get<
std::string> (
"PFParticleModuleLabel") ),
2112 fShowerModuleLabel (pset.
get<
std::string> (
"ShowerModuleLabel") ),
2113 fVertexModuleLabel (pset.
get<
std::
vector<
std::string> >(
"VertexModuleLabel") ),
2114 fTrackModuleLabel (pset.
get<
std::
vector<
std::string> >(
"TrackModuleLabel") ),
2115 fCalorimetryModuleLabel (pset.
get<
std::
vector<
std::string> >(
"CalorimetryModuleLabel")),
2116 fParticleIDModuleLabel (pset.
get<
std::
vector<
std::string> >(
"ParticleIDModuleLabel") ),
2117 fPOTModuleLabel (pset.
get<
std::string >(
"POTModuleLabel") ),
2120 fSaveAuxDetInfo (pset.
get<
bool >(
"SaveAuxDetInfo",
false)),
2122 fSaveGenieInfo (pset.
get<
bool >(
"SaveGenieInfo",
false)),
2123 fSaveGeantInfo (pset.
get<
bool >(
"SaveGeantInfo",
false)),
2125 fSaveTrackInfo (pset.
get<
bool >(
"SaveTrackInfo",
false)),
2126 fSaveShowerInfo (pset.
get<
bool >(
"SaveShowerInfo",
false)),
2127 fSaveVertexInfo (pset.
get<
bool >(
"SaveVertexInfo",
false)),
2128 fSaveSliceInfo (pset.
get<
bool >(
"SaveSliceInfo",
true)),
2129 fSaveHierarchyInfo (pset.
get<
std::
vector<
bool> >(
"SaveHierarchyInfo", {
false})),
2135 fG4minE (pset.get<
float>(
"G4minE",0.01)),
2136 fCaloAlg (pset.get< fhicl::ParameterSet >(
"CaloAlg"))
2138 if (fSaveAuxDetInfo ==
true) fSaveGeantInfo =
true;
2139 mf::LogInfo(
"AnalysisTree") <<
"Configuration:"
2140 <<
"\n UseBuffers: " << std::boolalpha << fUseBuffer
2143 throw art::Exception(art::errors::Configuration)
2144 <<
"AnalysisTree currently supports only up to " <<
kMaxTrackers
2145 <<
" tracking algorithms, but " << GetNTrackers() <<
" are specified."
2146 <<
"\nYou can increase kMaxTrackers and recompile.";
2148 if (fTrackModuleLabel.size() != fVertexModuleLabel.size()){
2149 throw art::Exception(art::errors::Configuration)
2150 <<
"fTrackModuleLabel.size() = "<<fTrackModuleLabel.size()<<
" does not match "
2151 <<
"fVertexModuleLabel.size() = "<<fVertexModuleLabel.size();
2153 if (fTrackModuleLabel.size() != fCalorimetryModuleLabel.size()){
2154 throw art::Exception(art::errors::Configuration)
2155 <<
"fTrackModuleLabel.size() = "<<fTrackModuleLabel.size()<<
" does not match "
2156 <<
"fCalorimetryModuleLabel.size() = "<<fCalorimetryModuleLabel.size();
2158 if (fTrackModuleLabel.size() != fParticleIDModuleLabel.size()){
2159 throw art::Exception(art::errors::Configuration)
2160 <<
"fTrackModuleLabel.size() = "<<fTrackModuleLabel.size()<<
" does not match "
2161 <<
"fParticleIDModuleLabel.size() = "<<fParticleIDModuleLabel.size();
2163 if (fTrackModuleLabel.size() != fSaveHierarchyInfo.size()){
2164 throw art::Exception(art::errors::Configuration)
2165 <<
"fTrackModuleLabel.size() = "<<fTrackModuleLabel.size()<<
" does not match "
2166 <<
"fSaveHierarchyInfo.size() = "<<fSaveHierarchyInfo.size();
2179 art::ServiceHandle<art::TFileService>
tfs;
2180 fTree = tfs->make<TTree>(
"anatree",
"analysis tree");
2182 CreateData(bClearData);
2189 art::Handle< sumdata::POTSummary > potListHandle;
2192 if(sr.getByLabel(fPOTModuleLabel,potListHandle))
2193 SubRunData.pot=potListHandle->totpot;
2201 std::cout<<
"AnalysisTree: processing event "<<evt.id().event()<<
"\n";
2204 art::ServiceHandle<geo::Geometry> geom;
2205 auto const detprop = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt);
2209 bool isMC = !evt.isRealData();
2212 art::Handle< std::vector<simb::MCFlux> > mcfluxListHandle;
2213 std::vector<art::Ptr<simb::MCFlux> > fluxlist;
2214 if (evt.getByLabel(fGenieGenModuleLabel,mcfluxListHandle))
2215 art::fill_ptr_vector(fluxlist, mcfluxListHandle);
2218 std::vector<const sim::SimChannel*> fSimChannels;
2219 if (isMC && fSaveGeantInfo)
2220 evt.getView(fTPCSimChannelModuleLabel, fSimChannels);
2223 std::vector<const sim::AuxDetSimChannel*> fAuxDetSimChannels;
2224 if (fSaveAuxDetInfo && fSaveGeantInfo)
2225 evt.getView(fLArG4ModuleLabel, fAuxDetSimChannels);
2228 art::Handle< std::vector<recob::Hit> > hitListHandle;
2229 std::vector<art::Ptr<recob::Hit> > hitlist;
2230 if (evt.getByLabel(fHitsModuleLabel,hitListHandle))
2231 art::fill_ptr_vector(hitlist, hitListHandle);
2234 art::Handle< std::vector<simb::MCTruth> > mctruthListHandle;
2235 std::vector<art::Ptr<simb::MCTruth> > mclist;
2236 if (evt.getByLabel(fGenieGenModuleLabel,mctruthListHandle))
2237 art::fill_ptr_vector(mclist, mctruthListHandle);
2240 art::Handle< std::vector<simb::MCTruth> > mctruthcryListHandle;
2241 std::vector<art::Ptr<simb::MCTruth> > mclistcry;
2243 if (evt.getByLabel(fCryGenModuleLabel,mctruthcryListHandle))
2244 art::fill_ptr_vector(mclistcry, mctruthcryListHandle);
2247 art::Ptr<simb::MCTruth> mctruthcry;
2248 int nCryPrimaries = 0;
2251 mctruthcry = mclistcry[0];
2252 nCryPrimaries = mctruthcry->NParticles();
2255 int nGeniePrimaries = 0, nGEANTparticles = 0, nMCNeutrinos = 0;
2257 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
2259 art::Ptr<simb::MCTruth> mctruth;
2264 if (!mclist.empty()){
2265 static bool isfirsttime =
true;
2267 for (
size_t i = 0; i<hitlist.size(); i++){
2270 if(DoesHitHaveSimChannel(fSimChannels,hitlist[i])) {
2271 std::vector<sim::TrackIDE> eveIDs = bt_serv->HitToTrackIDEs(clockData, hitlist[i]);
2272 for (
size_t e = 0;
e<eveIDs.size();
e++){
2273 art::Ptr<simb::MCTruth> ev_mctruth;
2274 if( TrackIdToMCTruth(eveIDs[
e].trackID, ev_mctruth)){
2282 isfirsttime =
false;
2286 mctruth = mclist[0];
2287 if (mctruth->NeutrinoSet()) nGeniePrimaries = mctruth->NParticles();
2289 const sim::ParticleList& plist = pi_serv->ParticleList();
2290 nGEANTparticles = plist.size();
2296 MF_LOG_DEBUG(
"AnalysisTree") <<
"Expected "
2297 << nGEANTparticles <<
" GEANT particles, "
2298 << nGeniePrimaries <<
" GENIE particles";
2303 nMCNeutrinos = mclist.size();
2306 if (fSaveGenieInfo){
2307 fData->ResizeGenie(nGeniePrimaries);
2308 fData->ResizeMCNeutrino(nMCNeutrinos);
2311 fData->ResizeCry(nCryPrimaries);
2313 fData->ResizeGEANT(nGEANTparticles);
2314 fData->ClearLocalData();
2317 const size_t NTrackers = GetNTrackers();
2318 const size_t NHits = hitlist.size();
2324 fData->SubRunData = SubRunData;
2326 fData->isdata = int(!isMC);
2341 std::vector< art::Handle< std::vector<recob::Track> > > trackListHandle(NTrackers);
2342 std::vector< art::Handle< std::vector<recob::Vertex> > > vtxListHandle(NTrackers);
2343 art::Handle< std::vector<recob::Shower> > showerHandle;
2344 std::vector< std::vector<art::Ptr<recob::Track> > > tracklist(NTrackers);
2345 std::vector< std::vector< art::Ptr<recob::Vertex> > > vtxlist(NTrackers);
2346 std::vector< art::Ptr<recob::Shower> > shwlist;
2347 std::vector< int > NVertices;
2351 typedef std::map<art::Ptr<recob::Track>, art::Ptr<recob::PFParticle> > trkPfpMap;
2352 typedef std::map<art::Ptr<recob::Vertex>, art::Ptr<recob::PFParticle> > vtxPfpMap;
2353 typedef std::map<art::Ptr<recob::Shower>, art::Ptr<recob::PFParticle> > shwPfpMap;
2354 typedef std::map<art::Ptr<recob::Track>, art::Ptr<recob::PFParticle> >::const_iterator trkPfpMapIt;
2355 typedef std::map<art::Ptr<recob::Vertex>, art::Ptr<recob::PFParticle> >::const_iterator vtxPfpMapIt;
2356 typedef std::map<art::Ptr<recob::Shower>, art::Ptr<recob::PFParticle> >::const_iterator shwPfpMapIt;
2358 trkPfpMap trackPFParticleMap;
2359 vtxPfpMap vertexPFParticleMap;
2360 shwPfpMap showerPFParticleMap;
2363 std::vector< trkPfpMap > trackerPFParticleMaps;
2364 std::vector< vtxPfpMap > verticesPFParticleMaps;
2367 art::Handle< std::vector<recob::PFParticle> > pfpHandle;
2368 if(evt.getByLabel(fPFParticleModuleLabel,pfpHandle)){
2369 if(pfpHandle->size()){
2370 art::fill_ptr_vector(pfplist, pfpHandle);
2373 mf::LogError(
"AnalysisTree:limits") <<
" Event has no PFParticle information ";
2378 for (
unsigned int iTracker=0; iTracker < NTrackers; ++iTracker){
2379 verticesPFParticleMaps.push_back(vertexPFParticleMap);
2380 trackerPFParticleMaps.push_back(trackPFParticleMap);
2382 if(!fSaveHierarchyInfo[iTracker])
continue;
2389 art::FindManyP<recob::Vertex> fvtx(pfpHandle, evt, fVertexModuleLabel[iTracker]);
2390 art::FindManyP<recob::Track> fmtrk(pfpHandle, evt, fTrackModuleLabel[iTracker]);
2392 for(
unsigned int i = 0; i < pfpHandle->size(); ++i) {
2393 const art::Ptr< recob::PFParticle > pfp( pfpHandle, i );
2396 std::vector< art::Ptr<recob::Vertex> > vtxAssn = fvtx.at(pfp.key());
2399 if(vtxAssn.size() > 1){
2400 throw cet::exception(
"AnalysisTree:limits") <<
"PFParticle has " << vtxAssn.size() <<
" associated vertices, should only have 1 or 0 ";
2402 if(vtxAssn.size() == 0)
continue;
2403 verticesPFParticleMaps.at(iTracker).emplace(vtxAssn.front(),pfp);
2406 for(
unsigned int i = 0; i < pfpHandle->size(); ++i) {
2407 const art::Ptr< recob::PFParticle > pfp( pfpHandle, i );
2409 std::vector< art::Ptr<recob::Track> > trkAssn = fmtrk.at(pfp.key());
2410 if(trkAssn.size() > 1){
2411 throw cet::exception(
"AnalysisTree:limits") <<
"PFParticle has " << trkAssn.size() <<
" associated tracks, should only have 1 or 0 ";
2413 if(trkAssn.size() == 0)
continue;
2414 trackerPFParticleMaps.at(iTracker).emplace(trkAssn.front(),pfp);
2419 if(pfpHandle->size()) {
2420 art::FindManyP<recob::Shower> fshw(pfpHandle, evt, fShowerModuleLabel);
2421 for(
unsigned int i = 0; i < pfpHandle->size(); ++i) {
2422 art::Ptr< recob::PFParticle > pfp( pfpHandle, i );
2425 std::vector< art::Ptr<recob::Shower> > shwAssn = fshw.at(pfp->Self());
2428 if(shwAssn.size() > 1){
2429 mf::LogError(
"AnalysisTree:limits") <<
"PFParticle has " << shwAssn.size() <<
" associated showers, should only have 1 or 0 ";
2432 if(shwAssn.size() == 0)
continue;
2433 showerPFParticleMap.emplace(shwAssn[0],pfp);
2439 if (evt.getByLabel(fShowerModuleLabel,showerHandle))
2440 art::fill_ptr_vector(shwlist, showerHandle);
2441 const size_t NShowers = shwlist.size();
2443 for (
unsigned int it = 0; it < NTrackers; ++it){
2444 if (evt.getByLabel(fTrackModuleLabel[it],trackListHandle[it]))
2445 art::fill_ptr_vector(tracklist[it], trackListHandle[it]);
2446 if (evt.getByLabel(fVertexModuleLabel[it],vtxListHandle[it]))
2447 art::fill_ptr_vector(vtxlist[it], vtxListHandle[it]);
2451 fData->run = evt.run();
2452 fData->subrun = evt.subRun();
2453 fData->event = evt.id().event();
2455 art::Timestamp ts = evt.time();
2456 TTimeStamp tts(ts.timeHigh(), ts.timeLow());
2457 fData->evttime = tts.AsDouble();
2461 art::Handle< raw::BeamInfo >
beam;
2462 if (evt.getByLabel(
"beam",beam)){
2463 fData->beamtime = (double)beam->get_t_ms();
2464 fData->beamtime/=1000.;
2472 fData->no_hits = (int) NHits;
2477 mf::LogError(
"AnalysisTree:limits") <<
"event has " << NHits
2478 <<
" hits, only kMaxHits=" <<
kMaxHits <<
" stored in tree";
2480 for (
size_t i = 0; i < NHits && i <
kMaxHits ; ++i){
2481 fData->hit_channel[i] = hitlist[i]->Channel();
2482 fData->hit_tpc[i] = hitlist[i]->WireID().TPC;
2483 fData->hit_plane[i] = hitlist[i]->WireID().Plane;
2484 fData->hit_wire[i] = hitlist[i]->WireID().Wire;
2485 fData->hit_peakT[i] = hitlist[i]->PeakTime();
2486 fData->hit_charge[i] = hitlist[i]->Integral();
2487 fData->hit_ph[i] = hitlist[i]->PeakAmplitude();
2488 fData->hit_startT[i] = hitlist[i]->PeakTimeMinusRMS();
2489 fData->hit_endT[i] = hitlist[i]->PeakTimePlusRMS();
2490 fData->hit_width[i] = hitlist[i]->RMS();
2491 fData->hit_reconelec[i] = fCaloAlg.ElectronsFromADCArea(hitlist[i]->Integral(),hitlist[i]->
WireID().
Plane);
2504 if (!evt.isRealData()){
2506 if( DoesHitHaveSimChannel(fSimChannels,hitlist[i]) ) {
2508 HitTruth(clockData, hitlist[i], fData->hit_mcid[i], fData->hit_frac[i], fData->hit_energy[i], fData->hit_nelec[i]);
2514 if (evt.getByLabel(fHitsModuleLabel,hitListHandle)){
2516 art::FindManyP<recob::Track> fmtk(hitListHandle,evt,fTrackModuleLabel[0]);
2517 for (
size_t i = 0; i < NHits && i <
kMaxHits ; ++i){
2518 if (fmtk.isValid()){
2519 if (fmtk.at(i).size()!=0) fData->hit_trkid[i] = fmtk.at(i)[0]->ID();
2520 else fData->hit_trkid[i] = -1;
2528 if (fSaveVertexInfo){
2529 for (
unsigned int iTracker=0; iTracker < NTrackers; ++iTracker){
2530 AnalysisTreeDataStruct::VertexDataStruct& VertexData = fData->GetVertexData(iTracker);
2532 size_t NVertices = vtxlist[iTracker].size();
2534 VertexData.SetMaxVertices(std::max(NVertices, (
size_t) 1));
2537 VertexData.nvtx =
static_cast<int>(NVertices);
2541 SetVerticesAddresses(iTracker);
2542 if (NVertices > VertexData.GetMaxVertices()) {
2545 mf::LogError(
"AnalysisTree:limits") <<
"event has " << NVertices
2546 <<
" " << fVertexModuleLabel[iTracker] <<
" vertices, only "
2547 << VertexData.GetMaxVertices() <<
" stored in tree";
2550 for (
size_t i = 0; i < NVertices && i <
kMaxVertices ; ++i){
2551 art::Ptr<recob::Vertex> pvertex(vtxListHandle[iTracker], i);
2555 for (
size_t j = 0; j<3; ++j){
2556 VertexData.vtx[i][j] = xyz[j];
2560 if(fSaveHierarchyInfo[iTracker]){
2561 vtxPfpMap vertexPFParticleMap = verticesPFParticleMaps.at(iTracker);
2562 vtxPfpMapIt it = vertexPFParticleMap.find(pvertex);
2565 if(it == vertexPFParticleMap.end())
continue;
2567 art::Ptr<recob::PFParticle> tempParticle = it->second;
2568 if(tempParticle->IsPrimary())
2569 VertexData.primaryvtx[i] = 1;
2570 else VertexData.primaryvtx[i] = 0;
2577 if (fSaveShowerInfo){
2578 AnalysisTreeDataStruct::ShowerDataStruct& ShowerData = fData->GetShowerData();
2582 mf::LogError(
"AnalysisTree:limits") <<
"event has " << NShowers
2583 <<
" showers, only kMaxShowers=" <<
kMaxShowers <<
" stored in tree";
2585 ShowerData.SetMaxShowers(std::max(NShowers, (
size_t) 1));
2588 ShowerData.nshowers = (int) NShowers;
2590 SetShowerAddresses();
2592 for (
size_t i = 0; i < NShowers && i <
kMaxShowers ; ++i){
2593 const art::Ptr<recob::Shower> &shw = shwlist[i];
2595 ShowerData.shwId[i] = shw->ID();
2596 ShowerData.shwbestplane[i] = shw->best_plane();
2597 ShowerData.shwlength[i] = shw->Length();
2598 ShowerData.shwopenangle[i] = shw->OpenAngle();
2599 ShowerData.shwstartx[i] = shw->ShowerStart()[0];
2600 ShowerData.shwstarty[i] = shw->ShowerStart()[1];
2601 ShowerData.shwstartz[i] = shw->ShowerStart()[2];
2602 ShowerData.shwdirx[i] = shw->Direction()[0];
2603 ShowerData.shwdiry[i] = shw->Direction()[1];
2604 ShowerData.shwdirz[i] = shw->Direction()[2];
2610 it = showerPFParticleMap.find(shw);
2611 if(it == showerPFParticleMap.end())
continue;
2613 art::Ptr<recob::PFParticle> tempParticle = it->second;
2615 ShowerData.shwndaughters[i] = tempParticle->NumDaughters();
2616 ShowerData.shwpfpid[i] = tempParticle->Self();
2617 ShowerData.shwparentpfpid[i] = tempParticle->Parent();
2623 if (fSaveTrackInfo){
2624 for (
unsigned int iTracker=0; iTracker < NTrackers; ++iTracker){
2625 AnalysisTreeDataStruct::TrackDataStruct& TrackerData = fData->GetTrackerData(iTracker);
2627 size_t NTracks = tracklist[iTracker].size();
2629 TrackerData.SetMaxTracks(std::max(NTracks, (
size_t) 1));
2630 TrackerData.Clear();
2632 TrackerData.ntracks = (int) NTracks;
2636 SetTrackerAddresses(iTracker);
2637 if (NTracks > TrackerData.GetMaxTracks()) {
2640 mf::LogError(
"AnalysisTree:limits") <<
"event has " << NTracks
2641 <<
" " << fTrackModuleLabel[iTracker] <<
" tracks, only "
2642 << TrackerData.GetMaxTracks() <<
" stored in tree";
2644 AnalysisTreeDataStruct::VertexDataStruct& VertexData = fData->GetVertexData(iTracker);
2646 size_t NVertices = vtxlist[iTracker].size();
2650 SetVerticesAddresses(iTracker);
2651 if (NVertices > VertexData.GetMaxVertices()) {
2654 mf::LogError(
"AnalysisTree:limits") <<
"event has " << NVertices
2655 <<
" " << fVertexModuleLabel[iTracker] <<
" vertices, only "
2656 << VertexData.GetMaxVertices() <<
" stored in tree";
2662 for(
size_t iTrk=0; iTrk < NTracks; ++iTrk){
2664 if (fCosmicTaggerAssocLabel.size() > iTracker) {
2665 art::FindManyP<anab::CosmicTag> fmct(trackListHandle[iTracker],evt,fCosmicTaggerAssocLabel[iTracker]);
2666 if (fmct.isValid()){
2667 TrackerData.trkncosmictags_tagger[iTrk] = fmct.at(iTrk).size();
2668 if (fmct.at(iTrk).size()>0){
2669 if(fmct.at(iTrk).size()>1)
2670 std::cerr <<
"\n Warning : more than one cosmic tag per track in module! assigning the first tag to the track" << fCosmicTaggerAssocLabel[iTracker];
2671 TrackerData.trkcosmicscore_tagger[iTrk] = fmct.at(iTrk).at(0)->CosmicScore();
2672 TrackerData.trkcosmictype_tagger[iTrk] = fmct.at(iTrk).at(0)->CosmicType();
2678 if (fFlashMatchAssocLabel.size() > iTracker) {
2680 art::FindManyP<anab::CosmicTag> fmbfm(trackListHandle[iTracker],evt,fFlashMatchAssocLabel[iTracker]);
2681 if (fmbfm.isValid()){
2682 TrackerData.trkncosmictags_flashmatch[iTrk] = fmbfm.at(iTrk).size();
2683 if (fmbfm.at(iTrk).size()>0){
2684 if(fmbfm.at(iTrk).size()>1)
2685 std::cerr <<
"\n Warning : more than one cosmic tag per track in module! assigning the first tag to the track" << fFlashMatchAssocLabel[iTracker];
2686 TrackerData.trkcosmicscore_flashmatch[iTrk] = fmbfm.at(iTrk).at(0)->CosmicScore();
2687 TrackerData.trkcosmictype_flashmatch[iTrk] = fmbfm.at(iTrk).at(0)->CosmicType();
2693 art::Ptr<recob::Track> ptrack(trackListHandle[iTracker], iTrk);
2702 const auto& pos = track.
Vertex();
2705 const auto&
end = track.
End();
2707 tlen = length(track);
2710 TrackID = track.
ID();
2712 double theta_xz = std::atan2(dir_start.X(), dir_start.Z());
2713 double theta_yz = std::atan2(dir_start.Y(), dir_start.Z());
2714 double dpos = bdist(pos);
2715 double dend = bdist(
end);
2717 TrackerData.trkId[iTrk] =
TrackID;
2718 TrackerData.trkstartx[iTrk] = pos.X();
2719 TrackerData.trkstarty[iTrk] = pos.Y();
2720 TrackerData.trkstartz[iTrk] = pos.Z();
2721 TrackerData.trkstartd[iTrk] = dpos;
2722 TrackerData.trkendx[iTrk] =
end.X();
2723 TrackerData.trkendy[iTrk] =
end.Y();
2724 TrackerData.trkendz[iTrk] =
end.Z();
2725 TrackerData.trkendd[iTrk] = dend;
2726 TrackerData.trktheta[iTrk] = dir_start.Theta();
2727 TrackerData.trkphi[iTrk] = dir_start.Phi();
2728 TrackerData.trkstartdcosx[iTrk] = dir_start.X();
2729 TrackerData.trkstartdcosy[iTrk] = dir_start.Y();
2730 TrackerData.trkstartdcosz[iTrk] = dir_start.Z();
2731 TrackerData.trkenddcosx[iTrk] = dir_end.X();
2732 TrackerData.trkenddcosy[iTrk] = dir_end.Y();
2733 TrackerData.trkenddcosz[iTrk] = dir_end.Z();
2734 TrackerData.trkthetaxz[iTrk] = theta_xz;
2735 TrackerData.trkthetayz[iTrk] = theta_yz;
2736 TrackerData.trkmom[iTrk] = mom;
2737 TrackerData.trklen[iTrk] = tlen;
2770 Float_t minsdist = 10000;
2771 Float_t minedist = 10000;
2772 for (
int ivx = 0; ivx < VertexData.nvtx && ivx <
kMaxVertices; ++ivx){
2773 Float_t sdist = sqrt(pow(TrackerData.trkstartx[iTrk]-VertexData.vtx[ivx][0],2)+
2774 pow(TrackerData.trkstarty[iTrk]-VertexData.vtx[ivx][1],2)+
2775 pow(TrackerData.trkstartz[iTrk]-VertexData.vtx[ivx][2],2));
2776 Float_t edist = sqrt(pow(TrackerData.trkendx[iTrk]-VertexData.vtx[ivx][0],2)+
2777 pow(TrackerData.trkendy[iTrk]-VertexData.vtx[ivx][1],2)+
2778 pow(TrackerData.trkendz[iTrk]-VertexData.vtx[ivx][2],2));
2779 if (sdist<minsdist){
2781 if (minsdist<10) TrackerData.trksvtxid[iTrk] = ivx;
2783 if (edist<minedist){
2785 if (minedist<10) TrackerData.trkevtxid[iTrk] = ivx;
2790 art::FindMany<anab::ParticleID> fmpid(trackListHandle[iTracker], evt, fParticleIDModuleLabel[iTracker]);
2791 if(fmpid.isValid()) {
2792 std::vector<const anab::ParticleID*> pids = fmpid.at(iTrk);
2793 if (pids.size() == 0){
2794 mf::LogError(
"AnalysisTree:limits")
2795 <<
"No track-PID association found for " << fTrackModuleLabel[iTracker]
2796 <<
" track " << iTrk <<
". Not saving particleID information.";
2799 double pidpdg[3] = {0,0,0};
2800 double pidchi[3] = {0.,0.,0.};
2801 for(
size_t planenum=0; planenum<3; ++planenum) {
2802 TrackerData.trkpidchimu[iTrk][planenum] = 0.;
2803 TrackerData.trkpidchipi[iTrk][planenum] = 0.;
2804 TrackerData.trkpidchika[iTrk][planenum] = 0.;
2805 TrackerData.trkpidchipr[iTrk][planenum] = 0.;
2806 TrackerData.trkpidpida[iTrk][planenum] = 0.;
2808 for (
size_t ipid=0; ipid<pids.size(); ipid++){
2809 std::vector<anab::sParticleIDAlgScores> AlgScoresVec = pids[ipid]->ParticleIDAlgScores();
2812 for (
size_t i_algscore=0; i_algscore<AlgScoresVec.size(); i_algscore++){
2825 if (AlgScore.
fPlaneMask.test(0)) planenum = 0;
2826 if (AlgScore.
fPlaneMask.test(1)) planenum = 1;
2827 if (AlgScore.
fPlaneMask.test(2)) planenum = 2;
2828 if (planenum<0 || planenum>2)
continue;
2832 TrackerData.trkpidchimu[iTrk][planenum] = AlgScore.
fValue;
2833 if (AlgScore.
fValue<pidchi[planenum] || (pidchi[planenum] == 0. && AlgScore.
fValue>0.)){
2834 pidchi[planenum] = AlgScore.
fValue;
2835 pidpdg[planenum] = TMath::Abs(AlgScore.
fAssumedPdg);
2838 else if (TMath::Abs(AlgScore.
fAssumedPdg) == 2212){
2839 TrackerData.trkpidchipr[iTrk][planenum] = AlgScore.
fValue;
2840 if (AlgScore.
fValue<pidchi[planenum] || (pidchi[planenum] == 0. && AlgScore.
fValue>0.)){
2841 pidchi[planenum] = AlgScore.
fValue;
2842 pidpdg[planenum] = TMath::Abs(AlgScore.
fAssumedPdg);
2845 else if (TMath::Abs(AlgScore.
fAssumedPdg) == 211){
2846 TrackerData.trkpidchipi[iTrk][planenum] = AlgScore.
fValue;
2847 if (AlgScore.
fValue<pidchi[planenum] || (pidchi[planenum] == 0. && AlgScore.
fValue>0.)){
2848 pidchi[planenum] = AlgScore.
fValue;
2849 pidpdg[planenum] = TMath::Abs(AlgScore.
fAssumedPdg);
2852 else if (TMath::Abs(AlgScore.
fAssumedPdg) == 321){
2853 TrackerData.trkpidchika[iTrk][planenum] = AlgScore.
fValue;
2854 if (AlgScore.
fValue<pidchi[planenum] || (pidchi[planenum] == 0. && AlgScore.
fValue>0.)){
2855 pidchi[planenum] = AlgScore.
fValue;
2856 pidpdg[planenum] = TMath::Abs(AlgScore.
fAssumedPdg);
2862 TrackerData.trkpidpida[iTrk][planenum] = AlgScore.
fValue;
2869 for (
size_t planenum=0; planenum<3; planenum++){
2870 TrackerData.trkpidchi[iTrk][planenum] = pidchi[planenum];
2871 TrackerData.trkpidpdg[iTrk][planenum] = pidpdg[planenum];
2875 art::FindMany<anab::Calorimetry> fmcal(trackListHandle[iTracker], evt, fCalorimetryModuleLabel[iTracker]);
2876 if (fmcal.isValid()){
2877 std::vector<const anab::Calorimetry*> calos = fmcal.at(iTrk);
2878 if (calos.size() > TrackerData.GetMaxPlanesPerTrack(iTrk)) {
2881 mf::LogError(
"AnalysisTree:limits")
2882 <<
"the " << fTrackModuleLabel[iTracker] <<
" track #" << iTrk
2883 <<
" has " << calos.size() <<
" planes for calorimetry , only "
2884 << TrackerData.GetMaxPlanesPerTrack(iTrk) <<
" stored in tree";
2886 for (
size_t ical = 0; ical<calos.size(); ++ical){
2887 if (!calos[ical])
continue;
2888 if (!calos[ical]->
PlaneID().isValid)
continue;
2889 int planenum = calos[ical]->PlaneID().Plane;
2890 if (planenum<0||planenum>2)
continue;
2891 TrackerData.trkke[iTrk][planenum] = calos[ical]->KineticEnergy();
2892 TrackerData.trkrange[iTrk][planenum] = calos[ical]->Range();
2894 TrackerData.trkpitchc[iTrk][planenum]= calos[ical] -> TrkPitchC();
2895 const size_t NHits = calos[ical] ->
dEdx().size();
2896 TrackerData.ntrkhits[iTrk][planenum] = (int) NHits;
2897 if (NHits > TrackerData.GetMaxHitsPerTrack(iTrk, planenum)) {
2899 mf::LogError(
"AnalysisTree:limits")
2900 <<
"the " << fTrackModuleLabel[iTracker] <<
" track #" << iTrk
2901 <<
" has " << NHits <<
" hits on calorimetry plane #" << planenum
2903 << TrackerData.GetMaxHitsPerTrack(iTrk, planenum) <<
" stored in tree";
2906 for(
size_t iTrkHit = 0; iTrkHit < NHits && iTrkHit < TrackerData.GetMaxHitsPerTrack(iTrk, planenum); ++iTrkHit) {
2907 TrackerData.trkdedx[iTrk][planenum][iTrkHit] = (calos[ical] ->
dEdx())[iTrkHit];
2908 TrackerData.trkdqdx[iTrk][planenum][iTrkHit] = (calos[ical] -> dQdx())[iTrkHit];
2909 TrackerData.trkresrg[iTrk][planenum][iTrkHit] = (calos[ical] -> ResidualRange())[iTrkHit];
2910 const auto& TrkPos = (calos[ical] -> XYZ())[iTrkHit];
2911 auto& TrkXYZ = TrackerData.trkxyz[iTrk][planenum][iTrkHit];
2912 TrkXYZ[0] = TrkPos.X();
2913 TrkXYZ[1] = TrkPos.Y();
2914 TrkXYZ[2] = TrkPos.Z();
2920 int bestPlane = 2, max = -999;
2921 for(
size_t ipl = 0; ipl < 3; ipl++){
2922 int N = TrackerData.ntrkhits[iTrk][ipl];
2923 if( N > max ) { max =
N; bestPlane = ipl;}
2925 TrackerData.trkpidbestplane[iTrk] = bestPlane;
2932 art::FindManyP<recob::Hit> fmht(trackListHandle[iTracker], evt, fTrackModuleLabel[iTracker]);
2933 std::vector< art::Ptr<recob::Hit> > allHits = fmht.at(iTrk);
2934 std::vector< art::Ptr<recob::Hit> > hits[
kNplanes];
2936 for(
size_t ah = 0; ah < allHits.size(); ++ah){
2938 allHits[ah]->
WireID().Plane < 3){
2939 hits[allHits[ah]->WireID().Plane].push_back(allHits[ah]);
2943 for (
size_t ipl = 0; ipl < 3; ++ipl){
2948 HitsPurity(clockData, hits[ipl],TrackerData.trkidtruth[iTrk][ipl],TrackerData.trkpurtruth[iTrk][ipl],maxe);
2950 if (TrackerData.trkidtruth[iTrk][ipl]>0){
2951 const art::Ptr<simb::MCTruth> mc = pi_serv->TrackIdToMCTruth_P(TrackerData.trkidtruth[iTrk][ipl]);
2952 TrackerData.trkorigin[iTrk][ipl] = mc->Origin();
2953 const simb::MCParticle *particle = pi_serv->TrackIdToParticle_P(TrackerData.trkidtruth[iTrk][ipl]);
2955 const std::vector<const sim::IDE*> vide(bt_serv->TrackIdToSimIDEs_Ps(TrackerData.trkidtruth[iTrk][ipl]));
2956 for (
auto ide: vide) {
2957 tote += ide->energy;
2958 TrackerData.trksimIDEenergytruth[iTrk][ipl] = ide->energy;
2959 TrackerData.trksimIDExtruth[iTrk][ipl] = ide->x;
2960 TrackerData.trksimIDEytruth[iTrk][ipl] = ide->y;
2961 TrackerData.trksimIDEztruth[iTrk][ipl] = ide->z;
2963 TrackerData.trkpdgtruth[iTrk][ipl] = particle->PdgCode();
2964 TrackerData.trkefftruth[iTrk][ipl] = maxe/(tote/
kNplanes);
2970 if(fSaveHierarchyInfo[iTracker]){
2971 trkPfpMap trackPFParticleMap = trackerPFParticleMaps[iTracker];
2974 it = trackPFParticleMap.find(ptrack);
2975 if(it == trackPFParticleMap.end())
continue;
2977 art::Ptr<recob::PFParticle> tempParticle = it->second;
2981 TrackerData.trkndaughters[iTrk] = tempParticle->NumDaughters();
2982 TrackerData.trkpfpid[iTrk] = tempParticle->Self();
2983 TrackerData.trkparentpfpid[iTrk] = tempParticle->Parent();
2998 if( fSaveSliceInfo ) {
3001 art::Handle< std::vector<recob::Slice> > sliceHandle;
3002 std::vector< art::Ptr<recob::Slice> > slicelist;
3003 if (evt.getByLabel(fPFParticleModuleLabel,sliceHandle))
3004 art::fill_ptr_vector(slicelist, sliceHandle);
3007 art::FindManyP<recob::Slice> fm_pfpslice(pfpHandle, evt, fPFParticleModuleLabel);
3009 art::FindManyP<recob::PFParticle> fm_slicepfp(slicelist, evt, fPFParticleModuleLabel);
3010 art::FindManyP<recob::Hit> fm_slicehits(sliceHandle, evt, fPFParticleModuleLabel);
3012 art::FindManyP<larpandoraobj::PFParticleMetadata> fm_pfpmd(pfpHandle, evt, fPFParticleModuleLabel);
3015 for(
auto const &pfp : pfplist ) {
3016 std::vector< art::Ptr<recob::Slice> > slcAssn = fm_pfpslice.at(pfp.key());
3017 if(slcAssn.size() == 1) fData->pfp_sliceid[pfp.key()] = slcAssn.at(0)->ID();
3018 fData->pfp_pdg[pfp.key()] = pfp->PdgCode();
3022 fData->num_pfps = (int) pfplist.size();
3023 fData->num_slices = (int) slicelist.size();
3027 std::vector<art::Ptr<recob::PFParticle>> nuPfpVec;
3028 std::vector<art::Ptr<recob::Slice>> nuSliceVec;
3029 for(
auto const &slice : slicelist ) {
3030 std::vector<art::Ptr<recob::PFParticle>> slicePFPs = fm_slicepfp.at(slice.key());
3031 for (
auto const &pfp : slicePFPs) {
3032 if ((pfp->PdgCode() == 12 || pfp->PdgCode() == 14)) {
3033 nuPfpVec.push_back(pfp);
3034 nuSliceVec.push_back(slice);
3040 fData->num_nuslices = (int)nuPfpVec.size();
3043 if(nuPfpVec.size()){
3046 float bestScore = -999.;
3047 art::Ptr<recob::Slice> bestNuSlice;
3048 art::Ptr<recob::PFParticle> bestNuPfp;
3049 for(
size_t i=0; i<nuPfpVec.size(); i++){
3050 float score = -999.;
3052 const std::vector<art::Ptr<larpandoraobj::PFParticleMetadata>> pfpMetaVec = fm_pfpmd.at(nuPfpVec.at(i)->Self());
3053 for (
auto const pfpMeta : pfpMetaVec) {
3055 score = propertiesMap.at(
"NuScore");
3056 if( score > bestScore ) {
3058 bestNuPfp = nuPfpVec.at(i);
3059 bestNuSlice = nuSliceVec.at(i);
3072 std::vector<art::Ptr<recob::Hit>> sliceHits = fm_slicehits.at(bestNuSlice.key());
3073 int nhits_slice = (int)sliceHits.size();
3077 int nhits_originNu = 0;
3078 bool foundNu =
false;
3080 art::Ptr<simb::MCTruth> mctrueNeutrino;
3081 for(
auto const hit : sliceHits){
3083 if( HitTruthId(clockData,
hit,trkId) ) {
3084 art::Ptr<simb::MCTruth> mctruth;
3085 if( TrackIdToMCTruth(trkId,mctruth) ) {
3086 if( origin < 0 ) origin = mctruth->Origin();
3087 if( mctruth->Origin() == simb::kBeamNeutrino ) {
3088 origin = mctruth->Origin();
3091 mctrueNeutrino = mctruth;
3101 int nhits_originNu_total = 0;
3102 for(
auto const hit : hitlist){
3104 if( HitTruthId(clockData,
hit,trkId) ) {
3105 art::Ptr<simb::MCTruth> mctruth;
3106 if( TrackIdToMCTruth(trkId,mctruth) ) {
3107 if( mctruth == mctrueNeutrino ) nhits_originNu_total++;
3113 fData->best_nuslice_id = bestNuSlice->ID();
3114 fData->best_nuslice_pfpid = bestNuPfp->Self();
3115 fData->best_nuslice_pdg = bestNuPfp->PdgCode();
3116 fData->best_nuslice_score = bestScore;
3117 fData->best_nuslice_origin =
origin;
3118 if( nhits_slice > 0 ) fData->best_nuslice_hitpurity = nhits_originNu/float(nhits_slice);
3119 if( nhits_originNu_total > 0 ) fData->best_nuslice_hitcomp = nhits_originNu/float(nhits_originNu_total);
3133 fData->mcevts_truthcry = mclistcry.size();
3134 fData->cry_no_primaries = nCryPrimaries;
3136 for(Int_t iPartc = 0; iPartc < mctruthcry->NParticles(); ++iPartc){
3137 const simb::MCParticle& partc(mctruthcry->GetParticle(iPartc));
3138 fData->cry_primaries_pdg[iPartc]=partc.PdgCode();
3139 fData->cry_Eng[iPartc]=partc.E();
3140 fData->cry_Px[iPartc]=partc.Px();
3141 fData->cry_Py[iPartc]=partc.Py();
3142 fData->cry_Pz[iPartc]=partc.Pz();
3143 fData->cry_P[iPartc]=partc.P();
3144 fData->cry_StartPointx[iPartc] = partc.Vx();
3145 fData->cry_StartPointy[iPartc] = partc.Vy();
3146 fData->cry_StartPointz[iPartc] = partc.Vz();
3147 fData->cry_status_code[iPartc]=partc.StatusCode();
3148 fData->cry_mass[iPartc]=partc.Mass();
3149 fData->cry_trackID[iPartc]=partc.TrackId();
3150 fData->cry_ND[iPartc]=partc.NumberDaughters();
3151 fData->cry_mother[iPartc]=partc.Mother();
3155 fData->mcevts_truth = mclist.size();
3159 art::FindOneP<simb::MCFlux> fmFluxNeutrino(mctruthListHandle, evt, fGenieGenModuleLabel);
3161 art::FindManyP< simb::GTruth > fmgt( mctruthListHandle, evt, fGenieGenModuleLabel );
3163 if (fData->mcevts_truth > 0){
3165 if (fSaveGenieInfo){
3171 fData->mcevts_truth = 0;
3172 for (
unsigned int i_mctruth = 0; i_mctruth < mclist.size(); i_mctruth++){
3174 art::Ptr<simb::MCTruth> curr_mctruth = mclist[i_mctruth];
3176 if (!curr_mctruth->NeutrinoSet())
continue;
3179 std::vector< art::Ptr<simb::GTruth> > mcgtAssn = fmgt.at(i_mctruth);
3181 fData->nuScatterCode_truth[i_mctruth] = mcgtAssn[0]->fGscatter;
3183 fData->nuPDG_truth[i_mctruth] = curr_mctruth->GetNeutrino().Nu().PdgCode();
3184 fData->ccnc_truth[i_mctruth] = curr_mctruth->GetNeutrino().CCNC();
3185 fData->mode_truth[i_mctruth] = curr_mctruth->GetNeutrino().Mode();
3186 fData->Q2_truth[i_mctruth] = curr_mctruth->GetNeutrino().QSqr();
3187 fData->W_truth[i_mctruth] = curr_mctruth->GetNeutrino().W();
3188 fData->hitnuc_truth[i_mctruth] = curr_mctruth->GetNeutrino().HitNuc();
3189 fData->enu_truth[i_mctruth] = curr_mctruth->GetNeutrino().Nu().E();
3190 fData->nuvtxx_truth[i_mctruth] = curr_mctruth->GetNeutrino().Nu().Vx();
3191 fData->nuvtxy_truth[i_mctruth] = curr_mctruth->GetNeutrino().Nu().Vy();
3192 fData->nuvtxz_truth[i_mctruth] = curr_mctruth->GetNeutrino().Nu().Vz();
3193 if (curr_mctruth->GetNeutrino().Nu().P()){
3194 fData->nu_dcosx_truth[i_mctruth] = curr_mctruth->GetNeutrino().Nu().Px()/curr_mctruth->GetNeutrino().Nu().P();
3195 fData->nu_dcosy_truth[i_mctruth] = curr_mctruth->GetNeutrino().Nu().Py()/curr_mctruth->GetNeutrino().Nu().P();
3196 fData->nu_dcosz_truth[i_mctruth] = curr_mctruth->GetNeutrino().Nu().Pz()/curr_mctruth->GetNeutrino().Nu().P();
3198 fData->lep_mom_truth[i_mctruth] = curr_mctruth->GetNeutrino().Lepton().P();
3199 if (curr_mctruth->GetNeutrino().Lepton().P()){
3200 fData->lep_dcosx_truth[i_mctruth] = curr_mctruth->GetNeutrino().Lepton().Px()/curr_mctruth->GetNeutrino().Lepton().P();
3201 fData->lep_dcosy_truth[i_mctruth] = curr_mctruth->GetNeutrino().Lepton().Py()/curr_mctruth->GetNeutrino().Lepton().P();
3202 fData->lep_dcosz_truth[i_mctruth] = curr_mctruth->GetNeutrino().Lepton().Pz()/curr_mctruth->GetNeutrino().Lepton().P();
3208 fData->nuID_truth[i_mctruth] = curr_mctruth.key();
3210 if (fmFluxNeutrino.isValid()){
3211 art::Ptr<simb::MCFlux> curr_mcflux = fmFluxNeutrino.at(i_mctruth);
3212 fData->tpx_flux[i_mctruth] = curr_mcflux->ftpx;
3213 fData->tpy_flux[i_mctruth] = curr_mcflux->ftpy;
3214 fData->tpz_flux[i_mctruth] = curr_mcflux->ftpz;
3215 fData->tptype_flux[i_mctruth] = curr_mcflux->ftptype;
3219 fData->mcevts_truth++;
3222 if (mctruth->NeutrinoSet()){
3257 fData->genie_no_primaries = mctruth->NParticles();
3259 size_t StoreParticles = std::min((
size_t) fData->genie_no_primaries, fData->GetMaxGeniePrimaries());
3260 if (fData->genie_no_primaries > (
int) StoreParticles) {
3263 mf::LogError(
"AnalysisTree:limits") <<
"event has "
3264 << fData->genie_no_primaries <<
" MC particles, only "
3265 << StoreParticles <<
" stored in tree";
3267 for(
size_t iPart = 0; iPart < StoreParticles; ++iPart){
3268 const simb::MCParticle& part(mctruth->GetParticle(iPart));
3269 fData->genie_primaries_pdg[iPart]=part.PdgCode();
3270 fData->genie_Eng[iPart]=part.E();
3271 fData->genie_Px[iPart]=part.Px();
3272 fData->genie_Py[iPart]=part.Py();
3273 fData->genie_Pz[iPart]=part.Pz();
3274 fData->genie_P[iPart]=part.P();
3275 fData->genie_status_code[iPart]=part.StatusCode();
3276 fData->genie_mass[iPart]=part.Mass();
3277 fData->genie_trackID[iPart]=part.TrackId();
3278 fData->genie_ND[iPart]=part.NumberDaughters();
3279 fData->genie_mother[iPart]=part.Mother();
3285 if (fSaveGeantInfo){
3286 const sim::ParticleList& plist = pi_serv->ParticleList();
3288 std::string pri(
"primary");
3291 int geant_particle=0;
3292 sim::ParticleList::const_iterator itPart = plist.begin(),
3295 for(
size_t iPart = 0; (iPart < plist.size()) && (itPart != pend); ++iPart){
3296 const simb::MCParticle* pPart = (itPart++)->
second;
3298 throw art::Exception(art::errors::LogicError)
3299 <<
"GEANT particle #" << iPart <<
" returned a null pointer";
3303 bool isPrimary = pPart->Process() == pri;
3304 if (isPrimary) ++primary;
3305 int TrackID = pPart->TrackId();
3308 TVector3 mcstart, mcend;
3309 double plen = length(*pPart, mcstart, mcend);
3310 bool isActive = plen != 0;
3317 float totalE_particle = 0;
3318 float totalne_particle = 0;
3320 std::vector<const sim::IDE* > ides = bt_serv->TrackIdToSimIDEs_Ps(TrackID, view);
3322 for (
auto ide: ides) {
3323 totalE_particle += ide->energy;
3324 totalne_particle += ide->numElectrons;
3330 totalE_particle /= nPlanes;
3331 totalne_particle /= nPlanes;
3335 if (iPart < fData->GetMaxGEANTparticles()) {
3336 if (pPart->E()>
fG4minE||isPrimary){
3337 fData->process_primary[iPart] = int(isPrimary);
3338 fData->processname[iPart]= pPart->Process();
3339 fData->Mother[iPart]=pPart->Mother();
3340 fData->TrackId[iPart]=
TrackID;
3341 fData->pdg[iPart]=pPart->PdgCode();
3342 fData->status[iPart] = pPart->StatusCode();
3343 fData->Eng[iPart]=pPart->E();
3344 fData->EndE[iPart]=pPart->EndE();
3345 fData->Mass[iPart]=pPart->Mass();
3346 fData->Px[iPart]=pPart->Px();
3347 fData->Py[iPart]=pPart->Py();
3348 fData->Pz[iPart]=pPart->Pz();
3349 fData->P[iPart]=pPart->Momentum().Vect().Mag();
3350 fData->StartPointx[iPart]=pPart->Vx();
3351 fData->StartPointy[iPart]=pPart->Vy();
3352 fData->StartPointz[iPart]=pPart->Vz();
3353 fData->StartT[iPart] = pPart->T();
3354 fData->EndPointx[iPart]=pPart->EndPosition()[0];
3355 fData->EndPointy[iPart]=pPart->EndPosition()[1];
3356 fData->EndPointz[iPart]=pPart->EndPosition()[2];
3357 fData->EndT[iPart] = pPart->EndT();
3358 fData->theta[iPart] = pPart->Momentum().Theta();
3359 fData->phi[iPart] = pPart->Momentum().Phi();
3360 fData->theta_xz[iPart] = std::atan2(pPart->Px(), pPart->Pz());
3361 fData->theta_yz[iPart] = std::atan2(pPart->Py(), pPart->Pz());
3362 fData->pathlen[iPart] = plen;
3363 fData->NumberDaughters[iPart]=pPart->NumberDaughters();
3364 fData->inTPCActive[iPart] = int(isActive);
3365 fData->DepEnergy[iPart] = totalE_particle;
3366 fData->NumElectrons[iPart] = totalne_particle;
3368 fData->StartPointx_tpcAV[iPart] = mcstart.X();
3369 fData->StartPointy_tpcAV[iPart] = mcstart.Y();
3370 fData->StartPointz_tpcAV[iPart] = mcstart.Z();
3371 fData->EndPointx_tpcAV[iPart] = mcend.X();
3372 fData->EndPointy_tpcAV[iPart] = mcend.Y();
3373 fData->EndPointz_tpcAV[iPart] = mcend.Z();
3379 const art::Ptr<simb::MCTruth> matched_mctruth = pi_serv->ParticleToMCTruth_P(pPart);
3380 fData->MotherNuId[iPart] = matched_mctruth.key();
3383 if (fSaveAuxDetInfo) {
3384 unsigned short nAD = 0;
3391 const std::vector<sim::AuxDetIDE>& setOfIDEs = c->AuxDetIDEs();
3396 std::vector<sim::AuxDetIDE>::const_iterator iIDE
3397 = std::find_if( setOfIDEs.begin(), setOfIDEs.end(),
3400 if (iIDE == setOfIDEs.end())
continue;
3408 for(
const auto& adtracks: setOfIDEs) {
3409 if( fabs(adtracks.trackID) ==
TrackID )
3410 totalE += adtracks.energyDeposited;
3415 fData->AuxDetID[iPart][nAD] = c->AuxDetID();
3416 fData->entryX[iPart][nAD] = iIDE->entryX;
3417 fData->entryY[iPart][nAD] = iIDE->entryY;
3418 fData->entryZ[iPart][nAD] = iIDE->entryZ;
3419 fData->entryT[iPart][nAD] = iIDE->entryT;
3420 fData->exitX[iPart][nAD] = iIDE->exitX;
3421 fData->exitY[iPart][nAD] = iIDE->exitY;
3422 fData->exitZ[iPart][nAD] = iIDE->exitZ;
3423 fData->exitT[iPart][nAD] = iIDE->exitT;
3424 fData->exitPx[iPart][nAD] = iIDE->exitMomentumX;
3425 fData->exitPy[iPart][nAD] = iIDE->exitMomentumY;
3426 fData->exitPz[iPart][nAD] = iIDE->exitMomentumZ;
3427 fData->CombinedEnergyDep[iPart][nAD] = totalE;
3432 fData->NAuxDets[iPart] = nAD;
3435 mf::LogError(
"AnalysisTree:limits") <<
"particle #" << iPart
3436 <<
" touches " << nAD <<
" auxiliary detector cells, only "
3437 <<
kMaxAuxDets <<
" of them are saved in the tree";
3443 }
else if (iPart == fData->GetMaxGEANTparticles()) {
3446 mf::LogError(
"AnalysisTree:limits") <<
"event has "
3447 << plist.size() <<
" MC particles, only "
3448 << fData->GetMaxGEANTparticles() <<
" will be stored in tree";
3456 float totalEdep = 0;
3458 for(
auto const &chan : fSimChannels ) {
3459 for(
auto const &tdcide : chan->TDCIDEMap() ) {
3460 for(
const auto& ide : tdcide.second) {
3461 totalEdep += ide.energy;
3462 totalne += ide.numElectrons;
3466 fData->total_DepEnergy = totalEdep/
kNplanes;
3467 fData->total_NumElectrons = totalne/
kNplanes;
3469 fData->geant_list_size_in_tpcAV = active;
3470 fData->no_primaries = primary;
3471 fData->geant_list_size = geant_particle;
3473 MF_LOG_DEBUG(
"AnalysisTree") <<
"Counted "
3474 << fData->geant_list_size <<
" GEANT particles ("
3475 << fData->geant_list_size_in_tpcAV <<
" in AV), "
3476 << fData->no_primaries <<
" primaries, "
3477 << fData->genie_no_primaries <<
" GENIE particles";
3479 FillWith(fData->MergedId, 0);
3482 std::map<int, size_t> TrackIDtoIndex;
3483 const size_t nTrackIDs = fData->TrackId.size();
3484 for (
size_t index = 0; index < nTrackIDs; ++index)
3485 TrackIDtoIndex.emplace(fData->TrackId[index], index);
3490 int currentMergedId = 1;
3491 for(
size_t iPart = fData->geant_list_size; iPart-- > 0; ) {
3493 if (fData->MergedId[iPart])
continue;
3495 fData->MergedId[iPart] = currentMergedId;
3498 int currentMotherTrackId = fData->Mother[iPart];
3499 while(currentMotherTrackId > 0) {
3501 std::map<int, size_t>::const_iterator iMother
3502 = TrackIDtoIndex.find(currentMotherTrackId);
3503 if (iMother == TrackIDtoIndex.end())
break;
3504 size_t currentMotherIndex = iMother->second;
3507 if (fData->pdg[iPart] != fData->pdg[currentMotherIndex])
break;
3510 fData->MergedId[currentMotherIndex] = currentMergedId;
3512 currentMotherTrackId = fData->Mother[currentMotherIndex];
3521 fData->taulife = detprop.ElectronLifetime();
3524 if (mf::isDebugEnabled()) {
3527 mf::LogDebug logStream(
"AnalysisTreeStructure");
3529 <<
"Tree data structure contains:"
3530 <<
"\n - " << fData->no_hits <<
" hits (" << fData->GetMaxHits() <<
")"
3531 <<
"\n - " << fData->genie_no_primaries <<
" genie primaries (" << fData->GetMaxGeniePrimaries() <<
")"
3532 <<
"\n - " << fData->geant_list_size <<
" GEANT particles (" << fData->GetMaxGEANTparticles() <<
"), "
3533 << fData->no_primaries <<
" primaries"
3534 <<
"\n - " << fData->geant_list_size_in_tpcAV <<
" GEANT particles in AV "
3535 <<
"\n - " << ((int) fData->kNTracker) <<
" trackers:"
3538 size_t iTracker = 0;
3539 for (
auto tracker = fData->TrackData.cbegin();
3540 tracker != fData->TrackData.cend(); ++tracker, ++iTracker
3543 <<
"\n -> " << tracker->ntracks <<
" " << fTrackModuleLabel[iTracker]
3544 <<
" tracks (" << tracker->GetMaxTracks() <<
")"
3546 for (
int iTrk = 0; iTrk < tracker->ntracks; ++iTrk) {
3547 logStream <<
"\n [" << iTrk <<
"] "<< tracker->ntrkhits[iTrk][0];
3548 for (
size_t ipl = 1; ipl < tracker->GetMaxPlanesPerTrack(iTrk); ++ipl)
3549 logStream <<
" + " << tracker->ntrkhits[iTrk][ipl];
3550 logStream <<
" hits (" << tracker->GetMaxHitsPerTrack(iTrk, 0);
3551 for (
size_t ipl = 1; ipl < tracker->GetMaxPlanesPerTrack(iTrk); ++ipl)
3552 logStream <<
" + " << tracker->GetMaxHitsPerTrack(iTrk, ipl);
3561 MF_LOG_DEBUG(
"AnalysisTreeStructure") <<
"Freeing the tree data structure";
3572 std::vector< art::Ptr<recob::Hit> >
const& hits, Int_t& trackid, Float_t& purity,
double& maxe){
3577 std::map<int,double> trkide;
3579 for(
size_t h = 0;
h < hits.size(); ++
h){
3581 art::Ptr<recob::Hit>
hit = hits[
h];
3582 std::vector<sim::TrackIDE> eveIDs = bt_serv->HitToEveTrackIDEs(clockData, hit);
3584 for(
size_t e = 0;
e < eveIDs.size(); ++
e){
3585 trkide[eveIDs[
e].trackID] += eveIDs[
e].energy;
3591 for (std::map<int,double>::iterator ii = trkide.begin(); ii!=trkide.end(); ++ii){
3593 if ((ii->second)>maxe){
3595 trackid = ii->first;
3607 bool isMatch =
false;
3608 for(
size_t sc = 0; sc < chans.size(); ++sc){
3609 if( chans[sc]->Channel() == hit->Channel() ) { isMatch =
true;
break; }
3618 Int_t& truthid, Float_t& truthidEnergyFrac, Float_t& energy, Float_t& numElectrons){
3622 std::vector<sim::TrackIDE> trackIDEs = bt_serv->HitToTrackIDEs(clockData, hit);
3623 if( !trackIDEs.size() )
return;
3627 Float_t bestfrac = 0;
3630 for(
size_t i = 0; i < trackIDEs.size(); ++i){
3631 ne += trackIDEs[i].numElectrons;
3632 if( trackIDEs[i].energy > maxe ) {
3633 maxe = trackIDEs[i].energy;
3634 bestfrac = trackIDEs[i].energyFrac;
3635 bestid = trackIDEs[i].trackID;
3640 truthidEnergyFrac = bestfrac;
3649 mcid = std::numeric_limits<int>::lowest();
3653 HitTruth(clockData,hit,mcid,dummy1,dummy2,dummy3);
3654 if( mcid > std::numeric_limits<int>::lowest() )
return true;
3664 bool matchFound =
false;
3666 mctruth = pi_serv->TrackIdToMCTruth_P(trkID);
3669 std::cout<<
"Exception thrown matching TrackID "<<trkID<<
" to MCTruth\n";
3680 art::ServiceHandle<geo::Geometry> geom;
3682 double d1 = pos.X();
3683 double d2 = 2.*geom->DetHalfWidth() - pos.X();
3684 double d3 = pos.Y() + geom->DetHalfHeight();
3685 double d4 = geom->DetHalfHeight() - pos.Y();
3686 double d5 = pos.Z();
3687 double d6 = geom->DetLength() - pos.Z();
3689 double result = std::min(std::min(std::min(std::min(std::min(d1, d2), d3), d4), d5), d6);
3705 art::ServiceHandle<geo::Geometry> geom;
3708 double xmin = -2.0 * geom->DetHalfWidth() - 1
e-8;
3709 double xmax = 2.0 * geom->DetHalfWidth() + 1
e-8;
3710 double ymin = -geom->DetHalfHeight() -1
e-8;
3711 double ymax = geom->DetHalfHeight() + 1
e-8;
3712 double zmin = 0. -1
e-8;
3713 double zmax = geom->DetLength() + 1
e-8;
3716 int n = part.NumberTrajectoryPoints();
3717 if( n <= 1 )
return 0.;
3723 for(
int i = 1; i <
n; ++i) {
3725 TVector3
p1(part.Vx(i),part.Vy(i),part.Vz(i));
3727 if(
p1.X() >= xmin &&
p1.X() <= xmax
3728 &&
p1.Y() >= ymin &&
p1.Y() <= ymax
3729 &&
p1.Z() >= zmin &&
p1.Z() <= zmax ) {
3731 TVector3 p0(part.Vx(i-1),part.Vy(i-1),part.Vz(i-1));
3733 if(first) start =
p1;
3734 else L += (
p1-p0).Mag();
3746 DEFINE_ART_MODULE(AnalysisTree)
bool fSaveGenieInfo
whether to extract and save CRY particle data
TrackData_t< Float_t > trkenddcosz
Float_t best_nuslice_lephitpurity
std::vector< Float_t > StartPointx_tpcAV
std::vector< Int_t > cry_mother
std::vector< Float_t > Eng
TrackData_t< Float_t > trkmommsllhd
TrackDataStruct(size_t maxTracks)
Creates a tracker data structure allowing up to maxTracks tracks.
Little helper functor class to create or reset branches in a tree.
VtxCoordData_t< Float_t > vtx
std::vector< Float_t > nu_dcosx_truth
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
std::vector< BoxedArray< T[kNplanes][kMaxTrackHits]>> HitData_t
std::vector< Float_t > nuvtxy_truth
TrackData_t< Float_t > trkstarty
Short_t hit_trkid[kMaxHits]
ShowerData_t< Int_t > shwpfpid
bool hasVertexInfo() const
Returns whether we have Vertex data.
std::string fPOTModuleLabel
Int_t mcevts_truth
! The number of MCNeutrinos there is currently room for
Float_t hit_frac[kMaxHits]
double VertexMomentum() const
std::vector< Int_t > process_primary
void CreateData(bool bClearData=false)
Creates the structure for the tree data; optionally initializes it.
static void BuildPFParticleMap(const PFParticleVector &particleVector, PFParticleMap &particleMap)
Build particle maps for reconstructed particles.
PlaneData_t< Int_t > trkpidpdg
information from the subrun
BEGIN_PROLOG true icarus_rawdigitfilter FilterTools FilterPlane1 Plane
std::vector< Float_t > EndPointx_tpcAV
std::vector< Float_t > Py
void CheckTree(std::string caller) const
Helper function: throws if no tree is available.
Float_t total_NumElectrons
ShowerData_t< Int_t > shwId
PlaneData_t< Float_t > trkpidchimu
int TrueParticleIDFromTotalTrueEnergy(detinfo::DetectorClocksData const &clockData, const std::vector< art::Ptr< recob::Hit > > &hits, bool rollup_unsaved_ids=1)
TrackData_t< Short_t > trkcosmictype_flashmatch
void SetShowerAddresses()
Sets the addresses of all the tree branches, creating the missing ones.
double GetMomentumMultiScatterChi2(art::Ptr< recob::Track > const &trk, const bool checkValidPoints=false)
Implementation of the Projection Matching Algorithm.
TrackData_t< Float_t > trkmom
void SetVerticesAddresses(size_t iTracker)
Int_t no_primaries
! how many particles there is currently room for
void Resize(size_t nVertices)
std::vector< Float_t > cry_StartPointz
std::vector< std::string > fCalorimetryModuleLabel
size_t GetMaxGEANTparticles() const
Returns the number of GEANT particles for which memory is allocated.
std::vector< Int_t > nuPDG_truth
BEGIN_PROLOG could also be cerr
bool isCosmics
if it contains cosmics
PlaneData_t< Short_t > ntrkhits
bool hasGeantInfo() const
Returns whether we have Geant data.
void SetShowerAddresses(TTree *pTree, std::string showerLabel, bool saveHierarchyInfo)
std::vector< Int_t > NumberDaughters
TrackData_t< Int_t > trkparentpfpid
void CheckData(std::string caller) const
Helper function: throws if no data structure is available.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
double bdist(const recob::Track::Point_t &pos)
Int_t geant_list_size_in_tpcAV
static constexpr size_t size()
begin/end interface
const TrackDataStruct & GetTrackerData(size_t iTracker) const
void Resize(size_t nShowers)
void SetTrackers(size_t nTrackers)
Allocates data structures for the given number of trackers (no Clear())
std::string fG4ModuleLabel
std::vector< bool > fSaveHierarchyInfo
whether to extract and save Slice information
void analyze(const art::Event &evt)
read access to event
Declaration of signal hit object.
std::vector< Int_t > genie_mother
void ResizeMCNeutrino(int nNeutrinos)
Resize the data structure for MCNeutrino particles.
std::vector< Float_t > theta
std::vector< Int_t > genie_ND
constexpr unsigned short kMaxVertices
size_t GetMaxHitsPerTrack(int=0, int=0) const
BranchCreator(TTree *tree)
BEGIN_PROLOG or score(default)}sbnd_crttrackmatchingalg_crID
std::vector< Float_t > cry_P
bool fSaveCaloCosmics
save calorimetry information for cosmics
TrackData_t< Float_t > trkphi
ShowerData_t< Float_t > shwlength
bool fSaveTrackInfo
whether to extract and save Hit information
Float_t hit_endT[kMaxHits]
TrackData_t< Float_t > trkstartz
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
bool fSaveShowerInfo
whether to extract and save Track information
Vector_t VertexDirection() const
bool fSaveVertexInfo
whether to extract and save Shower information
double length(const recob::Track &track)
TrackData_t< Float_t > trkstartdcosy
constexpr int kMaxTrackers
std::vector< Float_t > StartPointx
AuxDetMCData_t< Float_t > entryT
Entry T position of particle into AuxDet.
Definition of basic raw digits.
AuxDetMCData_t< Float_t > exitT
Exit T position of particle out of AuxDet.
ShowerData_t< Float_t > shwopenangle
AuxDetMCData_t< Float_t > exitPx
Exit x momentum of particle out of AuxDet.
std::vector< Int_t > cry_status_code
std::map< std::string, float > PropertiesMap
std::vector< Int_t > mode_truth
Short_t hit_channel[kMaxHits]
PlaneData_t< Float_t > trkke
process_name use argoneut_mc_hitfinder track
Creates a simple ROOT tree with tracking and calorimetry information.
Float_t best_nuslice_hitpurity
Short_t hit_wire[kMaxHits]
size_t GetMaxTrackers() const
Returns the number of trackers for which memory is allocated.
TrackData_t< Float_t > trkcosmicscore_tagger
TrackData_t< Int_t > trkpfpid
std::vector< Float_t > StartPointy
float fValue
Result of Particle ID algorithm/test.
TrackData_t< Float_t > trkenddcosx
void SetMaxShowers(size_t maxShowers)
std::vector< Float_t > Px
HitData_t< Float_t > trkdedx
std::vector< T > ShowerData_t
void SetShowerAddresses(TTree *pTree, std::string showerLabel, bool saveHierarchyInfo)
Connect this object with a tree.
void SetMaxTracks(size_t maxTracks)
std::vector< std::string > fFlashMatchAssocLabel
bool TrackIdToMCTruth(Int_t const trkID, art::Ptr< simb::MCTruth > &mctruth)
TrackData_t< Int_t > trkisprimary
If SaveHierarchyInfo is true, there are additional variables:
std::vector< Float_t > enu_truth
std::vector< Float_t > nuvtxz_truth
TrackData_t< Short_t > trkncosmictags_tagger
size_t MaxVertices
maximum number of storable vertices
Float_t hit_startT[kMaxHits]
bool hasSliceInfo() const
Returns whether we have Slice data.
PlaneData_t< Float_t > trkefftruth
std::vector< Float_t > EndPointy_tpcAV
std::vector< Float_t > StartPointy_tpcAV
std::vector< Float_t > genie_Eng
std::vector< Float_t > phi
Int_t pfp_sliceid[kMaxPFPs]
ShowerData_t< Int_t > shwndaughters
void SetAddresses(TTree *pTree, const std::vector< std::string > &trackers, std::string showerLabel, const std::vector< std::string > &vertexLabels, bool isCosmics, const std::vector< bool > &saveHierarchyInfo, bool saveShowerHierarchyInfo)
Connect this object with a tree.
std::string fCalDataModuleLabel
AnalysisTreeDataStruct(size_t nTrackers=0)
Constructor; clears all fields.
bool hasGenieInfo() const
Returns whether we have Genie data.
size_t MaxShowers
maximum number of storable showers
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
TrackData_t< Float_t > trkmomrange
Float_t hit_peakT[kMaxHits]
SubRunData_t SubRunData
subrun data collected at begin of subrun
std::bitset< 8 > fPlaneMask
Bitset for PlaneID used by algorithm, allowing for multiple planes and up to 8 total planes...
total_extent<T>value has the total number of elements of an array
bool fSaveShowerHierarchyInfo
if the user wants to access the showers with their hierarchy
ShowerData_t< Int_t > shwisprimary
If SaveHierarchyInfo is true, there are additional variables:
std::vector< Int_t > genie_status_code
std::vector< Float_t > cry_Px
AnalysisTreeDataStruct::SubRunData_t SubRunData
ShowerData_t< Float_t > shwdirz
std::vector< Float_t > tpx_flux
Float_t hit_reconelec[kMaxHits]
TrackData_t< Float_t > trkstartdcosx
size_t GetMaxPlanesPerShower(int=0) const
std::vector< std::string > fVertexModuleLabel
bool hasHitInfo() const
Returns whether we have Hit data.
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
static constexpr value_type value
size_t GetMaxTracks() const
AuxDetMCData_t< Float_t > exitPz
Exit z momentum of particle out of AuxDet.
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
std::string fAlgName
< determined particle ID
std::vector< Int_t > tptype_flux
bool DoesHitHaveSimChannel(std::vector< const sim::SimChannel * > chans, art::Ptr< recob::Hit > const &hit)
std::vector< Float_t > tpz_flux
std::string fLArG4ModuleLabel
Collection of particles crossing one auxiliary detector cell.
TrackData_t< Float_t > trkstartdcosz
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
PlaneData_t< Float_t > trksimIDExtruth
PlaneData_t< Float_t > trkpurtruth
std::vector< Int_t > genie_trackID
size_t MaxTracks
maximum number of storable tracks
std::vector< Int_t > status
PlaneData_t< Float_t > trkrange
void SetBits(unsigned int setbits, bool unset=false)
Sets the specified bits.
auto operator+(ptrdiff_t index) -> decltype(&*array)
PlaneData_t< Float_t > trkpidchipi
kVariableType fVariableType
Variable type enum: defined in ParticleID_VariableTypeEnums.h. Set to kNotSet by default.
Short_t hit_plane[kMaxHits]
std::vector< Float_t > genie_Pz
bool fSaveSliceInfo
whether to extract and save Vertex information
object containing MC truth information necessary for making RawDigits and doing back tracking ...
bool HitTruthId(detinfo::DetectorClocksData const &clockData, art::Ptr< recob::Hit > const &hit, Int_t &mcid)
A wrapper to a C array (needed to embed an array into a vector)
TTree * pTree
the tree to be worked on
double Length(size_t p=0) const
Access to various track properties.
std::vector< Float_t > tpy_flux
std::vector< Float_t > cry_Eng
std::vector< BoxedArray< T[3]> > VtxCoordData_t
HitCoordData_t< Float_t > trkxyz
void CreateTree(bool bClearData=false)
Create the output tree and the data structures, if needed.
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
std::vector< std::string > fTrackModuleLabel
std::vector< Float_t > W_truth
TrackData_t< Float_t > trkendx
art::ServiceHandle< cheat::ParticleInventoryService > pi_serv
fSaveShowerHierarchyInfo(pset.get< bool >("SaveShowerHierarchyInfo", false))
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
void SetAddresses()
Sets the addresses of all the tree branches, creating the missing ones.
std::vector< Float_t > NumElectrons
HitData_t< Float_t > trkresrg
std::vector< std::string > processname
bool fSaveGeantInfo
whether to extract and save Genie information
void SetAddresses(TTree *pTree, std::string vertexLabel, bool saveHierarchyInfo)
std::vector< Float_t > lep_dcosy_truth
std::string fGenieGenModuleLabel
std::vector< Float_t > genie_P
Point_t const & Vertex() const
ShowerData_t< Float_t > shwstarty
auto end(FixedBins< T, C > const &) noexcept
std::string fHitsModuleLabel
std::vector< Float_t > lep_dcosx_truth
TrackData_t< Float_t > trkendy
AnalysisTree(fhicl::ParameterSet const &pset)
AuxDetMCData_t< Float_t > exitY
Exit Y position of particle out of AuxDet.
AuxDetMCData_t< Float_t > exitX
Exit X position of particle out of AuxDet.
TrackData_t< Short_t > trkpidbestplane
fSaveCaloCosmics(pset.get< bool >("SaveCaloCosmics", false))
std::vector< Float_t > EndPointz
constexpr int kMaxShowers
size_t GetMaxShowers() const
AnalysisTreeDataStruct * fData
ShowerDataStruct & GetShowerData()
void ClearLocalData()
Clear all fields if this object (not the tracker algorithm data)
AuxDetMCData_t< Float_t > entryY
Entry Y position of particle into AuxDet.
std::vector< std::string > fParticleIDModuleLabel
void HitsPurity(detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::Hit > > const &hits, Int_t &trackid, Float_t &purity, double &maxe)
ShowerData_t< Float_t > shwdiry
std::vector< Float_t > genie_mass
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
std::vector< Int_t > hitnuc_truth
std::vector< Float_t > pathlen
std::string fShowerModuleLabel
std::vector< Float_t > StartPointz
bool hasShowerInfo() const
Returns whether we have Shower data.
std::vector< Float_t > lep_dcosz_truth
int TrueParticleIDFromTotalRecoHits(detinfo::DetectorClocksData const &clockData, const std::vector< art::Ptr< recob::Hit > > &hits, bool rollup_unsaved_ids=1)
void beginSubRun(const art::SubRun &sr)
auto operator-(ptrdiff_t index) -> decltype(&*array)
std::vector< Float_t > EndPointx
TrackData_t< Short_t > trkId
HitData_t< Float_t > trkdqdx
PlaneData_t< Float_t > trksimIDEenergytruth
ShowerData_t< Float_t > shwstartx
Declaration of cluster object.
TrackData_t< Short_t > trkevtxid
AuxDetMCData_t< Float_t > entryZ
Entry Z position of particle into AuxDet.
bool fUseBuffer
whether to use a permanent buffer (faster, huge memory)
ShowerDataStruct()
Creates an empty showerer data structure.
Definition of data types for geometry description.
VertexData_t< Int_t > primaryvtx
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
std::vector< Float_t > EndE
void operator()(std::string name, void *address, std::string leaflist)
Create a branch if it does not exist, and set its address.
Provides recob::Track data product.
void ResizeGEANT(int nParticles)
Resize the data strutcure for GEANT particles.
const Data_t * begin() const
TrackData_t< Float_t > trkendz
PlaneData_t< Float_t > trksimIDEytruth
std::vector< Int_t > cry_primaries_pdg
std::vector< Int_t > nuScatterCode_truth
std::vector< Float_t > genie_Px
TrackData_t< Float_t > trkthetaxz
void DestroyData()
Destroy the local buffers (existing branches will point to invalid address!)
std::vector< Float_t > cry_Py
ShowerData_t< Int_t > shwbestplane
Float_t best_nuslice_lephitcomp
art::ServiceHandle< cheat::BackTrackerService > bt_serv
Int_t best_nuslice_origin
std::vector< Float_t > Q2_truth
std::vector< Int_t > genie_primaries_pdg
ShowerData_t< Float_t > shwstartz
size_t GetMaxVertices() const
std::vector< T > VertexData_t
std::vector< Float_t > Pz
ShowerDataStruct(size_t maxShowers)
Creates a shower data structure allowing up to maxShowers showers.
auto begin(FixedBins< T, C > const &) noexcept
Short_t hit_tpc[kMaxHits]
bool hasTrackInfo() const
Returns whether we have Track data.
AuxDetMCData_t< Float_t > exitPy
Exit y momentum of particle out of AuxDet.
PlaneData_t< Float_t > trkpidchipr
void SetVertices(size_t nTrackers)
Allocates data structures for the given number of trackers (no Clear())
PlaneData_t< Int_t > trkidtruth_recoutils_totaltrueenergy
unsigned int bits
complementary information
Float_t hit_nelec[kMaxHits]
std::vector< BoxedArray< T[kNplanes]>> PlaneData_t
std::vector< Float_t > StartPointz_tpcAV
constexpr int kMaxTrackHits
size_t GetMaxHits() const
Returns the number of hits for which memory is allocated.
const Data_t * end() const
BoxedArray(const This_t &from)
std::string fDigitModuleLabel
size_t GetNTrackers() const
Returns the number of trackers configured.
TrackData_t< Float_t > trkthetayz
bool fSaveHitInfo
whether to extract and save Geant information
auto operator*() -> decltype(*array)
TrackData_t< Float_t > trklen
TrackData_t< Float_t > trkstartd
PlaneData_t< Float_t > trkpitchc
std::vector< Float_t > EndT
std::vector< Int_t > inTPCActive
bool hasCryInfo() const
Returns whether we have Cry data.
PlaneData_t< Int_t > trkpdgtruth
Contains all timing reference information for the detector.
std::vector< Int_t > cry_ND
ShowerData_t< Int_t > shwparentpfpid
ShowerData_t< Float_t > shwdirx
std::vector< Float_t > lep_mom_truth
VertexDataStruct & GetVertexData(size_t iTracker)
TrackDataStruct()
Creates an empty tracker data structure.
void SetMaxVertices(size_t maxVertices)
PlaneData_t< Int_t > trkidtruth_recoutils_totalrecohits
Vector_t EndDirection() const
ShowerDataStruct ShowerData
std::vector< Float_t > cry_mass
auto operator[](size_t index) -> decltype(*array)
Array interface.
MC truth information to make RawDigits and do back tracking.
Float_t best_nuslice_score
Float_t best_nuslice_hitcomp
AuxDetMCData_t< Float_t > CombinedEnergyDep
Sum energy of all particles with this trackID (+ID or -ID) in AuxDet.
process_name largeant stream1 can override from command line with o or output physics producers generator N
void ResizeCry(int nPrimaries)
Resize the data strutcure for Cry primaries.
tracking::Point_t Point_t
std::vector< Float_t > nu_dcosz_truth
VertexDataStruct()
Creates an empty tracker data structure.
TrackData_t< Float_t > trkendd
object containing MC truth information necessary for making RawDigits and doing back tracking ...
std::vector< Float_t > DepEnergy
void Resize(size_t nTracks)
std::vector< T > TrackData_t
Float_t hit_width[kMaxHits]
size_t GetMaxPlanesPerTrack(int=0) const
std::vector< Float_t > cry_StartPointy
TrackDataStruct & GetTrackerData(size_t iTracker)
std::vector< VertexDataStruct > VertexData
bool fSaveAuxDetInfo
whether to extract and save auxiliary detector data
std::remove_all_extents< Array_t >::type Data_t
PlaneData_t< Float_t > trksimIDEztruth
TrackData_t< Short_t > trksvtxid
std::vector< Float_t > nuvtxx_truth
std::vector< TrackDataStruct > TrackData
Point_t const & End() const
std::vector< Float_t > EndPointz_tpcAV
stream1 can override from command line with o or output services user sbnd
std::vector< Float_t > cry_StartPointx
Float_t hit_energy[kMaxHits]
std::string fCryGenModuleLabel
std::string fTPCSimChannelModuleLabel
TrackData_t< Float_t > trkcosmicscore_flashmatch
std::vector< Float_t > theta_xz
int TrueParticleIDFromTotalRecoCharge(detinfo::DetectorClocksData const &clockData, const std::vector< art::Ptr< recob::Hit > > &hits, bool rollup_unsaved_ids=1)
TrackData_t< Float_t > trkmommschi2
Planes which measure W (third view for Bo, MicroBooNE, etc).
float fG4minE
Energy threshold to save g4 particle info.
art::ServiceHandle< art::TFileService > tfs
std::vector< Int_t > nuID_truth
calo::CalorimetryAlg fCaloAlg
PlaneData_t< Int_t > trkidtruth_recoutils_totalrecocharge
std::vector< Int_t > MergedId
PlaneData_t< Float_t > trkpidchika
std::vector< Float_t > nu_dcosy_truth
TrackData_t< Short_t > trkncosmictags_flashmatch
size_t GetMaxGeniePrimaries() const
Returns the number of GENIE primaries for which memory is allocated.
Float_t hit_charge[kMaxHits]
std::vector< Float_t > genie_Py
TrackData_t< Float_t > trkstartx
AuxDetMCData_t< Short_t > AuxDetID
Which AuxDet this particle went through.
TrackData_t< Float_t > trkenddcosy
std::vector< UShort_t > NAuxDets
Number of AuxDets crossed by this particle.
TrackData_t< Short_t > trkcosmictype_tagger
double GetMomentumMultiScatterLLHD(art::Ptr< recob::Track > const &trk)
void SetTrackerAddresses(size_t iTracker)
PlaneData_t< Float_t > trkpidchi
std::vector< BoxedArray< T[kNplanes][kMaxTrackHits][3]>> HitCoordData_t
std::vector< BoxedArray< T[kMaxAuxDets]>> AuxDetMCData_t
helper function for LArPandoraInterface producer module
void ResizeGenie(int nPrimaries)
Resize the data strutcure for Genie primaries.
const Array_t & data() const
std::vector< Int_t > MotherNuId
void SetAddresses(TTree *pTree, std::string tracker, bool isCosmics, bool saveHierarchyInfo)
TrackData_t< Int_t > trkndaughters
std::vector< Float_t > cry_Pz
std::vector< Int_t > TrackId
PlaneData_t< Short_t > trkorigin
void Clear()
Clear all fields.
std::vector< Int_t > ccnc_truth
void HitTruth(detinfo::DetectorClocksData const &clockData, art::Ptr< recob::Hit > const &hit, Int_t &truthid, Float_t &frac, Float_t &energy, Float_t &numElectrons)
TrackData_t< Float_t > trktheta
fG4minE(pset.get< float >("G4minE", 0.01))
std::vector< Int_t > cry_trackID
std::vector< Float_t > StartT
physics associatedGroupsWithLeft p1
size_t GetNTrackers() const
Returns the number of trackers for which data structures are allocated.
BEGIN_PROLOG don t mess with this pandoraTrackGausCryoW true
art framework interface to geometry description
BEGIN_PROLOG could also be cout
static bool IsFinalState(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Determine whether a particle has been reconstructed as a final-state particle.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
std::string fPFParticleModuleLabel
PlaneData_t< Int_t > trkidtruth
constexpr Point origin()
Returns a origin position with a point of the specified type.
AuxDetMCData_t< Float_t > entryX
Entry X position of particle into AuxDet.
double GetTrackMomentum(double trkrange, int pdg) const
VertexDataStruct(size_t maxVertices)
Creates a vertex data structure allowing up to maxVertices vertices.
int fAssumedPdg
PDG of particle hypothesis assumed by algorithm, if applicable. Set to 0 by default.
std::vector< Float_t > Mass
std::vector< Float_t > EndPointy
PlaneData_t< Float_t > trkpidpida
std::vector< std::string > fCosmicTaggerAssocLabel
constexpr unsigned short kMaxAuxDets
max number of auxiliary detector cells per MC particle
std::vector< Float_t > theta_yz
bool hasAuxDetector() const
Returns whether we have auxiliary detector data.
std::vector< Int_t > Mother
AuxDetMCData_t< Float_t > exitZ
Exit Z position of particle out of AuxDet.