CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
LaserSorter Class Reference

#include <LaserSorter.h>

Inheritance diagram for LaserSorter:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  IndexRecord
 
class  OutStreamRecord
 
struct  stats_t
 

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 
 LaserSorter (const edm::ParameterSet &)
 
 ~LaserSorter ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef boost::ptr_list
< OutStreamRecord
OutStreamList
 

Private Member Functions

void closeAllStreams ()
 
void closeOldStreams (edm::LuminosityBlockNumber_t lumiBlock)
 
OutStreamList::iterator closeOutStream (OutStreamList::iterator streamRecord)
 
OutStreamList::iterator createOutStream (int fedId, edm::LuminosityBlockNumber_t lumiBlock)
 
int dcc2Lme (int dccNum, int dccSide)
 
int getDetailedTriggerType (const edm::Handle< FEDRawDataCollection > &rawdata, double *proba=0)
 
std::vector< int > getFullyReadoutDccs (const FEDRawDataCollection &data) const
 
void getOutputFedList (const edm::Event &event, const FEDRawDataCollection &data, std::vector< unsigned > &fedIds) const
 
OutStreamRecordgetStream (int fedId, edm::LuminosityBlockNumber_t lumiBlock)
 
bool isDccEventEmpty (const FEDRawData &data, size_t *dccLen=0, int *nTowerBlocks=0) const
 
int readFormatVersion (std::ifstream &in, const std::string &fileName)
 
bool readIndexTable (std::ifstream &in, std::string &inName, OutStreamRecord &outRcd, std::string *err)
 
bool renameAsBackup (const std::string &fileName, std::string &newFileName)
 
void restoreStreamsOfLumiBlock (int lumiBlock)
 
void streamFileName (int fedId, edm::LuminosityBlockNumber_t lumiBlock, std::string &tmpName, std::string &finalName)
 
bool writeEvent (OutStreamRecord &out, const edm::Event &event, int detailedTriggerType, const FEDRawDataCollection &data)
 
bool writeEventHeader (std::ofstream &out, const edm::Event &evt, int fedId, unsigned nFeds)
 
bool writeFedBlock (std::ofstream &out, const FEDRawData &data)
 
void writeFileHeader (std::ofstream &out)
 
bool writeIndexTable (std::ofstream &out, std::vector< IndexRecord > &indices)
 

Static Private Member Functions

static std::string toString (uint64_t t)
 

Private Attributes

int detailedTrigType_
 
bool disableOutput_
 
bool doOutputList_
 
edm::InputTag fedRawDataCollectionTag_
 
std::vector< std::string > fedSubDirs_
 
unsigned char formatVersion_
 
int iNoEcalDataMess_
 
int iNoFullReadoutDccError_
 
std::ofstream logFile_
 
edm::LuminosityBlockNumber_t lumiBlock_
 
int lumiBlockSpan_
 
int maxFullReadoutDccError_
 
int maxNoEcalDataMess_
 
std::string outputDir_
 
std::ofstream outputList_
 
std::string outputListFile_
 
OutStreamList outStreamList_
 
edm::RunNumber_t runNumber_
 
struct LaserSorter::stats_t stats_
 
std::ofstream timeLog_
 
std::string timeLogFile_
 
timeval timer_
 
bool timing_
 
int verbosity_
 

Static Private Attributes

static const int ecalDccFedIdMax_ = 654
 
static const int ecalDccFedIdMin_ = 601
 
static const int indexOffset32_ = 1
 
static const int matacqFedId_ = 655
 
static const unsigned maxEvents_ = 1<<20
 
static stats_t stats_init = {0, 0, 0, 0, 0}
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

This module is used to classify events of laser sequence acquired in a global run. Sorting: Events are grouped by bunch of consecutive events from the same FED. A file of such a bunch of events is identified by the FED or ECAL sector and the luminosity block id of the first event.

Sorting strategy: It is assumes that:

File completion: while being feeding, .part is appended at the end of the each output file.Once a file is completed (see above), it is renamed without the enclosing .part suffix.

Definition at line 44 of file LaserSorter.h.

Member Typedef Documentation

typedef boost::ptr_list<OutStreamRecord> LaserSorter::OutStreamList
private

Definition at line 117 of file LaserSorter.h.

Constructor & Destructor Documentation

LaserSorter::LaserSorter ( const edm::ParameterSet pset)

Definition at line 84 of file LaserSorter.cc.

References gather_cfg::cout, doOutputList_, edm::hlt::Exception, fedSubDirs_, logFile_, now(), dbtoconf::out, outputDir_, outputList_, outputListFile_, timeLog_, timeLogFile_, timer_, and timing_.

85  : lumiBlock_(0),
86  formatVersion_(5),
87  outputDir_(pset.getParameter<std::string>("outputDir")),
88  fedSubDirs_(pset.getParameter<std::vector<std::string> >("fedSubDirs")),
89  timeLogFile_(pset.getUntrackedParameter<std::string>("timeLogFile", "")),
90  disableOutput_(pset.getUntrackedParameter<bool>("disableOutput", false)),
91  runNumber_(0),
92  outputListFile_(pset.getUntrackedParameter<string>("outputListFile", "")),
93  doOutputList_(false),
94  verbosity_(pset.getUntrackedParameter<int>("verbosity", 0)),
96  maxFullReadoutDccError_(pset.getParameter<int>("maxFullReadoutDccError")),
98  maxNoEcalDataMess_(pset.getParameter<int>("maxNoEcalDataMess")),
99  lumiBlockSpan_(pset.getParameter<int>("lumiBlockSpan")),
100  fedRawDataCollectionTag_(pset.getParameter<edm::InputTag>("fedRawDataCollectionTag")),
102 {
103 
104  gettimeofday(&timer_, 0);
105  logFile_.open("eventSelect.log", ios::app | ios::out);
106 
107  const unsigned nEcalFeds= 54;
108  if(fedSubDirs_.size()!= nEcalFeds+1){
109  throw cms::Exception("LaserSorter")
110  << "Configuration error: "
111  << "fedSubDirs parameter must be a vector "
112  << " of " << nEcalFeds << " strings"
113  << " (subdirectory for unknown triggered FED followed by "
114  "subdirectories for FED ID 601 "
115  "to FED ID 654 in increasing FED ID order)";
116  }
117 
118  if(outputListFile_.size()!=0){
119  outputList_.open(outputListFile_.c_str(), ios::app);
120  if(outputList_.bad()){
121  throw cms::Exception("FileOpen")
122  << "Failed to open file '" << outputListFile_
123  << "' for logging of output file path list.";
124  }
125  doOutputList_ = true;
126  }
127 
128  if(timeLogFile_.size()>0){
129  timeLog_.open(timeLogFile_.c_str());
130  if(timeLog_.fail()){
131  cout << "[LaserSorter " << now() << "] "
132  << "Failed to open file " << timeLogFile_ << " to log timing.\n";
133  timing_ = false;
134  } else{
135  timing_ = true;
136  }
137  }
138 
139  struct stat fileStat;
140  if(0==stat(outputDir_.c_str(), &fileStat)){
141  if(!S_ISDIR(fileStat.st_mode)){
142  throw cms::Exception("[LaserSorter]")
143  << "File " << outputDir_ << " exists but is not a directory "
144  << " as expected.";
145  }
146  } else {//directory does not exists, let's try to create it
147  if(0!=mkdir(outputDir_.c_str(), 0755)){
148  throw cms::Exception("[LaserSorter]")
149  << "Failed to create directory " << outputDir_
150  << " for writing data.";
151  }
152  }
153 
154  logFile_ << "# "
155  "run\t"
156  "LB\t"
157  "event\t"
158  "trigType\t"
159  "FED\t"
160  "side\t"
161  "LB out\t"
162  "Written\t"
163  "ECAL data\n";
164 }
edm::InputTag fedRawDataCollectionTag_
Definition: LaserSorter.h:430
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int lumiBlockSpan_
Definition: LaserSorter.h:428
bool disableOutput_
Definition: LaserSorter.h:346
int maxFullReadoutDccError_
Definition: LaserSorter.h:406
edm::RunNumber_t runNumber_
Definition: LaserSorter.h:350
edm::LuminosityBlockNumber_t lumiBlock_
Definition: LaserSorter.h:321
std::vector< std::string > fedSubDirs_
Definition: LaserSorter.h:338
unsigned char formatVersion_
Definition: LaserSorter.h:330
std::string outputDir_
Definition: LaserSorter.h:334
timeval timer_
Definition: LaserSorter.h:354
std::string outputListFile_
Definition: LaserSorter.h:366
std::string timeLogFile_
Definition: LaserSorter.h:342
int iNoEcalDataMess_
Definition: LaserSorter.h:411
tuple out
Definition: dbtoconf.py:99
static std::string now()
Definition: LaserSorter.cc:70
std::ofstream outputList_
Definition: LaserSorter.h:378
std::ofstream logFile_
Definition: LaserSorter.h:317
struct LaserSorter::stats_t stats_
static stats_t stats_init
Definition: LaserSorter.h:461
tuple cout
Definition: gather_cfg.py:121
int maxNoEcalDataMess_
Definition: LaserSorter.h:415
int iNoFullReadoutDccError_
Definition: LaserSorter.h:401
bool doOutputList_
Definition: LaserSorter.h:370
std::ofstream timeLog_
Definition: LaserSorter.h:358
LaserSorter::~LaserSorter ( )

