StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
gl3Conductor.h
1 //:>------------------------------------------------------------------
2 //: FILE: gl3Conductor.h
3 //: HISTORY:
4 //: 1feb2000 version 1.00
5 //: 6jul2000 add St_l3_Coordinate_Transformer
6 //: 16jul2000 add runStart and runEnd
7 //: 17jul2000 add runNumber
8 //: 18jul2000 add timing information
9 //: 27jul2000 add print timing
10 //: 13aug2000 replace trackMerging with maxSectorNForTrackMerging
11 //: 24aug2000 move functionality of the constructor into setup
12 //: function. this has to be called directly now
13 //:<------------------------------------------------------------------
14 #include "Stl3Util/gl3/gl3Event.h"
15 #include "Stl3Util/gl3/gl3Algorithm.h"
16 
17 #include "Stl3Util/base/St_l3_Coordinate_Transformer.h"
18 
19 #include "Stl3Util/foreign/RC_Config.h"
20 
21 #include <stdio.h>
22 #include <math.h>
23 #include <list>
24 #include <vector>
25 
26 #ifndef GL3CONDUCTOR
27 #define GL3CONDUCTOR
28 
29 #define NTOKENS 4096
30 
31 typedef gl3Algorithm* pGl3Algorithm ;
32 
34 public:
35  short accept ;
36  short build ;
37  int status[4];
38  gl3EventDecision ( ):accept(0),build(0)
39  {
40  for(int i = 0 ; i < 4 ; i++ )
41  status[i] = 0 ;
42  } ;
43 };
44 
45 
46 class gl3HistoContainer {
47 public:
48  int nBytes;
49  int nHistos;
50  int runNumber ;
51  int buffer;
52 };
53 
54 class gl3Conductor {
55 
56 
57 public:
58  short maxEvents ;
59  short maxAlgorithms ;
60  short communicationsFlag ;
61  int nEvents ;
62  int nAlgorithms ;
63  int maxTokens ;
64  int runNumber ;
65  pGl3Algorithm* algorithm ;
66  int* tokenIndex ;
67  // unsigned int mask[32];
68 
69  //
70  // Options
71  //
72  short hitProcessing ; // 0 = does read hits
73  // 1 = reassigns trackId in hits to
74  // pass that info downstream
75  // 2 = full hit unpacking for module use
76  int maxSectorNForTrackMerging ; // Max multipliticy for track merging
77 
78  public:
79  gl3Conductor (void ) ; // empty constructor, functionality moved to setup
80  ~gl3Conductor ( ) ;
81 
82  //int configure (char *file);
83  int configure (L3_CFG *cfg);
84  int add ( gl3Algorithm* algorithm ) ;
85 
86 
87  int fillSummary(int token, struct L3_summary*, struct L3_SUMD *);
88  int collectSummary(int token);
89  int fillTracks(int token);
90 
91  void clearAlgorithms();
92  int checkHistoRequest() ;
93  int init ( ) ;
94 
95  int processEvent(EventDescriptor *desc, L3_P* l3data,
96  TrgSumData* = NULL, RawTrgDet* = NULL);
97 
98  // int processEvent(int token, L3_P* l3data,
99  // TrgSumData* = NULL, RawTrgDet* = NULL);
100 
101  gl3Event* getEvent ( int token ) ;
102  int releaseToken ( int token ) ;
103  int resetHistos ( ) ;
104  int runStart ( int _runNumber ) ;
105  int runEnd ( ) ;
106  int end ( ) ;
107 
108 
109  void setBField ( float bField ) ;
110  void setHitProcessing ( int hitPro ) ;
111  void setMaxSectorNForTrackMerging ( int _trackMerging ) ;
112  int setup ( St_l3_Coordinate_Transformer* _trans,
113  int maxEvents=1, int maxAlgorithm=10 ) ;
114  int setCommunications ( ) ;
115  int writeHistos ( int maxBytes, char *buffer ) ;
116 
117  private:
118  int getFreeEventIndex();
119  int getTokenIndex(int);
120 
121  gl3Event* event ;
122  L3_summary* summary;
123  L3_SUMD* summaryData;
124 
125  int nReco;
126 
127 
128  // Histogramming/histo communication stuff
129  list<gl3Histo *> histoList ;
130  gl3Histo* l3Rates;
131 
132 
133  int socketFd, remoteSocket ;
134  int gl3Port ;
135 
136  // Timing
137  void resetTimer();
138  void timingMark();
139 
140  void allocateTimingHistos();
141  void fillTimingHistos();
142 
143  void printTiming();
144 
145  int lastTimeEntry;
146  vector<unsigned long> cpuTimes, realTimes;
147  vector<gl3Histo*> timingHistos;
148 
149  double ccPerMs;
150 };
151 #endif