CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LaserSorter.h
Go to the documentation of this file.
1 /*
2  * $Id: LaserSorter.h,v 1.5 2010/04/20 21:46:27 pgras Exp $
3  */
4 
5 #ifndef EVENT_SELECT_H
6 #define EVENT_SELECT_H
7 
8 #include <vector>
9 #include <iostream>
10 #include <fstream>
11 #include <inttypes.h>
12 #include "boost/ptr_container/ptr_list.hpp"
13 
16 
20 
21 #include <sys/time.h>
22 #include <time.h>
23 #include <map>
24 
44 class LaserSorter : public edm::EDAnalyzer {
45  //inner classes
46 private:
47  struct IndexRecord{
48  uint32_t orbit;
49  uint32_t filePos;
50  bool operator<(const IndexRecord& i) const { return orbit < i.orbit; }
51  };
52 
54  public:
55  //default ctor
56  OutStreamRecord(int fedId__,
57  edm::LuminosityBlockNumber_t startingLumiBlock__,
58  std::ofstream* out__,
59  std::string& tmpFileName__,
60  std::string& finalFileName__):
61  fedId_(fedId__),
62  startingLumiBlock_(startingLumiBlock__),
63  out_(out__),
64  tmpFileName_(tmpFileName__), finalFileName_(finalFileName__),
66  indices_.reserve(indexReserve_);
67  }
68 
69  int fedId() const { return fedId_; }
71  return startingLumiBlock_;
72  }
73  std::ofstream* out() const { return out_.get(); }
74  std::string finalFileName() const { return finalFileName_; }
75  std::string tmpFileName() const { return tmpFileName_; }
76  std::vector<IndexRecord> * indices() { return &indices_; }
77 
78 
83  std::set<uint32_t>& excludedOrbit() { return excludedOrbit_; }
84 
85  private:
86  int fedId_;
88  std::auto_ptr<std::ofstream> out_;
89  std::string tmpFileName_;
90  std::string finalFileName_;
91  static std::string emptyString_;
92 
97  std::vector<IndexRecord> indices_;
98 
102  std::set<uint32_t> excludedOrbit_;
103 
108 
111  static size_t indexReserve_;
112 
113  };
114 
115  //typedefs:
116 private:
117  typedef boost::ptr_list<OutStreamRecord> OutStreamList;
118 
119  //ctors/dtors
120 public:
122  ~LaserSorter();
123 
124 
125  //methods
126 public:
127  virtual void analyze(const edm::Event&, const edm::EventSetup&);
128  virtual void endJob();
129  virtual void beginJob();
130 
131 private:
132  int dcc2Lme(int dccNum, int dccSide);
133 
145  double* proba = 0);
146 
151 
154  void closeAllStreams();
155 
156 
163  OutStreamRecord* getStream(int fedId,
164  edm::LuminosityBlockNumber_t lumiBlock);
165 
176  int detailedTriggerType,
177  const FEDRawDataCollection& data);
178 
184  bool writeFedBlock(std::ofstream& out,
185  const FEDRawData& data);
186 
192  OutStreamList::iterator closeOutStream(OutStreamList::iterator streamRecord);
193 
202  OutStreamList::iterator createOutStream(int fedId,
203  edm::LuminosityBlockNumber_t lumiBlock);
204 
208  void writeFileHeader(std::ofstream& out);
209 
215  bool writeEventHeader(std::ofstream& out,
216  const edm::Event& evt,
217  int fedId,
218  unsigned nFeds);
219 
220 
228  void streamFileName(int fedId, edm::LuminosityBlockNumber_t lumiBlock,
229  std::string& tmpName, std::string& finalName);
230 
231 
241  bool isDccEventEmpty(const FEDRawData& data, size_t* dccLen = 0,
242  int* nTowerBlocks = 0) const;
243 
248  void getOutputFedList(const edm::Event& event,
249  const FEDRawDataCollection& data,
250  std::vector<unsigned>& fedIds) const;
251 
260  bool readIndexTable(std::ifstream& in, std::string& inName,
261  OutStreamRecord& outRcd, std::string* err);
262 
268  bool writeIndexTable(std::ofstream& out,
269  std::vector<IndexRecord>& indices);
270 
271  bool renameAsBackup(const std::string& fileName,
272  std::string& newFileName);
273 
274 
280  int readFormatVersion(std::ifstream& in,
281  const std::string& fileName);
282 
285  static std::string toString(uint64_t t);
286 
293  void restoreStreamsOfLumiBlock(int lumiBlock);
294 
299  std::vector<int> getFullyReadoutDccs(const FEDRawDataCollection& data) const;
300 
301  //fields
302 private:
305  static const int ecalDccFedIdMin_;
306 
309  static const int ecalDccFedIdMax_;
310 
314 
317  std::ofstream logFile_;
318 
322 
327 
330  unsigned char formatVersion_;
331 
334  std::string outputDir_;
335 
338  std::vector<std::string> fedSubDirs_;
339 
342  std::string timeLogFile_;
343 
347 
351 
354  timeval timer_;
355 
358  std::ofstream timeLog_;
359 
362  bool timing_;
363 
366  std::string outputListFile_;
367 
371 
375 
378  std::ofstream outputList_;
379 
380 #if 0
381 
383  bool storeFirstOrbitId_;
384 
387  std::ofstream firstOrbitOut_;
388 
391  std::string firstOrbitOutputFile_;
392 
395  uint32_t minOrbitId_;
396 
397 #endif
398 
402 
403 
407 
408 
412 
416 
429 
432  static const int matacqFedId_ = 655;
433 
436  static const int indexOffset32_;
437 
441  static const unsigned maxEvents_ = 1<<20;
442 
445  struct stats_t {
447  double nRead;
449  double nWritten;
457  double nRestoredDcc;
458  } stats_;
460 };
461 
462 #endif //EVENT_SELECT_H not defined
OutStreamRecord * getStream(int fedId, edm::LuminosityBlockNumber_t lumiBlock)
Definition: LaserSorter.cc:441
int i
Definition: DBlmapReader.cc:9
int lumiBlockSpan_
Definition: LaserSorter.h:428
bool disableOutput_
Definition: LaserSorter.h:346
std::vector< int > getFullyReadoutDccs(const FEDRawDataCollection &data) const
Definition: LaserSorter.cc:932
int maxFullReadoutDccError_
Definition: LaserSorter.h:406
double nRestoredDcc
number of events whose DCC ID was restored based on FED block sizes
Definition: LaserSorter.h:457
OutStreamRecord(int fedId__, edm::LuminosityBlockNumber_t startingLumiBlock__, std::ofstream *out__, std::string &tmpFileName__, std::string &finalFileName__)
Definition: LaserSorter.h:56
static std::string toString(uint64_t t)
static std::string emptyString_
Definition: LaserSorter.h:91
static const int ecalDccFedIdMin_
Definition: LaserSorter.h:305
std::set< uint32_t > excludedOrbit_
Definition: LaserSorter.h:102
static const int indexOffset32_
Definition: LaserSorter.h:436
virtual void beginJob()
Definition: LaserSorter.cc:857
bool writeIndexTable(std::ofstream &out, std::vector< IndexRecord > &indices)
Definition: LaserSorter.cc:944
edm::LuminosityBlockNumber_t startingLumiBlock_
Definition: LaserSorter.h:87
bool readIndexTable(std::ifstream &in, std::string &inName, OutStreamRecord &outRcd, std::string *err)
Definition: LaserSorter.cc:984
bool writeEvent(OutStreamRecord &out, const edm::Event &event, int detailedTriggerType, const FEDRawDataCollection &data)
Definition: LaserSorter.cc:471
edm::RunNumber_t runNumber_
Definition: LaserSorter.h:350
bool isDccEventEmpty(const FEDRawData &data, size_t *dccLen=0, int *nTowerBlocks=0) const
Definition: LaserSorter.cc:860
virtual void endJob()
Definition: LaserSorter.cc:851
void writeFileHeader(std::ofstream &out)
Definition: LaserSorter.cc:695
std::ofstream * out() const
Definition: LaserSorter.h:73
void streamFileName(int fedId, edm::LuminosityBlockNumber_t lumiBlock, std::string &tmpName, std::string &finalName)
Definition: LaserSorter.cc:749
edm::LuminosityBlockNumber_t lumiBlock_
Definition: LaserSorter.h:321
std::set< uint32_t > & excludedOrbit()
Definition: LaserSorter.h:83
void getOutputFedList(const edm::Event &event, const FEDRawDataCollection &data, std::vector< unsigned > &fedIds) const
Definition: LaserSorter.cc:903
static int dccNum[12][12]
static const int matacqFedId_
Definition: LaserSorter.h:432
OutStreamList::iterator closeOutStream(OutStreamList::iterator streamRecord)
Definition: LaserSorter.cc:803
unsigned int LuminosityBlockNumber_t
Definition: EventID.h:31
std::string finalFileName() const
Definition: LaserSorter.h:74
void closeAllStreams()
Definition: LaserSorter.cc:409
std::vector< std::string > fedSubDirs_
Definition: LaserSorter.h:338
std::vector< IndexRecord > indices_
Definition: LaserSorter.h:97
edm::LuminosityBlockNumber_t startingLumiBlock() const
Definition: LaserSorter.h:70
std::auto_ptr< std::ofstream > out_
Definition: LaserSorter.h:88
double nRead
number of events read out
Definition: LaserSorter.h:447
unsigned char formatVersion_
Definition: LaserSorter.h:330
std::vector< IndexRecord > * indices()
Definition: LaserSorter.h:76
int dcc2Lme(int dccNum, int dccSide)
Definition: LaserSorter.cc:337
std::string outputDir_
Definition: LaserSorter.h:334
timeval timer_
Definition: LaserSorter.h:354
bool writeFedBlock(std::ofstream &out, const FEDRawData &data)
Definition: LaserSorter.cc:501
std::string outputListFile_
Definition: LaserSorter.h:366
std::string timeLogFile_
Definition: LaserSorter.h:342
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
int iNoEcalDataMess_
Definition: LaserSorter.h:411
static const unsigned maxEvents_
Definition: LaserSorter.h:441
void closeOldStreams(edm::LuminosityBlockNumber_t lumiBlock)
Definition: LaserSorter.cc:416
tuple out
Definition: dbtoconf.py:99
int getDetailedTriggerType(const edm::Handle< FEDRawDataCollection > &rawdata, double *proba=0)
Definition: LaserSorter.cc:368
boost::ptr_list< OutStreamRecord > OutStreamList
Definition: LaserSorter.h:117
LaserSorter(const edm::ParameterSet &)
Definition: LaserSorter.cc:85
int detailedTrigType_
Definition: LaserSorter.h:313
unsigned long long uint64_t
Definition: Time.h:15
static const int ecalDccFedIdMax_
Definition: LaserSorter.h:309
std::ofstream outputList_
Definition: LaserSorter.h:378
int readFormatVersion(std::ifstream &in, const std::string &fileName)
std::ofstream logFile_
Definition: LaserSorter.h:317
struct LaserSorter::stats_t stats_
static stats_t stats_init
Definition: LaserSorter.h:459
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
bool writeEventHeader(std::ofstream &out, const edm::Event &evt, int fedId, unsigned nFeds)
Definition: LaserSorter.cc:712
OutStreamList::iterator createOutStream(int fedId, edm::LuminosityBlockNumber_t lumiBlock)
Definition: LaserSorter.cc:559
int maxNoEcalDataMess_
Definition: LaserSorter.h:415
unsigned int RunNumber_t
Definition: EventRange.h:32
int iNoFullReadoutDccError_
Definition: LaserSorter.h:401
void restoreStreamsOfLumiBlock(int lumiBlock)
dictionary rawdata
Definition: lumiPlot.py:393
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: LaserSorter.cc:178
std::string tmpFileName() const
Definition: LaserSorter.h:75
bool doOutputList_
Definition: LaserSorter.h:370
double nWritten
number of events written out
Definition: LaserSorter.h:449
OutStreamList outStreamList_
Definition: LaserSorter.h:326
bool operator<(const IndexRecord &i) const
Definition: LaserSorter.h:50
std::ofstream timeLog_
Definition: LaserSorter.h:358
bool renameAsBackup(const std::string &fileName, std::string &newFileName)
Definition: LaserSorter.cc:538