Definition at line 166 of file LaserSorter.cc.

References logFile_, LaserSorter::stats_t::nInvalidDccStrict, LaserSorter::stats_t::nInvalidDccWeak, LaserSorter::stats_t::nRead, LaserSorter::stats_t::nRestoredDcc, LaserSorter::stats_t::nWritten, and stats_.

166  {
167  logFile_ << "Summary. Event count: "
168  << stats_.nRead << " processed, "
169  << stats_.nWritten << " written, "
170  << stats_.nInvalidDccStrict << " with errors in DCC ID values, "
171  << stats_.nInvalidDccWeak << " with unusable DCC ID values, "
172  << stats_.nRestoredDcc << " restored DCC ID based on DCC block size\n";
173 }
double nRestoredDcc
number of events whose DCC ID was restored based on FED block sizes
Definition: LaserSorter.h:459
double nRead
number of events read out
Definition: LaserSorter.h:449
std::ofstream logFile_
Definition: LaserSorter.h:317
struct LaserSorter::stats_t stats_
double nWritten
number of events written out
Definition: LaserSorter.h:451

Member Function Documentation

void LaserSorter::analyze ( const edm::Event event,
const edm::EventSetup es 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 178 of file LaserSorter.cc.

References closeAllStreams(), closeOldStreams(), create_public_lumi_plots::color, colorNames, gather_cfg::cout, ecaldqm::dccId(), detailedTrigNames, detailedTrigType_, disableOutput_, ecalDccFedIdMax_, ecalDccFedIdMin_, LaserSorter::OutStreamRecord::excludedOrbit(), fedRawDataCollectionTag_, LaserSorter::OutStreamRecord::finalFileName(), getDetailedTriggerType(), getFullyReadoutDccs(), getStream(), i, edm::EventBase::id(), iNoEcalDataMess_, iNoFullReadoutDccError_, logFile_, lumiBlock_, lumiBlockSpan_, edm::EventBase::luminosityBlock(), maxFullReadoutDccError_, csvLumiCalc::maxLumi, csvLumiCalc::minLumi, LaserSorter::stats_t::nInvalidDccStrict, LaserSorter::stats_t::nInvalidDccWeak, now(), LaserSorter::stats_t::nRead, LaserSorter::stats_t::nRestoredDcc, LaserSorter::stats_t::nWritten, edm::EventBase::orbitNumber(), dbtoconf::out, lumiPlot::rawdata, restoreStreamsOfLumiBlock(), edm::EventID::run(), runNumber_, LaserSorter::OutStreamRecord::startingLumiBlock(), stats_, lumiQTWidget::t, timeLog_, timer_, timing_, verbosity_, and writeEvent().

178  {
179  if(timing_){
180  timeval t;
181  gettimeofday(&t, 0);
182  timeLog_ << t.tv_sec << "."
183  << setfill('0') << setw(3) << (t.tv_usec+500)/1000 << setfill(' ')
184  << "\t"
185  << (t.tv_usec - timer_.tv_usec)*1.
186  + (t.tv_sec - timer_.tv_sec)*1.e6 << "\t";
187  timer_ = t;
188  }
189 
190  ++stats_.nRead;
191 
192  if(event.id().run()!=runNumber_){//run changed or first event
193  //for a new run, starts with a new output stream set.
194  closeAllStreams();
195  runNumber_ = event.id().run();
197  iNoEcalDataMess_ = 0;
198  }
199 
201  event.getByLabel(fedRawDataCollectionTag_, rawdata);
202 
203  //The "detailed trigger type DCC field content:
204  double dttProba = 0;
205  detailedTrigType_ = getDetailedTriggerType(rawdata, &dttProba);
206 
207  const int trigType = (detailedTrigType_ >>8 ) & 0x7;
208  const int color = (detailedTrigType_ >>6 ) & 0x3;
209  const int dccId = (detailedTrigType_ >>0 ) & 0x3F;
210  int triggeredFedId = (detailedTrigType_ == -2) ? -1 : (600 + dccId);
211  const int side = (detailedTrigType_ >>11) & 0x1;
212  //monitoring region extended id:
213  // const int lme = dcc2Lme(dccId, side);
214 
215  if(detailedTrigType_ > -2){
216  if(dttProba < 1. || triggeredFedId < ecalDccFedIdMin_
217  || triggeredFedId > ecalDccFedIdMax_){
219  }
220 
221  if(triggeredFedId<ecalDccFedIdMin_ || triggeredFedId > ecalDccFedIdMax_){
222  if(verbosity_) cout << "[LaserSorter " << now() << "] " << "DCC ID (" << dccId
223  << ") found in trigger type is out of range.";
225  vector<int> ids = getFullyReadoutDccs(*rawdata);
226  if(ids.size()==0){
228  cout << " No fully read-out DCC found\n";
230  }
231  } else if(ids.size()==1){
232  triggeredFedId = ids[0];
233  if(verbosity_) cout << " ID guessed from DCC payloads\n";
235  } else{ //ids.size()>1
236  if(verbosity_){
237  cout << " Several fully read-out Dccs:";
238  for(unsigned i=0; i < ids.size(); ++i) cout << " " << ids[i];
239  cout << "\n";
240  }
241  }
242  }
243 
244  if(verbosity_>1) cout << "\n----------------------------------------------------------------------\n"
245  << "Event id: "
246  << " " << event.id() << "\n"
247  << "Lumin block: " << event.luminosityBlock() << "\n"
248  << "TrigType: " << detailedTrigNames[trigType&0x7]
249  << " Color: " << colorNames[color&0x3]
250  << " FED: " << triggeredFedId
251  << " side:" << side << "\n"
252  << "\n----------------------------------------------------------------------\n";
253 
254  } else{ //NO ECAL DATA
255  if(verbosity_>1) cout << "\n----------------------------------------------------------------------\n"
256  << "Event id: "
257  << " " << event.id() << "\n"
258  << "Lumin block: " << event.luminosityBlock() << "\n"
259  << "No ECAL data\n"
260  << "\n----------------------------------------------------------------------\n";
261  }
262 
263  logFile_ << event.id().run() << "\t"
264  << event.luminosityBlock() << "\t"
265  << event.id().event() << "\t"
266  << trigType << "\t"
267  << triggeredFedId << "\t"
268  << side;
269 
270  bool written = false;
271  int assignedLB = -1;
272 
273  if(event.luminosityBlock()!=lumiBlock_){
274  //lumi block change => need for stream garbage collection
275  const int lb = event.luminosityBlock();
276  closeOldStreams(lb);
277  int minLumi = event.luminosityBlock() - lumiBlockSpan_;
278  int maxLumi = event.luminosityBlock() + lumiBlockSpan_;
279  for(int lb1 = minLumi; lb1 <= maxLumi; ++lb1){
281  }
282  }
283 
284 // if(event.luminosityBlock() < lumiBlock_){
285 // throw cms::Exception("LaserSorter")
286 // << "Process event has a lumi block (" << event.luminosityBlock() << ")"
287 // << "older than previous one (" << lumiBlock_ << "). "
288 // << "This can be due by wrong input file ordering or bad luminosity "
289 // << "block indication is the event header. "
290 // << "Event cannot be processed";
291 // }
292 
293  if(disableOutput_){
294  /* NO OP*/
295  } else{
296  OutStreamRecord* out = getStream(triggeredFedId, event.luminosityBlock());
297 
298  if(out!=0){
299  assignedLB = out->startingLumiBlock();
300  if(out->excludedOrbit().find(event.orbitNumber())
301  ==out->excludedOrbit().end()){
302  if(verbosity_ > 1) cout << "[LaserSorter " << now() << "] "
303  << "Writing out event from FED " << triggeredFedId
304  << " LB " << event.luminosityBlock()
305  << " orbit " << event.orbitNumber() << "\n";
306  int dtt = (detailedTrigType_ >=0) ? detailedTrigType_ : -1; //shall we use -1 or 0 for undefined value?
307  written = written
308  || writeEvent(*out, event, dtt, *rawdata);
309  ++stats_.nWritten;
310  } else{
311  if(verbosity_) cout << "[LaserSorter " << now() << "] "
312  << "File " << out->finalFileName() << " "
313  << "already contains calibration event from FED "
314  << triggeredFedId << ", LB = "
315  << event.luminosityBlock()
316  << " with orbit ID "
317  << event.orbitNumber() << ". Event skipped.\n";
318  }
319  }
320  }
321  lumiBlock_ = event.luminosityBlock();
322 
323  logFile_ << "\t";
324  if(assignedLB>=0) logFile_ << assignedLB; else logFile_ << "-";
325  logFile_ << "\t" << (written?"Y":"N") << "\n";
326  logFile_ << "\t" << (detailedTrigType_==-2?"N":"Y") << "\n";
327 
328  if(timing_){
329  timeval t;
330  gettimeofday(&t, 0);
331  timeLog_ << (t.tv_usec - timer_.tv_usec)*1.
332  + (t.tv_sec - timer_.tv_sec)*1.e6 << "\n";
333  timer_ = t;
334  }
335 }
RunNumber_t run() const
Definition: EventID.h:42
edm::InputTag fedRawDataCollectionTag_
Definition: LaserSorter.h:430
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:459
static const char *const detailedTrigNames[]
Definition: LaserSorter.cc:49
static const int ecalDccFedIdMin_
Definition: LaserSorter.h:305
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
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
unsigned dccId(const DetId &)
edm::LuminosityBlockNumber_t lumiBlock_
Definition: LaserSorter.h:321
void closeAllStreams()
Definition: LaserSorter.cc:409
edm::LuminosityBlockNumber_t startingLumiBlock() const
Definition: LaserSorter.h:70
double nRead
number of events read out
Definition: LaserSorter.h:449
timeval timer_
Definition: LaserSorter.h:354
int orbitNumber() const
Definition: EventBase.h:63
int iNoEcalDataMess_
Definition: LaserSorter.h:411
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
int detailedTrigType_
Definition: LaserSorter.h:313
static const int ecalDccFedIdMax_
Definition: LaserSorter.h:309
static std::string now()
Definition: LaserSorter.cc:70
std::ofstream logFile_
Definition: LaserSorter.h:317
struct LaserSorter::stats_t stats_
edm::EventID id() const
Definition: EventBase.h:56
tuple cout
Definition: gather_cfg.py:121
static const char *const colorNames[]
Definition: LaserSorter.cc:60
int iNoFullReadoutDccError_
Definition: LaserSorter.h:401
void restoreStreamsOfLumiBlock(int lumiBlock)
dictionary rawdata
Definition: lumiPlot.py:393
double nWritten
number of events written out
Definition: LaserSorter.h:451
std::ofstream timeLog_
Definition: LaserSorter.h:358
void LaserSorter::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 857 of file LaserSorter.cc.

