4231 std::vector<art::Ptr<raw::RawDigit> > rawdigitlist;
4233 if (rawdigitVecHandle)
4237 std::vector<art::Ptr<recob::Wire> > recobwirelist;
4239 if (recobwireVecHandle)
4253 std::vector<art::Ptr<recob::Hit> > hitlist;
4260 std::vector<art::Ptr<recob::Cluster> > clusterlist;
4263 if (clusterListHandle)
4268 std::vector<art::Ptr<recob::OpFlash> > flashlist;
4270 if (flashListHandle)
4274 std::vector<art::Ptr<raw::ExternalTrigger> > countlist;
4276 if (countListHandle)
4281 std::vector<art::Ptr<simb::MCTruth> > mclist;
4284 if (mctruthListHandle)
4289 int nSimEnergyDepositsTPCActive = 0;
4290 int nParticlesWithSimEnergyDepositsTPCActive = 0;
4291 int nLowestParticleIDSimEnergyDepositsTPCActive = 0;
4292 int nHighestParticleIDSimEnergyDepositsTPCActive = 0;
4294 std::vector<art::Ptr<sim::SimEnergyDeposit> > energyDepositTPCActivelist;
4298 if (energyDepositTPCActiveHandle)
4301 nSimEnergyDepositsTPCActive = energyDepositTPCActivelist.size();
4303 std::vector<int> tempparticleID;
4304 tempparticleID.resize(nSimEnergyDepositsTPCActive);
4305 FillWith(tempparticleID, 0);
4307 for(
int sedavit = 0; sedavit < nSimEnergyDepositsTPCActive; sedavit++)
4309 if( std::find(tempparticleID.begin(), tempparticleID.end(), energyDepositTPCActivelist[sedavit]->TrackID()) == tempparticleID.end() )
4311 tempparticleID[nParticlesWithSimEnergyDepositsTPCActive] = energyDepositTPCActivelist[sedavit]->TrackID();
4312 nParticlesWithSimEnergyDepositsTPCActive++;
4314 if(energyDepositTPCActivelist[sedavit]->
TrackID() < nLowestParticleIDSimEnergyDepositsTPCActive) nLowestParticleIDSimEnergyDepositsTPCActive=energyDepositTPCActivelist[sedavit]->TrackID();
4315 if(energyDepositTPCActivelist[sedavit]->
TrackID() > nHighestParticleIDSimEnergyDepositsTPCActive) nHighestParticleIDSimEnergyDepositsTPCActive=energyDepositTPCActivelist[sedavit]->TrackID();
4322 std::vector<art::Ptr<simb::MCTruth> > mclistcry;
4325 if (mctruthcryListHandle){
4331 mf::LogError(
"AnaRootParser") <<
"Requested CRY information but none exists, hence not saving CRY information.";
4336 std::vector<art::Ptr<simb::MCTruth> > mclistproto;
4339 if (mctruthprotoListHandle){
4345 mf::LogError(
"AnaRootParser") <<
"Requested protoDUNE beam generator information but none exists, hence not saving protoDUNE beam generator information.";
4356 nMCShowers = mcshowerh->size();
4365 nMCTracks = mctrackh->size();
4368 int nCryPrimaries = 0;
4371 mctruthcry = mclistcry[0];
4376 int nProtoPrimaries = 0;
4378 mctruthproto = mclistproto[0];
4379 nProtoPrimaries = mctruthproto->
NParticles();
4383 int nGeniePrimaries = 0, nGeneratorParticles = 0, nGEANTparticles = 0, nGEANTparticlesInAV = 0, nGEANTtrajectorysteps=0;
4391 auto const allmclists = evt.
getMany<std::vector<simb::MCTruth>>();
4392 for(
size_t mcl = 0; mcl < allmclists.size(); ++mcl){
4394 for(
size_t m = 0;
m < mclistHandle->size(); ++
m){
4402 if (!mclist.empty()){
4416 mctruth = mclist[0];
4421 const sim::ParticleList& plist = pi_serv->
ParticleList();
4422 nGEANTparticles = plist.size();
4428 for(
size_t iPart = 0; (iPart < plist.size()) && (itPart != pend); ++iPart)
4434 <<
"GEANT particle #" << iPart <<
" returned a null pointer";
4438 if(pPart->
Mother() == 0 && pPart->
Process() == pri) nGeneratorParticles++;
4440 TLorentzVector mcstart, mcend;
4441 unsigned int pstarti, pendi;
4442 double plen =
length(*pPart, mcstart, mcend, pstarti, pendi);
4443 if( plen != 0) nGEANTparticlesInAV += 1;
4450 for (
auto const& pmt : (*photonHandle) )
4452 std::map<int, int> PhotonsMap = pmt.DetectedPhotons;
4454 for(
auto itphoton = PhotonsMap.begin(); itphoton!= PhotonsMap.end(); itphoton++)
4456 for(
int i = 0; i < itphoton->second ; i++)
4465 << nGEANTparticles <<
" GEANT particles, " 4466 << nGeniePrimaries <<
" GENIE particles";
4484 std::cout <<
"nGeneratorParticles: " << nGeneratorParticles <<
std::endl;
4485 std::cout <<
"nGEANTparticles: " << nGEANTparticles <<
std::endl;
4486 std::cout <<
"nGEANTtrajectorysteps: " << nGEANTtrajectorysteps <<
std::endl;
4487 std::cout <<
"nGEANTparticlesInAV: " << nGEANTparticlesInAV <<
std::endl;
4488 std::cout <<
"nSimEnergyDepositsTPCActive: " << nSimEnergyDepositsTPCActive <<
std::endl;
4489 std::cout <<
"nParticlesWithSimEnergyDepositsTPCActive: " << nParticlesWithSimEnergyDepositsTPCActive <<
std::endl;
4490 std::cout <<
"nLowestParticleIDSimEnergyDepositsTPCActive: " << nLowestParticleIDSimEnergyDepositsTPCActive <<
std::endl;
4491 std::cout <<
"nHighestParticleIDSimEnergyDepositsTPCActive: " << nHighestParticleIDSimEnergyDepositsTPCActive <<
std::endl;
4492 std::cout <<
"nPhotons: " << nPhotons <<
std::endl;
4495 fData->ClearLocalData();
4499 const size_t NChannels = rawdigitlist.size();
4500 const size_t NRecoChannels = recobwirelist.size();
4501 const size_t NHits = hitlist.size();
4503 const size_t NClusters = clusterlist.size();
4504 const size_t NFlashes = flashlist.size();
4505 const size_t NExternCounts = countlist.size();
4516 std::vector<art::Ptr<raw::Trigger> > triggerlist;
4520 if (triggerlist.size()){
4521 fData->triggernumber = triggerlist[0]->TriggerNumber();
4522 fData->triggertime = triggerlist[0]->TriggerTime();
4523 fData->beamgatetime = triggerlist[0]->BeamGateTime();
4524 fData->triggerbits = triggerlist[0]->TriggerBits();
4528 std::vector< art::Handle< std::vector<recob::Vertex> > > vertexListHandle(NVertexAlgos);
4529 std::vector< std::vector<art::Ptr<recob::Vertex> > > vertexlist(NVertexAlgos);
4530 for (
unsigned int it = 0; it < NVertexAlgos; ++it){
4532 if (vertexListHandle[it])
4542 std::vector< art::Handle< std::vector<recob::Track> > > trackListHandle(NTrackers);
4543 std::vector< std::vector<art::Ptr<recob::Track> > > tracklist(NTrackers);
4544 for (
unsigned int it = 0; it < NTrackers; ++it){
4546 if (trackListHandle[it])
4555 std::vector<std::vector<recob::Shower>
const*> showerList;
4556 std::vector< art::Handle< std::vector<recob::Shower> > > showerListHandle;
4560 auto ShowerHandle = evt.
getHandle<std::vector<recob::Shower>>(ShowerInputTag);
4561 if (!ShowerHandle) {
4562 showerList.push_back(
nullptr);
4565 <<
"Showers with input tag '" << ShowerInputTag.encode()
4566 <<
"' were not found in the event." 4567 " If you really know what you are doing," 4568 " set AnaRootParser's configuration parameter IgnoreMissingShowers" 4569 " to \"true\"; the lack of any shower set will be tolerated," 4570 " and the shower list in the corresponding event will be set to" 4571 " a list of one shower, with an invalid ID.\n";
4576 <<
"No showers found for input tag '" << ShowerInputTag.encode()
4577 <<
"' ; FILLING WITH FAKE DATA AS FOR USER'S REQUEST";
4581 else showerList.push_back(ShowerHandle.product());
4583 showerListHandle.push_back(ShowerHandle);
4595 std::vector<const sim::AuxDetSimChannel*> fAuxDetSimChannels;
4600 std::vector<const sim::SimChannel*> fSimChannels;
4614 fData->beamtime = (double)
beam->get_t_ms();
4615 fData->beamtime/=1000.;
4616 std::map<std::string, std::vector<double>> datamap =
beam->GetDataMap();
4617 if (datamap[
"E:TOR860"].
size()){
4618 fData->potbnb = datamap[
"E:TOR860"][0];
4620 if (datamap[
"E:TORTGT"].
size()){
4621 fData->potnumitgt = datamap[
"E:TORTGT"][0];
4623 if (datamap[
"E:TOR101"].
size()){
4624 fData->potnumi101 = datamap[
"E:TOR101"][0];
4637 fData->no_channels = (
int) NChannels;
4640 fData->no_ticks = (
int) rawdigitlist[0]->Samples();
4645 fData->no_ticks = 0;
4646 fData->no_ticksinallchannels = 0;
4649 for (
int i = 0; i <
fData->no_channels ; i++)
4651 fData->rawD_Channel[i] = (
int) rawdigitlist[i]->Channel();
4656 fData->rawD_ADC[j] = rawdigitlist[i]->ADC(k);
4664 fData->no_recochannels = (
int) NRecoChannels;
4667 for(
int i = 0; i <
fData->no_recochannels; i++)
4669 fData->recoW_NTicks[i]=0;
4670 fData->recoW_Channel[i] = recobwirelist[i]->Channel();
4673 for(
const auto& range : signalROI.
get_ranges())
4675 const std::vector<float>& signal = range.data();
4676 int NTicksInThisROI = range.end_index() - range.begin_index();
4678 for(
int j = 0; j < NTicksInThisROI; j++)
4680 fData->recoW_Tick[RecoWTick] = j+range.begin_index();
4681 fData->recoW_ADC[RecoWTick] = signal.at(j);
4684 fData->recoW_NTicks[i] += NTicksInThisROI;
4687 fData->no_recoticksinallchannels = RecoWTick;
4695 float purity = -9999;
4698 fData->NHitsInAllTracks = (
int) NHits;
4699 fData->no_hits_stored = TMath::Min( (
int) NHits, (
int)
kMaxHits);
4703 mf::LogError(
"AnaRootParser:limits") <<
"event has " << NHits
4704 <<
" hits, only kMaxHits=" <<
kMaxHits <<
" stored in tree";
4711 const auto & fitParams = hitResults->vectors();
4713 for (
size_t i = 0; i < NHits && i <
kMaxHits ; ++i){
4714 fData->hit_channel[i] = hitlist[i]->Channel();
4715 fData->hit_tpc[i] = hitlist[i]->WireID().TPC;
4716 fData->hit_view[i] = hitlist[i]->WireID().Plane;
4717 fData->hit_wire[i] = hitlist[i]->WireID().Wire;
4718 fData->hit_peakT[i] = hitlist[i]->PeakTime();
4719 fData->hit_chargesum[i] = hitlist[i]->SummedADC();
4720 fData->hit_chargeintegral[i] = hitlist[i]->Integral();
4721 fData->hit_ph[i] = hitlist[i]->PeakAmplitude();
4722 fData->hit_startT[i] = hitlist[i]->StartTick();
4723 fData->hit_endT[i] = hitlist[i]->EndTick();
4724 fData->hit_rms[i] = hitlist[i]->RMS();
4725 fData->hit_goodnessOfFit[i] = hitlist[i]->GoodnessOfFit();
4727 fData->hit_fitparamt0[i] = fitParams[i][0];
4728 fData->hit_fitparamtau1[i] = fitParams[i][1];
4729 fData->hit_fitparamtau2[i] = fitParams[i][2];
4730 fData->hit_fitparamampl[i] = fitParams[i][3];
4732 fData->hit_multiplicity[i] = hitlist[i]->Multiplicity();
4737 HitsBackTrack(clockData, hitlist[i], trueID, maxe, purity );
4739 fData->hit_trueID[i] = trueID;
4740 fData->hit_trueEnergyMax[i] = maxe;
4741 fData->hit_trueEnergyFraction[i] = purity;
4863 for (
size_t i = 0; i < NHits && i <
kMaxHits ; ++i){
4864 if (fmtk.isValid()){
4865 if (fmtk.at(i).size()!=0){
4866 fData->hit_trkid[i] = fmtk.at(i)[0]->ID();
4871 fData->hit_trkid[i] = -1;
4883 for (
size_t i = 0; i < NHits && i <
kMaxHits ; ++i){
4884 if (fmcl.isValid()){
4885 if (fmcl.at(i).size()!=0){
4886 fData->hit_clusterid[i] = fmcl.at(i)[0]->ID();
4890 fData->hit_clusterid[i] = -1;
4904 for (
unsigned int n = 0;
n < particleVector.size(); ++
n) {
4912 mf::LogError(
"AnaRootParser:limits") <<
"event has " << nprim
4913 <<
" nu neutrino vertices, only kMaxVertices=" <<
kMaxVertices <<
" stored in tree";
4916 fData->nnuvtx = nprim;
4919 for (
unsigned int n = 0;
n < particleVector.size(); ++
n) {
4923 if (particlesToVertices.end() != vIter) {
4925 if (!vertexVector.empty()) {
4926 if (vertexVector.size() == 1) {
4928 double xyz[3] = {0.0, 0.0, 0.0} ;
4930 fData->nuvtxx[iv] = xyz[0];
4931 fData->nuvtxy[iv] = xyz[1];
4932 fData->nuvtxz[iv] = xyz[2];
4943 fData->nclusters = (
int) NClusters;
4947 mf::LogError(
"AnaRootParser:limits") <<
"event has " << NClusters
4948 <<
" clusters, only kMaxClusters=" <<
kMaxClusters <<
" stored in tree";
4950 for(
unsigned int ic=0; ic<NClusters;++ic){
4953 fData->clusterId[ic] = cluster.
ID();
4954 fData->clusterView[ic] = cluster.
View();
4956 if(
fData->clusterView[ic] == 3) {
fData->clusterView[ic] = 0;}
4957 if(
fData->clusterView[ic] == 2) {
fData->clusterView[ic] = 1;}
4976 if(
fData->clusterView[ic] == 1){
fData->cluster_StartWire[ic]+=320;
fData->cluster_EndWire[ic] += 320;}
4993 fData->no_flashes = (
int) NFlashes;
4997 mf::LogError(
"AnaRootParser:limits") <<
"event has " << NFlashes
4998 <<
" flashes, only kMaxFlashes=" <<
kMaxFlashes <<
" stored in tree";
5000 for (
size_t i = 0; i < NFlashes && i <
kMaxFlashes ; ++i){
5001 fData->flash_time[i] = flashlist[i]->Time();
5002 fData->flash_pe[i] = flashlist[i]->TotalPE();
5003 fData->flash_ycenter[i] = flashlist[i]->YCenter();
5004 fData->flash_zcenter[i] = flashlist[i]->ZCenter();
5005 fData->flash_ywidth[i] = flashlist[i]->YWidth();
5006 fData->flash_zwidth[i] = flashlist[i]->ZWidth();
5007 fData->flash_timewidth[i] = flashlist[i]->TimeWidth();
5012 fData->no_ExternCounts = (
int) NExternCounts;
5016 mf::LogError(
"AnaRootParser:limits") <<
"event has " << NExternCounts
5017 <<
" External Counters, only kMaxExternCounts=" <<
kMaxExternCounts <<
" stored in tree";
5020 fData->externcounts_time[i] = countlist[i]->GetTrigTime();
5021 fData->externcounts_id[i] = countlist[i]->GetTrigID();
5027 std::map<Short_t, Short_t> trackIDtoPFParticleIDMap, vertexIDtoPFParticleIDMap, showerIDtoPFParticleIDMap;
5031 AnaRootParserDataStruct::PFParticleDataStruct& PFParticleData =
fData->GetPFParticleData();
5032 size_t NPFParticles = pfparticlelist.size();
5034 PFParticleData.SetMaxPFParticles(
std::max(NPFParticles, (
size_t) 1));
5035 PFParticleData.Clear();
5037 PFParticleData.nPFParticles = (short) NPFParticles;
5043 if (NPFParticles > PFParticleData.GetMaxPFParticles()) {
5044 mf::LogError(
"AnaRootParser:limits") <<
"event has " << NPFParticles
5045 <<
" PFParticles, only " 5046 << PFParticleData.GetMaxPFParticles() <<
" stored in tree";
5051 PFParticleData.pfp_numNeutrinos = neutrinoPFParticles.size();
5054 PFParticleData.pfp_neutrinoIDs[i] = neutrinoPFParticles[i]->Self();
5058 std::cerr <<
"Warning: there were " << neutrinoPFParticles.size() <<
" reconstructed PFParticle neutrinos; only the first " <<
kMaxNPFPNeutrinos <<
" being stored in tree" <<
std::endl;
5075 for (
size_t i = 0; i < NPFParticles && i < PFParticleData.GetMaxPFParticles() ; ++i){
5076 PFParticleData.pfp_selfID[i] = pfparticlelist[i]->Self();
5077 PFParticleData.pfp_isPrimary[i] = (Short_t)pfparticlelist[i]->IsPrimary();
5078 PFParticleData.pfp_numDaughters[i] = pfparticlelist[i]->NumDaughters();
5079 PFParticleData.pfp_parentID[i] = pfparticlelist[i]->Parent();
5080 PFParticleData.pfp_pdgCode[i] = pfparticlelist[i]->PdgCode();
5084 std::vector<size_t> daughterIDs = pfparticlelist[i]->Daughters();
5086 for (
size_t j = 0; j < daughterIDs.size(); ++j)
5087 PFParticleData.pfp_daughterIDs[i][j] = daughterIDs[j];
5090 auto vertexMapIter = pfParticleToVertexMap.find(pfparticlelist[i]);
5091 if (vertexMapIter != pfParticleToVertexMap.end()) {
5094 if (pfParticleVertices.size() > 1)
5095 std::cerr <<
"Warning: there was more than one vertex found for PFParticle with ID " << pfparticlelist[i]->Self() <<
", storing only one" <<
std::endl;
5097 if (pfParticleVertices.size() > 0) {
5098 PFParticleData.pfp_vertexID[i] = pfParticleVertices.at(0)->ID();
5099 vertexIDtoPFParticleIDMap.insert(std::make_pair(pfParticleVertices.at(0)->ID(), pfparticlelist[i]->Self()));
5103 std::cerr <<
"Warning: there was no vertex found for PFParticle with ID " << pfparticlelist[i]->Self() <<
std::endl;
5106 PFParticleData.pfp_isTrack[i] = 1;
5109 auto trackMapIter = pfParticleToTrackMap.find(pfparticlelist[i]);
5110 if (trackMapIter != pfParticleToTrackMap.end()) {
5113 if (pfParticleTracks.size() > 1)
5114 std::cerr <<
"Warning: there was more than one track found for PFParticle with ID " << pfparticlelist[i]->Self() <<
std::endl;
5116 if (pfParticleTracks.size() > 0) {
5117 PFParticleData.pfp_trackID[i] = pfParticleTracks.at(0)->ID();
5118 trackIDtoPFParticleIDMap.insert(std::make_pair(pfParticleTracks.at(0)->ID(), pfparticlelist[i]->Self()));
5122 std::cerr <<
"Warning: there was no track found for track-like PFParticle with ID " << pfparticlelist[i]->Self() <<
std::endl;
5125 PFParticleData.pfp_isTrack[i] = 0;
5128 PFParticleData.pfp_isShower[i] = 1;
5130 auto showerMapIter = pfParticleToShowerMap.find(pfparticlelist[i]);
5131 if (showerMapIter != pfParticleToShowerMap.end()) {
5134 if (pfParticleShowers.size() > 1)
5135 std::cerr <<
"Warning: there was more than one shower found for PFParticle with ID " << pfparticlelist[i]->Self() <<
std::endl;
5137 if (pfParticleShowers.size() > 0) {
5138 PFParticleData.pfp_showerID[i] = pfParticleShowers.at(0)->ID();
5139 showerIDtoPFParticleIDMap.insert(std::make_pair(pfParticleShowers.at(0)->ID(), pfparticlelist[i]->Self()));
5143 std::cerr <<
"Warning: there was no shower found for shower-like PFParticle with ID " << pfparticlelist[i]->Self() <<
std::endl;
5146 PFParticleData.pfp_isShower[i] = 0;
5149 auto clusterMapIter = pfParticleToClusterMap.find(pfparticlelist[i]);
5150 if (clusterMapIter != pfParticleToClusterMap.end()) {
5152 PFParticleData.pfp_numClusters[i] = pfParticleClusters.size();
5154 for (
size_t j = 0; j < pfParticleClusters.size(); ++j)
5155 PFParticleData.pfp_clusterIDs[i][j] = pfParticleClusters[j]->ID();
5165 for (
size_t iShowerAlgo = 0; iShowerAlgo < NShowerAlgos; ++iShowerAlgo) {
5166 AnaRootParserDataStruct::ShowerDataStruct& ShowerData
5167 =
fData->GetShowerData(iShowerAlgo);
5168 std::vector<recob::Shower>
const* pShowers = showerList[iShowerAlgo];
5176 if(fmvapid.isValid()){
5177 for(
unsigned int iShower=0;iShower<showerHandle->size();++iShower){
5179 ShowerData.shwr_pidmvamu[iShower] = pid->
mvaOutput.at(
"muon");
5180 ShowerData.shwr_pidmvae[iShower] = pid->
mvaOutput.at(
"electron");
5181 ShowerData.shwr_pidmvapich[iShower] = pid->
mvaOutput.at(
"pich");
5182 ShowerData.shwr_pidmvaphoton[iShower] = pid->
mvaOutput.at(
"photon");
5183 ShowerData.shwr_pidmvapr[iShower] = pid->
mvaOutput.at(
"proton");
5188 else ShowerData.MarkMissing(
fTree);
5199 for (
unsigned int iTracker=0; iTracker < NTrackers; ++iTracker){
5200 AnaRootParserDataStruct::TrackDataStruct& TrackerData =
fData->GetTrackerData(iTracker);
5202 size_t NTracks = tracklist[iTracker].size();
5205 TrackerData.SetMaxTracks(
std::max(NTracks, (
size_t) 1));
5206 TrackerData.Clear();
5208 TrackerData.ntracks = (
int) NTracks;
5232 if (NTracks > TrackerData.GetMaxTracks()) {
5235 mf::LogError(
"AnaRootParser:limits") <<
"event has " << NTracks
5237 << TrackerData.GetMaxTracks() <<
" stored in tree";
5250 float maxe = -9999.;
5251 float purity = -9999.;
5253 for(
size_t iTrk=0; iTrk < NTracks; ++iTrk){
5256 art::FindManyP<anab::T0> fmt0(trackListHandle[iTracker],evt,
fFlashT0FinderLabel[iTracker]);
5257 if (fmt0.isValid()){
5258 if(fmt0.at(iTrk).size()>0){
5259 if(fmt0.at(iTrk).size()>1)
5260 std::cerr <<
"\n Warning : more than one cosmic tag per track in module! assigning the first tag to the track" <<
fFlashT0FinderLabel[iTracker];
5261 TrackerData.trkflashT0[iTrk] = fmt0.at(iTrk).at(0)->Time();
5266 art::FindManyP<anab::T0> fmmct0(trackListHandle[iTracker],evt,
fMCT0FinderLabel[iTracker]);
5267 if (fmmct0.isValid()){
5268 if(fmmct0.at(iTrk).size()>0){
5269 if(fmmct0.at(iTrk).size()>1)
5270 std::cerr <<
"\n Warning : more than one cosmic tag per track in module! assigning the first tag to the cluster" <<
fMCT0FinderLabel[iTracker];
5271 TrackerData.trktrueT0[iTrk] = fmmct0.at(iTrk).at(0)->Time();
5277 if (fmct.isValid()){
5278 TrackerData.trkncosmictags_tagger[iTrk] = fmct.at(iTrk).size();
5279 if (fmct.at(iTrk).size()>0){
5280 if(fmct.at(iTrk).size()>1)
5281 std::cerr <<
"\n Warning : more than one cosmic tag per track in module! assigning the first tag to the track" <<
fCosmicTaggerAssocLabel[iTracker];
5282 TrackerData.trkcosmicscore_tagger[iTrk] = fmct.at(iTrk).at(0)->CosmicScore();
5283 TrackerData.trkcosmictype_tagger[iTrk] = fmct.at(iTrk).at(0)->CosmicType();
5289 if (fmcnt.isValid()){
5290 TrackerData.trkncosmictags_containmenttagger[iTrk] = fmcnt.at(iTrk).size();
5291 if (fmcnt.at(iTrk).size()>0){
5292 if(fmcnt.at(iTrk).size()>1)
5293 std::cerr <<
"\n Warning : more than one containment tag per track in module! assigning the first tag to the track" <<
fContainmentTaggerAssocLabel[iTracker];
5294 TrackerData.trkcosmicscore_containmenttagger[iTrk] = fmcnt.at(iTrk).at(0)->CosmicScore();
5295 TrackerData.trkcosmictype_containmenttagger[iTrk] = fmcnt.at(iTrk).at(0)->CosmicType();
5301 art::FindManyP<anab::CosmicTag> fmbfm(trackListHandle[iTracker],evt,
fFlashMatchAssocLabel[iTracker]);
5302 if (fmbfm.isValid()){
5303 TrackerData.trkncosmictags_flashmatch[iTrk] = fmbfm.at(iTrk).size();
5304 if (fmbfm.at(iTrk).size()>0){
5305 if(fmbfm.at(iTrk).size()>1)
5306 std::cerr <<
"\n Warning : more than one cosmic tag per track in module! assigning the first tag to the track" <<
fFlashMatchAssocLabel[iTracker];
5307 TrackerData.trkcosmicscore_flashmatch[iTrk] = fmbfm.at(iTrk).at(0)->CosmicScore();
5308 TrackerData.trkcosmictype_flashmatch[iTrk] = fmbfm.at(iTrk).at(0)->CosmicType();
5316 TVector3
pos, dir_start, dir_end,
end;
5317 TVector3 dir_start_flipped, dir_end_flipped;
5318 double tlen = 0., mom = 0.;
5323 pos = track.
Vertex<TVector3>();
5326 end = track.
End<TVector3>();
5328 dir_start_flipped.SetXYZ(dir_start.Z(), dir_start.Y(), dir_start.X());
5329 dir_end_flipped.SetXYZ(dir_end.Z(), dir_end.Y(), dir_end.X());
5335 TrackID = track.
ID();
5337 double theta_xz = std::atan2(dir_start.X(), dir_start.Z());
5338 double theta_yz = std::atan2(dir_start.Y(), dir_start.Z());
5339 double dpos =
bdist(pos);
5340 double dend =
bdist(end);
5342 TrackerData.trkId[iTrk] =
TrackID;
5343 TrackerData.trkstartx[iTrk] = pos.X();
5344 TrackerData.trkstarty[iTrk] = pos.Y();
5345 TrackerData.trkstartz[iTrk] = pos.Z();
5346 TrackerData.trkstartd[iTrk] = dpos;
5347 TrackerData.trkendx[iTrk] = end.X();
5348 TrackerData.trkendy[iTrk] = end.Y();
5349 TrackerData.trkendz[iTrk] = end.Z();
5350 TrackerData.trkendd[iTrk] = dend;
5351 TrackerData.trkstarttheta[iTrk] = (180.0/3.14159)*dir_start_flipped.Theta();
5352 TrackerData.trkstartphi[iTrk] = (180.0/3.14159)*dir_start_flipped.Phi();
5353 TrackerData.trkstartdirectionx[iTrk] = dir_start.X();
5354 TrackerData.trkstartdirectiony[iTrk] = dir_start.Y();
5355 TrackerData.trkstartdirectionz[iTrk] = dir_start.Z();
5360 std::cout <<
"start.X(): " << pos.X() <<
"\t" <<
"start.Y(): " << pos.Y() <<
"\t" <<
"start.Z(): " << pos.Z() <<
std::endl;
5361 std::cout <<
"end.X(): " << end.X() <<
"\t" <<
"end.Y(): " << end.Y() <<
"\t" <<
"end.Z(): " << end.Z() <<
std::endl;
5362 std::cout <<
"dir_start.X(): " << dir_start.X() <<
"\t" <<
"dir_start.Y(): " << dir_start.Y() <<
"\t" <<
"dir_start.Z(): " << dir_start.Z() <<
std::endl;
5363 std::cout <<
"dir_end.X(): " << dir_end.X() <<
"\t" <<
"dir_end.Y(): " << dir_end.Y() <<
"\t" <<
"dir_end.Z(): " << dir_end.Z() <<
std::endl;
5364 std::cout <<
"dir_start_flipped.Theta(): " << (180.0/3.14159)*dir_start_flipped.Theta() <<
"\t" <<
"dir_start_flipped.Phi(): " << (180.0/3.14159)*dir_start_flipped.Phi() <<
std::endl;
5365 std::cout <<
"dir_end_flipped.Theta(): " << (180.0/3.14159)*dir_end_flipped.Theta() <<
"\t" <<
"dir_end_flipped.Phi(): " << (180.0/3.14159)*dir_end_flipped.Phi() <<
std::endl;
5369 TrackerData.trkendtheta[iTrk] = (180.0/3.14159)*dir_end_flipped.Theta();
5370 TrackerData.trkendphi[iTrk] = (180.0/3.14159)*dir_end_flipped.Phi();
5371 TrackerData.trkenddirectionx[iTrk] = dir_end.X();
5372 TrackerData.trkenddirectiony[iTrk] = dir_end.Y();
5373 TrackerData.trkenddirectionz[iTrk] = dir_end.Z();
5375 TrackerData.trkthetaxz[iTrk] = theta_xz;
5376 TrackerData.trkthetayz[iTrk] = theta_yz;
5377 TrackerData.trkmom[iTrk] = mom;
5378 TrackerData.trkchi2PerNDF[iTrk] = track.
Chi2PerNdof();
5379 TrackerData.trkNDF[iTrk] = track.
Ndof();
5380 TrackerData.trklen[iTrk] = tlen;
5381 TrackerData.trklenstraightline[iTrk] = sqrt(
pow(pos.X()-end.X(),2) +
pow(pos.Y()-end.Y(),2) +
pow(pos.Z()-end.Z(),2));
5382 TrackerData.trkmomrange[iTrk] = trkm.GetTrackMomentum(tlen,13);
5383 TrackerData.trkmommschi2[iTrk] = trkm.GetMomentumMultiScatterChi2(ptrack);
5384 TrackerData.trkmommsllhd[iTrk] = trkm.GetMomentumMultiScatterLLHD(ptrack);
5389 TrackerData.trkmommscfwd[iTrk] = res.
fwdMomentum();
5390 TrackerData.trkmommscbwd[iTrk] = res.
bwdMomentum();
5396 auto mapIter = trackIDtoPFParticleIDMap.find(TrackID);
5397 if (mapIter != trackIDtoPFParticleIDMap.end()) {
5399 TrackerData.trkhasPFParticle[iTrk] = 1;
5400 TrackerData.trkPFParticleID[iTrk] = mapIter->second;
5403 TrackerData.trkhasPFParticle[iTrk] = 0;
5484 if(fmvapid.isValid()) {
5486 TrackerData.trkpidmvamu[iTrk] = pid->
mvaOutput.at(
"muon");
5487 TrackerData.trkpidmvae[iTrk] = pid->
mvaOutput.at(
"electron");
5488 TrackerData.trkpidmvapich[iTrk] = pid->
mvaOutput.at(
"pich");
5489 TrackerData.trkpidmvaphoton[iTrk] = pid->
mvaOutput.at(
"photon");
5490 TrackerData.trkpidmvapr[iTrk] = pid->
mvaOutput.at(
"proton");
5495 art::FindManyP<recob::Hit, recob::TrackHitMeta> fmthm(trackListHandle[iTracker], evt,
"pmtrack");
5498 auto vhit = fmthm.at(iTrk);
5499 auto vmeta = fmthm.data(iTrk);
5501 TrackerData.NHitsPerTrack[iTrk] = vhit.size();
5502 art::FindManyP<recob::SpacePoint> fmspts(vhit, evt,
"pmtrack");
5511 std::cout <<
"vhit.size(): " << vhit.size() <<
std::endl;
5512 std::cout <<
"vmeta.size(): " << vmeta.size() <<
std::endl;
5513 std::cout <<
"fmspts.size(): " << fmspts.size() <<
std::endl;
5516 for (
unsigned int h = 0;
h < vhit.size();
h++)
5520 const TVector3&
dir = tracklist[iTracker][iTrk]->DirectionAtPoint<TVector3>(
h);
5521 const TVector3&
loc = tracklist[iTracker][iTrk]->LocationAtPoint<TVector3>(
h);
5522 double cosgamma =
std::abs(std::sin(angleToVert)*dir.Y() + std::cos(angleToVert)*dir.Z());
5525 TrackerData.hittrklocaltrackdirectionx[HitIterator2] = dir.X();
5526 TrackerData.hittrklocaltrackdirectiony[HitIterator2] = dir.Y();
5527 TrackerData.hittrklocaltrackdirectionz[HitIterator2] = dir.Z();
5531 std::vector< art::Ptr<recob::SpacePoint> > sptv = fmspts.at(
h);
5532 TrackerData.hittrkx[HitIterator2] = sptv[0]->XYZ()[0];
5533 TrackerData.hittrky[HitIterator2] = sptv[0]->XYZ()[1];
5534 TrackerData.hittrkz[HitIterator2] = sptv[0]->XYZ()[2];
5536 TVector3 dir_hit_flipped;
5537 dir_hit_flipped.SetXYZ(dir.Z(), dir.Y(), dir.X());
5539 TrackerData.hittrklocaltrackdirectiontheta[HitIterator2] = (180.0/3.14159)*dir_hit_flipped.Theta();
5540 TrackerData.hittrklocaltrackdirectionphi[HitIterator2] = (180.0/3.14159)*dir_hit_flipped.Phi();
5543 if(vhit[
h]->
WireID().
Plane == 0) TrackerData.hittrkpitchC[HitIterator2] =
std::abs(geomhandle->
WirePitch()/( sin(dir_hit_flipped.Theta())*sin(dir_hit_flipped.Phi()) ));
5544 if(vhit[
h]->
WireID().Plane == 1) TrackerData.hittrkpitchC[HitIterator2] =
std::abs(geomhandle->
WirePitch()/( sin(dir_hit_flipped.Theta())*cos(dir_hit_flipped.Phi()) ));
5546 TrackerData.hittrkds[HitIterator2] = vmeta[
h]->Dx();
5550 std::cout <<
"pos.X(): " << sptv[0]->XYZ()[0] <<
"\t" <<
"pos.Y(): " << sptv[0]->XYZ()[1] <<
"\t" <<
"pos.Z(): " << sptv[0]->XYZ()[2] <<
std::endl;
5551 std::cout <<
"pos2.X(): " << loc.X() <<
"\t" <<
"pos2.Y(): " << loc.Y() <<
"\t" <<
"pos2.Z(): " << loc.Z() <<
std::endl;
5552 std::cout <<
"dir.X(): " << dir.X() <<
"\t" <<
"dir.Y(): " << dir.Y() <<
"\t" <<
"dir.Z(): " << dir.Z() <<
std::endl;
5553 std::cout <<
"dir_hit_flipped.Theta(): " << (180.0/3.14159)*dir_hit_flipped.Theta() <<
"\t" <<
"dir_hit_flipped.Phi(): " << (180.0/3.14159)*dir_hit_flipped.Phi() <<
std::endl;
5554 std::cout <<
"vmeta[h]->Dx(): " << vmeta[
h]->Dx() <<
std::endl;
5555 std::cout <<
"Dx corrected pitch old: " << geomhandle->
WirePitch()/cosgamma <<
std::endl;
5556 std::cout <<
"Dx corrected pitch new: " << TrackerData.hittrkpitchC[HitIterator2] <<
std::endl;
5557 std::cout <<
"view: " << vhit[
h]->WireID().Plane <<
std::endl;
5561 TrackerData.hittrkchannel[HitIterator2] = vhit[
h]->Channel();
5562 TrackerData.hittrktpc[HitIterator2] = vhit[
h]->WireID().TPC;
5563 TrackerData.hittrkview[HitIterator2] = vhit[
h]->WireID().Plane;
5564 TrackerData.hittrkwire[HitIterator2] = vhit[
h]->WireID().Wire;
5565 TrackerData.hittrkpeakT[HitIterator2] = vhit[
h]->PeakTime();
5566 TrackerData.hittrkchargeintegral[HitIterator2] = vhit[
h]->Integral();
5567 TrackerData.hittrkph[HitIterator2] = vhit[
h]->PeakAmplitude();
5568 TrackerData.hittrkchargesum[HitIterator2] = vhit[
h]->SummedADC();
5569 TrackerData.hittrkstarT[HitIterator2] = vhit[
h]->StartTick();
5570 TrackerData.hittrkendT[HitIterator2] = vhit[
h]->EndTick();
5571 TrackerData.hittrkrms[HitIterator2] = vhit[
h]->RMS();
5572 TrackerData.hittrkgoddnessofFit[HitIterator2] = vhit[
h]->GoodnessOfFit();
5573 TrackerData.hittrkmultiplicity[HitIterator2] = vhit[
h]->Multiplicity();
5579 TrackerData.hittrktrueID[HitIterator2] = trueID;
5580 TrackerData.hittrktrueEnergyMax[HitIterator2] = maxe;
5581 TrackerData.hittrktrueEnergyFraction[HitIterator2] = purity;
5588 TrackerData.ntrkhitsperview[iTrk][0] = NHitsView0;
5589 TrackerData.ntrkhitsperview[iTrk][1] = NHitsView1;
5627 if (fmcal.isValid()){
5628 std::vector<const anab::Calorimetry*> calos = fmcal.at(iTrk);
5629 if (calos.size() > TrackerData.GetMaxPlanesPerTrack(iTrk)) {
5634 <<
" has " << calos.size() <<
" planes for calorimetry , only " 5635 << TrackerData.GetMaxPlanesPerTrack(iTrk) <<
" stored in tree";
5639 for (
size_t ical = calos.size() - 1; ical <= 1 ; --ical){
5640 if (!calos[ical])
continue;
5641 if (!calos[ical]->
PlaneID().isValid)
continue;
5642 int planenum = calos[ical]->PlaneID().Plane;
5643 if (planenum<0||planenum>1)
continue;
5644 TrackerData.trkke[iTrk][planenum] = calos[ical]->KineticEnergy();
5645 TrackerData.trkrange[iTrk][planenum] = calos[ical]->Range();
5647 TrackerData.trkpitchc[iTrk][planenum]= calos[ical] -> TrkPitchC();
5648 const size_t NHits = calos[ical] ->
dEdx().size();
5650 if (NHits > TrackerData.GetMaxHitsPerTrack(iTrk, planenum)) {
5654 <<
" has " << NHits <<
" hits on calorimetry plane #" << planenum
5656 << TrackerData.GetMaxHitsPerTrack(iTrk, planenum) <<
" stored in tree";
5659 for(
size_t iTrkHit = 0; iTrkHit < NHits && iTrkHit < TrackerData.GetMaxHitsPerTrack(iTrk, planenum); ++iTrkHit) {
5660 TrackerData.trkdedx[iTrk][planenum][iTrkHit] = (calos[ical] ->
dEdx())[iTrkHit];
5661 TrackerData.trkdqdx[iTrk][planenum][iTrkHit] = (calos[ical] -> dQdx())[iTrkHit];
5662 TrackerData.trkresrg[iTrk][planenum][iTrkHit] = (calos[ical] -> ResidualRange())[iTrkHit];
5663 TrackerData.trktpc[iTrk][planenum][iTrkHit] = (calos[ical] ->
PlaneID()).
TPC;
5664 const auto& TrkPos = (calos[ical] -> XYZ())[iTrkHit];
5665 auto& TrkXYZ = TrackerData.trkxyz[iTrk][planenum][iTrkHit];
5666 TrkXYZ[0] = TrkPos.X();
5667 TrkXYZ[1] = TrkPos.Y();
5668 TrkXYZ[2] = TrkPos.Z();
5670 TrackerData.trkdedx2[HitIterator] = (calos[ical] ->
dEdx())[iTrkHit];
5671 TrackerData.trkdqdx2[HitIterator] = (calos[ical] -> dQdx())[iTrkHit];
5672 TrackerData.trktpc2[HitIterator] = (calos[ical] ->
PlaneID()).
TPC;
5673 TrackerData.trkx2[HitIterator] = TrkPos.X();
5674 TrackerData.trky2[HitIterator] = TrkPos.Y();
5675 TrackerData.trkz2[HitIterator] = TrkPos.Z();
5683 if(TrackerData.ntrkhitsperview[iTrk][0] > TrackerData.ntrkhitsperview[iTrk][1] && TrackerData.ntrkhitsperview[iTrk][0] > TrackerData.ntrkhitsperview[iTrk][2]) TrackerData.trkpidbestplane[iTrk] = 0;
5684 else if(TrackerData.ntrkhitsperview[iTrk][1] > TrackerData.ntrkhitsperview[iTrk][0] && TrackerData.ntrkhitsperview[iTrk][1] > TrackerData.ntrkhitsperview[iTrk][2]) TrackerData.trkpidbestplane[iTrk] = 1;
5685 else if(TrackerData.ntrkhitsperview[iTrk][2] > TrackerData.ntrkhitsperview[iTrk][0] && TrackerData.ntrkhitsperview[iTrk][2] > TrackerData.ntrkhitsperview[iTrk][1]) TrackerData.trkpidbestplane[iTrk] = 2;
5686 else if(TrackerData.ntrkhitsperview[iTrk][2] == TrackerData.ntrkhitsperview[iTrk][0] && TrackerData.ntrkhitsperview[iTrk][2] > TrackerData.ntrkhitsperview[iTrk][1]) TrackerData.trkpidbestplane[iTrk] = 2;
5687 else if(TrackerData.ntrkhitsperview[iTrk][2] == TrackerData.ntrkhitsperview[iTrk][1] && TrackerData.ntrkhitsperview[iTrk][2] > TrackerData.ntrkhitsperview[iTrk][0]) TrackerData.trkpidbestplane[iTrk] = 2;
5688 else if(TrackerData.ntrkhitsperview[iTrk][1] == TrackerData.ntrkhitsperview[iTrk][0] && TrackerData.ntrkhitsperview[iTrk][1] > TrackerData.ntrkhitsperview[iTrk][2]) TrackerData.trkpidbestplane[iTrk] = 0;
5689 else if(TrackerData.ntrkhitsperview[iTrk][1] == TrackerData.ntrkhitsperview[iTrk][0] && TrackerData.ntrkhitsperview[iTrk][1] == TrackerData.ntrkhitsperview[iTrk][2]) TrackerData.trkpidbestplane[iTrk] = 2;
5766 for (
unsigned int iVertexAlg=0; iVertexAlg < NVertexAlgos; ++iVertexAlg){
5767 AnaRootParserDataStruct::VertexDataStruct& VertexData =
fData->GetVertexData(iVertexAlg);
5769 size_t NVertices = vertexlist[iVertexAlg].size();
5771 VertexData.SetMaxVertices(
std::max(NVertices, (
size_t) 1));
5774 VertexData.nvtx = (short) NVertices;
5779 if (NVertices > VertexData.GetMaxVertices()) {
5782 mf::LogError(
"AnaRootParser:limits") <<
"event has " << NVertices
5784 << VertexData.GetMaxVertices() <<
" stored in tree";
5787 for (
size_t i = 0; i < NVertices && i <
kMaxVertices ; ++i){
5788 VertexData.vtxId[i] = vertexlist[iVertexAlg][i]->ID();
5789 Double_t xyz[3] = {};
5790 vertexlist[iVertexAlg][i] -> XYZ(xyz);
5791 VertexData.vtxx[i] = xyz[0];
5792 VertexData.vtxy[i] = xyz[1];
5793 VertexData.vtxz[i] = xyz[2];
5796 auto mapIter = vertexIDtoPFParticleIDMap.find(vertexlist[iVertexAlg][i]->
ID());
5797 if (mapIter != vertexIDtoPFParticleIDMap.end()) {
5799 VertexData.vtxhasPFParticle[i] = 1;
5800 VertexData.vtxPFParticleID[i] = mapIter->second;
5803 VertexData.vtxhasPFParticle[i] = 0;
5807 art::FindMany<recob::PFParticle> fmPFParticle(vertexListHandle[iVertexAlg], evt,
fPFParticleModuleLabel);
5808 if(fmPFParticle.isValid()) {
5809 std::vector<const recob::PFParticle*> pfparticles = fmPFParticle.at(i);
5810 if(pfparticles.size() > 1)
5811 std::cerr <<
"Warning: more than one associated PFParticle found for a vertex. Only one stored in tree." << std::endl;
5812 if (pfparticles.size() == 0)
5813 VertexData.vtxhasPFParticle[i] = 0;
5815 VertexData.vtxhasPFParticle[i] = 1;
5816 VertexData.vtxPFParticleID[i] = pfparticles.at(0)->Self();
5832 fData->mcevts_truthcry = mclistcry.size();
5833 fData->cry_no_primaries = nCryPrimaries;
5835 for(Int_t iPartc = 0; iPartc < mctruthcry->
NParticles(); ++iPartc){
5837 fData->cry_primaries_pdg[iPartc]=partc.PdgCode();
5838 fData->cry_Eng[iPartc]=partc.E();
5839 fData->cry_Px[iPartc]=partc.Px();
5840 fData->cry_Py[iPartc]=partc.Py();
5841 fData->cry_Pz[iPartc]=partc.Pz();
5842 fData->cry_P[iPartc]=partc.P();
5843 fData->cry_StartPointx[iPartc] = partc.Vx();
5844 fData->cry_StartPointy[iPartc] = partc.Vy();
5845 fData->cry_StartPointz[iPartc] = partc.Vz();
5846 fData->cry_StartPointt[iPartc] = partc.T();
5847 fData->cry_status_code[iPartc]=partc.StatusCode();
5848 fData->cry_mass[iPartc]=partc.Mass();
5849 fData->cry_trackID[iPartc]=partc.TrackId();
5850 fData->cry_ND[iPartc]=partc.NumberDaughters();
5851 fData->cry_mother[iPartc]=partc.Mother();
5857 fData->proto_no_primaries = nProtoPrimaries;
5858 for(Int_t iPartp = 0; iPartp < nProtoPrimaries; ++iPartp){
5861 fData->proto_isGoodParticle[iPartp] = (partp.Process() ==
"primary");
5862 fData->proto_vx[iPartp] = partp.Vx();
5863 fData->proto_vy[iPartp] = partp.Vy();
5864 fData->proto_vz[iPartp] = partp.Vz();
5865 fData->proto_t[iPartp] = partp.T();
5866 fData->proto_px[iPartp] = partp.Px();
5867 fData->proto_py[iPartp] = partp.Py();
5868 fData->proto_pz[iPartp] = partp.Pz();
5869 fData->proto_momentum[iPartp] = partp.P();
5870 fData->proto_energy[iPartp] = partp.E();
5871 fData->proto_pdg[iPartp] = partp.PdgCode();
5876 fData->mcevts_truth = mclist.size();
5877 if (
fData->mcevts_truth > 0)
5882 for(
unsigned int iList = 0; (iList < mclist.size()) && (neutrino_i <
kMaxTruth) ; ++iList){
5883 if (mclist[iList]->NeutrinoSet()){
5884 fData->nuPDG_truth[neutrino_i] = mclist[iList]->GetNeutrino().Nu().PdgCode();
5885 fData->ccnc_truth[neutrino_i] = mclist[iList]->GetNeutrino().CCNC();
5886 fData->mode_truth[neutrino_i] = mclist[iList]->GetNeutrino().Mode();
5887 fData->Q2_truth[neutrino_i] = mclist[iList]->GetNeutrino().QSqr();
5888 fData->W_truth[neutrino_i] = mclist[iList]->GetNeutrino().W();
5889 fData->X_truth[neutrino_i] = mclist[iList]->GetNeutrino().X();
5890 fData->Y_truth[neutrino_i] = mclist[iList]->GetNeutrino().Y();
5891 fData->hitnuc_truth[neutrino_i] = mclist[iList]->GetNeutrino().HitNuc();
5892 fData->enu_truth[neutrino_i] = mclist[iList]->GetNeutrino().Nu().E();
5893 fData->nuvtxx_truth[neutrino_i] = mclist[iList]->GetNeutrino().Nu().Vx();
5894 fData->nuvtxy_truth[neutrino_i] = mclist[iList]->GetNeutrino().Nu().Vy();
5895 fData->nuvtxz_truth[neutrino_i] = mclist[iList]->GetNeutrino().Nu().Vz();
5896 if (mclist[iList]->GetNeutrino().Nu().
P()){
5897 fData->nu_dcosx_truth[neutrino_i] = mclist[iList]->GetNeutrino().Nu().Px()/mclist[iList]->GetNeutrino().Nu().P();
5898 fData->nu_dcosy_truth[neutrino_i] = mclist[iList]->GetNeutrino().Nu().Py()/mclist[iList]->GetNeutrino().Nu().P();
5899 fData->nu_dcosz_truth[neutrino_i] = mclist[iList]->GetNeutrino().Nu().Pz()/mclist[iList]->GetNeutrino().Nu().P();
5901 fData->lep_mom_truth[neutrino_i] = mclist[iList]->GetNeutrino().Lepton().P();
5902 if (mclist[iList]->GetNeutrino().Lepton().
P()){
5903 fData->lep_dcosx_truth[neutrino_i] = mclist[iList]->GetNeutrino().Lepton().Px()/mclist[iList]->GetNeutrino().Lepton().P();
5904 fData->lep_dcosy_truth[neutrino_i] = mclist[iList]->GetNeutrino().Lepton().Py()/mclist[iList]->GetNeutrino().Lepton().P();
5905 fData->lep_dcosz_truth[neutrino_i] = mclist[iList]->GetNeutrino().Lepton().Pz()/mclist[iList]->GetNeutrino().Lepton().P();
5964 size_t StoreParticles =
std::min((
size_t)
fData->genie_no_primaries,
fData->GetMaxGeniePrimaries());
5965 if (
fData->genie_no_primaries > (
int) StoreParticles) {
5969 <<
fData->genie_no_primaries <<
" MC particles, only " 5970 << StoreParticles <<
" stored in tree";
5972 for(
size_t iPart = 0; iPart < StoreParticles; ++iPart){
5974 fData->genie_primaries_pdg[iPart]=part.PdgCode();
5975 fData->genie_Eng[iPart]=part.E();
5976 fData->genie_Px[iPart]=part.Px();
5977 fData->genie_Py[iPart]=part.Py();
5978 fData->genie_Pz[iPart]=part.Pz();
5979 fData->genie_P[iPart]=part.P();
5980 fData->genie_status_code[iPart]=part.StatusCode();
5981 fData->genie_mass[iPart]=part.Mass();
5982 fData->genie_trackID[iPart]=part.TrackId();
5983 fData->genie_ND[iPart]=part.NumberDaughters();
5984 fData->genie_mother[iPart]=part.Mother();
5993 fData->no_mcshowers = nMCShowers;
5996 imcshwr != mcshowerh->end(); ++imcshwr) {
6005 fData->mcshwr_endX[shwr] = mcshwr.
End().
X();
6006 fData->mcshwr_endY[shwr] = mcshwr.
End().
Y();
6007 fData->mcshwr_endZ[shwr] = mcshwr.
End().
Z();
6009 fData->mcshwr_isEngDeposited[shwr] = 1;
6017 fData->mcshwr_dEdx[shwr] = mcshwr.
dEdx();
6023 fData->mcshwr_isEngDeposited[shwr] = 0;
6044 fData->mcshwr_Process.resize(shwr);
6045 fData->mcshwr_MotherProcess.resize(shwr);
6046 fData->mcshwr_AncestorProcess.resize(shwr);
6052 fData->no_mctracks = nMCTracks;
6056 TLorentzVector tpcstart, tpcend, tpcmom;
6057 double plen =
driftedLength(detProp, mctrk, tpcstart, tpcend, tpcmom);
6065 fData->mctrk_endX[trk] = mctrk.
End().
X();
6066 fData->mctrk_endY[trk] = mctrk.
End().
Y();
6067 fData->mctrk_endZ[trk] = mctrk.
End().
Z();
6087 fData->mctrk_len_drifted[trk] = plen;
6090 fData->mctrk_startX_drifted[trk] = tpcstart.X();
6091 fData->mctrk_startY_drifted[trk] = tpcstart.Y();
6092 fData->mctrk_startZ_drifted[trk] = tpcstart.Z();
6093 fData->mctrk_endX_drifted[trk] = tpcend.X();
6094 fData->mctrk_endY_drifted[trk] = tpcend.Y();
6095 fData->mctrk_endZ_drifted[trk] = tpcend.Z();
6096 fData->mctrk_p_drifted[trk] = tpcmom.Vect().Mag();
6097 fData->mctrk_px_drifted[trk] = tpcmom.X();
6098 fData->mctrk_py_drifted[trk] = tpcmom.Y();
6099 fData->mctrk_pz_drifted[trk] = tpcmom.Z();
6104 fData->mctrk_Process.resize(trk);
6105 fData->mctrk_MotherProcess.resize(trk);
6106 fData->mctrk_AncestorProcess.resize(trk);
6113 int photoncounter=0;
6114 for (
auto const& pmt : (*photonHandle) )
6116 std::map<int, int> PhotonsMap = pmt.DetectedPhotons;
6118 for(
auto itphoton = PhotonsMap.begin(); itphoton!= PhotonsMap.end(); itphoton++)
6120 for(
int iphotonatthistime = 0; iphotonatthistime < itphoton->second ; iphotonatthistime++)
6122 fData->photons_time[photoncounter]=itphoton->first;
6123 fData->photons_channel[photoncounter]=pmt.OpChannel;
6128 fData->numberofphotons=photoncounter;
6134 const sim::ParticleList& plist = pi_serv->
ParticleList();
6136 size_t generator_particle=0;
6140 for(
size_t iPart = 0; (iPart < plist.size()) && (itPart != pend); ++iPart){
6145 <<
"GEANT particle #" << iPart <<
" returned a null pointer";
6148 if (iPart < fData->GetMaxGeneratorparticles()) {
6156 fData->Eng[generator_particle]=pPart->
E();
6157 fData->Mass[generator_particle]=pPart->
Mass();
6158 fData->Px[generator_particle]=pPart->
Px();
6159 fData->Py[generator_particle]=pPart->
Py();
6160 fData->Pz[generator_particle]=pPart->
Pz();
6161 fData->P[generator_particle]=pPart->
Momentum().Vect().Mag();
6162 fData->StartPointx[generator_particle]=pPart->
Vx();
6163 fData->StartPointy[generator_particle]=pPart->
Vy();
6164 fData->StartPointz[generator_particle]=pPart->
Vz();
6165 fData->StartT[generator_particle] = pPart->
T();
6167 TVector3 momentum_start_flipped;
6168 momentum_start_flipped.SetXYZ(pPart->
Pz(), pPart->
Py(), pPart->
Px());
6170 fData->theta[generator_particle] = (180.0/3.14159)*momentum_start_flipped.Theta();
6171 fData->phi[generator_particle] = (180.0/3.14159)*momentum_start_flipped.Phi();
6173 ++generator_particle;
6175 else if (iPart ==
fData->GetMaxGeneratorparticles()) {
6179 << plist.size() <<
" MC particles, only " 6180 <<
fData->GetMaxGeneratorparticles() <<
" will be stored in tree";
6183 fData->generator_list_size = generator_particle;
6184 fData->processname.resize(generator_particle);
6187 <<
fData->generator_list_size <<
" Generator particles";
6197 const sim::ParticleList& plist = pi_serv->
ParticleList();
6202 size_t geant_particle=0;
6207 std::map<int, size_t> TrackIDtoIndex;
6208 std::vector<int> gpdg;
6209 std::vector<int> gmother;
6210 for(
size_t iPart = 0; (iPart < plist.size()) && (itPart != pend); ++iPart){
6214 <<
"GEANT particle #" << iPart <<
" returned a null pointer";
6217 bool isPrimary = pPart->
Process() == pri;
6218 int TrackID = pPart->
TrackId();
6219 TrackIDtoIndex.emplace(TrackID, iPart);
6220 gpdg.push_back(pPart->
PdgCode());
6221 gmother.push_back(pPart->
Mother());
6222 if (iPart < fData->GetMaxGEANTparticles()) {
6224 if (isPrimary) ++primary;
6226 TLorentzVector mcstart, mcend;
6227 unsigned int pstarti, pendi;
6228 double plen =
length(*pPart, mcstart, mcend, pstarti, pendi);
6229 bool isActive = plen != 0;
6245 fData->process_primary[geant_particle] =
int(isPrimary);
6251 fData->Eng[geant_particle]=pPart->
E();
6252 fData->EndE[geant_particle]=pPart->
EndE();
6253 fData->Mass[geant_particle]=pPart->
Mass();
6254 fData->Px[geant_particle]=pPart->
Px();
6255 fData->Py[geant_particle]=pPart->
Py();
6256 fData->Pz[geant_particle]=pPart->
Pz();
6258 fData->StartPointx[geant_particle]=pPart->
Vx();
6259 fData->StartPointy[geant_particle]=pPart->
Vy();
6260 fData->StartPointz[geant_particle]=pPart->
Vz();
6261 fData->StartT[geant_particle] = pPart->
T();
6265 fData->EndT[geant_particle] = pPart->
EndT();
6272 TVector3 momentum_start_flipped;
6273 momentum_start_flipped.SetXYZ(pPart->
Pz(), pPart->
Py(), pPart->
Px());
6275 fData->theta[geant_particle] = (180.0/3.14159)*momentum_start_flipped.Theta();
6276 fData->phi[geant_particle] = (180.0/3.14159)*momentum_start_flipped.Phi();
6278 fData->theta_xz[geant_particle] = std::atan2(pPart->
Px(), pPart->
Pz());
6279 fData->theta_yz[geant_particle] = std::atan2(pPart->
Py(), pPart->
Pz());
6282 fData->inTPCActive[geant_particle] =
int(isActive);
6286 fData->origin[geant_particle] = mc_truth->
Origin();
6287 fData->MCTruthIndex[geant_particle] = mc_truth.
key();
6291 fData->pathlen_tpcAV[active] = plen;
6295 fData->StartPointx_tpcAV[active] = mcstart.X();
6296 fData->StartPointy_tpcAV[active] = mcstart.Y();
6297 fData->StartPointz_tpcAV[active] = mcstart.Z();
6298 fData->StartT_tpcAV[active] = mcstart.T();
6299 fData->StartE_tpcAV[active] = pPart->
E(pstarti);
6300 fData->StartP_tpcAV[active] = pPart->
P(pstarti);
6301 fData->StartPx_tpcAV[active] = pPart->
Px(pstarti);
6302 fData->StartPy_tpcAV[active] = pPart->
Py(pstarti);
6303 fData->StartPz_tpcAV[active] = pPart->
Pz(pstarti);
6304 fData->EndPointx_tpcAV[active] = mcend.X();
6305 fData->EndPointy_tpcAV[active] = mcend.Y();
6306 fData->EndPointz_tpcAV[active] = mcend.Z();
6307 fData->EndT_tpcAV[active] = mcend.T();
6308 fData->EndE_tpcAV[active] = pPart->
E(pendi);
6309 fData->EndP_tpcAV[active] = pPart->
P(pendi);
6310 fData->EndPx_tpcAV[active] = pPart->
Px(pendi);
6311 fData->EndPy_tpcAV[active] = pPart->
Py(pendi);
6312 fData->EndPz_tpcAV[active] = pPart->
Pz(pendi);
6315 TVector3 momentum_start_tpcAv_flipped;
6316 momentum_start_tpcAv_flipped.SetXYZ(pPart->
Pz(pstarti), pPart->
Py(pstarti), pPart->
Px(pstarti));
6317 TVector3 momentum_end_tpcAv_flipped;
6318 momentum_end_tpcAv_flipped.SetXYZ(pPart->
Pz(pendi), pPart->
Py(pendi), pPart->
Px(pendi));
6320 fData->thetastart_tpcAV[active] = (180.0/3.14159)*momentum_start_tpcAv_flipped.Theta();
6321 fData->phistart_tpcAV[active] = (180.0/3.14159)*momentum_start_tpcAv_flipped.Phi();
6323 fData->thetaend_tpcAV[active] = (180.0/3.14159)*momentum_end_tpcAv_flipped.Theta();
6324 fData->phiend_tpcAV[active] = (180.0/3.14159)*momentum_end_tpcAv_flipped.Phi();
6353 unsigned short nAD = 0;
6360 const std::vector<sim::AuxDetIDE>& setOfIDEs =
c->AuxDetIDEs();
6367 setOfIDEs.begin(), setOfIDEs.end(),
6370 if (iIDE == setOfIDEs.end())
continue;
6378 for(
const auto& adtracks: setOfIDEs) {
6379 if( fabs(adtracks.trackID) ==
TrackID )
6380 totalE += adtracks.energyDeposited;
6385 fData->AuxDetID[geant_particle][nAD] =
c->AuxDetID();
6386 fData->entryX[geant_particle][nAD] = iIDE->entryX;
6387 fData->entryY[geant_particle][nAD] = iIDE->entryY;
6388 fData->entryZ[geant_particle][nAD] = iIDE->entryZ;
6389 fData->entryT[geant_particle][nAD] = iIDE->entryT;
6390 fData->exitX[geant_particle][nAD] = iIDE->exitX;
6391 fData->exitY[geant_particle][nAD] = iIDE->exitY;
6392 fData->exitZ[geant_particle][nAD] = iIDE->exitZ;
6393 fData->exitT[geant_particle][nAD] = iIDE->exitT;
6394 fData->exitPx[geant_particle][nAD] = iIDE->exitMomentumX;
6395 fData->exitPy[geant_particle][nAD] = iIDE->exitMomentumY;
6396 fData->exitPz[geant_particle][nAD] = iIDE->exitMomentumZ;
6397 fData->CombinedEnergyDep[geant_particle][nAD] = totalE;
6401 fData->NAuxDets[geant_particle] = nAD;
6406 <<
"particle #" << iPart
6407 <<
" touches " << nAD <<
" auxiliary detector cells, only " 6408 <<
kMaxAuxDets <<
" of them are saved in the tree";
6414 else if (iPart ==
fData->GetMaxGEANTparticles()) {
6418 << plist.size() <<
" MC particles, only " 6419 <<
fData->GetMaxGEANTparticles() <<
" will be stored in tree";
6423 fData->geant_list_size_in_tpcAV = active;
6424 fData->no_primaries = primary;
6425 fData->geant_list_size = geant_particle;
6426 fData->processname.resize(geant_particle);
6429 <<
fData->geant_list_size <<
" GEANT particles (" 6430 <<
fData->geant_list_size_in_tpcAV <<
" in AV), " 6431 <<
fData->no_primaries <<
" primaries, " 6432 <<
fData->genie_no_primaries <<
" GENIE particles";
6434 FillWith(
fData->MergedId, 0);
6441 int currentMergedId = 1;
6442 for(
size_t iPart = 0; iPart < geant_particle; ++iPart){
6444 if (
fData->MergedId[iPart])
continue;
6446 fData->MergedId[iPart] = currentMergedId;
6447 int currentMotherTrackId =
fData->Mother[iPart];
6448 while (currentMotherTrackId > 0) {
6449 if (TrackIDtoIndex.find(currentMotherTrackId)==TrackIDtoIndex.end())
break;
6450 unsigned int gindex = TrackIDtoIndex[currentMotherTrackId];
6451 if (gindex>=plist.size())
break;
6454 if (gpdg[gindex]!=
fData->pdg[iPart])
break;
6455 if (TrackIDtoIndex.find(currentMotherTrackId)!=TrackIDtoIndex.end()){
6456 unsigned int igeantMother = TrackIDtoIndex[currentMotherTrackId];
6457 if (igeantMother<geant_particle){
6458 fData->MergedId[igeantMother] = currentMergedId;
6461 currentMotherTrackId = gmother[gindex];
6471 const sim::ParticleList& plist = pi_serv->
ParticleList();
6474 int trajpointcounter = 0;
6476 for(
size_t iPart = 0; (iPart < plist.size()) && (itPart != pend); ++iPart)
6482 <<
"GEANT particle #" << iPart <<
" returned a null pointer";
6486 for(
unsigned int trajpoint=0; trajpoint < numberTrajectoryPoints; ++trajpoint)
6488 const TLorentzVector& trajpointPosition= pPart->
Position(trajpoint);
6491 fData->TrajTrackId[trajpointcounter] = pPart->
TrackId();
6492 fData->TrajPDGCode[trajpointcounter] = pPart->
PdgCode();
6494 fData->TrajX[trajpointcounter] = trajpointPosition.X();
6495 fData->TrajY[trajpointcounter] = trajpointPosition.Y();
6496 fData->TrajZ[trajpointcounter] = trajpointPosition.Z();
6497 fData->TrajT[trajpointcounter] = pPart->
T(trajpoint);
6498 fData->TrajE[trajpointcounter] = pPart->
E(trajpoint);
6499 fData->TrajP[trajpointcounter] = pPart->
P(trajpoint);
6500 fData->TrajPx[trajpointcounter] = pPart->
Px(trajpoint);
6501 fData->TrajPy[trajpointcounter] = pPart->
Py(trajpoint);
6502 fData->TrajPz[trajpointcounter] = pPart->
Pz(trajpoint);
6504 TVector3 trajpointMomentum_flipped;
6505 trajpointMomentum_flipped.SetXYZ(pPart->
Pz(trajpoint), pPart->
Py(trajpoint), pPart->
Px(trajpoint));
6507 fData->TrajTheta[trajpointcounter] = (180.0/3.14159)*trajpointMomentum_flipped.Theta();
6508 fData->TrajPhi[trajpointcounter] = (180.0/3.14159)*trajpointMomentum_flipped.Phi();
6513 std::cout <<
"trajpointcounter: " << trajpointcounter <<
std::endl;
6514 std::cout <<
"fData->TrajTrackId[trajpointcounter]: " <<
fData->TrajTrackId[trajpointcounter] <<
std::endl;
6515 std::cout <<
"fData->TrajPDGCode[trajpointcounter]: " <<
fData->TrajPDGCode[trajpointcounter] <<
std::endl;
6516 std::cout <<
"fData->TrajX[trajpointcounter]: " <<
fData->TrajX[trajpointcounter] <<
std::endl;
6517 std::cout <<
"fData->TrajY[trajpointcounter]: " <<
fData->TrajY[trajpointcounter] <<
std::endl;
6518 std::cout <<
"fData->TrajZ[trajpointcounter]: " <<
fData->TrajZ[trajpointcounter] <<
std::endl;
6519 std::cout <<
"fData->TrajT[trajpointcounter]: " <<
fData->TrajT[trajpointcounter] <<
std::endl;
6520 std::cout <<
"fData->TrajE[trajpointcounter]: " <<
fData->TrajE[trajpointcounter] <<
std::endl;
6521 std::cout <<
"fData->TrajP[trajpointcounter]: " <<
fData->TrajP[trajpointcounter] <<
std::endl;
6522 std::cout <<
"fData->TrajPx[trajpointcounter]: " <<
fData->TrajPx[trajpointcounter] <<
std::endl;
6523 std::cout <<
"fData->TrajPy[trajpointcounter]: " <<
fData->TrajPy[trajpointcounter] <<
std::endl;
6524 std::cout <<
"fData->TrajPz[trajpointcounter]: " <<
fData->TrajPz[trajpointcounter] <<
std::endl;
6525 std::cout <<
"fData->TrajTheta[trajpointcounter]: " <<
fData->TrajTheta[trajpointcounter] <<
std::endl;
6526 std::cout <<
"fData->TrajPhi[trajpointcounter]: " <<
fData->TrajPhi[trajpointcounter] <<
std::endl;
6533 fData->geant_trajectory_size = trajpointcounter;
6539 fData->simenergydeposit_size = nSimEnergyDepositsTPCActive;
6540 fData->particleswithsimenergydeposit_size = nParticlesWithSimEnergyDepositsTPCActive;
6543 int particlewithsedit=0;
6544 for(
int sedavit = 0; sedavit < nSimEnergyDepositsTPCActive; sedavit++)
6546 if (std::find(
fData->ParticleIDSimEnergyDepositsTPCActivePerParticle.begin(),
fData->ParticleIDSimEnergyDepositsTPCActivePerParticle.end(), energyDepositTPCActivelist[sedavit]->TrackID()) ==
fData->ParticleIDSimEnergyDepositsTPCActivePerParticle.end() )
6548 fData->ParticleIDSimEnergyDepositsTPCActivePerParticle[particlewithsedit] = energyDepositTPCActivelist[sedavit]->TrackID();
6550 particlewithsedit++;
6555 std::sort(
fData->ParticleIDSimEnergyDepositsTPCActivePerParticle.begin(),
fData->ParticleIDSimEnergyDepositsTPCActivePerParticle.end());
6559 std::vector<int> it_sortedbyparticleID;
6562 for(
int psedavit = 0; psedavit < nParticlesWithSimEnergyDepositsTPCActive; psedavit++)
6564 int NSEDForThisParticle = 0;
6565 for(
int sedavit = 0; sedavit < nSimEnergyDepositsTPCActive; sedavit++)
6567 if(energyDepositTPCActivelist[sedavit]->
TrackID() ==
fData->ParticleIDSimEnergyDepositsTPCActivePerParticle[psedavit])
6569 NSEDForThisParticle++;
6570 it_sortedbyparticleID.push_back(sedavit);
6574 fData->NSimEnergyDepositsTPCActivePerParticle[psedavit] = NSEDForThisParticle;
6575 totalsed += NSEDForThisParticle;
6669 for(
int sedavit = 0; sedavit < nSimEnergyDepositsTPCActive; sedavit++)
6671 fData->SEDTPCAVTrackID[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->TrackID();
6672 fData->SEDTPCAVPDGCode[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->PdgCode();
6673 fData->SEDTPCAVEnergy[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->Energy();
6674 fData->SEDTPCAVNumPhotons[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->NumPhotons();
6675 fData->SEDTPCAVNumElectrons[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->NumElectrons();
6676 fData->SEDTPCAVLength[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->StepLength();
6678 fData->SEDTPCAVStartTime[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->StartT();
6679 fData->SEDTPCAVStartX[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->StartX();
6680 fData->SEDTPCAVStartY[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->StartY();
6681 fData->SEDTPCAVStartZ[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->StartZ();
6683 fData->SEDTPCAVMidTime[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->Time();
6684 fData->SEDTPCAVMidX[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->MidPointX();
6685 fData->SEDTPCAVMidY[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->MidPointY();
6686 fData->SEDTPCAVMidZ[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->MidPointZ();
6688 fData->SEDTPCAVEndTime[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->EndT();
6689 fData->SEDTPCAVEndX[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->EndX();
6690 fData->SEDTPCAVEndY[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->EndY();
6691 fData->SEDTPCAVEndZ[sedavit] = energyDepositTPCActivelist[it_sortedbyparticleID[sedavit]]->EndZ();
6697 std::cout <<
"sedavit: " << sedavit <<
std::endl;
6698 std::cout <<
"fData->SEDTPCAVTrackID[" << sedavit <<
"]: " <<
fData->SEDTPCAVTrackID[sedavit] <<
std::endl;
6699 std::cout <<
"fData->SEDTPCAVPDGCode[" << sedavit <<
"]: " <<
fData->SEDTPCAVPDGCode[sedavit] <<
std::endl;
6700 std::cout <<
"fData->SEDTPCAVEnergy[" << sedavit <<
"]: " <<
fData->SEDTPCAVEnergy[sedavit] <<
std::endl;
6701 std::cout <<
"fData->SEDTPCAVNumPhotons[" << sedavit <<
"]: " <<
fData->SEDTPCAVNumPhotons[sedavit] <<
std::endl;
6702 std::cout <<
"fData->SEDTPCAVNumElectrons[" << sedavit <<
"]: " <<
fData->SEDTPCAVNumElectrons[sedavit] <<
std::endl;
6704 std::cout <<
"fData->SEDTPCAVLength[" << sedavit <<
"]: " <<
fData->SEDTPCAVLength[sedavit] <<
std::endl;
6705 std::cout <<
"fData->SEDTPCAVStartTime[" << sedavit <<
"]: " <<
fData->SEDTPCAVStartTime[sedavit] <<
std::endl;
6706 std::cout <<
"fData->SEDTPCAVStartX[" << sedavit <<
"]: " <<
fData->SEDTPCAVStartX[sedavit] <<
std::endl;
6707 std::cout <<
"fData->SEDTPCAVStartY[" << sedavit <<
"]: " <<
fData->SEDTPCAVStartY[sedavit] <<
std::endl;
6708 std::cout <<
"fData->SEDTPCAVStartZ[" << sedavit <<
"]: " <<
fData->SEDTPCAVStartZ[sedavit] <<
std::endl;
6709 std::cout <<
"fData->SEDTPCAVMidTime[" << sedavit <<
"]: " <<
fData->SEDTPCAVMidTime[sedavit] <<
std::endl;
6710 std::cout <<
"fData->SEDTPCAVMidX[" << sedavit <<
"]: " <<
fData->SEDTPCAVMidX[sedavit] <<
std::endl;
6711 std::cout <<
"fData->SEDTPCAVMidY[" << sedavit <<
"]: " <<
fData->SEDTPCAVMidY[sedavit] <<
std::endl;
6712 std::cout <<
"fData->SEDTPCAVMidZ[" << sedavit <<
"]: " <<
fData->SEDTPCAVMidZ[sedavit] <<
std::endl;
6713 std::cout <<
"fData->SEDTPCAVEndTime[" << sedavit <<
"]: " <<
fData->SEDTPCAVEndTime[sedavit] <<
std::endl;
6714 std::cout <<
"fData->SEDTPCAVEndX[" << sedavit <<
"]: " <<
fData->SEDTPCAVEndX[sedavit] <<
std::endl;
6715 std::cout <<
"fData->SEDTPCAVEndY[" << sedavit <<
"]: " <<
fData->SEDTPCAVEndY[sedavit] <<
std::endl;
6716 std::cout <<
"fData->SEDTPCAVEndZ[" << sedavit <<
"]: " <<
fData->SEDTPCAVEndZ[sedavit] <<
std::endl;
6723 fData->taulife = detProp.ElectronLifetime();
6732 <<
"Tree data structure contains:" 6733 <<
"\n - " <<
fData->no_hits <<
" hits (" <<
fData->GetMaxHits() <<
")" 6734 <<
"\n - " <<
fData->NHitsInAllTracks <<
" hits (" <<
fData->GetMaxHits() <<
")" 6735 <<
"\n - " <<
fData->genie_no_primaries <<
" genie primaries (" <<
fData->GetMaxGeniePrimaries() <<
")" 6736 <<
"\n - " <<
fData->geant_list_size <<
" GEANT particles (" <<
fData->GetMaxGEANTparticles() <<
"), " 6737 <<
fData->no_primaries <<
" primaries" 6738 <<
"\n - " <<
fData->geant_list_size_in_tpcAV <<
" GEANT particles in AV " 6739 <<
"\n - " << ((
int)
fData->kNTracker) <<
" trackers:" 6742 size_t iTracker = 0;
6743 for (
auto tracker =
fData->TrackData.cbegin();
6744 tracker !=
fData->TrackData.cend(); ++tracker, ++iTracker
6748 <<
" tracks (" << tracker->GetMaxTracks() <<
")" 6750 for (
int iTrk = 0; iTrk < tracker->ntracks; ++iTrk) {
6751 logStream <<
"\n [" << iTrk <<
"] "<< tracker->ntrkhitsperview[iTrk][0];
6752 for (
size_t ipl = 1; ipl < tracker->GetMaxPlanesPerTrack(iTrk); ++ipl)
6753 logStream <<
" + " << tracker->ntrkhitsperview[iTrk][ipl];
6754 logStream <<
" hits (" << tracker->GetMaxHitsPerTrack(iTrk, 0);
6755 for (
size_t ipl = 1; ipl < tracker->GetMaxPlanesPerTrack(iTrk); ++ipl)
6756 logStream <<
" + " << tracker->GetMaxHitsPerTrack(iTrk, ipl);
6766 MF_LOG_DEBUG(
"AnaRootParserStructure") <<
"Freeing the tree data structure";
double E(const int i=0) const
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
std::string fElecDriftModuleLabel
void XYZ(double *xyz) const
Legacy method to access vertex position, preserved to avoid breaking code. Please try to use Vertex::...
unsigned int NumberTrajectoryPoints() const
const TLorentzVector & Position(const int i=0) const
simb::Origin_t Origin() const
std::vector< std::string > fCalorimetryModuleLabel
constexpr std::uint32_t timeLow() const
bool fSaveHitInfo
whether to extract and save MC Track information
void DestroyData()
Destroy the local buffers (existing branches will point to invalid address!)
double VertexMomentum() const
const MCStep & End() const
double Py(const int i=0) const
std::string fClusterModuleLabel
float SummedADCaverage() const
Returns the average signal ADC counts of the cluster hits.
float IntegralAverage() const
Returns the average charge of the cluster hits.
constexpr int kMaxClusters
std::vector< std::string > fMCT0FinderLabel
float bwdLogLikelihood() const
minimum negative log likelihood value from fit assuming a backward track direction ...
const TLorentzVector & EndPosition() const
std::string fRawDigitModuleLabel
bool fSaveGeantTrajectoryInfo
whether to extract and save Geant information
bool fSaveGeantInfo
whether to extract and save Geant information
bool fSaveSimEnergyDepositTPCActiveInfo
whether to extract and save Geant information
std::map< art::Ptr< recob::PFParticle >, ClusterVector > PFParticlesToClusters
std::string fPFParticleModuleLabel
AdcChannelData::View View
unsigned int TrackID() const
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
constexpr int kMaxNPFPNeutrinos
void HitsBackTrack(detinfo::DetectorClocksData const &clockData, art::Ptr< recob::Hit > const &hit, int &trackid, float &maxe, float &purity)
Handle< PROD > getHandle(SelectorBase const &) const
bool fIsMC
whether to use a permanent buffer (faster, huge memory)
constexpr int kMaxVertices
const std::string & AncestorProcess() const
float bwdMomentum() const
momentum value from fit assuming a backward track direction
std::string fPhotonPropS1ModuleLabel
size_t GetNVertexAlgos() const
std::string fSimEnergyDepositTPCActiveLabel
constexpr std::uint32_t timeHigh() const
simb::Origin_t Origin() const
std::string fHitsModuleLabel
bool fSaveGenieInfo
whether to extract and save CRY particle data
double Px(const int i=0) const
const MCStep & MotherEnd() const
unsigned int AncestorTrackID() const
static std::unique_ptr< FVectorReader > create(const art::Event &evt, const art::InputTag &tag)
size_t GetNTrackers() const
Returns the number of trackers configured.
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
float StartWire() const
Returns the wire coordinate of the start of the cluster.
Vector_t VertexDirection() const
static bool IsShower(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as shower-like.
const range_list_t & get_ranges() const
Returns the internal list of non-void ranges.
std::pair< float, std::string > P
int PdgCode() const
Return the type of particle as a PDG ID.
bool isCosmics
if it contains cosmics
Set of hits with a 2D structure.
std::vector< art::Ptr< recob::Shower > > ShowerVector
float EndTick() const
Returns the tick coordinate of the end of the cluster.
std::string fPandoraNuVertexModuleLabel
float MultipleHitDensity() const
Density of wires in the cluster with more than one hit.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Cluster finding and building.
std::string fCalDataModuleLabel
std::string Process() const
std::vector< std::string > fMVAPIDTrackModuleLabel
bool fSaveGeantInAVInfo
whether to extract and save Geant information
int AncestorPdgCode() const
std::string fExternalCounterModuleLabel
bool isValid() const
Returns if the cluster is valid (that is, if its ID is not invalid)
const MCStep & End() const
float StartAngle() const
Returns the starting angle of the cluster.
bool fUseBuffer
whether to use a permanent buffer (faster, huge memory)
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
void CreateTree(bool bClearData=false)
Create the output tree and the data structures, if needed.
std::map< art::Ptr< recob::PFParticle >, TrackVector > PFParticlesToTracks
const art::Ptr< simb::MCTruth > & ParticleToMCTruth_P(const simb::MCParticle *p) const
int NumberDaughters() const
unsigned int MotherTrackID() const
std::map< art::Ptr< recob::PFParticle >, VertexVector > PFParticlesToVertices
recob::MCSFitResult fitMcs(const recob::TrackTrajectory &traj) const
bool fSaveGeneratorInfo
whether to extract and save collected photons
bool isValid() const noexcept
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
const TVector3 & StartDir() const
Collection of particles crossing one auxiliary detector cell.
std::vector< std::string > fShowerModuleLabel
bool fSavePFParticleInfo
whether to extract and save Shower information
float EndCharge() const
Returns the charge on the last wire of the cluster.
double dEdx(float dqdx, float Efield)
std::string fCryGenModuleLabel
float SummedADC() const
Returns the total charge of the cluster from signal ADC counts.
double bdist(const TVector3 &pos)
float bestMomentum() const
momentum for best direction fit
simb::Origin_t Origin() const
std::vector< std::string > fCosmicTaggerAssocLabel
whether to extract and save PFParticle information
std::map< art::Ptr< recob::PFParticle >, ShowerVector > PFParticlesToShowers
bool fSaveExternCounterInfo
whether to extract and save Flash information
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
int MotherPdgCode() const
const std::string & AncestorProcess() const
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
static void CollectShowers(const art::Event &evt, const std::string &label, ShowerVector &showerVector, PFParticlesToShowers &particlesToShowers)
Collect the reconstructed PFParticles and associated Showers from the ART event record.
trkf::TrajectoryMCSFitter fMCSFitter
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const
float Chi2PerNdof() const
double P(const int i=0) const
key_type key() const noexcept
void CreateData(bool bClearData=false)
Creates the structure for the tree data; optionally initializes it.
bool fSavePhotonInfo
whether to extract and save ProtDUNE beam simulation information
float Width() const
A measure of the cluster width, in homogenized units.
constexpr int kMaxFlashes
std::vector< std::string > fFlashT0FinderLabel
Point_t const & Vertex() const
std::vector< std::string > fContainmentTaggerAssocLabel
static void CollectVertices(const art::Event &evt, const std::string &label, VertexVector &vertexVector, PFParticlesToVertices &particlesToVertices)
Collect the reconstructed PFParticles and associated Vertices from the ART event record.
void SetVertexAddresses(size_t iVertexAlg)
double T(const int i=0) const
double length(const recob::Track &track)
bool fSaveShowerInfo
whether to extract and save External Counter information
std::string fMCTrackModuleLabel
std::unique_ptr< AnaRootParserDataStruct > fData
SubRunNumber_t subRun() const
bool fSaveProtoInfo
whether to extract and save Genie information
bool IsPrimary() const
Returns whether the particle is the root of the flow.
size_t GetNShowerAlgos() const
Returns the number of shower algorithms configured.
bool fSaveCaloCosmics
save calorimetry information for cosmics
std::vector< art::Ptr< recob::Track > > TrackVector
const MCStep & AncestorStart() const
static int max(int a, int b)
constexpr unsigned short kMaxAuxDets
max number of auxiliary detector cells per MC particle
void FillShowers(AnaRootParserDataStruct::ShowerDataStruct &showerData, std::vector< recob::Shower > const &showers, const bool fSavePFParticleInfo, const std::map< Short_t, Short_t > &showerIDtoPFParticleIDMap) const
Stores the information of all showers into showerData.
const MCStep & AncestorStart() const
static void CollectTracks(const art::Event &evt, const std::string &label, TrackVector &trackVector, PFParticlesToTracks &particlesToTracks)
Collect the reconstructed PFParticles and associated Tracks from the ART event record.
const std::string & MotherProcess() const
std::string fOpFlashModuleLabel
double driftedLength(detinfo::DetectorPropertiesData const &detProp, const simb::MCParticle &part, TLorentzVector &start, TLorentzVector &end, unsigned int &starti, unsigned int &endi)
static void CollectPFParticles(const art::Event &evt, const std::string &label, PFParticleVector &particleVector)
Collect the reconstructed PFParticles from the ART event record.
unsigned int AncestorTrackID() const
bool fSaveRecobWireInfo
whether to extract and save raw digit information
std::string fGenieGenModuleLabel
bool bIgnoreMissingShowers
whether to ignore missing shower information
const MCStep & AncestorEnd() const
const MCStep & DetProfile() const
std::vector< std::string > fVertexModuleLabel
const sim::ParticleList & ParticleList() const
Class storing the result of the Maximum Likelihood fit of Multiple Coulomb Scattering angles between ...
bool fSavePandoraNuVertexInfo
whether to extract and save Cluster information
const simb::MCParticle & GetParticle(int i) const
static void SelectNeutrinoPFParticles(const PFParticleVector &inputParticles, PFParticleVector &outputParticles)
Select reconstructed neutrino particles from a list of all reconstructed particles.
bool fSaveRawDigitInfo
whether to extract and save Hit information
bool fSaveMCShowerInfo
whether to extract and save Cluster information
bool fSaveClusterInfo
whether to extract and save Vertex information
const MCStep & Start() const
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
double Vx(const int i=0) const
geo::View_t View() const
Returns the view for this cluster.
constexpr int kMaxExternCounts
const MCStep & MotherStart() const
void SetTrackerAddresses(size_t iTracker)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
int MotherPdgCode() const
const MCStep & MotherEnd() const
float StartCharge() const
Returns the charge on the first wire of the cluster.
bool fSaveFlashInfo
whether to extract and save nu vertex information from Pandora
ID_t ID() const
Identifier of this cluster.
bool fSaveAuxDetInfo
whether to extract and save auxiliary detector data
std::vector< std::string > fMVAPIDShowerModuleLabel
bool fSaveTrackInfo
whether to extract and save recob wire information
Vector_t EndDirection() const
MC truth information to make RawDigits and do back tracking.
const TLorentzVector & Momentum(const int i=0) const
const std::string & Process() const
const std::string & MotherProcess() const
std::vector< std::string > fFlashMatchAssocLabel
static bool IsTrack(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as track-like.
double Pz(const int i=0) const
float fwdLogLikelihood() const
minimum negative log likelihood value from fit assuming a forward track direction ...
unsigned int MotherTrackID() const
double Vz(const int i=0) const
const std::string & Process() const
std::vector< art::Ptr< recob::Vertex > > VertexVector
EventNumber_t event() const
Point_t const & End() const
const MCStep & MotherStart() const
detail::Node< FrameID, bool > PlaneID
const MCStep & Start() const
bool fSaveMCTrackInfo
whether to extract and save MC Shower information
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
std::vector< art::Ptr< recob::Cluster > > ClusterVector
unsigned int NHits() const
Number of hits in the cluster.
unsigned int TrackID() const
AnaRootParserDataStruct::SubRunData_t SubRunData
int AncestorPdgCode() const
float fwdMomentum() const
momentum value from fit assuming a forward track direction
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
std::map< std::string, double > mvaOutput
void SetPFParticleAddress()
float EndAngle() const
Returns the ending angle of the cluster.
std::string fMCShowerModuleLabel
second_as<> second
Type of time stored in seconds, in double precision.
recob::tracking::Plane Plane
constexpr int kMaxReadoutTicksInAllChannels
float StartTick() const
Returns the tick coordinate of the start of the cluster.
std::vector< std::string > fTrackModuleLabel
std::string fProtoGenModuleLabel
double WireAngleToVertical(geo::View_t view, geo::TPCID const &tpcid) const
Returns the angle of the wires in the specified view from vertical.
double Vy(const int i=0) const
const MCStep & AncestorEnd() const
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
bool fSaveVertexInfo
whether to extract and save Track information
QTextStream & endl(QTextStream &s)
float Integral() const
Returns the total charge of the cluster from hit shape.
float EndWire() const
Returns the wire coordinate of the end of the cluster.