summaryrefslogtreecommitdiff
path: root/fileio/root.C
diff options
context:
space:
mode:
authorAnthony LaTorre <tlatorre9@gmail.com>2011-09-02 12:12:38 -0400
committerAnthony LaTorre <tlatorre9@gmail.com>2011-09-02 12:12:38 -0400
commit707ca1b366f11032682cc864ca2848905e6b485c (patch)
treee0e66c498cb29168acb0f8fab8479b12489b2f30 /fileio/root.C
parent7e2a7e988031c22898249f3801aa0d3c690bb729 (diff)
downloadchroma-707ca1b366f11032682cc864ca2848905e6b485c.tar.gz
chroma-707ca1b366f11032682cc864ca2848905e6b485c.tar.bz2
chroma-707ca1b366f11032682cc864ca2848905e6b485c.zip
update event structure. break gpu.GPU class into separate smaller independent classes.
Diffstat (limited to 'fileio/root.C')
-rw-r--r--fileio/root.C209
1 files changed, 93 insertions, 116 deletions
diff --git a/fileio/root.C b/fileio/root.C
index 07e50a1..2b39b1b 100644
--- a/fileio/root.C
+++ b/fileio/root.C
@@ -3,166 +3,143 @@
#include <TTree.h>
#include <string>
+struct Vertex {
+ std::string particle_name;
+ TVector3 pos;
+ TVector3 dir;
+ TVector3 pol;
+ double ke;
+ double t0;
+
+ ClassDef(Vertex, 1);
+};
+
struct Photon {
- double time;
- TVector3 position;
- TVector3 direction;
- TVector3 polarization;
+ double t;
+ TVector3 pos;
+ TVector3 dir;
+ TVector3 pol;
double wavelength; // nm
- unsigned int history;
+ unsigned int flag;
int last_hit_triangle;
ClassDef(Photon, 1);
};
-struct Track {
- std::string particle;
- TVector3 position;
- TVector3 direction;
- double start_time;
- double total_energy;
+struct Channel {
+ Channel() : id(-1), t(-1e9), q(-1e9) { };
+ int id;
+ double t;
+ double q;
+ unsigned int flag;
- ClassDef(Track, 1);
+ ClassDef(Channel, 1);
};
-struct MC {
- std::string particle;
- TVector3 gen_position;
- TVector3 gen_direction;
- double gen_total_energy;
-
- int nphoton;
-
- std::vector<Track> subtrack;
- std::vector<Photon> photon_start;
- std::vector<Photon> photon_stop;
+struct Event {
+ int id;
+ unsigned int nhit;
+ unsigned int nchannels;
- ClassDef(MC, 1);
-};
+ Vertex primary_vertex;
-struct Channel {
- Channel() : channel_id(-1), time(-9999.0), charge(-9999.0) { };
- int channel_id;
- double time;
- double charge;
- unsigned int mc_history;
+ std::vector<Vertex> vertices;
+ std::vector<Photon> photons_beg;
+ std::vector<Photon> photons_end;
+ std::vector<Channel> channels;
- ClassDef(Channel, 1);
+ ClassDef(Event, 1);
};
-
-struct Event {
- int event_id;
- MC mc;
- int nhit;
- int max_channel_id;
- std::vector<Channel> channel;
- ClassDef(Event, 1);
+void fill_channels(Event *ev, unsigned int nhit, unsigned int *ids, float *t,
+ float *q, unsigned int *flags, unsigned int nchannels)
+{
+ ev->nhit = 0;
+ ev->nchannels = nchannels;
+ ev->channels.resize(0);
- // 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, unsigned int *mc_history=0)
- {
- for (unsigned int i=0; i < nentries; i++) {
- hit[i] = 0;
- time[i] = -1e9f;
- charge[i] = -1e9f;
- if (mc_history)
- mc_history[i] = 0;
- }
+ Channel ch;
+ unsigned int id;
+ for (unsigned int i=0; i < nhit; i++) {
+ ev->nhit++;
+ id = ids[i];
+ ch.id = id;
+ ch.t = t[id];
+ ch.q = q[id];
+ ch.flag = flags[id];
+ ev->channels.push_back(ch);
+ }
+}
+
+void get_channels(Event *ev, int *hit, float *t, float *q, unsigned int *flags)
+{
+ for (unsigned int i=0; i < ev->nchannels; i++) {
+ hit[i] = 0;
+ t[i] = -1e9f;
+ q[i] = -1e9f;
+ flags[i] = 0;
+ }
- for (unsigned int i=0; i < channel.size(); i++) {
- unsigned int channel_id = channel[i].channel_id;
+ unsigned int id;
+ for (unsigned int i=0; i < ev->channels.size(); i++) {
+ id = ev->channels[i].id;
- if (channel_id < nentries) {
- hit[channel_id] = 1;
- time[channel_id] = channel[i].time;
- charge[channel_id] = channel[i].charge;
- if (mc_history)
- mc_history[channel_id] = channel[i].mc_history;
- }
+ if (id < ev->nchannels) {
+ hit[id] = 1;
+ t[id] = ev->channels[i].t;
+ q[id] = ev->channels[i].q;
+ flags[id] = ev->channels[i].flag;
}
}
+}
-};
-
-void get_photons(const std::vector<Photon> &photons, float *positions,
- float *directions, float *polarizations, float *wavelengths,
- float *times, unsigned int *histories, int *last_hit_triangles)
+void get_photons(const std::vector<Photon> &photons, float *pos, float *dir,
+ float *pol, float *wavelengths, float *t,
+ int *last_hit_triangles, unsigned int *flags)
{
for (unsigned int i=0; i < photons.size(); i++) {
const Photon &photon = photons[i];
- positions[3*i] = photon.position.X();
- positions[3*i+1] = photon.position.Y();
- positions[3*i+2] = photon.position.Z();
+ pos[3*i] = photon.pos.X();
+ pos[3*i+1] = photon.pos.Y();
+ pos[3*i+2] = photon.pos.Z();
- directions[3*i] = photon.direction.X();
- directions[3*i+1] = photon.direction.Y();
- directions[3*i+2] = photon.direction.Z();
+ dir[3*i] = photon.dir.X();
+ dir[3*i+1] = photon.dir.Y();
+ dir[3*i+2] = photon.dir.Z();
- polarizations[3*i] = photon.polarization.X();
- polarizations[3*i+1] = photon.polarization.Y();
- polarizations[3*i+2] = photon.polarization.Z();
+ pol[3*i] = photon.pol.X();
+ pol[3*i+1] = photon.pol.Y();
+ pol[3*i+2] = photon.pol.Z();
wavelengths[i] = photon.wavelength;
- times[i] = photon.time;
- histories[i] = photon.history;
+ t[i] = photon.t;
+ flags[i] = photon.flag;
last_hit_triangles[i] = photon.last_hit_triangle;
}
}
-
void fill_photons(std::vector<Photon> &photons,
unsigned int nphotons, float *pos, float *dir,
- float *pol, float *wavelength, float *t0,
- unsigned int *histories=0, int *last_hit_triangle=0)
+ float *pol, float *wavelengths, float *t,
+ int *last_hit_triangles, unsigned int *flags)
{
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;
- ev->max_channel_id = nchannels - 1;
+ photon.t = t[i];
+ photon.pos.SetXYZ(pos[3*i], pos[3*i + 1], pos[3*i + 2]);
+ photon.dir.SetXYZ(dir[3*i], dir[3*i + 1], dir[3*i + 2]);
+ photon.pol.SetXYZ(pol[3*i], pol[3*i + 1], pol[3*i + 2]);
+ photon.wavelength = wavelengths[i];
+ photon.last_hit_triangle = last_hit_triangles[i];
+ photon.flag = flags[i];
- 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<Track>;
+#pragma link C++ class vector<Vertex>;
#pragma link C++ class vector<Photon>;
#pragma link C++ class vector<Channel>;
#endif