857  {
858 }
void LaserSorter::closeAllStreams ( )
private

Closes all opened output streams.

Definition at line 409 of file LaserSorter.cc.

References closeOutStream(), and outStreamList_.

Referenced by analyze(), and endJob().

409  {
410  for(OutStreamList::iterator it = outStreamList_.begin();
411  it != outStreamList_.end();/*NOOP*/){
412  it = closeOutStream(it);
413  }
414 }
OutStreamList::iterator closeOutStream(OutStreamList::iterator streamRecord)
Definition: LaserSorter.cc:803
OutStreamList outStreamList_
Definition: LaserSorter.h:326
void LaserSorter::closeOldStreams ( edm::LuminosityBlockNumber_t  lumiBlock)
private

Closes output stream 2 lumi block older than the input 'lumiBlock' ID.

Parameters
lumiBlockID of the reference luminosity block.

Definition at line 416 of file LaserSorter.cc.

References closeOutStream(), gather_cfg::cout, lumiBlockSpan_, now(), outStreamList_, and verbosity_.

Referenced by analyze().

416  {
417  const edm::LuminosityBlockNumber_t minLumiBlock = lumiBlock - lumiBlockSpan_;
418  const edm::LuminosityBlockNumber_t maxLumiBlock = lumiBlock + lumiBlockSpan_;
419  //If container type is ever changed, beware that
420  //closeOutStream call in the loop removes it from outStreamList
421  for(boost::ptr_list<OutStreamRecord>::iterator it = outStreamList_.begin();
422  it != outStreamList_.end();
423  /*NOOP*/){
424  if(it->startingLumiBlock() < minLumiBlock
425  || it->startingLumiBlock() > maxLumiBlock){
426  //event older than 2 lumi block => stream can be closed
427  if(verbosity_) cout << "[LaserSorter " << now() << "] "
428  << "Closing file for "
429  << "FED "
430  << it->fedId()
431  << " LB " << it->startingLumiBlock()
432  << "\n";
433  it = closeOutStream(it);
434  } else{
435  ++it;
436  }
437  }
438 }
int lumiBlockSpan_
Definition: LaserSorter.h:428
OutStreamList::iterator closeOutStream(OutStreamList::iterator streamRecord)
Definition: LaserSorter.cc:803
unsigned int LuminosityBlockNumber_t
Definition: EventID.h:31
static std::string now()
Definition: LaserSorter.cc:70
tuple cout
Definition: gather_cfg.py:121
OutStreamList outStreamList_
Definition: LaserSorter.h:326
LaserSorter::OutStreamList::iterator LaserSorter::closeOutStream ( OutStreamList::iterator  streamRecord)
private

Closes an output stream and removed it from opened stream records. Beware: this methode modifies outStreamList_.

Parameters
streamRecordrecord of the output stream to close.
Returns
iterator to element next to the deleted one.

Definition at line 803 of file LaserSorter.cc.

References gather_cfg::cout, doOutputList_, f, analyzePatCleaning_cfg::inputFile, now(), dbtoconf::out, outputList_, outStreamList_, AlCaHLTBitMon_QueryRunRegistry::string, lumiQTWidget::t, cond::rpcobgas::time, verbosity_, and writeIndexTable().

Referenced by closeAllStreams(), and closeOldStreams().

804  {
805  if(streamRecord==outStreamList_.end()) return outStreamList_.end();
806 
807  if(verbosity_) cout << "[LaserSorter " << now() << "] " << "Writing Index table of file "
808  << streamRecord->finalFileName() << "\n";
809  ofstream& out = *streamRecord->out();
810  out.clear();
811  if(!writeIndexTable(out, *streamRecord->indices())){
812  cout << "Error while writing index table for file "
813  << streamRecord->finalFileName() << ". "
814  << "Resulting file might be corrupted. "
815  << "The error can be due to a lack of disk space.";
816  }
817 
818  if(verbosity_) cout << "[LaserSorter " << now() << "] " << "Closing file "
819  << streamRecord->finalFileName() << ".\n";
820  out.close();
821 
822  const std::string& tmpFileName = streamRecord->tmpFileName();
823  const std::string& finalFileName = streamRecord->finalFileName();
824 
825  if(verbosity_) cout << "[LaserSorter " << now() << "] " << "Renaming " << tmpFileName
826  << " to " << finalFileName << ".\n";
827 
828  if(0!=rename(tmpFileName.c_str(), finalFileName.c_str())){
829  cout << "[LaserSorter " << now() << "] "
830  << " Failed to rename output file from "
831  << tmpFileName << " to " << finalFileName
832  << ". " << strerror(errno) << "\n";
833  }
834 
835  if(doOutputList_){
836  char buf[256];
837  time_t t = time(0);
838  strftime(buf, sizeof(buf), "%F %R:%S", localtime(&t));
839 
840  ifstream f(".watcherfile");
841  string inputFile;
842  f >> inputFile;
843  outputList_ << finalFileName << "\t" << buf
844  << "\t" << inputFile
845  << endl;
846  }
847 
848  return outStreamList_.erase(streamRecord);
849 }
bool writeIndexTable(std::ofstream &out, std::vector< IndexRecord > &indices)
Definition: LaserSorter.cc:944
double f[11][100]
tuple out
Definition: dbtoconf.py:99
static std::string now()
Definition: LaserSorter.cc:70
std::ofstream outputList_
Definition: LaserSorter.h:378
tuple cout
Definition: gather_cfg.py:121
bool doOutputList_
Definition: LaserSorter.h:370
OutStreamList outStreamList_
Definition: LaserSorter.h:326
LaserSorter::OutStreamList::iterator LaserSorter::createOutStream ( int  fedId,
edm::LuminosityBlockNumber_t  lumiBlock 
)
private

Creates an output stream. It must be ensured before calling this method that the output stream is not already opened (See outStreamList_).

Parameters
fedIdFED ID of the event to stream out.
lumiBlockstarting lumi block of the event group to write to the stream.
Returns
iterator to the new stream record. outStreamList_.end() in case of failure.

Definition at line 559 of file LaserSorter.cc.

References trackerHits::c, gather_cfg::cout, end, edm::hlt::Exception, formatVersion_, recoMuon::in, bookConverter::min, now(), dbtoconf::out, outStreamList_, readFormatVersion(), readIndexTable(), renameAsBackup(), streamFileName(), AlCaHLTBitMon_QueryRunRegistry::string, estimatePileup_makeJSON::trunc, verbosity_, and writeFileHeader().

Referenced by getStream().

