Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DEventSourceHDDM.h
Go to the documentation of this file.
1 // Author: David Lawrence June 24, 2004
2 //
3 //
4 // DEventSourceHDDM
5 //
6 /// Implements JEventSource for HDDM files
7 //
8 // Changes: Oct 3, 2012 Yi Qiang: add classes for Cerenkov detector
9 // OCt 10, 2012 Yi Qiang: modifed Cerenkov classes with general Cere hits
10 // Oct 8, 2013 Yi Qiang: added dedicated object for RICH Truth Hit
11 // June 22, 2015 J. Stevens: changed RICH -> DIRC and remove CERE
12 // May 7, 2017 R. Dzhygadlo: added DDIRCTruthPmtHit DDIRCTruthBarHit
13 
14 #ifndef _JEVENT_SOURCEHDDM_H_
15 #define _JEVENT_SOURCEHDDM_H_
16 
17 #include <vector>
18 #include <string>
19 using namespace std;
20 
21 #include <pthread.h>
22 
23 #include <JANA/JEventSource.h>
24 #include <JANA/jerror.h>
25 #include <JANA/JCalibration.h>
26 
27 #include <HDDM/hddm_s.hpp>
28 
29 #include "TRACKING/DMCTrackHit.h"
30 #include "TRACKING/DMCThrown.h"
32 #include "BCAL/DBCALSiPMHit.h"
33 #include "BCAL/DBCALSiPMSpectrum.h"
34 #include "BCAL/DBCALDigiHit.h"
36 #include "BCAL/DBCALTDCDigiHit.h"
37 #include "BCAL/DBCALTruthShower.h"
38 #include "BCAL/DBCALTruthCell.h"
39 #include "BCAL/DBCALGeometry.h"
40 #include "CDC/DCDCHit.h"
41 #include "FDC/DFDCHit.h"
42 #include "FCAL/DFCALTruthShower.h"
43 #include "FCAL/DFCALHit.h"
44 #include "CCAL/DCCALTruthShower.h"
45 #include "CCAL/DCCALHit.h"
46 #include "TOF/DTOFTruth.h"
47 #include "TOF/DTOFHit.h"
48 #include "TOF/DTOFHitMC.h"
50 #include "START_COUNTER/DSCHit.h"
51 #include <PID/DMCReaction.h>
52 #include <PID/DBeamPhoton.h>
54 #include <TAGGER/DTAGMHit.h>
55 #include <TAGGER/DTAGHHit.h>
56 #include <TAGGER/DTAGMGeometry.h>
57 #include <TAGGER/DTAGHGeometry.h>
58 // load CERE headers, yqiang Oct 3, 2012
59 // modified by yqiang, Oct 10 2012
60 // added RichTruthHit object, yqiang, Oct 7, 2013
61 #include <CERE/DCereHit.h>
62 #include "DIRC/DDIRCTruthBarHit.h"
63 #include "DIRC/DDIRCTruthPmtHit.h"
64 #include "DIRC/DDIRCPmtHit.h"
65 #include <RF/DRFTime.h>
66 #include <DANA/DApplication.h>
71 #include "FMWPC/DFMWPCTruthHit.h"
72 #include "FMWPC/DFMWPCHit.h"
74 #include "TPOL/DTPOLHit.h"
75 #include "TPOL/DTPOLTruthHit.h"
76 #include "DResourcePool.h"
77 
78 class DEventSourceHDDM:public JEventSource
79 {
80  public:
81  DEventSourceHDDM(const char* source_name);
82  virtual ~DEventSourceHDDM();
83  virtual const char* className(void){return static_className();}
84  static const char* static_className(void){return "DEventSourceHDDM";}
85 
86  jerror_t GetEvent(JEvent &event);
87  void FreeEvent(JEvent &event);
88  jerror_t GetObjects(JEvent &event, JFactory_base *factory);
89 
90  jerror_t Extract_DMCTrackHit(hddm_s::HDDM *record, JFactory<DMCTrackHit> *factory, string tag);
91  jerror_t GetCDCTruthHits(hddm_s::HDDM *record, vector<DMCTrackHit*>& data);
92  jerror_t GetFDCTruthHits(hddm_s::HDDM *record, vector<DMCTrackHit*>& data);
93  jerror_t GetBCALTruthHits(hddm_s::HDDM *record, vector<DMCTrackHit*>& data);
94  jerror_t GetTOFTruthHits(hddm_s::HDDM *record, vector<DMCTrackHit*>& data);
95  jerror_t GetCherenkovTruthHits(hddm_s::HDDM *record, vector<DMCTrackHit*>& data);
96  jerror_t GetFCALTruthHits(hddm_s::HDDM *record, vector<DMCTrackHit*>& data);
97  jerror_t GetCCALTruthHits(hddm_s::HDDM *record, vector<DMCTrackHit*>& data);
98  jerror_t GetSCTruthHits(hddm_s::HDDM *record, vector<DMCTrackHit*>& data);
99 
100  jerror_t Extract_DRFTime(hddm_s::HDDM *record, JFactory<DRFTime> *factory, JEventLoop* locEventLoop);
101  jerror_t Extract_DBCALTruthShower(hddm_s::HDDM *record, JFactory<DBCALTruthShower> *factory, string tag);
102  jerror_t Extract_DBCALTruthCell(hddm_s::HDDM *record, JFactory<DBCALTruthCell> *factory, string tag);
103  jerror_t Extract_DBCALSiPMHit(hddm_s::HDDM *record, JFactory<DBCALSiPMHit> *factory, string tag);
104  jerror_t Extract_DBCALSiPMSpectrum(hddm_s::HDDM *record, JFactory<DBCALSiPMSpectrum>* factory, string tag);
105  jerror_t Extract_DBCALDigiHit(hddm_s::HDDM *record, JFactory<DBCALDigiHit> *factory, string tag);
106  jerror_t Extract_DBCALIncidentParticle(hddm_s::HDDM *record, JFactory<DBCALIncidentParticle> *factory, string tag);
107  jerror_t Extract_DBCALTDCDigiHit(hddm_s::HDDM *record, JFactory<DBCALTDCDigiHit> *factory, string tag);
108  jerror_t Extract_DMCReaction(hddm_s::HDDM *record, JFactory<DMCReaction> *factory, string tag, JEventLoop *loop);
109  jerror_t Extract_DMCThrown(hddm_s::HDDM *record, JFactory<DMCThrown> *factory, string tag);
110  jerror_t Extract_DCDCHit(JEventLoop* locEventLoop, hddm_s::HDDM *record, JFactory<DCDCHit> *factory, string tag);
111  jerror_t Extract_DFDCHit(hddm_s::HDDM *record, JFactory<DFDCHit> *factory, string tag);
112  jerror_t Extract_DFCALTruthShower(hddm_s::HDDM *record, JFactory<DFCALTruthShower> *factory, string tag);
113  jerror_t Extract_DCCALHit(hddm_s::HDDM *record, JFactory<DCCALHit> *factory, string tag, JEventLoop* eventLoop);
114  jerror_t Extract_DCCALTruthShower(hddm_s::HDDM *record, JFactory<DCCALTruthShower> *factory, string tag);
115  jerror_t Extract_DFCALHit(hddm_s::HDDM *record, JFactory<DFCALHit> *factory, string tag, JEventLoop* eventLoop);
116  jerror_t Extract_DMCTrajectoryPoint(hddm_s::HDDM *record, JFactory<DMCTrajectoryPoint> *factory, string tag);
117  jerror_t Extract_DTOFTruth(hddm_s::HDDM *record, JFactory<DTOFTruth> *factory, string tag);
118 
119  jerror_t Extract_DTOFHit( hddm_s::HDDM *record, JFactory<DTOFHit>* factory, JFactory<DTOFHitMC>* factoryMC, string tag);
120  jerror_t Extract_DTOFHitMC( hddm_s::HDDM *record, JFactory<DTOFHitMC>* factoryMC, JFactory<DTOFHit>* factory, string tag);
121 
122  jerror_t Extract_DSCHit(hddm_s::HDDM *record, JFactory<DSCHit> *factory, string tag);
123  jerror_t Extract_DSCTruthHit(hddm_s::HDDM *record, JFactory<DSCTruthHit> *factory, string tag);
124 
125  jerror_t Extract_DTrackTimeBased(hddm_s::HDDM *record, JFactory<DTrackTimeBased> *factory, string tag, int32_t runnumber, JEventLoop* locEventLoop);
126  string StringToTMatrixFSym(string &str_vals, TMatrixFSym* mat, int Nrows, int Ncols);
127 
128  jerror_t Extract_DTAGMHit( hddm_s::HDDM *record, JFactory<DTAGMHit>* factory, string tag);
129  jerror_t Extract_DTAGHHit( hddm_s::HDDM *record, JFactory<DTAGHHit>* factory, string tag);
130 
131  jerror_t Extract_DPSHit(hddm_s::HDDM *record,JFactory<DPSHit>* factory,
132  string tag);
133  jerror_t Extract_DPSCHit(hddm_s::HDDM *record,JFactory<DPSCHit>* factory,
134  string tag);
135  jerror_t Extract_DPSTruthHit(hddm_s::HDDM *record,JFactory<DPSTruthHit>* factory,
136  string tag);
137  jerror_t Extract_DPSCTruthHit(hddm_s::HDDM *record,JFactory<DPSCTruthHit>* factory,
138  string tag);
139  jerror_t Extract_DFMWPCTruthHit(hddm_s::HDDM *record, JFactory<DFMWPCTruthHit> *factory, string tag);
140  jerror_t Extract_DFMWPCHit(hddm_s::HDDM *record, JFactory<DFMWPCHit> *factory, string tag);
141 
142  jerror_t Extract_DTPOLHit(hddm_s::HDDM *record, JFactory<DTPOLHit>* factory, string tag);
143  jerror_t Extract_DTPOLTruthHit(hddm_s::HDDM *record, JFactory<DTPOLTruthHit>* factory, string tag);
144 
145  Particle_t IDTrack(float locCharge, float locMass) const;
146 
147  // add RICH hit and Truth, yqiang Oct 3, 2012
148  // modifed by yqiang, Oct 10 2012 now include both truth hits in DMCThrown
149  // Oct 8, 2013, added dedicated object for RICH truth hit
150  jerror_t Extract_DCereHit(hddm_s::HDDM *record, JFactory<DCereHit> *factory, string tag);
151  jerror_t Extract_DDIRCTruthBarHit(hddm_s::HDDM *record, JFactory<DDIRCTruthBarHit> *factory, string tag);
152  jerror_t Extract_DDIRCTruthPmtHit(hddm_s::HDDM *record, JFactory<DDIRCTruthPmtHit> *factory, string tag);
153  jerror_t Extract_DDIRCPmtHit(hddm_s::HDDM *record, JFactory<DDIRCPmtHit> *factory, string tag, JEventLoop* eventLoop);
154 
155  std::ifstream *ifs;
156  hddm_s::istream *fin;
159  const DGeometry *geom;
160 
161  private:
164  static thread_local shared_ptr<DResourcePool<TMatrixFSym>> dResourcePool_TMatrixFSym;
165 
166  map<unsigned int, double> dTargetCenterZMap; //unsigned int is run number
167  map<unsigned int, double> dBeamBunchPeriodMap; //unsigned int is run number
168 
170 
172 
173 
174  JCalibration *jcalib;
175  float uscale[192],vscale[192];
176 
177 };
178 
179 #endif //_JEVENT_SOURCEHDDM_H_
hddm_s::istream * fin
const int Ncols
const DMagneticFieldMap * bfield
JCalibration * jcalib
const DGeometry * geom
virtual const char * className(void)
DApplication * dapp
map< unsigned int, double > dBeamBunchPeriodMap
const DPSGeometry * psGeom
static const char * static_className(void)
const DBCALGeometry * dBCALGeom
map< unsigned int, double > dTargetCenterZMap
static thread_local shared_ptr< DResourcePool< TMatrixFSym > > dResourcePool_TMatrixFSym
std::ifstream * ifs
static Particle_t IDTrack(float locCharge, float locMass)
Particle_t
Definition: particleType.h:12