Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DPTriggerAnalyzer.h
Go to the documentation of this file.
1 #ifndef DPTriggerAnalyzer_H
2 #define DPTriggerAnalyzer_H
3 #include <vector>
4 #include <string>
5 #include <iostream>
6 #include <set>
7 #include <list>
8 #include <map>
9 #include <string>
10 #include <TString.h>
11 #include <fun4all/SubsysReco.h>
12 class SQRun;
13 class SQEvent;
14 class SQHitVector;
15 
16 #define NTRPLANES 4
17 
19 {
20 public:
21  DPTriggerRoad();
22  DPTriggerRoad(const std::list<int>& path);
23 
25  void addTrElement(int uniqueID) { uniqueTrIDs.push_back(uniqueID); }
26  void addTrElement(int detectorID, int elementID) { addTrElement(detectorID*1000 + elementID); }
27 
29  int getTB();
30 
32  void flipTB();
33 
35 
36  int getRoadID() const { return roadID; }
37  double getSigWeight() const { return sigWeight; }
38  double getBkgRate() const { return bkgRate; }
39  double getPxMin() const { return pXmin; }
40  int getTrID(unsigned int i) const { return i < NTRPLANES ? uniqueTrIDs[i] : 0; }
41  int getTrDetectorID(unsigned int i) const { return getTrID(i)/1000; }
42  int getTrElementID(unsigned int i) const { return getTrID(i) % 1000; }
43  TString getStringID();
45 
47 
48  void setRoadID(int id) { roadID = id; }
49  void setSigWeight(double weight) { sigWeight = weight; }
50  void setBkgRate(double rate) { bkgRate = rate; }
51  void setPxMin(double pxmin) { pXmin = pxmin; }
53 
55 
56  bool operator == (const DPTriggerRoad& elem) const;
57  bool operator < (const DPTriggerRoad& elem) const;
59 
61  friend std::ostream& operator << (std::ostream& os, const DPTriggerRoad& road);
62 
63 private:
64 
66  int roadID;
67 
69  double sigWeight;
70 
72  double bkgRate;
73 
75  double pXmin;
76 
78  std::vector<int> uniqueTrIDs;
79 };
80 
82 {
83 public:
85  class MatrixNode;
86 
87 public:
88  typedef enum { NIM_AND, NIM_OR } NimMode;
89  DPTriggerAnalyzer(const std::string &name = "DPTriggerAnalyzer");
90  virtual ~DPTriggerAnalyzer();
91 
92  int Init(PHCompositeNode *topNode);
93  int InitRun(PHCompositeNode *topNode);
94  int process_event(PHCompositeNode *topNode);
95  int End(PHCompositeNode *topNode);
96 
97  const std::string& get_road_set_file_name() const {
98  return _road_set_file_name;
99  }
100 
101  void set_road_set_file_name(const std::string& roadSetFileName) {
102  _road_set_file_name = roadSetFileName;
103  }
104 
105  void set_nim_mode(const NimMode nim1, const NimMode nim2);
106 
108  void buildTriggerMatrix();
109 
111  //void analyzeTrigger(DPMCRawEvent* rawEvent);
112 
114  void searchMatrix(MatrixNode* node, int level, int index);
115 
117  void deleteMatrix(MatrixNode* node);
118 
120  std::list<DPTriggerRoad>& getRoadsFound(int index) { return roads_found[index]; }
121 
123  void printHitPattern();
124  void printPath();
125 
126 private:
127 
128  int GetNodes(PHCompositeNode *topNode);
129 
131  std::string _road_set_file_name;
132  NimMode _mode_nim1;
133  NimMode _mode_nim2;
134 
136  typedef std::vector<std::set<int> > TrHitPattern;
137  TrHitPattern data;
138 
140 
141  MatrixNode* matrix[2];
142  std::map<TString, DPTriggerRoad> roads[2];
144 
146  std::list<DPTriggerRoad> roads_found[2];
147 
149  std::list<int> path;
150 
152  bool NIMONLY;
153 
154  SQRun* _run_header;
155  SQEvent* _event_header;
156  SQHitVector* _hit_vector;
157 };
158 
160 {
161 public:
162  MatrixNode(int uID);
163 
165  void add(MatrixNode* child);
166 
167 public:
168  int uniqueID;
169  std::list<MatrixNode*> children;
170 };
171 
172 #endif
friend std::ostream & operator<<(std::ostream &os, const DPTriggerRoad &road)
printer
bool operator<(const DPTriggerRoad &elem) const
void printHitPattern()
Helper functions to print various things.
void setBkgRate(double rate)
int Init(PHCompositeNode *topNode)
void buildTriggerMatrix()
Build the trigger matrix by the input roads list.
void add(MatrixNode *child)
add a child
int End(PHCompositeNode *topNode)
Called at the end of all processing.
int InitRun(PHCompositeNode *topNode)
const std::string & get_road_set_file_name() const
bool operator==(const DPTriggerRoad &elem) const
comparison
DPTriggerAnalyzer(const std::string &name="DPTriggerAnalyzer")
int getTrElementID(unsigned int i) const
int getRoadID() const
Other gets.
void searchMatrix(MatrixNode *node, int level, int index)
Test the trigger pattern.
void setSigWeight(double weight)
void flipTB()
flip the LR or TB
void deleteMatrix(MatrixNode *node)
Tree deletion.
void addTrElement(int uniqueID)
add one hit into the road
void set_road_set_file_name(const std::string &roadSetFileName)
int process_event(PHCompositeNode *topNode)
std::list< MatrixNode * > children
int getTB()
Get the sign of LR or TB.
int getTrID(unsigned int i) const
void addTrElement(int detectorID, int elementID)
double getBkgRate() const
An SQ interface class to hold a list of SQHit objects.
Definition: SQHitVector.h:32
double getPxMin() const
An SQ interface class to hold one event header.
Definition: SQEvent.h:17
std::list< DPTriggerRoad > & getRoadsFound(int index)
Helper function to retrieve the found road list.
An SQ interface class to hold the run-level info.
Definition: SQRun.h:18
double getSigWeight() const
void set_nim_mode(const NimMode nim1, const NimMode nim2)
void setPxMin(double pxmin)
void setRoadID(int id)
Sets.
int getTrDetectorID(unsigned int i) const
#define NTRPLANES