560  {
561  if(verbosity_) cout << "[LaserSorter " << now() << "] " << "Creating a stream for FED " << fedId
562  << " lumi block " << lumiBlock << ".\n";
563  std::string tmpName;
564  std::string finalName;
565 
566  streamFileName(fedId, lumiBlock, tmpName, finalName);
567 
568  errno = 0;
569 
570  //checks if a file with tmpName name already exists:
571  ofstream* out = new ofstream(tmpName.c_str(), ios::out | ios::in);
572  if(out->is_open()){//temporary file already exists. Making a backup:
573  string newName;
574  if(!renameAsBackup(tmpName, newName)){
575  throw cms::Exception("LaserSorter")
576  << "Failed to rename file " << tmpName
577  << " to " << newName << "\n";
578  }
579  if(verbosity_) cout << "[LaserSorter " << now() << "] "
580  << "Already existing File " << tmpName
581  << " renamed to "
582  << newName << "\n";
583  out->close();
584  }
585 
586  out->clear();
587  out->open(tmpName.c_str(), ios::out | ios::trunc);
588 
589  if(out->fail()){//failed to create file
590  delete out;
591  throw cms::Exception("LaserSorter")
592  << "Failed to create file "
593  << tmpName << " for writing event from FED " << fedId
594  << " lumi block " << lumiBlock
595  << ": " << strerror(errno) << "\n.";
596  }
597 
598  ifstream in(finalName.c_str());
599  bool newFile = true;
600  if(in.good()){//file already exists with final name.
601  if(verbosity_) cout << "[LaserSorter " << now() << "] " << "File "
602  << finalName
603  << " already exists. It will be updated if needed.\n";
604  //Copying its contents:
605  char buffer[256];
606  streamsize nread = -1;
607  int vers = readFormatVersion(in, finalName);
608  if(vers==-1){
609  edm::LogWarning("LaserSorter") << "File " << tmpName.c_str()
610  << " is not an LMF file despite its extension or "
611  << "it is corrupted.\n";
612  } else if(vers!=formatVersion_){
613  edm::LogWarning("LaserSorter") << "Cannot include events already in file "
614  << tmpName.c_str()
615  << " because of version "
616  << "mismatch (found version "
617  << (int)vers << " while "
618  << "only version "
619  << (int)formatVersion_
620  << " is supported).\n";
621  } else{
622  newFile = false;
623  //read index table offset value:
624  const int indexTableOffsetPos8 = 1*sizeof(uint32_t);
625  uint32_t indexTableOffsetValue = 0;
626  in.clear();
627  in.seekg(indexTableOffsetPos8, ios::beg);
628  in.read((char*) &indexTableOffsetValue,
629  sizeof(indexTableOffsetValue));
630  if(in.fail()){
631  cout << "[LaserSorter " << now() << "] " << "Failed to read offset of index table "
632  " in the existing file " << finalName << "\n";
633  } else{
634  if(verbosity_>2) cout << "[LaserSorter " << now() << "] " << "Index table offset of "
635  "original file " << finalName << ": 0x"
636  << hex << setfill('0')
637  << setw(8) << indexTableOffsetValue
638  << dec << setfill(' ') << "\n";
639  }
640  in.clear();
641  in.seekg(0, ios::beg);
642 
643  //copy legacy file contents except the index table
644  uint32_t toRead = indexTableOffsetValue;
645  cout << "[LaserSorter " << now() << "] " << "Copying " << finalName << " to " << tmpName << endl;
646  while(!in.eof()
647  && (toRead > 0)
648  && (nread=in.readsome(buffer, min(toRead, (uint32_t)sizeof(buffer))))!=0){
649  // cout << "Writing " << nread << " bytes to file "
650  // << tmpName.c_str() << "\n";
651  toRead -= nread;
652  // out->seekp(0, ios::end);
653  out->write(buffer, nread);
654  if(out->bad()){
655  throw cms::Exception("LaserSorter") << "Error while writing to file "
656  << tmpName
657  << ". Check if there is enough "
658  << "space on the device.\n";
659  }
660  }
661 
662  //resets index table offset field:
663  indexTableOffsetValue = 0 ;
664  out->clear();
665  out->seekp(indexTableOffsetPos8, ios::beg);
666  out->write((char*)&indexTableOffsetValue, sizeof(uint32_t));
667  out->clear();
668  out->seekp(0, ios::end);
669  }
670  }
671 
672 #if 0
673  out->flush();
674  cout << "Press enter... file name was " << tmpName << endl;
675  char c;
676  cin >> c;
677 #endif
678 
679  OutStreamRecord* outRcd = new OutStreamRecord(fedId, lumiBlock,
680  out,
681  tmpName, finalName);
682 
683  if(newFile){
684  writeFileHeader(*out);
685  } else{
686  std::string errMsg;
687  if(!readIndexTable(in, finalName, *outRcd, &errMsg)){
688  throw cms::Exception("LaserSorter") << errMsg << "\n";
689  }
690  }
691 
692  return outStreamList_.insert(outStreamList_.end(), outRcd);
693 }
bool readIndexTable(std::ifstream &in, std::string &inName, OutStreamRecord &outRcd, std::string *err)
Definition: LaserSorter.cc:984
void writeFileHeader(std::ofstream &out)
Definition: LaserSorter.cc:695
void streamFileName(int fedId, edm::LuminosityBlockNumber_t lumiBlock, std::string &tmpName, std::string &finalName)
Definition: LaserSorter.cc:749
unsigned char formatVersion_
Definition: LaserSorter.h:330
#define end
Definition: vmac.h:37
tuple out
Definition: dbtoconf.py:99
static std::string now()
Definition: LaserSorter.cc:70
int readFormatVersion(std::ifstream &in, const std::string &fileName)
tuple cout
Definition: gather_cfg.py:121
OutStreamList outStreamList_
Definition: LaserSorter.h:326
bool renameAsBackup(const std::string &fileName, std::string &newFileName)
Definition: LaserSorter.cc:538
int LaserSorter::dcc2Lme ( int  dccNum,
int  dccSide 
)
private

Definition at line 337 of file LaserSorter.cc.

References bookConverter::min.

337  {
338  int fedid = (dcc%600) + 600; //to handle both FED and DCC id.
339  vector<int> lmes;
340  // EE -
341  if( fedid <= 609 ) {
342  if ( fedid <= 607 ) {
343  lmes.push_back(fedid-601+83);
344  } else if ( fedid == 608 ) {
345  lmes.push_back(90);
346  lmes.push_back(91);
347  } else if ( fedid == 609 ) {
348  lmes.push_back(92);
349  }
350  } //EB
351  else if ( fedid >= 610 && fedid <= 645 ) {
352  lmes.push_back(2*(fedid-610)+1);
353  lmes.push_back(lmes[0]+1);
354  } // EE+
355  else if ( fedid >= 646 ) {
356  if ( fedid <= 652 ) {
357  lmes.push_back(fedid-646+73);
358  } else if ( fedid == 653 ) {
359  lmes.push_back(80);
360  lmes.push_back(81);
361  } else if ( fedid == 654 ) {
362  lmes.push_back(82);
363  }
364  }
365  return lmes.size()==0?-1:lmes[min(lmes.size(), (size_t)side)];
366 }
void LaserSorter::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 851 of file LaserSorter.cc.

References closeAllStreams().

851  {
852  //TODO: better treatement of last files:
853  //they might be imcomplete...
854  closeAllStreams();
855 }
void closeAllStreams()
Definition: LaserSorter.cc:409
int LaserSorter::getDetailedTriggerType ( const edm::Handle< FEDRawDataCollection > &  rawdata,
double *  proba = 0 
)
private

Retrieve detailed trigger type (trigger type, DCC, side) from raw event

Parameters
rawdataFED data collection
probaif not null used to store the maximum of occurence frequency of the detailed trigger types (DTT) appearing in each DCC block. In normal condition every DCC indicated the same DTT and this value is 1.
Returns
detailed trigger type. In case of descripancy between the DCCs, the most frequent value is returned if it covers more than 80% of the present DCC blocks, -1 is returned otherwise. If event does not contain any ECAL data -2 is returned.

Definition at line 368 of file LaserSorter.cc.

References Majority< T >::add(), gather_cfg::cout, FEDRawData::data(), data, ecalDccFedIdMax_, ecalDccFedIdMin_, iNoEcalDataMess_, FEDNumbering::inRange(), maxNoEcalDataMess_, now(), AlCaHLTBitMon_ParallelJobs::p, Majority< T >::result(), FEDRawData::size(), and verbosity_.

Referenced by analyze().

