#ifndef __JAANETTESTKIT__ #define __JAANETTESTKIT__ #include "TRandom3.h" #include "km3net-dataformat/offline/Head.hh" #include "km3net-dataformat/offline/Evt.hh" #include "JAAnet/JPDB.hh" #include "JMath/JRandom.hh" /** * \author mdejong */ using JMATH::getRandom; /** * Global file format parameter. */ static bool use_root; /** * Randomize 3D vector. * * \param p pointer to valid object */ inline void randomize(Vec* p) { p->x = getRandom(); p->y = getRandom(); p->z = getRandom(); }; /** * Type definition for position. */ struct pos_type : public Vec {}; /** * Randomize position. * * \param p pointer to valid object */ inline void randomize(pos_type* p) { p->x = getRandom(-1.0e4, +1.0e4, 1.0); p->y = getRandom(-1.0e4, +1.0e4, 1.0); p->z = getRandom(-1.0e4, +1.0e4, 1.0); }; /** * Type definition for direction. */ struct dir_type : public Vec {}; /** * Randomize direction. * * \param p pointer to valid object */ inline void randomize(dir_type* p) { p->x = getRandom(-1.0, +1.0, 1.0e-3); p->y = getRandom(-1.0, +1.0, 1.0e-3); p->z = getRandom(-1.0, +1.0, 1.0e-3); }; /** * Randomize hit. * * \param p pointer to valid object */ inline void randomize(Hit* p) { p->id = getRandom(0, 1000); if (use_root) { p->dom_id = getRandom(0, 1000); p->channel_id = getRandom(0, 31); p->tdc = getRandom(); p->tot = getRandom(0, 256); p->trig = getRandom(0, 1000); } p->pmt_id = getRandom(0, 1000); p->t = getRandom(0.0, 100.0e6, 0.1); p->a = getRandom(0.0, 100.0e0, 0.1); if (use_root) { p->pos = getRandom(); p->dir = getRandom(); } p->type = getRandom(0, 1000); p->origin = getRandom(0, 1000); } /** * PDG particle type. */ struct pdg_type { operator int() const { return type; } int type; }; /** * Randomize PDG particle type. * * \param p pointer to valid object */ inline void randomize(pdg_type* p) { using namespace JAANET; const JPDB& pdb = JPDB::getInstance(); for ( ; ; ) { const JParticle& particle = pdb[getRandom(0, pdb.size())]; if ( (use_root) || (particle.geant != GEANT4_TYPE_NEUTRINO && particle.geant != 0) ) { p->type = abs(particle.pdg); return; } } } /** * Randomize track. * * \param p pointer to valid object */ inline void randomize(Trk* p) { p->id = getRandom(0, 1000); p->pos = getRandom(); p->dir = getRandom(); p->t = getRandom(0.0, 1.0e6, 1.0); p->E = getRandom(1.0, 1.0e6, 1.0); if (use_root) { p->len = getRandom(); p->lik = getRandom(); } p->type = getRandom(); p->comment = "track_in:"; // aanet storage specifier } /** * Randomize event. * * \param p pointer to valid object */ inline void randomize(Evt* p) { new (p) Evt(); if (use_root) { p->id = getRandom(0, 1000); p->det_id = getRandom(0, 1000); } p->mc_id = getRandom(0, 1000); if (use_root) { p->run_id = getRandom(0, 1000); p->mc_run_id = getRandom(0, 1000); p->frame_index = getRandom(0, 1000); p->trigger_mask = getRandom(0, 1000); p->trigger_counter = getRandom(0, 1000); } for (int i = getRandom(1, 1000); i != 0; --i) { p->mc_hits.push_back(getRandom()); } for (int i = getRandom(1, 100); i != 0; --i) { p->mc_trks.push_back(getRandom()); } if (use_root) { for (int i = getRandom(1, 1000); i != 0; --i) { p->hits.push_back(getRandom()); } for (int i = getRandom(1, 100); i != 0; --i) { p->trks.push_back(getRandom()); } } } /** * Equal operator hit. * * \param first first hit * \param second second hit * \return true if hits are equal; else false */ inline bool operator==(const Hit& first, const Hit& second) { return (first.id == second.id && first.channel_id == second.channel_id && first.tdc == second.tdc && first.tot == second.tot && first.trig == second.trig && first.pmt_id == second.pmt_id && first.t == second.t && first.a == second.a && first.pos == second.pos && first.dir == second.dir && first.type == second.type && first.origin == second.origin); } /** * Equal operator track. * * \param first first track * \param second second track * \return true if tracks are equal; else false */ inline bool operator==(const Trk& first, const Trk& second) { return (first.id == second.id && first.pos == second.pos && first.dir == second.dir && first.t == second.t && first.E == second.E && first.len == second.len && first.lik == second.lik && first.type == second.type && first.rec_type == second.rec_type && first.rec_stages == second.rec_stages && first.fitinf == second.fitinf && first.hit_ids == second.hit_ids && first.error_matrix == second.error_matrix); } /** * Equal operator event. * * \param first first event * \param second second event * \return true if events are equal; else false */ inline bool operator==(const Evt& first, const Evt& second) { return (first.id == second.id && first.det_id == second.det_id && first.mc_id == second.mc_id && first.run_id == second.run_id && first.mc_run_id == second.mc_run_id && first.frame_index == second.frame_index && first.trigger_mask == second.trigger_mask && first.trigger_counter == second.trigger_counter && first.hits == second.hits && first.trks == second.trks && first.mc_hits == second.mc_hits && first.mc_trks == second.mc_trks); } #endif