summaryrefslogtreecommitdiff
path: root/io/root.C
diff options
context:
space:
mode:
authorAnthony LaTorre <tlatorre9@gmail.com>2011-08-05 18:28:23 -0400
committerAnthony LaTorre <tlatorre9@gmail.com>2011-08-05 18:28:23 -0400
commit643f3df7b8538d5c52ea782ec3c22406cadc7c6e (patch)
treec93b44285888c2500fd0d85d58ca688db2ebe9b7 /io/root.C
parent97467c888720451e97dcd0881d90f61641f43b47 (diff)
parentd7f835b3325611ad25209c9a25256b46d4944827 (diff)
downloadchroma-643f3df7b8538d5c52ea782ec3c22406cadc7c6e.tar.gz
chroma-643f3df7b8538d5c52ea782ec3c22406cadc7c6e.tar.bz2
chroma-643f3df7b8538d5c52ea782ec3c22406cadc7c6e.zip
merge heads
Diffstat (limited to 'io/root.C')
-rw-r--r--io/root.C78
1 files changed, 78 insertions, 0 deletions
diff --git a/io/root.C b/io/root.C
new file mode 100644
index 0000000..dfcb3c0
--- /dev/null
+++ b/io/root.C
@@ -0,0 +1,78 @@
+#include <TVector3.h>
+#include <vector>
+#include <TTree.h>
+#include <string>
+
+struct Photon {
+ double t;
+ TVector3 pos;
+ TVector3 dir;
+ TVector3 pol;
+ double wavelength; // nm
+ int state;
+ int last_triangle;
+ int last_solid;
+};
+
+struct MC {
+ std::string particle;
+ TVector3 gen_pos;
+ TVector3 gen_dir;
+ double gen_ke;
+
+ std::vector<Photon> photon;
+
+ void clear() {
+ particle = "none";
+ photon.clear();
+ }
+};
+
+struct Channel {
+ Channel() : channel_id(-1), t(-9999.0), q(-9999.0) { };
+ int channel_id;
+ double t;
+ double q;
+};
+
+struct Event {
+ int event_id;
+ MC mc;
+ int nhit;
+ std::vector<Channel> channel;
+
+ void clear() {
+ mc.clear();
+ channel.clear();
+ }
+};
+
+void fill_event(TTree *T,
+ Event *ev, int event_id, double *gen_pos, int nchannels,
+ float *channel_times)
+{
+ ev->clear();
+ ev->event_id = event_id;
+ MC &mc = ev->mc;
+ mc.gen_pos.SetXYZ(gen_pos[0], gen_pos[1], gen_pos[2]);
+ ev->nhit = 0;
+ Channel ch;
+ for (int i=0; i < nchannels; i++) {
+ if (channel_times[i] < 1e8) {
+ ev->nhit++;
+ ch.channel_id = i;
+ ch.t = channel_times[i];
+ ch.q = 1.0;
+ ev->channel.push_back(ch);
+ }
+ }
+ T->Fill();
+}
+
+
+#ifdef __MAKECINT__
+#pragma link C++ class vector<Photon>;
+#pragma link C++ class vector<Channel>;
+#endif
+
+