369  {
370  Majority<int> stat;
371  bool ecalData = false;
372  for(int id=ecalDccFedIdMin_; id<=ecalDccFedIdMax_; ++id){
373  if(!FEDNumbering::inRange(id)) continue;
374  const FEDRawData& data = rawdata->FEDData(id);
375  const int detailedTrigger32 = 5;
376  if(verbosity_>3) cout << "[LaserSorter " << now() << "] "
377  << "FED " << id << " data size: "
378  << data.size() << "\n";
379  if(data.size()>=4*(detailedTrigger32+1)){
380  ecalData = true;
381  const uint32_t* pData32 = (const uint32_t*) data.data();
382  int tType = pData32[detailedTrigger32] & 0xFFF;
383  if(verbosity_>3) cout << "[LaserSorter " << now() << "] "
384  << "Trigger type " << tType << "\n";
385  stat.add(tType);
386  }
387  }
388  if(!ecalData) return -2;
389  double p;
390  int tType = stat.result(&p);
391  if(p<0){
392  //throw cms::Exception("NotFound") << "No ECAL DCC data found\n";
394  edm::LogWarning("NotFound") << "No ECAL DCC data found. "
395  "(This warning will be disabled for the current run after "
396  << maxNoEcalDataMess_ << " occurences.)";
398  }
399  tType = -1;
400  } else if(p<.8){
401  //throw cms::Exception("EventCorruption") << "Inconsitency in detailed trigger type indicated in ECAL DCC data headers\n";
402  edm::LogWarning("EventCorruption") << "Inconsitency in detailed trigger type indicated in ECAL DCC data headers\n";
403  tType = -1;
404  }
405  if(proba) *proba = p;
406  return tType;
407 }
static const int ecalDccFedIdMin_
Definition: LaserSorter.h:305
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void add(const T &value)
Definition: Majority.h:24
int iNoEcalDataMess_
Definition: LaserSorter.h:411
static const int ecalDccFedIdMax_
Definition: LaserSorter.h:309
static std::string now()
Definition: LaserSorter.cc:70
static bool inRange(int)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
tuple cout
Definition: gather_cfg.py:121
int maxNoEcalDataMess_
Definition: LaserSorter.h:415
T result(double *proba) const
Definition: Majority.h:29
std::vector< int > LaserSorter::getFullyReadoutDccs ( const FEDRawDataCollection data) const
private

Retrieves DCCs which were fully read out (>=68 readout channels).

Parameters
dataDCC data collection
Returns
FED ids.

Definition at line 932 of file LaserSorter.cc.

References ecalDccFedIdMax_, ecalDccFedIdMin_, FEDRawDataCollection::FEDData(), isDccEventEmpty(), and query::result.

Referenced by analyze().

932  {
933  int nTowers;
934  vector<int> result;
935  for(int fed = ecalDccFedIdMin_; fed < ecalDccFedIdMax_; ++fed){
936  const FEDRawData& fedData = data.FEDData(fed);
937  isDccEventEmpty(fedData, 0, &nTowers);
938  if(nTowers>=68) result.push_back(fed);
939  }
940  return result;
941 }
static const int ecalDccFedIdMin_
Definition: LaserSorter.h:305
bool isDccEventEmpty(const FEDRawData &data, size_t *dccLen=0, int *nTowerBlocks=0) const
Definition: LaserSorter.cc:860
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
tuple result
Definition: query.py:137
static const int ecalDccFedIdMax_
Definition: LaserSorter.h:309
void LaserSorter::getOutputFedList ( const edm::Event event,
const FEDRawDataCollection data,
std::vector< unsigned > &  fedIds 
) const
private

Computes the list of FEDs which data must be written out.

Parameters
dataCMS raw event
fedIds[out] list of FEDs to keep

Definition at line 903 of file LaserSorter.cc.

References ecalDccFedIdMax_, ecalDccFedIdMin_, FEDRawDataCollection::FEDData(), isDccEventEmpty(), matacqFedId_, and FEDRawData::size().

Referenced by writeEvent().

905  {
906  fedIds.erase(fedIds.begin(), fedIds.end());
907  for(int id=ecalDccFedIdMin_; id<=ecalDccFedIdMax_; ++id){
908  size_t dccLen;
909  const FEDRawData& dccEvent = data.FEDData(id);
910  if(id==matacqFedId_
911  || !isDccEventEmpty(dccEvent, &dccLen)){
912  fedIds.push_back(id);
913  }
914  if(dccLen*sizeof(uint64_t)!=dccEvent.size()){
915  edm::LogWarning("LaserSorter")
916  << "Length error in data of FED " << id
917  << " in event " << event.id()
918  << ", Data of this FED dropped.";
919  }
920  }
921  // cout << __FILE__ << ":" << __LINE__ << ": "
922  // << "data.FEDData(" << matacqFedId_ << ").size() = "
923  // << data.FEDData(matacqFedId_).size() << "\n";
924  if(data.FEDData(matacqFedId_).size()>4){//matacq block present
925  // cout << __FILE__ << ":" << __LINE__ << ": "
926  // << "Adding matacq to list of FEDs\n";
927  fedIds.push_back(matacqFedId_);
928  }
929 }
static const int ecalDccFedIdMin_
Definition: LaserSorter.h:305
bool isDccEventEmpty(const FEDRawData &data, size_t *dccLen=0, int *nTowerBlocks=0) const
Definition: LaserSorter.cc:860
static const int matacqFedId_
Definition: LaserSorter.h:434
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
unsigned long long uint64_t
Definition: Time.h:15
static const int ecalDccFedIdMax_
Definition: LaserSorter.h:309
LaserSorter::OutStreamRecord * LaserSorter::getStream ( int  fedId,
edm::LuminosityBlockNumber_t  lumiBlock 
)
private

Gets and eventually creates the output stream for writing the events of a given FED and luminosity block.

Parameters
fedIdID of the FED the event is issued from
lumiBlockluminositu block of the event
Returns
pointer of the output stream record or null if not found.

Definition at line 441 of file LaserSorter.cc.

References funct::abs(), gather_cfg::cout, createOutStream(), ecalDccFedIdMax_, lumiBlockSpan_, now(), outStreamList_, and verbosity_.

Referenced by analyze(), and restoreStreamsOfLumiBlock().

442  {
443 
444  if((fedId != -1) &&
445  (fedId < ecalDccFedIdMin_ || fedId > ecalDccFedIdMax_)) fedId = -1;
446 
447  if(verbosity_>1) cout << "[LaserSorter " << now() << "] "
448  << "Looking for an opened output file for FED "
449  << fedId << " LB " << lumiBlock
450  << "\n";
451 
452  //first look if stream is already open:
453  for(OutStreamList::iterator it = outStreamList_.begin();
454  it != outStreamList_.end();
455  ++it){
456  if(it->fedId()==fedId &&
457  (abs((int)it->startingLumiBlock()-(int)lumiBlock)<=lumiBlockSpan_)){
458  //stream found!
459  return &(*it);
460  }
461  }
462  //stream was not found. Let's create one
463 
464  if(verbosity_) cout << "[LaserSorter " << now() << "] "
465  << "File not yet opened. Opening it.\n";
466 
467  OutStreamList::iterator streamRecord = createOutStream(fedId, lumiBlock);
468  return streamRecord!=outStreamList_.end()?&(*streamRecord):0;
469 }
int lumiBlockSpan_
Definition: LaserSorter.h:428
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const int ecalDccFedIdMax_
Definition: LaserSorter.h:309
static std::string now()
Definition: LaserSorter.cc:70
OutStreamList::iterator createOutStream(int fedId, edm::LuminosityBlockNumber_t lumiBlock)
Definition: LaserSorter.cc:559
tuple cout
Definition: gather_cfg.py:121
OutStreamList outStreamList_
Definition: LaserSorter.h:326
bool LaserSorter::isDccEventEmpty ( const FEDRawData data,
size_t *  dccLen = 0,
int *  nTowerBlocks = 0 
) const
private

Checks if an ECAL DCC event is empty. It is considered as empty if it does not contains FE data ("tower" block). So an event containing SRP or TCC data can be tagged as empty by this method. , if not null filled with the event length read from the DCC header. if not null, filled with number of tower blocks

Returns
true if event is empty, false otherwise

Definition at line 860 of file LaserSorter.cc.

References FEDRawData::data(), dtTPAnalyzer_cfg::dataType, and FEDRawData::size().

Referenced by getFullyReadoutDccs(), and getOutputFedList().

861  {
862  if(nTowerBlocks) *nTowerBlocks = 0;
863  //DCC event is considered empty if it does not contains any Tower block
864  //( = FE data)
865  bool rc = true;
866  if(dccLen) *dccLen = 0;
867  const unsigned nWord32 = data.size()/sizeof(uint32_t);
868  if(nWord32==0){
869  //cout << "[LaserSorter " << now() << "] " << "FED block completly empty\n";
870  return true;
871  }
872  for(unsigned iWord32 = 0; iWord32 < nWord32; iWord32 += 2){
873  uint32_t* data32 = ((uint32_t*)(data.data())) + iWord32;
874  int dataType = (data32[1] >>28) & 0xF;
875  // cout << hex << "0x" << setfill('0')
876  // << setw(8) << data32[1] << "'" << setw(8) << data32[0]
877  // << " dataType: 0x" << dataType
878  // << dec << setfill(' ') << "\n";
879  if(0==(dataType>>2)){//in DCC header
880  const int dccHeaderId = (data32[1] >>24) & 0x3F;
881  if(dccHeaderId==1){
882  if(dccLen) *dccLen=((data32[0] >>0 ) & 0xFFFFFF);
883  }
884  } if((dataType>>2)==3){//Tower block
885  rc = false;
886  if(nTowerBlocks){//number of tower block must be counted
887  ++(*nTowerBlocks);
888  } else{
889  break;
890  }
891  }
892  }
893  // cout << "[LaserSorter " << now() << "] " << "DCC Len: ";
894 
895  // if(dccLen){
896  // cout << (*dccLen) << " event ";
897  // }
898  // cout << (rc?"":"non") << " empty"
899  // << endl;
900  return rc;
901 }
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
int LaserSorter::readFormatVersion ( std::ifstream &  in,
const std::string &  fileName 
)
private

