4 #include "TClassTable.h"
6 #include "TDictionary.h"
7 #include "TDictAttributeMap.h"
8 #include "TProtoClass.h"
10 #include "TParameter.h"
12 #include "../NumuReco/TrackAlgo.h"
14 std::vector<std::string>
ProcessClass(TClass *tclass,
const std::string &prefix) {
15 std::vector<std::string> ret;
16 TList *members = tclass->GetListOfDataMembers();
17 TIterator *m_iterator = members->MakeIterator();
19 while ((obj = m_iterator->Next()) != NULL) {
20 TDataMember *member = (TDataMember *)obj;
21 TDataType *basic_type = member->GetDataType();
22 if (basic_type != NULL) {
24 assert(basic_type->GetType() == kFloat_t);
26 if (member->GetArrayDim() == 0) {
28 ret.push_back(prefix +
"." + std::string(obj->GetName()));
33 for (
unsigned i = 0; i < member->GetArrayDim(); i++) {
34 max_ind = max_ind * member->GetMaxIndex(i);
36 for (
unsigned i = 0; i < max_ind; i++) {
37 std::vector<unsigned> each_ind(member->GetArrayDim(), 0);
39 for (
int j = member->GetArrayDim()-1; j >= 0; j--) {
40 unsigned this_i = ind % member->GetMaxIndex(j);
42 ind = ind / member->GetMaxIndex(j);
44 std::string base = prefix +
"." + std::string(obj->GetName());
52 assert(!member->IsEnum());
54 assert(!member->IsaPointer());
56 assert(!member->IsSTLContainer());
58 if (!member->IsBasic()) {
59 DictFuncPtr_t next = gClassTable->GetDict(member->GetTypeName());
61 std::cout <<
"Missing dictionary for class type: " << member->GetTypeName() << std::endl;
64 std::vector<std::string> this_ret =
ProcessClass(next(), prefix +
"." + std::string(obj->GetName()));
65 ret.insert(ret.end(), this_ret.begin(), this_ret.end());
72 DictFuncPtr_t classdict = gClassTable->GetDict(classname.c_str());
73 std::vector<std::string> var_names =
ProcessClass(classdict(), prefix);
75 for (
unsigned i = 0; i < var_names.size(); i++) {
77 if (i < var_names.size() -1) ret +=
":";
84 std::string output_name = config->get<std::string>(
"OutputFile",
"output.root");
93 for (
unsigned i = 0; i <
NWorkers(); i++) {
94 std::string
name = output_name;
96 fOutputFiles[i] =
new TFile(name.c_str(),
"RECREATE");
97 fOutputFiles[i]->cd();
98 fNtuples[i] =
new TNtuple(
"interaction",
"interaction", ntuple.c_str());
103 unsigned i = WorkerID();
104 fOutputFiles[i]->cd();
108 unsigned ind = WorkerID();
110 eventTree->SetBranchAddress(
"reco_event", &fRecoEvents[ind]);
115 fInteractions[ind].meta.mc_type = fMCTypes[ind];
116 fInteractions[ind].meta.detector = fConfigExperimentID;
120 unsigned index = WorkerID();
123 const numu::RecoTrack &primary_track = fRecoEvents[index]->tracks.at(interaction.slice.primary_track_index);
137 primary_track.
end.GetXYZ(track.
end);
152 slice.
flash_score = interaction.slice.flash_match.score;
153 slice.
flash_time = interaction.slice.flash_match.time;
157 if (interaction.match.has_match) {
158 neutrino.
E = ev->
truth[interaction.match.mctruth_track_id].neutrino.energy;
159 neutrino.
Q2 = ev->
truth[interaction.match.mctruth_track_id].neutrino.Q2;
160 ev->
truth[interaction.match.mctruth_track_id].neutrino.position.GetXYZ(neutrino.
vertex);
162 else neutrino.
E = -1;
166 for (
unsigned i = 0; i < 10; i++) event_info.
crt_hit_pes[i] = -1;
175 event_info.
pass_trig = fCuts.PassFlashTrigger(*fRecoEvents[index]);
179 fNtuples[index]->Fill((
float *)&fInteractions[index]);
182 fInteractions[index].meta.pot = 0;
183 fInteractions[index].meta.n_gen_events = 0;
189 unsigned index = WorkerID();
190 fInteractions[index].meta.pot += subrun->
totgoodpot;
194 unsigned index = WorkerID();
195 fInteractions[index].meta.n_gen_events += meta->
n_gen_events;
199 TList *merge =
new TList;
200 fOutputFiles[0]->cd();
201 for (
unsigned i = 1; i < NWorkers(); i++) {
202 merge->Add(fNtuples[i]);
204 fNtuples[0]->Merge(merge);
205 fNtuples[0]->Write();
208 for (
unsigned i = 1; i < NWorkers(); i++) {
209 const char *
name = fOutputFiles[i]->GetName();
210 fOutputFiles[i]->Close();
211 gSystem->Unlink(name);
Track track
CRT Track match.
TVector3 start_momentum
Particle directional momentum for first trajectory point inside TPC AV [GeV].
float distance
//!< Distance from projected track to CRT Hit. Nonsense if present is false.
bool is_cosmic
Whether this particle is of cosmic origin.
CRTMatch crt_match
CRTMatch.
bool present
Whether this CRTMatch has a matching track.
void ProcessSubRun(const SubRun *subrun)
int mcparticle_id
MCParticle ID of the particle this track matches to (same as the ID of the RecoTrack of that particle...
void ProcessEvent(const event::Event *event)
std::vector< numu::flat::FlatInteraction > fInteractions
process_name use argoneut_mc_hitfinder track
bool is_contained
is it contained in a single cryostat active volume
const geo::GeometryCore * GetGeometryProvider() const
std::vector< TFile * > fOutputFiles
std::vector< numu::RecoEvent * > fRecoEvents
process_name standard_reco_uboone reco
float RangeMomentum(const numu::RecoTrack &track)
TVector3 start
start position of track
#define DECLARE_SBN_POSTPROCESSOR(classname)
for($it=0;$it< $RaceTrack_number;$it++)
float length
Length of track.
float MCSMomentum(const numu::RecoTrack &track)
std::vector< numu::MCType > fMCTypes
bool present
Whether this CRTMatch has a matching hit.
The standard subrun data definition.
void ProcessFileMeta(const FileMeta *meta)
bool has_match
Whether a track match exists.
The standard event data definition.
TrackTruthMatch match
Truth matching information.
std::string to_string(WindowPattern const &pattern)
int pdgid
Particle ID code.
void Initialize(fhicl::ParameterSet *config)
std::vector< std::string > ProcessClass(TClass *tclass, const std::string &prefix)
float angle
Angle between TPC track and CRT track.
std::string ClasstoNTupleName(const std::string &classname, const std::string &prefix)
TVector3 end
end position of track
std::vector< TNtuple * > fNtuples
void SetEvent(numu::RecoEvent &event, const event::Event &core, const ana::SBNOsc::Cuts &cuts, numu::MCType file_type, bool use_calorimetry=true)
ProviderManager * fProviderManager
Interface for provider access.
void Initialize(const fhicl::ParameterSet &cfg, const geo::GeometryCore *geometry)
Wall wall_enter
the face of the TPC that the particle crosses on enter
Wall wall_exit
the face of the TPC that the particle crosses on exit
HitMatch hit_match
CRT Hit match.
BEGIN_PROLOG could also be cout
float costh
cosine of angle to z axis
float start_time
start time of track
void FileSetup(TFile *f, TTree *eventTree)
std::vector< Interaction > truth
All truth interactions.
float time
Matching time [us] of track. T==0 is set to beam spill start time.