#include #include #include #include struct Photon { double time; TVector3 position; TVector3 direction; TVector3 polarization; double wavelength; // nm unsigned int history; int last_hit_triangle; }; struct Track { std::string particle; double time; TVector3 position; TVector3 direction; double start_time; double total_energy; }; struct MC { std::string particle; TVector3 gen_position; TVector3 gen_direction; double gen_total_energy; int nphoton; std::vector subtrack; std::vector photon_start; std::vector photon_stop; }; struct Channel { Channel() : channel_id(-1), time(-9999.0), charge(-9999.0) { }; int channel_id; double time; double charge; unsigned int mc_history; }; struct Event { int event_id; MC mc; int nhit; std::vector channel; // Populate arrays of length nentries with hit, time, and charge // information, indexed by channel ID void get_channels(unsigned int nentries, int *hit, float *time, float *charge) { for (unsigned int i=0; i < nentries; i++) { hit[i] = 0; time[i] = -1e9f; charge[i] = -1e9f; } for (unsigned int i=0; i < channel.size(); i++) { unsigned int channel_id = channel[i].channel_id; if (channel_id < nentries) { hit[channel_id] = 1; time[channel_id] = channel[i].time; charge[channel_id] = channel[i].charge; } } } }; void fill_photons(Event *ev, bool start, unsigned int nphotons, float *pos, float *dir, float *pol, float *wavelength, float *t0, int *histories=0, int *last_hit_triangle=0) { std::vector &photons = start ? ev->mc.photon_start : ev->mc.photon_stop; photons.resize(nphotons); for (unsigned int i=0; i < nphotons; i++) { Photon &photon = photons[i]; photon.time = t0[i]; photon.position.SetXYZ(pos[3*i], pos[3*i + 1], pos[3*i + 2]); photon.direction.SetXYZ(dir[3*i], dir[3*i + 1], dir[3*i + 2]); photon.polarization.SetXYZ(pol[3*i], pol[3*i + 1], pol[3*i + 2]); photon.wavelength = wavelength[i]; if (histories) photon.history = histories[i]; else photon.history = 0; if (last_hit_triangle) photon.last_hit_triangle = last_hit_triangle[i]; else photon.last_hit_triangle = -1; } } void fill_hits(Event *ev, unsigned int nchannels, float *time, float *charge, unsigned int *history) { ev->channel.resize(0); ev->nhit = 0; Channel ch; for (unsigned int i=0; i < nchannels; i++) { if (time[i] < 1e8) { ev->nhit++; ch.channel_id = i; ch.time = time[i]; ch.charge = charge[i]; ch.mc_history = history[i]; ev->channel.push_back(ch); } } } #ifdef __MAKECINT__ #pragma link C++ class vector; #pragma link C++ class vector; #pragma link C++ class vector; #endif