Gets format version of an LMF file. Position of file is preserved.

Parameters
instream to read the file
fileNamename of the file. Used in error message.
Returns
version or -1 in case of error.

Definition at line 1058 of file LaserSorter.cc.

References data, AlCaHLTBitMon_ParallelJobs::p, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by createOutStream().

1059  {
1060  int vers = -1;
1061  streampos p = in.tellg();
1062 
1063  uint32_t data;
1064 
1065  in.read((char*)&data, sizeof(data));
1066 
1067  char magic[4];
1068 
1069  magic[0] = data & 0xFF;
1070  magic[1] = (data >>8) & 0xFF;
1071  magic[2] = (data >>16) & 0xFF;
1072  magic[3] = 0;
1073 
1074 
1075  const string lmf = string("LMF");
1076 
1077  if(in.good() && lmf.compare(magic)==0){
1078  vers = (data >>24) & 0xFF;
1079  }
1080 
1081  if(lmf.compare(magic)!=0){
1082  edm::LogWarning("LaserSorter") << "File " << fileName
1083  << "is not an LMF file.\n";
1084  }
1085 
1086  in.clear();
1087  in.seekg(p);
1088  return vers;
1089 }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
bool LaserSorter::readIndexTable ( std::ifstream &  in,
std::string &  inName,
OutStreamRecord outRcd,
std::string *  err 
)
private

Read index table of an LMF file.

Parameters
inLMF file whose index table must be read.
inNamename of the in file
outRcdrecord of the output file. whose the index table must be copied to.
errif not nul, in case of failure filled with the error message.
Returns
true in case of success, false otherwise

Definition at line 984 of file LaserSorter.cc.

References gather_cfg::cout, LaserSorter::OutStreamRecord::excludedOrbit(), i, recoMuon::in, LaserSorter::OutStreamRecord::indices(), maxEvents_, jetmet_cfg::nevts, now(), alignCSCRings::s, and verbosity_.

Referenced by createOutStream().

987  {
988  stringstream errMsg;
989 
990  ifstream* s = &in;
991 
992  //streampos pos = s->tellg();
993  s->clear();
994  s->seekg(0);
995 
996  uint32_t fileHeader[2];
997  s->read((char*)&fileHeader[0], sizeof(fileHeader));
998  uint32_t indexTablePos = fileHeader[1];
999 
1000  if(s->eof()){
1001  s->clear();
1002  s->seekg(0);
1003  errMsg << "Failed to read header of file " << inName
1004  << ".";
1005  if(err) *err = errMsg.str();
1006  return false;
1007  }
1008 
1009  s->seekg(indexTablePos);
1010 
1011  uint32_t nevts = 0;
1012  s->read((char*)&nevts, sizeof(nevts));
1013  s->ignore(4);
1014  if(s->bad()){
1015  errMsg << "Failed to read index table from file "
1016  << inName << ".";
1017  if(err) *err = errMsg.str();
1018  return false;
1019  }
1020  if(nevts>maxEvents_){
1021  errMsg << "Number of events indicated in event index of file "
1022  << inName << " (" << nevts << ") "
1023  << "is unexpectively large.";
1024  if(err) *err = errMsg.str();
1025  return false;
1026  }
1027  outRcd.indices()->resize(nevts);
1028  s->read((char*)&(*outRcd.indices())[0], nevts*sizeof(IndexRecord));
1029  if(s->bad()){
1030  outRcd.indices()->clear();
1031  errMsg << "Failed to read index table from file "
1032  << inName << ".";
1033  if(err) *err = errMsg.str();
1034  return false;
1035  }
1036  if(nevts>maxEvents_){
1037  errMsg << "Number of events indicated in event index of file "
1038  << inName << " is unexpectively large.";
1039  if(err) *err = errMsg.str();
1040  outRcd.indices()->clear();
1041  return false;
1042  }
1043 
1044  if(verbosity_ > 1) cout << "[LaserSorter " << now() << "] " << "Orbit IDs of events "
1045  << "already contained in the file "
1046  << inName << ":";
1047  for(unsigned i = 0; i < outRcd.indices()->size(); ++i){
1048  if(verbosity_>1){
1049  cout << " " << setw(9) << (*outRcd.indices())[i].orbit;
1050  }
1051  outRcd.excludedOrbit().insert((*outRcd.indices())[i].orbit);
1052  }
1053  if(verbosity_>1) cout << "\n";
1054 
1055  return true;
1056 }
int i
Definition: DBlmapReader.cc:9
static const unsigned maxEvents_
Definition: LaserSorter.h:443
static std::string now()
Definition: LaserSorter.cc:70
tuple cout
Definition: gather_cfg.py:121
int nevts
Definition: jetmet_cfg.py:3
bool LaserSorter::renameAsBackup ( const std::string &  fileName,
std::string &  newFileName 
)
private

Definition at line 538 of file LaserSorter.cc.

References i, and link().

Referenced by createOutStream().

539  {
540  int i = 0;
541  int err;
542  static const int maxTries = 100;
543  stringstream newFileName_;
544  do{
545  newFileName_.str("");
546  newFileName_ << fileName << "~";
547  if(i>0) newFileName_ << i;
548  err = link(fileName.c_str(), newFileName_.str().c_str());
549  if(err==0){
550  newFileName = newFileName_.str();
551  err = unlink(fileName.c_str());
552  }
553  ++i;
554  } while((err!=0) && (errno == EEXIST) && (i < maxTries));
555  return err==0;
556 }
int i
Definition: DBlmapReader.cc:9
std::string link(std::string &nm, std::string &ns)
Definition: hierarchy.cc:24
void LaserSorter::restoreStreamsOfLumiBlock ( int  lumiBlock)
private

Opens output streams associated to a lumi block according to already existing files. To be used when previously processed luminosity block is not

Parameters
lumiBlockID of the luminosity block whose output streams must be reopened.

Definition at line 1106 of file LaserSorter.cc.

References ecalDccFedIdMax_, ecalDccFedIdMin_, convertXMLtoSQLite_cfg::fileName, getStream(), alignCSCRings::s, and streamFileName().

Referenced by analyze().

1106  {
1107  string dummy;
1108  string fileName;
1109 
1110  for(int fedId = ecalDccFedIdMin_-2; fedId <= ecalDccFedIdMax_; ++fedId){
1111  int fedId_;
1112  if(fedId == ecalDccFedIdMin_-2) fedId_ = -1; //stream for event w/o ECAL data
1113  else fedId_ = fedId;
1114  streamFileName(fedId_, lumiBlock, dummy, fileName);
1115  struct stat s;
1116  //TODO: could be optimized by adding an option to get stream
1117  //to open only existing file: would avoid double call to streamFileName.
1118  if(stat(fileName.c_str(), &s)==0){//file exists
1119  getStream(fedId_, lumiBlock);
1120  }
1121  }
1122 }
OutStreamRecord * getStream(int fedId, edm::LuminosityBlockNumber_t lumiBlock)
Definition: LaserSorter.cc:441
static const int ecalDccFedIdMin_
Definition: LaserSorter.h:305
void streamFileName(int fedId, edm::LuminosityBlockNumber_t lumiBlock, std::string &tmpName, std::string &finalName)
Definition: LaserSorter.cc:749
static const int ecalDccFedIdMax_
Definition: LaserSorter.h:309
void LaserSorter::streamFileName ( int  fedId,
edm::LuminosityBlockNumber_t  lumiBlock,
std::string &  tmpName,
std::string &  finalName 
)
private

Builds the file names for the group of event corresponding to a FED and a starting lumi block.

Parameters
fedIdFED ID of the event set
lumiBlockstarting luminoisty block of the event set
[out]tmpNamename of the file to use when filling it.
[out]finalNamename of the file once completed.

Definition at line 749 of file LaserSorter.cc.

References gather_cfg::cout, dir, ecalDccFedIdMax_, ecalDccFedIdMin_, edm::hlt::Exception, fedSubDirs_, convertXMLtoSQLite_cfg::fileName, now(), outputDir_, runNumber_, and verbosity_.

Referenced by createOutStream(), and restoreStreamsOfLumiBlock().

