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 
9 
10 #include <string>
11 #include <inttypes.h>
12 #include <fstream>
13 #include <memory>
14 
15 #include <sys/time.h>
16 
17 #define USE_STORAGE_MANAGER
18 
19 #ifdef USE_STORAGE_MANAGER
22 #else //USE_STORAGE_MANAGER not defined
23 # ifndef _LARGEFILE64_SOURCE
24 # define _LARGEFILE64_SOURCE
25 # endif //_LARGEFILE64_SOURCE not defined
26 # include <stdio.h>
27 #endif //USE_STORAGE_MANAGER defined
28 
29 struct NullOut{
30  NullOut&
31  operator<<(std::ostream& (*pf)(std::ostream&)){
32  return *this;
33  }
34  template<typename T>
35  inline NullOut& operator<<(const T& a){
36  return *this;
37  }
38 };
39 
52 {
53 public:
55  laserType = 4,
56  ledType = 5,
57  tpType = 6,
58  pedType = 7
59  };
60 private:
61 #ifdef USE_STORAGE_MANAGER
63  typedef std::auto_ptr<Storage> FILE_t;
64 #else
65  typedef off_t filepos_t;
66  typedef FILE* FILE_t;
67 #endif
68  struct MatacqEventId{
69  MatacqEventId(): run(0), orbit(0){}
70  MatacqEventId(uint32_t r, uint32_t o): run(r), orbit(o){}
71 
74  uint32_t run;
75 
78  uint32_t orbit;
79 
80  bool
82  return (this->run < a.run)
83  || ((this->run == a.run) && (this->orbit < a.orbit));
84  }
85 
86  bool
88  return (this->run > a.run)
89  || ((this->run == a.run) && (this->orbit > a.orbit));
90  }
91 
92  bool
94  return !((*this) < a || (*this) > a);
95  }
96  };
97 
98 
106  //Note: a better estimate could be obtained by using segment of linear
107  //functions. In such implementation, the estimator must be updated
108  //each time a point with wrong estimate has been found.
109  public:
111  invalid_(true), verbosity_(0) { }
112  void init(MatacqProducer* mp);
113  bool invalid() const { return invalid_; }
114  int64_t pos(int orb) const;
115  int eventLength() const { return eventLength_; }
116  int firstOrbit() const { return firstOrbit_; }
117  void verbosity(int verb) { verbosity_ = verb; }
118  private:
122  bool invalid_;
124  };
125 
126 public:
130  explicit
131  MatacqProducer(const edm::ParameterSet& params);
132 
135  ~MatacqProducer();
136 
141  virtual void
142  produce(edm::Event& event, const edm::EventSetup& eventSetup);
143 
144 private:
149  void
151 
159  bool
160  getMatacqFile(uint32_t runNumber, uint32_t orbitId, bool* fileChange =0);
161 
162  bool
163  getMatacqEvent(uint32_t runNumber, int32_t orbitId,
164  bool fileChange);
165  /*,bool doWrap = false, std::streamoff maxPos = -1);*/
166 
167  uint32_t getRunNumber(edm::Event& ev) const;
168  uint32_t getOrbitId(edm::Event& ev) const;
169  int getCalibTriggerType(edm::Event& ev) const;
170 
173  void loadOrbitOffset();
174 
181  bool mseek(filepos_t offset, int whence = SEEK_SET, const char* mess = 0);
182 
183  bool mtell(filepos_t& pos);
184 
193  bool mread(char* buf, size_t n, const char* mess = 0, bool peek = false);
194 
195  bool mcheck(const std::string& name);
196 
197  bool mopen(const std::string& name);
198 
199  void mclose();
200 
201  bool misOpened();
202 
203  bool meof();
204 
205  bool mrewind();
206 
207  bool msize(filepos_t& s);
208 
209  static std::string runSubDir(uint32_t runNumber);
210 
211 private:
212  std::vector<std::string> fileNames_;
213 
216  std::string digiInstanceName_;
217 
220  std::string rawInstanceName_;
221 
224  bool timing_;
225 
228  bool disabled_;
229 
233 
237 
241 
246 
250  bool mergeRaw_;
251 
255 
257 
261 
262  static const int bufferSize = 30000; //must greater or equal to maximum
263  // matacq event size.
264  std::vector<unsigned char> data_;
266  static int orbitTolerance_;
268  int32_t lastOrb_;
270 
272 
273  timeval startTime_;
274 
279  std::string orbitOffsetFile_;
280 
283  std::map<uint32_t,uint32_t> orbitOffset_;
284 
288 
291  std::string inFileName_;
292 
293  static const int matacqFedId_ = 655;
294 
295  struct stats_t {
296  double nEvents;
299  } stats_;
300 
304  std::string logFileName_;
305 
308  std::ofstream logFile_;
309 };
310 
311 #endif
std::string inFileName_
std::map< uint32_t, uint32_t > orbitOffset_
std::ofstream logFile_
static const int matacqFedId_
static int orbitTolerance_
bool operator<(const MatacqEventId &a)
std::vector< std::string > fileNames_
std::string digiInstanceName_
uint32_t getRunNumber(edm::Event &ev) const
uint32_t getOrbitId(edm::Event &ev) const
static stats_t stats_init
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
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_
IOOffset filepos_t
string s
Definition: asciidump.py:422
std::string logFileName_
bool msize(filepos_t &s)
std::vector< unsigned char > data_
std::auto_ptr< Storage > FILE_t
bool getMatacqFile(uint32_t runNumber, uint32_t orbitId, bool *fileChange=0)
long double T
NullOut & operator<<(const T &a)
bool mopen(const std::string &name)
bool getMatacqEvent(uint32_t runNumber, int32_t orbitId, bool fileChange)