Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventProcessor_BCAL_Hadronic_Eff.h
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: JEventProcessor_BCAL_Hadronic_Eff.h
4 //
5 
6 #ifndef _JEventProcessor_BCAL_Hadronic_Eff_
7 #define _JEventProcessor_BCAL_Hadronic_Eff_
8 
9 #include <JANA/JEventProcessor.h>
10 #include <JANA/JApplication.h>
11 
12 #include "TH1I.h"
13 #include "TH2I.h"
14 
15 #include "BCAL/DBCALShower.h"
16 #include "BCAL/DBCALPoint.h"
17 #include "BCAL/DBCALUnifiedHit.h"
18 #include "BCAL/DBCALGeometry.h"
19 #include "TRIGGER/DTrigger.h"
21 
22 #include "PID/DChargedTrack.h"
24 #include "PID/DParticleID.h"
25 #include "PID/DDetectorMatches.h"
26 #include "ANALYSIS/DCutActions.h"
28 
29 #include <vector>
30 #include <string>
31 #include <iostream>
32 #include <map>
33 #include <set>
34 #include <thread>
35 
36 using namespace jana;
37 using namespace std;
38 
39 class JEventProcessor_BCAL_Hadronic_Eff : public jana::JEventProcessor
40 {
41  public:
44  const char* className(void){return "JEventProcessor_BCAL_Hadronic_Eff";}
45 
46  private:
47  jerror_t init(void); ///< Called once at program start.
48  jerror_t brun(jana::JEventLoop* locEventLoop, int locRunNumber); ///< Called every time a new run number is detected.
49  jerror_t evnt(jana::JEventLoop* locEventLoop, uint64_t locEventNumber); ///< Called every event.
50  jerror_t erun(void); ///< Called every time run number changes, provided brun has been called.
51  jerror_t fini(void); ///< Called after last event of last event source has been processed.
52 
53  double Calc_AverageSector(const map<int, set<const DBCALPoint*> >& locBCALPoints);
54  double Calc_ProjectedSector(int locLayer, const map<int, map<int, set<const DBCALPoint*> > >& locSortedPoints);
55 
56  pair<const DBCALPoint*, double> Find_NearestPoint(double locProjectedSector, const map<int, set<const DBCALPoint*> >& locLayerBCALPoints, const DBCALCluster* locBCALCluster, double locTimeCut = -1.0);
57  pair<const DBCALUnifiedHit*, double> Find_NearestHit(double locProjectedSector, const map<int, set<const DBCALUnifiedHit*> >& locLayerUnifiedHits, const DBCALCluster* locBCALCluster, const DBCALGeometry *locBCALGeom, double locTimeCut = -1.0);
58 
59  const DBCALPoint* Find_ClosestTimePoint(const set<const DBCALPoint*>& locPoints, const DBCALCluster* locBCALCluster, double locTimeCut);
60  const DBCALUnifiedHit* Find_ClosestTimeHit(const set<const DBCALUnifiedHit*>& locHits, const DBCALCluster* locBCALCluster, double locTimeCut, const DBCALGeometry *locBCALGeom);
61 
62  template <typename DType> DType Calc_DeltaSector(DType locHitSector, DType locProjectedSector) const;
63 
64  bool Cut_BCALTiming(const DChargedTrackHypothesis* locChargedTrackHypothesis);
65 
66  //TRACK REQUIREMENTS
67  double dMinTrackingFOM, dMaxBCALDeltaT;
68  unsigned int dMinNumTrackHits;
69  int dMinHitRingsPerCDCSuperlayer, dMinHitPlanesPerFDCPackage;
70  double dMaxVertexR;
72 
73  //HISTOGRAMS
74  int dHistFoundDeltaSector; //for histograms ONLY!!!
75  map<int, map<bool, TH1I*> > dHistMap_HitFound, dHistMap_HitTotal; //int = layer, bool = isUpstream
76 
77  //TREE
79  //thread_local: Each thread has its own object: no lock needed
80  //important: manages it's own data internally: don't want to call new/delete every event!
81  static thread_local DTreeFillData dTreeFillData;
82 
83  //VERTEX-Z
85 
86  //EFFECTIVE VELOCITIES
87  vector<double> effective_velocities;
88 
89 };
90 
91 template <typename DType> inline DType JEventProcessor_BCAL_Hadronic_Eff::Calc_DeltaSector(DType locHitSector, DType locProjectedSector) const
92 {
93  //beware 2pi wrap-around!
94  double locDeltaSector = double(locHitSector) - locProjectedSector;
95  if(locDeltaSector > DType(96))
96  locDeltaSector -= DType(192);
97  if(locDeltaSector < -DType(96))
98  locDeltaSector += DType(192);
99  return locDeltaSector;
100 }
101 
102 #endif // _JEventProcessor_BCAL_Hadronic_Eff_
DType Calc_DeltaSector(DType locHitSector, DType locProjectedSector) const
map< int, map< bool, TH1I * > > dHistMap_HitTotal
DCutAction_TrackHitPattern * dCutAction_TrackHitPattern
static thread_local DTreeFillData dTreeFillData