751  {
752  int iFed;
753  if(fedId >= ecalDccFedIdMin_ && fedId <= ecalDccFedIdMax_){
754  iFed = fedId - ecalDccFedIdMin_ + 1;
755  } else if(fedId < 0){
756  iFed = -1; //event w/o ECAL data
757  } else {
758  iFed = 0;
759  }
760  if(iFed < -1 || iFed >= (int)fedSubDirs_.size()){
761  throw cms::Exception("LaserSorter")
762  << "Bug found at " << __FILE__ << ":" << __LINE__
763  << ". FED ID is out of index!";
764  }
765 
766 
767  struct stat fileStat;
768 
769  stringstream buf;
770  buf << outputDir_ << "/"
771  << (iFed<0 ? "Empty" : fedSubDirs_[iFed]);
772 
773  string dir = buf.str();
774  if(0==stat(dir.c_str(), &fileStat)){
775  if(!S_ISDIR(fileStat.st_mode)){
776  throw cms::Exception("[LaserSorter]")
777  << "File " << dir << " exists but is not a directory "
778  << " as expected.";
779  }
780  } else {//directory does not exists, let's try to create it
781  if(0!=mkdir(dir.c_str(), 0755)){
782  throw cms::Exception("[LaserSorter]")
783  << "Failed to create directory " << dir
784  << " for writing data.";
785  }
786  }
787 
788  buf.str("");
789  buf << "Run" << runNumber_
790  << "_LB" << setfill('0') << setw(4) << lumiBlock
791  << ".lmf";
792  string fileName = buf.str();
793  string tmpFileName = fileName + ".part";
794 
795  finalName = dir + "/" + fileName;
796  tmpName = dir + "/" + tmpFileName;
797 
798  if(verbosity_>3) cout << "[LaserSorter " << now() << "] " << "File path: "
799  << finalName << "\n";
800 }
static const int ecalDccFedIdMin_
Definition: LaserSorter.h:305
edm::RunNumber_t runNumber_
Definition: LaserSorter.h:350
std::vector< std::string > fedSubDirs_
Definition: LaserSorter.h:338
std::string outputDir_
Definition: LaserSorter.h:334
static const int ecalDccFedIdMax_
Definition: LaserSorter.h:309
static std::string now()
Definition: LaserSorter.cc:70
tuple cout
Definition: gather_cfg.py:121
dbl *** dir
Definition: mlp_gen.cc:35
std::string LaserSorter::toString ( uint64_t  t)
staticprivate

Help function to format a date

Definition at line 1091 of file LaserSorter.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by writeEventHeader().

1091  {
1092  char buf[256];
1093 
1094  time_t tsec = t>>32;
1095 
1096  uint32_t tusec = t & 0xFFFFFFFF;
1097  strftime(buf, sizeof(buf), "%F %R %S s", localtime(&tsec));
1098  buf[sizeof(buf)-1] = 0;
1099 
1100  stringstream buf2;
1101  buf2 << (tusec+500)/1000;
1102 
1103  return string(buf) + " " + buf2.str() + " ms";
1104 }
bool LaserSorter::writeEvent ( OutStreamRecord out,
const edm::Event event,
int  detailedTriggerType,
const FEDRawDataCollection data 
)
private

Writes a monitoring events to an output stream.

Parameters
outstream to write the event out
eventEDM event, used to retrieve meta information like timestamp and ID.
IDof the unique FED block of the event
dataDCC data
Returns
true on success, false on failure
See Also
getStream(int, edm::LuminosityBlockNumber_t)

Definition at line 471 of file LaserSorter.cc.

References FEDRawDataCollection::FEDData(), getOutputFedList(), LaserSorter::OutStreamRecord::indices(), LaserSorter::OutStreamRecord::out(), dbtoconf::out, edm::Event::size(), writeEventHeader(), and writeFedBlock().

Referenced by analyze().

473  {
474 
475  ofstream& out = *outRcd.out();
476  bool rc = true;
477  vector<unsigned> fedIds;
478  getOutputFedList(event, data, fedIds);
479 
480  out.clear();
481  uint32_t evtStart = out.tellp();
482  if(out.bad()) evtStart = 0;
483  // cout << "------> fedIds.size() = " << fedIds.size() << endl;
484  rc &= writeEventHeader(out, event, dtt, fedIds.size());
485 
486  for(unsigned iFed = 0; iFed < fedIds.size() && rc; ++iFed){
487 // cout << "------> data.FEDData(" << fedIds[iFed] << ").size = "
488 // << data.FEDData(fedIds[iFed]).size() << "\n";
489  rc &= writeFedBlock(out, data.FEDData(fedIds[iFed]));
490  }
491 
492  if(rc){
493  //update index table for this file:
494  vector<IndexRecord>& indices = *outRcd.indices();
495  IndexRecord indexRcd = {event.orbitNumber(), evtStart};
496  indices.push_back(indexRcd);
497  }
498  return rc;
499 }
size_t size() const
Definition: Event.cc:190
void getOutputFedList(const edm::Event &event, const FEDRawDataCollection &data, std::vector< unsigned > &fedIds) const
Definition: LaserSorter.cc:903
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
bool writeFedBlock(std::ofstream &out, const FEDRawData &data)
Definition: LaserSorter.cc:501
tuple out
Definition: dbtoconf.py:99
bool writeEventHeader(std::ofstream &out, const edm::Event &evt, int fedId, unsigned nFeds)
Definition: LaserSorter.cc:712
bool LaserSorter::writeEventHeader ( std::ofstream &  out,
const edm::Event evt,
int  fedId,
unsigned  nFeds 
)
private

Write event header with event identification and timestamp.

Parameters
outoutput stream to write to
evtevent
Returns
false in case of write failure

Definition at line 712 of file LaserSorter.cc.

References edm::EventBase::bunchCrossing(), colorNames, gather_cfg::cout, data, detailedTrigNames, edm::EventID::event(), edm::EventBase::id(), edm::EventBase::luminosityBlock(), now(), edm::EventBase::orbitNumber(), edm::Event::run(), edm::EventBase::time(), toString(), edm::Timestamp::value(), and verbosity_.

Referenced by writeEvent().

715  {
716  uint32_t data[10];
717 
718  data[0] = evt.time().value() & 0xFFFFFFFF;
719  data[1] = evt.time().value() >>32;
720  data[2] = evt.luminosityBlock();
721  data[3] = evt.run();
722  data[4] = evt.orbitNumber();
723  data[5] = evt.bunchCrossing();
724  data[6] = evt.id().event();
725  data[7] = dtt;
726  data[8] = nFeds;
727  data[9] = 0; //reserved (to be aligned on 64-bits)
728 
729  if(verbosity_>1){
730  cout << "[LaserSorter " << now() << "] " << "Write header of event: "
731  << "Time: " << toString(evt.time().value())
732  << ", LB: " << evt.luminosityBlock()
733  << ", Run: " << evt.run()
734  << ", Bx: " << evt.bunchCrossing()
735  << ", Event ID: " << evt.id().event()
736  << ", Detailed trigger type: 0x" << hex << dtt << dec
737  << " (" << detailedTrigNames[(dtt>>8)&0x7] << ", "
738  << colorNames[(dtt>>6)&0x3] << ", DCC " << (dtt&0x3f)
739  << ", side " << ((dtt>>10) &0x1) << ")"
740  << ", number of FEDs: " << nFeds
741  << "\n";
742  }
743 
744  out.clear();
745  out.write((char*)data, sizeof(data));
746  return !out.bad();
747 }
EventNumber_t event() const
Definition: EventID.h:44
static const char *const detailedTrigNames[]
Definition: LaserSorter.cc:49
static std::string toString(uint64_t t)
int bunchCrossing() const
Definition: EventBase.h:62
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
RunNumber_t run() const
Definition: Event.h:88
int orbitNumber() const
Definition: EventBase.h:63
tuple out
Definition: dbtoconf.py:99
static std::string now()
Definition: LaserSorter.cc:70
edm::EventID id() const
Definition: EventBase.h:56
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
tuple cout
Definition: gather_cfg.py:121
static const char *const colorNames[]
Definition: LaserSorter.cc:60
TimeValue_t value() const
Definition: Timestamp.h:56
edm::Timestamp time() const
Definition: EventBase.h:57
bool LaserSorter::writeFedBlock ( std::ofstream &  out,
const FEDRawData data 
)
private

Writes out data of a FED

Parameters
outstream to write the event out
dataFED data
Returns
true on success, false on failure

Definition at line 501 of file LaserSorter.cc.

References gather_cfg::cout, FEDRawData::data(), edm::hlt::Exception, now(), FEDRawData::size(), and verbosity_.

Referenced by writeEvent().

502  {
503  bool rc = false;
504  if (data.size()>4){
505  const uint32_t * pData
506  = reinterpret_cast<uint32_t*>(const_cast<unsigned char*> ( data.data()));
507 
508  uint32_t dccLen64 = pData[2] & 0x00FFFFFF; //in 32-byte unit
509 
510  if(data.size() != dccLen64*sizeof(uint64_t)){
511 // throw cms::Exception("Bug") << "Bug found in "
512 // << __FILE__ << ":" << __LINE__ << ".";
513  throw cms::Exception("LaserSorter")
514  << "Mismatch between FED fragment size indicated in header "
515  << "(" << dccLen64 << "*8 Byte) "
516  << "and actual size (" << data.size() << " Byte) "
517  << "for FED ID " << ((pData[0] >>8) & 0xFFF) << "!\n";
518  }
519 
520  if(verbosity_>3) cout << "[LaserSorter " << now() << "] " << "Event fragment size: "
521  << data.size() << " Byte"
522  << "\t From Dcc header: " << dccLen64*8 << " Byte\n";
523 
524  const size_t nBytes = data.size();
525  // cout << "[LaserSorter " << now() << "] "
526  // << "Writing " << nBytes << " byte from adress "
527  // << (void*) data.data() << " to file.\n";
528  if(out.fail()) cout << "[LaserSorter " << now() << "] " << "Problem with stream!\n";
529  out.write((char*)data.data(), nBytes);
530  rc = true;
531  } else{
532  throw cms::Exception("Bug") << "Bug found in "
533  << __FILE__ << ":" << __LINE__ << ".\n";
534  }
535  return rc;
536 }
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
tuple out
Definition: dbtoconf.py:99
unsigned long long uint64_t
Definition: Time.h:15
static std::string now()
Definition: LaserSorter.cc:70
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
tuple cout
Definition: gather_cfg.py:121
void LaserSorter::writeFileHeader ( std::ofstream &  out)
private

