CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MatacqProducer.h
Go to the documentation of this file.
1 #ifndef PRODUCER_H
2 #define PRODUCER_H
3 
4 //#define USE_STORAGE_MANAGER
5 
6 #ifdef USE_STORAGE_MANAGER
9 #else //USE_STORAGE_MANAGER not defined
10 # ifndef _LARGEFILE64_SOURCE
11 # define _LARGEFILE64_SOURCE
12 # endif //_LARGEFILE64_SOURCE not defined
13 # define _FILE_OFFSET_BITS 64
14 # include <stdio.h>
15 #endif //USE_STORAGE_MANAGER defined
16 
17 
24 
25 #include <string>
26 #include <inttypes.h>
27 #include <fstream>
28 #include <memory>
29 
30 #include <sys/time.h>
31 
32 struct NullOut{
33  NullOut&
34  operator<<(std::ostream& (*pf)(std::ostream&)){
35  return *this;
36  }
37  template<typename T>
38  inline NullOut& operator<<(const T& a){
39  return *this;
40  }
41 };
42 
44 {
45 public:
47  laserType = 4,
48  ledType = 5,
49  tpType = 6,
50  pedType = 7
51  };
52 private:
53 #ifdef USE_STORAGE_MANAGER
54  typedef IOOffset filepos_t;
55  typedef std::auto_ptr<Storage> FILE_t;
56 #else
57  typedef off_t filepos_t;
58  typedef FILE* FILE_t;
59 #endif
60  struct MatacqEventId{
61  MatacqEventId(): run(0), orbit(0){}
62  MatacqEventId(uint32_t r, uint32_t o): run(r), orbit(o){}
63 
66  uint32_t run;
67 
70  uint32_t orbit;
71 
72  bool
74  return (this->run < a.run)
75  || ((this->run == a.run) && (this->orbit < a.orbit));
76  }
77 
78  bool
80  return (this->run > a.run)
81  || ((this->run == a.run) && (this->orbit > a.orbit));
82  }
83 
84  bool
86  return !((*this) < a || (*this) > a);
87  }
88  };
89 
90 
97  class PosEstimator{
98  //Note: a better estimate could be obtained by using segment of linear
99  //functions. In such implementation, the estimator must be updated
100  //each time a point with wrong estimate has been found.
101  public:
103  invalid_(true), verbosity_(0) { }
104  void init(MatacqProducer* mp);
105  bool invalid() const { return invalid_; }
106  int64_t pos(int orb) const;
107  int eventLength() const { return eventLength_; }
108  int firstOrbit() const { return firstOrbit_; }
109  void verbosity(int verb) { verbosity_ = verb; }
110  private:
114  bool invalid_;
116  };
117 
118 public:
122  explicit
123  MatacqProducer(const edm::ParameterSet& params);
124 
127  ~MatacqProducer();
128 
133  virtual void
134  produce(edm::Event& event, const edm::EventSetup& eventSetup);
135 
136 private:
141  void
143 
151  bool
152  getMatacqFile(uint32_t runNumber, uint32_t orbitId, bool* fileChange =0);
153 
154  bool
155  getMatacqEvent(uint32_t runNumber, int32_t orbitId,
156  bool fileChange);
157  /*,bool doWrap = false, std::streamoff maxPos = -1);*/
158 
159  uint32_t getRunNumber(edm::Event& ev) const;
160  uint32_t getOrbitId(edm::Event& ev) const;
161  int getCalibTriggerType(edm::Event& ev) const;
162 
165  void loadOrbitOffset();
166 
173  bool mseek(filepos_t offset, int whence = SEEK_SET, const char* mess = 0);
174 
175  bool mtell(filepos_t& pos);
176 
185  bool mread(char* buf, size_t n, const char* mess = 0, bool peek = false);
186 
187  bool mcheck(const std::string& name);
188 
189  bool mopen(const std::string& name);
190 
191  void mclose();
192 
193  bool misOpened();
194 
195  bool meof();
196 
197  bool mrewind();
198 
199  bool msize(filepos_t& s);
200 
201  void newRun(int prevRun, int newRun);
202 
203  static std::string runSubDir(uint32_t runNumber);
204 
205 private:
206  std::vector<std::string> fileNames_;
207 
211 
215 
218  bool timing_;
219 
222  bool disabled_;
223 
227 
231 
235 
240 
244  bool mergeRaw_;
245 
249 
251 
255 
256  static const int bufferSize = 30000; //must greater or equal to maximum
257  // matacq event size.
258  std::vector<unsigned char> data_;
260  const static int orbitTolerance_;
262  int32_t lastOrb_;
264 
266 
267  timeval startTime_;
268 
274 
277  std::map<uint32_t,uint32_t> orbitOffset_;
278 
282 
286 
287  static const int matacqFedId_ = 655;
288 
289  struct stats_t {
290  double nEvents;
293  } stats_;
294 
295  const static stats_t stats_init;
299 
302  std::ofstream logFile_;
303 
304 
308 
312 
318  timeval timer_;
319 
322  std::ofstream timeLog_;
323 
327 
330  uint32_t runNumber_;
331 };
332 
333 #endif
std::string inFileName_
std::map< uint32_t, uint32_t > orbitOffset_
uint32_t runNumber_
std::ofstream logFile_
static const int matacqFedId_
static const int orbitTolerance_
std::ofstream timeLog_
bool operator<(const MatacqEventId &a)
std::vector< std::string > fileNames_
bool ev
std::string digiInstanceName_
uint32_t getRunNumber(edm::Event &ev) const
uint32_t getOrbitId(edm::Event &ev) const
bool mcheck(const std::string &name)
struct MatacqProducer::stats_t stats_
int64_t pos(int orb) const
void addMatacqData(edm::Event &event)
static std::string runSubDir(uint32_t runNumber)
bool mread(char *buf, size_t n, const char *mess=0, bool peek=false)
virtual void produce(edm::Event &event, const edm::EventSetup &eventSetup)
edm::InputTag inputRawCollection_
unsigned int offset(bool)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::string orbitOffsetFile_
int getCalibTriggerType(edm::Event &ev) const
std::string timeLogFile_
bool operator>(const MatacqEventId &a)
MatacqDataFormatter formatter_
NullOut & operator<<(std::ostream &(*pf)(std::ostream &))
bool operator==(const MatacqEventId &a)
uint32_t openedFileRunNumber_
MatacqEventId(uint32_t r, uint32_t o)
int64_t IOOffset
Definition: IOTypes.h:19
PosEstimator posEstim_
void init(MatacqProducer *mp)
bool mtell(filepos_t &pos)
static const int bufferSize
MatacqProducer(const edm::ParameterSet &params)
bool mseek(filepos_t offset, int whence=SEEK_SET, const char *mess=0)
double a
Definition: hdecay.h:121
MatacqRawEvent matacq_
std::string rawInstanceName_
std::string logFileName_
bool msize(filepos_t &s)
std::vector< unsigned char > data_
void newRun(int prevRun, int newRun)
bool getMatacqFile(uint32_t runNumber, uint32_t orbitId, bool *fileChange=0)
static const stats_t stats_init
long double T
NullOut & operator<<(const T &a)
bool mopen(const std::string &name)
bool getMatacqEvent(uint32_t runNumber, int32_t orbitId, bool fileChange)