Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DEventProcessor_mc_tree.h
Go to the documentation of this file.
1 /*
2  * DEventProcessor_mc_tree.h
3  *
4  * Created on: Aug 1, 2012
5  * Author: yqiang
6  *
7  * Modified on:
8  * Sep 28, 2012, yqiang, added RICH hits to ROOTfile
9  * Oct 10 2012, yqiang, add full Cherenkov support
10  * Oct 7, 2013, yqiang, add dedicated object for RICH truth hit
11  *
12  */
13 
14 #ifndef DEVENTPROCESSOR_MC_TREE_H_
15 #define DEVENTPROCESSOR_MC_TREE_H_
16 
17 #include <iostream>
18 #include <vector>
19 using namespace std;
20 
21 #include <JANA/JFactory.h>
22 #include <JANA/JEventProcessor.h>
23 #include <JANA/JEventLoop.h>
24 #include <JANA/JApplication.h>
25 using namespace jana;
26 
27 #include <TRACKING/DMCThrown.h>
28 #include <TRACKING/DMCTrackHit.h>
29 #include <FDC/DFDCHit.h>
30 #include <CDC/DCDCTrackHit.h>
31 #include <PID/DParticleSet.h>
32 #include <PID/DKinematicData.h>
33 #include <PID/DBeamPhoton.h>
34 #include <RICH/DRichHit.h>
35 #include <CERE/DCereHit.h>
36 #include <RICH/DRichTruthHit.h>
37 
38 #include <TMath.h>
39 #include <TFile.h>
40 #include <TTree.h>
41 #include <TDirectoryFile.h>
42 #include <TThread.h>
43 #include <TLorentzVector.h>
44 #include <TVector3.h>
45 #include <TROOT.h>
46 #include <TClonesArray.h>
47 using namespace ROOT;
48 
49 #include "Event.h"
50 #include "Particle.h"
51 #include "RichHit.h"
52 #include "CereHit.h"
53 #include "RichTruthHit.h"
54 
55 class DEventProcessor_mc_tree: public JEventProcessor {
56 
57 public:
60 
61  class particle_set {
62  public:
63  vector<Particle> photons;
64  vector<Particle> neutrons;
65  vector<Particle> piplus;
66  vector<Particle> piminus;
67  vector<Particle> protons;
68  vector<Particle> Kplus;
69  vector<Particle> Kminus;
70  vector<Particle> electrons;
71  vector<Particle> positrons;
72  vector<RichHit> richhits;
73  vector<CereHit> cerehits;
74  vector<RichTruthHit> richtruthhits;
75  };
76 
77  class hit_set {
78  public:
79  Int_t hits_cdc; // Number of hits in CDC
80  Int_t hits_fdc; // Number of hits in FDC
81  Int_t hits_bcal; // Number of hits in BCAL
82  Int_t hits_fcal; // Number of hits in FCAL
83  Int_t hits_upv; // Number of hits in UPV
84  Int_t hits_tof; // Number of hits in TOF
85  Int_t hits_rich; // Number of hits in RICH
86  Int_t hits_cere; // Number of hits in Cherenkov
87  };
88 
90  TTree *tree_thrown;
91 
92  pthread_mutex_t mutex;
93 
94 private:
95  jerror_t init(void); ///< Invoked via DEventProcessor virtual method
96  jerror_t evnt(JEventLoop *loop, uint64_t eventnumber);///< Invoked via DEventProcessor virtual method
97  jerror_t erun(void); ///< Invoked via DEventProcessor virtual method
98  jerror_t fini(void); ///< Invoked via DEventProcessor virtual method
99 
100  bool static CompareLorentzEnergy(const Particle &a, const Particle &b) {
101  return a.p.E() < b.p.E();
102  }
103 
104  Particle MakeParticle(const DKinematicData *kd, double mass, hit_set hits);
105  RichHit MakeRichHit(const DRichHit *rhit);
106  CereHit MakeCereHit(const DCereHit *chit);
107  RichTruthHit MakeRichTruthHit(const DRichTruthHit *rthit);
108  void FillEvent(Event *evt, particle_set &pset);
109  bool IsFiducial(const DKinematicData *kd);
110 };
111 
112 #endif /* DEVENTPROCESSOR_MC_TREE_H_ */
static bool CompareLorentzEnergy(const Particle &a, const Particle &b)
TLorentzVector p