Writing file header for an LMF binary file

Parameters
outstream of the output file

Definition at line 695 of file LaserSorter.cc.

References edm::hlt::Exception, and formatVersion_.

Referenced by createOutStream().

695  {
696  out.clear();
697 
698  uint32_t id = 'L' | ('M' <<8) | ('F' <<16) | (formatVersion_<<24);
699 
700  out.write((char*)&id, sizeof(uint32_t));
701 
702  //index position (to be filled at end of writing)
703  uint32_t zero = 0;
704  out.write((char*)&zero, sizeof(uint32_t));
705 
706  if(out.fail()){
707  throw cms::Exception("LaserSorter")
708  << "Failed to write file header.\n";
709  }
710 }
unsigned char formatVersion_
Definition: LaserSorter.h:330
tuple out
Definition: dbtoconf.py:99
bool LaserSorter::writeIndexTable ( std::ofstream &  out,
std::vector< IndexRecord > &  indices 
)
private

Writes index table in LMF output file. stream must be positionned to the place for the index table (end of file).

Parameters
outstream of output file.
indicesindex table

Definition at line 944 of file LaserSorter.cc.

References data, end, i, indexOffset32_, jetmet_cfg::nevts, and python.multivaluedict::sort().

Referenced by closeOutStream().

945  {
946  uint32_t indexTablePos = out.tellp();
947  uint32_t nevts = indices.size();
948 
949  out.clear();
950  out.write((char*)&nevts, sizeof(nevts));
951  const uint32_t reserved = 0;
952  out.write((char*)&reserved, sizeof(reserved));
953 
954  if(out.bad()) return false;
955 
956  sort(indices.begin(), indices.end());
957 
958  for(unsigned i = 0; i < indices.size(); ++i){
959  uint32_t data[2];
960  data[0] = indices[i].orbit;
961  data[1] = indices[i].filePos;
962  out.write((char*)data, sizeof(data));
963  }
964 
965  if(out.bad()) return false; //intial 0 valur for index table position
966  // is left to indicate corrupted table.
967 
968  //writes index table position:x
969  out.clear();
970  out.seekp(indexOffset32_*sizeof(uint32_t));
971  // cout << "[LaserSorter] Index table position: 0x" << hex << indexTablePos
972  // << dec << "\n";
973  if(!out.bad()) out.write((char*)&indexTablePos, sizeof(uint32_t));
974 
975  bool rc = !out.bad();
976 
977  //reposition pointer to eof:
978  out.seekp(0, ios::end);
979 
980  return rc;
981 }
int i
Definition: DBlmapReader.cc:9
static const int indexOffset32_
Definition: LaserSorter.h:438
#define end
Definition: vmac.h:37
tuple out
Definition: dbtoconf.py:99
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int nevts
Definition: jetmet_cfg.py:3

Member Data Documentation

int LaserSorter::detailedTrigType_
private

Trigger type of calibration event. -1 if unkown.

Definition at line 313 of file LaserSorter.h.

Referenced by analyze().

bool LaserSorter::disableOutput_
private

Switch to disable writing output file (for test purpose).

Definition at line 346 of file LaserSorter.h.

Referenced by analyze().

bool LaserSorter::doOutputList_
private

Switch for logging paths of the output files

Definition at line 370 of file LaserSorter.h.

Referenced by closeOutStream(), and LaserSorter().

const int LaserSorter::ecalDccFedIdMax_ = 654
staticprivate
const int LaserSorter::ecalDccFedIdMin_ = 601
staticprivate

Lower bound of ECAL DCC FED ID

Definition at line 305 of file LaserSorter.h.

Referenced by analyze(), getDetailedTriggerType(), getFullyReadoutDccs(), getOutputFedList(), restoreStreamsOfLumiBlock(), and streamFileName().

edm::InputTag LaserSorter::fedRawDataCollectionTag_
private

Definition at line 430 of file LaserSorter.h.

Referenced by analyze().

std::vector<std::string> LaserSorter::fedSubDirs_
private

Subdirectories for output file of each FED

Definition at line 338 of file LaserSorter.h.

Referenced by LaserSorter(), and streamFileName().

unsigned char LaserSorter::formatVersion_
private

Data format version of lmf output file

Definition at line 330 of file LaserSorter.h.

Referenced by createOutStream(), and writeFileHeader().

const int LaserSorter::indexOffset32_ = 1
staticprivate

Definition at line 438 of file LaserSorter.h.

Referenced by writeIndexTable().

int LaserSorter::iNoEcalDataMess_
private

number of "ECAL DCC data" message in a run

Definition at line 411 of file LaserSorter.h.

Referenced by analyze(), and getDetailedTriggerType().

int LaserSorter::iNoFullReadoutDccError_
private

Number of "No fully readout DCC error"

Definition at line 401 of file LaserSorter.h.

Referenced by analyze().

std::ofstream LaserSorter::logFile_
private

File for logging

Definition at line 317 of file LaserSorter.h.

Referenced by analyze(), LaserSorter(), and ~LaserSorter().

edm::LuminosityBlockNumber_t LaserSorter::lumiBlock_
private

Luminosity block of event under processing

Definition at line 321 of file LaserSorter.h.

Referenced by analyze().

int LaserSorter::lumiBlockSpan_
private

Tolerance on lumi block spanning of a FED sequence. Subsequent events of a same FED must span at most on 2*lumiBlockSpan_+1 luminosity blocks.

  • It is important that the laser sequence scane does not pass twice on the same FED within the 2*lumiBlockSpan_+1. Failing this requirement will result mixing event of different passes in the same output file.
  • The number of input files opened simultinuously is proportional to 2*lumiBlockSpan_+1. So increasing lumiBlockSpan_ will also increase the number of opened files and may have some impact of sorting time performances.

Definition at line 428 of file LaserSorter.h.

Referenced by analyze(), closeOldStreams(), and getStream().

const int LaserSorter::matacqFedId_ = 655
staticprivate

FED ID associated to Matacq data

Definition at line 434 of file LaserSorter.h.

Referenced by getOutputFedList().

const unsigned LaserSorter::maxEvents_ = 1<<20
staticprivate

Limit of number of events to prevent exhausting memory with indexTable_ in case of file corruption.

Definition at line 443 of file LaserSorter.h.

Referenced by readIndexTable().

int LaserSorter::maxFullReadoutDccError_
private

Maximum number of "No fully readout DCC error" message in a run

Definition at line 406 of file LaserSorter.h.

Referenced by analyze().

int LaserSorter::maxNoEcalDataMess_
private

Maximum number of "ECAL DCC data" message in a run

Definition at line 415 of file LaserSorter.h.

Referenced by getDetailedTriggerType().

std::string LaserSorter::outputDir_
private

Top directory for output files

Definition at line 334 of file LaserSorter.h.

Referenced by LaserSorter(), valtools.webpage::readCaptions(), and streamFileName().

std::ofstream LaserSorter::outputList_
private

stream where list of output file is listed to

Definition at line 378 of file LaserSorter.h.

Referenced by closeOutStream(), and LaserSorter().

std::string LaserSorter::outputListFile_
private

name of file where list of output file is listed to

Definition at line 366 of file LaserSorter.h.

Referenced by LaserSorter().

OutStreamList LaserSorter::outStreamList_
private

List of output stream to write sorted data

Definition at line 326 of file LaserSorter.h.

Referenced by closeAllStreams(), closeOldStreams(), closeOutStream(), createOutStream(), and getStream().

edm::RunNumber_t LaserSorter::runNumber_
private

Run number of event under process

Definition at line 350 of file LaserSorter.h.

Referenced by analyze(), and streamFileName().

struct LaserSorter::stats_t LaserSorter::stats_
private

Referenced by analyze(), and ~LaserSorter().

LaserSorter::stats_t LaserSorter::stats_init = {0, 0, 0, 0, 0}
staticprivate

Definition at line 461 of file LaserSorter.h.

std::ofstream LaserSorter::timeLog_
private

Output stream to log code timing

Definition at line 358 of file LaserSorter.h.

Referenced by analyze(), and LaserSorter().

std::string LaserSorter::timeLogFile_
private

Name of the file to log the processing time

Definition at line 342 of file LaserSorter.h.

Referenced by LaserSorter().

timeval LaserSorter::timer_
private

Buffer for timing

Definition at line 354 of file LaserSorter.h.

Referenced by analyze(), and LaserSorter().

bool LaserSorter::timing_
private

Switch for code timing.

Definition at line 362 of file LaserSorter.h.

Referenced by analyze(), and LaserSorter().

int LaserSorter::verbosity_
private