CMS 3D CMS Logo

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

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void endJob () override
 
 LaserSorter (const edm::ParameterSet &)
 
 ~LaserSorter () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

typedef std::list< std::unique_ptr< 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=nullptr)
 
std::vector< int > getFullyReadoutDccs (const FEDRawDataCollection &data) const
 
int getOrbitFromDcc (const edm::Handle< FEDRawDataCollection > &rawdata) const
 
void getOutputFedList (const edm::Event &event, const FEDRawDataCollection &data, std::vector< unsigned > &fedIds) const
 
std::unique_ptr< OutStreamRecord > & getStream (int fedId, edm::LuminosityBlockNumber_t lumiBlock)
 
bool isDccEventEmpty (const FEDRawData &data, size_t *dccLen=nullptr, int *nTowerBlocks=nullptr) 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_
 
edm::EDGetTokenT< FEDRawDataCollectionfedRawDataCollectionToken_
 
std::vector< std::string > fedSubDirs_
 
unsigned char formatVersion_
 
int iNoEcalDataMess_
 
int iNoFullReadoutDccError_
 
std::ofstream logFile_
 
edm::LuminosityBlockNumber_t lumiBlock_
 
edm::LuminosityBlockNumber_t lumiBlockPrev_
 
int lumiBlockSpan_
 
int maxFullReadoutDccError_
 
int maxNoEcalDataMess_
 
int orbit_
 
int orbitCountInALumiBlock_
 
struct timeval orbitZeroTime_
 
std::string outputDir_
 
std::ofstream outputList_
 
std::string outputListFile_
 
OutStreamList outStreamList_
 
bool overWriteLumiBlockId_
 
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 const stats_t stats_init = {0, 0, 0, 0, 0}
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (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

◆ OutStreamList

typedef std::list<std::unique_ptr<OutStreamRecord> > LaserSorter::OutStreamList
private

Definition at line 114 of file LaserSorter.h.

Constructor & Destructor Documentation

◆ LaserSorter()

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

Definition at line 74 of file LaserSorter.cc.

75  : lumiBlock_(0),
76  lumiBlockPrev_(0),
77  formatVersion_(5),
78  outputDir_(pset.getParameter<std::string>("outputDir")),
79  fedSubDirs_(pset.getParameter<std::vector<std::string> >("fedSubDirs")),
80  timeLogFile_(pset.getUntrackedParameter<std::string>("timeLogFile", "")),
81  disableOutput_(pset.getUntrackedParameter<bool>("disableOutput", false)),
82  runNumber_(0),
83  outputListFile_(pset.getUntrackedParameter<string>("outputListFile", "")),
84  doOutputList_(false),
85  verbosity_(pset.getUntrackedParameter<int>("verbosity", 0)),
87  maxFullReadoutDccError_(pset.getParameter<int>("maxFullReadoutDccError")),
89  maxNoEcalDataMess_(pset.getParameter<int>("maxNoEcalDataMess")),
90  lumiBlockSpan_(pset.getParameter<int>("lumiBlockSpan")),
91  fedRawDataCollectionTag_(pset.getParameter<edm::InputTag>("fedRawDataCollectionTag")),
93  overWriteLumiBlockId_(pset.getParameter<bool>("overWriteLumiBlockId")),
94  orbitCountInALumiBlock_(pset.getParameter<int>("orbitCountInALumiBlock")),
95  orbit_(-1),
97  gettimeofday(&timer_, nullptr);
98  logFile_.open("eventSelect.log", ios::app | ios::out);
99 
100  const unsigned nEcalFeds = 54;
101  if (fedSubDirs_.size() != nEcalFeds + 1) {
102  throw cms::Exception("LaserSorter") << "Configuration error: "
103  << "fedSubDirs parameter must be a vector "
104  << " of " << nEcalFeds << " strings"
105  << " (subdirectory for unknown triggered FED followed by "
106  "subdirectories for FED ID 601 "
107  "to FED ID 654 in increasing FED ID order)";
108  }
109 
110  fedRawDataCollectionToken_ = consumes<FEDRawDataCollection>(fedRawDataCollectionTag_);
111 
112  if (!outputListFile_.empty()) {
113  outputList_.open(outputListFile_.c_str(), ios::app);
114  if (outputList_.bad()) {
115  throw cms::Exception("FileOpen") << "Failed to open file '" << outputListFile_
116  << "' for logging of output file path list.";
117  }
118  doOutputList_ = true;
119  }
120 
121  if (!timeLogFile_.empty()) {
122  timeLog_.open(timeLogFile_.c_str());
123  if (timeLog_.fail()) {
124  cout << "[LaserSorter " << now() << "] "
125  << "Failed to open file " << timeLogFile_ << " to log timing.\n";
126  timing_ = false;
127  } else {
128  timing_ = true;
129  }
130  }
131 
132  struct stat fileStat;
133  if (0 == stat(outputDir_.c_str(), &fileStat)) {
134  if (!S_ISDIR(fileStat.st_mode)) {
135  throw cms::Exception("[LaserSorter]") << "File " << outputDir_ << " exists but is not a directory "
136  << " as expected.";
137  }
138  } else { //directory does not exists, let's try to create it
139  if (0 != mkdir(outputDir_.c_str(), 0755)) {
140  throw cms::Exception("[LaserSorter]") << "Failed to create directory " << outputDir_ << " for writing data.";
141  }
142  }
143 
144  logFile_ << "# "
145  "run\t"
146  "LB\t"
147  "event\t"
148  "trigType\t"
149  "FED\t"
150  "side\t"
151  "LB out\t"
152  "Written\t"
153  "ECAL data\n";
154 }

References gather_cfg::cout, doOutputList_, Exception, fedRawDataCollectionTag_, fedRawDataCollectionToken_, fedSubDirs_, logFile_, eostools::mkdir(), now(), MillePedeFileConverter_cfg::out, outputDir_, outputList_, outputListFile_, edm_modernize_messagelogger::stat, timeLog_, timeLogFile_, timer_, and timing_.

◆ ~LaserSorter()

LaserSorter::~LaserSorter ( )
override

Definition at line 156 of file LaserSorter.cc.

156  {
157  logFile_ << "Summary. Event count: " << stats_.nRead << " processed, " << stats_.nWritten << " written, "
158  << stats_.nInvalidDccStrict << " with errors in DCC ID values, " << stats_.nInvalidDccWeak
159  << " with unusable DCC ID values, " << stats_.nRestoredDcc << " restored DCC ID based on DCC block size\n";
160 }

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

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 163 of file LaserSorter.cc.

163  {
164  if (timing_) {
165  timeval t;
166  gettimeofday(&t, nullptr);
167  timeLog_ << t.tv_sec << "." << setfill('0') << setw(3) << (t.tv_usec + 500) / 1000 << setfill(' ') << "\t"
168  << (t.tv_usec - timer_.tv_usec) * 1. + (t.tv_sec - timer_.tv_sec) * 1.e6 << "\t";
169  timer_ = t;
170  }
171 
172  ++stats_.nRead;
173 
174  if (event.id().run() != runNumber_) { //run changed or first event
175  //for a new run, starts with a new output stream set.
176  closeAllStreams();
177  runNumber_ = event.id().run();
179  iNoEcalDataMess_ = 0;
180  lumiBlockPrev_ = 0;
181  lumiBlock_ = 0;
182  }
183 
185  event.getByToken(fedRawDataCollectionToken_, rawdata);
186 
187  //orbit number
188  //FIXME: orbit from edm Event is currently wrong. Forcing to use of CMS orbit until
189  //it is fixed. See https://hypernews.cern.ch/HyperNews/CMS/get/commissioning/5343/2.html
190 #if 0
191  orbit_ = event.orbitNumber();
192 #else
193  orbit_ = -1;
194 #endif
195 
196  // std::cerr << "Orbit ID CMS, ECAL: " << orbit_ << "\t" << getOrbitFromDcc(rawdata) << "\n";
197 
198  if (orbit_ < 0) { //For local run CMSSW failed to find the orbit number
199  // cout << "Look for orbit from DCC headers....\n";
200  orbit_ = getOrbitFromDcc(rawdata);
201  }
202 
203  //The "detailed trigger type DCC field content:
204  double dttProba = 0;
205  int dtt = getDetailedTriggerType(rawdata, &dttProba);
206 
207  if (overWriteLumiBlockId_) {
210  if (lb != lumiBlock_) {
211  std::cout << "[LaserSorter " << now() << "] Overwrite LB mode. LB number changed from: " << lb << " to "
212  << lumiBlock_ << "\n";
213  }
214  } else {
216  lumiBlock_ = event.luminosityBlock();
217  if (lb != lumiBlock_) {
218  std::cout << "[LaserSorter " << now() << "] Standard LB mode. LB number changed from: " << lb << " to "
219  << lumiBlock_ << "\n";
220  }
221  }
222 
223  detailedTrigType_ = dtt;
224  const int trigType = (detailedTrigType_ >> 8) & 0x7;
225  const int color = (detailedTrigType_ >> 6) & 0x3;
226  const int dccId = (detailedTrigType_ >> 0) & 0x3F;
227  int triggeredFedId = (detailedTrigType_ == -2) ? -1 : (600 + dccId);
228  const int side = (detailedTrigType_ >> 11) & 0x1;
229  //monitoring region extended id:
230  // const int lme = dcc2Lme(dccId, side);
231 
232  if (detailedTrigType_ > -2) {
233  if (dttProba < 1. || triggeredFedId < ecalDccFedIdMin_ || triggeredFedId > ecalDccFedIdMax_) {
235  }
236 
237  if (triggeredFedId < ecalDccFedIdMin_ || triggeredFedId > ecalDccFedIdMax_) {
238  if (verbosity_)
239  cout << "[LaserSorter " << now() << "] "
240  << "DCC ID (" << dccId << ") found in trigger type is out of range.";
242  vector<int> ids = getFullyReadoutDccs(*rawdata);
243  if (ids.empty()) {
245  cout << " No fully read-out DCC found\n";
247  }
248  } else if (ids.size() == 1) {
249  triggeredFedId = ids[0];
250  if (verbosity_)
251  cout << " ID guessed from DCC payloads\n";
253  } else { //ids.size()>1
254  if (verbosity_) {
255  cout << " Several fully read-out Dccs:";
256  for (unsigned i = 0; i < ids.size(); ++i)
257  cout << " " << ids[i];
258  cout << "\n";
259  }
260  }
261  }
262 
263  if (verbosity_ > 1)
264  cout << "\n----------------------------------------------------------------------\n"
265  << "Event id: "
266  << " " << event.id() << "\n"
267  << "Lumin block: " << lumiBlock_ << "\n"
268  << "TrigType: " << detailedTrigNames[trigType & 0x7] << " Color: " << colorNames[color & 0x3]
269  << " FED: " << triggeredFedId << " side:" << side << "\n"
270  << "\n----------------------------------------------------------------------\n";
271 
272  } else { //NO ECAL DATA
273  if (verbosity_ > 1)
274  cout << "\n----------------------------------------------------------------------\n"
275  << "Event id: "
276  << " " << event.id() << "\n"
277  << "Lumin block: " << lumiBlock_ << "\n"
278  << "No ECAL data\n"
279  << "\n----------------------------------------------------------------------\n";
280  }
281 
282  logFile_ << event.id().run() << "\t" << lumiBlock_ << "\t" << event.id().event() << "\t" << trigType << "\t"
283  << triggeredFedId << "\t" << side;
284 
285  bool written = false;
286  int assignedLB = -1;
287 
288  if (lumiBlock_ != lumiBlockPrev_) {
289  //lumi block change => need for stream garbage collection
290  const int lb = lumiBlock_;
291  closeOldStreams(lb);
292  int minLumi = lumiBlock_ - lumiBlockSpan_;
293  int maxLumi = lumiBlock_ + lumiBlockSpan_;
294  for (int lb1 = minLumi; lb1 <= maxLumi; ++lb1) {
296  }
297  }
298 
299  // if(lumiBlock_ < lumiBlockPrev_){
300  // throw cms::Exception("LaserSorter")
301  // << "Process event has a lumi block (" << lumiBlock_ << ")"
302  // << "older than previous one (" << lumiBlockPrev_ << "). "
303  // << "This can be due by wrong input file ordering or bad luminosity "
304  // << "block indication is the event header. "
305  // << "Event cannot be processed";
306  // }
307 
308  if (disableOutput_) {
309  /* NO OP*/
310  } else {
311  auto& out = getStream(triggeredFedId, lumiBlock_);
312 
313  if (out != nullptr) {
314  assignedLB = out->startingLumiBlock();
315  if (out->excludedOrbit().find(orbit_) == out->excludedOrbit().end()) {
316  if (verbosity_ > 1)
317  cout << "[LaserSorter " << now() << "] "
318  << "Writing out event from FED " << triggeredFedId << " LB " << lumiBlock_ << " orbit " << orbit_
319  << "\n";
320  int dtt = (detailedTrigType_ >= 0) ? detailedTrigType_ : -1; //shall we use -1 or 0 for undefined value?
321  written = written || writeEvent(*out, event, dtt, *rawdata);
322  ++stats_.nWritten;
323  } else {
324  if (verbosity_)
325  cout << "[LaserSorter " << now() << "] "
326  << "File " << out->finalFileName() << " "
327  << "already contains calibration event from FED " << triggeredFedId << ", LB = " << lumiBlock_
328  << " with orbit ID " << orbit_ << ". Event skipped.\n";
329  }
330  }
331  }
333 
334  logFile_ << "\t";
335  if (assignedLB >= 0)
336  logFile_ << assignedLB;
337  else
338  logFile_ << "-";
339  logFile_ << "\t" << (written ? "Y" : "N") << "\n";
340  logFile_ << "\t" << (detailedTrigType_ == -2 ? "N" : "Y") << "\n";
341 
342  if (timing_) {
343  timeval t;
344  gettimeofday(&t, nullptr);
345  timeLog_ << (t.tv_usec - timer_.tv_usec) * 1. + (t.tv_sec - timer_.tv_sec) * 1.e6 << "\n";
346  timer_ = t;
347  }
348 }

References closeAllStreams(), closeOldStreams(), colorNames, gather_cfg::cout, ecaldqm::dccId(), detailedTrigNames, detailedTrigType_, disableOutput_, ecalDccFedIdMax_, fedRawDataCollectionToken_, getDetailedTriggerType(), getFullyReadoutDccs(), getOrbitFromDcc(), getStream(), mps_fire::i, iNoEcalDataMess_, iNoFullReadoutDccError_, logFile_, lumiBlock_, lumiBlockPrev_, lumiBlockSpan_, maxFullReadoutDccError_, LaserSorter::stats_t::nInvalidDccStrict, LaserSorter::stats_t::nInvalidDccWeak, now(), LaserSorter::stats_t::nRead, LaserSorter::stats_t::nRestoredDcc, LaserSorter::stats_t::nWritten, orbit_, orbitCountInALumiBlock_, MillePedeFileConverter_cfg::out, overWriteLumiBlockId_, restoreStreamsOfLumiBlock(), runNumber_, stats_, submitPVValidationJobs::t, timeLog_, timer_, timing_, verbosity_, writeEvent(), and testProducerWithPsetDescEmpty_cfi::x1.

◆ beginJob()

void LaserSorter::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 894 of file LaserSorter.cc.

894 {}

◆ beginRun()

void LaserSorter::beginRun ( edm::Run const &  run,
edm::EventSetup const &  es 
)
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 1159 of file LaserSorter.cc.

1159  {
1160  // cout << "Run starts at :" << run.runAuxiliary().beginTime().value() << "\n";
1161 }

◆ closeAllStreams()

void LaserSorter::closeAllStreams ( )
private

Closes all opened output streams.

Definition at line 448 of file LaserSorter.cc.

448  {
449  for (OutStreamList::iterator it = outStreamList_.begin(); it != outStreamList_.end(); /*NOOP*/) {
450  it = closeOutStream(it);
451  }
452 }

References closeOutStream(), and outStreamList_.

Referenced by analyze(), and endJob().

◆ closeOldStreams()

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 454 of file LaserSorter.cc.

454  {
455  const edm::LuminosityBlockNumber_t minLumiBlock = lumiBlock - lumiBlockSpan_;
456  const edm::LuminosityBlockNumber_t maxLumiBlock = lumiBlock + lumiBlockSpan_;
457  //If container type is ever changed, beware that
458  //closeOutStream call in the loop removes it from outStreamList
459  for (OutStreamList::iterator it = outStreamList_.begin(); it != outStreamList_.end();
460  /*NOOP*/) {
461  if ((*it)->startingLumiBlock() < minLumiBlock || (*it)->startingLumiBlock() > maxLumiBlock) {
462  //event older than 2 lumi block => stream can be closed
463  if (verbosity_)
464  cout << "[LaserSorter " << now() << "] "
465  << "Closing file for "
466  << "FED " << (*it)->fedId() << " LB " << (*it)->startingLumiBlock() << "\n";
467  it = closeOutStream(it);
468  } else {
469  ++it;
470  }
471  }
472 }

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

Referenced by analyze().

◆ closeOutStream()

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 841 of file LaserSorter.cc.

841  {
842  if (streamRecord == outStreamList_.end())
843  return outStreamList_.end();
844 
845  if (verbosity_)
846  cout << "[LaserSorter " << now() << "] "
847  << "Writing Index table of file " << (*streamRecord)->finalFileName() << "\n";
848  ofstream& out = *(*streamRecord)->out();
849  out.clear();
850  if (!writeIndexTable(out, *(*streamRecord)->indices())) {
851  cout << "Error while writing index table for file " << (*streamRecord)->finalFileName() << ". "
852  << "Resulting file might be corrupted. "
853  << "The error can be due to a lack of disk space.";
854  }
855 
856  if (verbosity_)
857  cout << "[LaserSorter " << now() << "] "
858  << "Closing file " << (*streamRecord)->finalFileName() << ".\n";
859  out.close();
860 
861  const std::string& tmpFileName = (*streamRecord)->tmpFileName();
862  const std::string& finalFileName = (*streamRecord)->finalFileName();
863 
864  if (verbosity_)
865  cout << "[LaserSorter " << now() << "] "
866  << "Renaming " << tmpFileName << " to " << finalFileName << ".\n";
867 
868  if (0 != rename(tmpFileName.c_str(), finalFileName.c_str())) {
869  cout << "[LaserSorter " << now() << "] "
870  << " Failed to rename output file from " << tmpFileName << " to " << finalFileName << ". " << strerror(errno)
871  << "\n";
872  }
873 
874  if (doOutputList_) {
875  char buf[256];
876  time_t t = time(nullptr);
877  strftime(buf, sizeof(buf), "%F %R:%S", localtime(&t));
878 
879  ifstream f(".watcherfile");
880  string inputFile;
881  f >> inputFile;
882  outputList_ << finalFileName << "\t" << buf << "\t" << inputFile << endl;
883  }
884 
885  return outStreamList_.erase(streamRecord);
886 }

References visDQMUpload::buf, gather_cfg::cout, doOutputList_, f, dtResolutionTest_cfi::inputFile, now(), MillePedeFileConverter_cfg::out, outputList_, outStreamList_, AlCaHLTBitMon_QueryRunRegistry::string, submitPVValidationJobs::t, protons_cff::time, verbosity_, and writeIndexTable().

Referenced by closeAllStreams(), and closeOldStreams().

◆ createOutStream()

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 612 of file LaserSorter.cc.

612  {
613  if (verbosity_)
614  cout << "[LaserSorter " << now() << "] "
615  << "Creating a stream for FED " << fedId << " lumi block " << lumiBlock << ".\n";
616  std::string tmpName;
617  std::string finalName;
618 
619  streamFileName(fedId, lumiBlock, tmpName, finalName);
620 
621  errno = 0;
622 
623  //checks if a file with tmpName name already exists:
624  ofstream* out = new ofstream(tmpName.c_str(), ios::out | ios::in);
625  if (out->is_open()) { //temporary file already exists. Making a backup:
626  string newName;
627  if (!renameAsBackup(tmpName, newName)) {
628  throw cms::Exception("LaserSorter") << "Failed to rename file " << tmpName << " to " << newName << "\n";
629  }
630  if (verbosity_)
631  cout << "[LaserSorter " << now() << "] "
632  << "Already existing File " << tmpName << " renamed to " << newName << "\n";
633  out->close();
634  }
635 
636  out->clear();
637  out->open(tmpName.c_str(), ios::out | ios::trunc);
638 
639  if (out->fail()) { //failed to create file
640  delete out;
641  throw cms::Exception("LaserSorter") << "Failed to create file " << tmpName << " for writing event from FED "
642  << fedId << " lumi block " << lumiBlock << ": " << strerror(errno) << "\n.";
643  }
644 
645  ifstream in(finalName.c_str());
646  bool newFile = true;
647  if (in.good()) { //file already exists with final name.
648  if (verbosity_)
649  cout << "[LaserSorter " << now() << "] "
650  << "File " << finalName << " already exists. It will be updated if needed.\n";
651  //Copying its contents:
652  char buffer[256];
653  streamsize nread = -1;
654  int vers = readFormatVersion(in, finalName);
655  if (vers == -1) {
656  edm::LogWarning("LaserSorter") << "File " << tmpName.c_str() << " is not an LMF file despite its extension or "
657  << "it is corrupted.\n";
658  } else if (vers != formatVersion_) {
659  edm::LogWarning("LaserSorter") << "Cannot include events already in file " << tmpName.c_str()
660  << " because of version "
661  << "mismatch (found version " << (int)vers << " while "
662  << "only version " << (int)formatVersion_ << " is supported).\n";
663  } else {
664  newFile = false;
665  //read index table offset value:
666  const int indexTableOffsetPos8 = 1 * sizeof(uint32_t);
667  uint32_t indexTableOffsetValue = 0;
668  in.clear();
669  in.seekg(indexTableOffsetPos8, ios::beg);
670  in.read((char*)&indexTableOffsetValue, sizeof(indexTableOffsetValue));
671  if (in.fail()) {
672  cout << "[LaserSorter " << now() << "] "
673  << "Failed to read offset of index table "
674  " in the existing file "
675  << finalName << "\n";
676  } else {
677  if (verbosity_ > 2)
678  cout << "[LaserSorter " << now() << "] "
679  << "Index table offset of "
680  "original file "
681  << finalName << ": 0x" << hex << setfill('0') << setw(8) << indexTableOffsetValue << dec << setfill(' ')
682  << "\n";
683  }
684  in.clear();
685  in.seekg(0, ios::beg);
686 
687  //copy legacy file contents except the index table
688  uint32_t toRead = indexTableOffsetValue;
689  cout << "[LaserSorter " << now() << "] "
690  << "Copying " << finalName << " to " << tmpName << endl;
691  while (!in.eof() && (toRead > 0) && (nread = in.readsome(buffer, min(toRead, (uint32_t)sizeof(buffer)))) != 0) {
692  // cout << "Writing " << nread << " bytes to file "
693  // << tmpName.c_str() << "\n";
694  toRead -= nread;
695  // out->seekp(0, ios::end);
696  out->write(buffer, nread);
697  if (out->bad()) {
698  throw cms::Exception("LaserSorter")
699  << "Error while writing to file " << tmpName << ". Check if there is enough "
700  << "space on the device.\n";
701  }
702  }
703 
704  //resets index table offset field:
705  indexTableOffsetValue = 0;
706  out->clear();
707  out->seekp(indexTableOffsetPos8, ios::beg);
708  out->write((char*)&indexTableOffsetValue, sizeof(uint32_t));
709  out->clear();
710  out->seekp(0, ios::end);
711  }
712  }
713 
714 #if 0
715  out->flush();
716  cout << "Press enter... file name was " << tmpName << endl;
717  char c;
718  cin >> c;
719 #endif
720 
721  OutStreamRecord* outRcd = new OutStreamRecord(fedId, lumiBlock, out, tmpName, finalName);
722 
723  if (newFile) {
725  } else {
726  std::string errMsg;
727  if (!readIndexTable(in, finalName, *outRcd, &errMsg)) {
728  throw cms::Exception("LaserSorter") << errMsg << "\n";
729  }
730  }
731 
732  return outStreamList_.emplace(outStreamList_.end(), outRcd);
733 }

References edmScanValgrind::buffer, c, gather_cfg::cout, TauDecayModes::dec, mps_fire::end, Exception, l1tstage2_dqm_sourceclient-live_cfg::fedId, formatVersion_, recoMuon::in, createfilelist::int, min(), mps_merge::newName, now(), MillePedeFileConverter_cfg::out, outStreamList_, readFormatVersion(), readIndexTable(), renameAsBackup(), streamFileName(), AlCaHLTBitMon_QueryRunRegistry::string, pileupReCalc_HLTpaths::trunc, verbosity_, and writeFileHeader().

Referenced by getStream().

◆ dcc2Lme()

int LaserSorter::dcc2Lme ( int  dccNum,
int  dccSide 
)
private

Definition at line 350 of file LaserSorter.cc.

350  {
351  int fedid = (dcc % 600) + 600; //to handle both FED and DCC id.
352  vector<int> lmes;
353  // EE -
354  if (fedid <= 609) {
355  if (fedid <= 607) {
356  lmes.push_back(fedid - 601 + 83);
357  } else if (fedid == 608) {
358  lmes.push_back(90);
359  lmes.push_back(91);
360  } else if (fedid == 609) {
361  lmes.push_back(92);
362  }
363  } //EB
364  else if (fedid >= 610 && fedid <= 645) {
365  lmes.push_back(2 * (fedid - 610) + 1);
366  lmes.push_back(lmes[0] + 1);
367  } // EE+
368  else if (fedid >= 646) {
369  if (fedid <= 652) {
370  lmes.push_back(fedid - 646 + 73);
371  } else if (fedid == 653) {
372  lmes.push_back(80);
373  lmes.push_back(81);
374  } else if (fedid == 654) {
375  lmes.push_back(82);
376  }
377  }
378  return lmes.empty() ? -1 : lmes[min(lmes.size(), (size_t)side)];
379 }

References PixelSLinkDataInputSource_cfi::fedid, and min().

◆ endJob()

void LaserSorter::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 888 of file LaserSorter.cc.

888  {
889  //TODO: better treatement of last files:
890  //they might be imcomplete...
891  closeAllStreams();
892 }

References closeAllStreams().

Referenced by o2olib.O2ORunMgr::executeJob().

◆ getDetailedTriggerType()

int LaserSorter::getDetailedTriggerType ( const edm::Handle< FEDRawDataCollection > &  rawdata,
double *  proba = nullptr 
)
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 404 of file LaserSorter.cc.

404  {
406  bool ecalData = false;
407  for (int id = ecalDccFedIdMin_; id <= ecalDccFedIdMax_; ++id) {
408  if (!FEDNumbering::inRange(id))
409  continue;
410  const FEDRawData& data = rawdata->FEDData(id);
411  const int detailedTrigger32 = 5;
412  if (verbosity_ > 3)
413  cout << "[LaserSorter " << now() << "] "
414  << "FED " << id << " data size: " << data.size() << "\n";
415  if (data.size() >= 4 * (detailedTrigger32 + 1)) {
416  ecalData = true;
417  const uint32_t* pData32 = (const uint32_t*)data.data();
418  int tType = pData32[detailedTrigger32] & 0xFFF;
419  if (verbosity_ > 3)
420  cout << "[LaserSorter " << now() << "] "
421  << "Trigger type " << tType << "\n";
422  stat.add(tType);
423  }
424  }
425  if (!ecalData)
426  return -2;
427  double p;
428  int tType = stat.result(&p);
429  if (p < 0) {
430  //throw cms::Exception("NotFound") << "No ECAL DCC data found\n";
432  edm::LogWarning("NotFound") << "No ECAL DCC data found. "
433  "(This warning will be disabled for the current run after "
434  << maxNoEcalDataMess_ << " occurences.)";
436  }
437  tType = -1;
438  } else if (p < .8) {
439  //throw cms::Exception("EventCorruption") << "Inconsitency in detailed trigger type indicated in ECAL DCC data headers\n";
440  edm::LogWarning("EventCorruption") << "Inconsitency in detailed trigger type indicated in ECAL DCC data headers\n";
441  tType = -1;
442  }
443  if (proba)
444  *proba = p;
445  return tType;
446 }

References gather_cfg::cout, data, ecalDccFedIdMax_, ecalDccFedIdMin_, FEDRawDataCollection::FEDData(), triggerObjects_cff::id, iNoEcalDataMess_, FEDNumbering::inRange(), maxNoEcalDataMess_, now(), AlCaHLTBitMon_ParallelJobs::p, edm_modernize_messagelogger::stat, and verbosity_.

Referenced by analyze().

◆ getFullyReadoutDccs()

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 967 of file LaserSorter.cc.

967  {
968  int nTowers;
969  vector<int> result;
970  for (int fed = ecalDccFedIdMin_; fed <= ecalDccFedIdMax_; ++fed) {
971  const FEDRawData& fedData = data.FEDData(fed);
972  isDccEventEmpty(fedData, nullptr, &nTowers);
973  if (nTowers >= 68)
974  result.push_back(fed);
975  }
976  return result;
977 }

References data, ecalDccFedIdMax_, ecalDccFedIdMin_, isDccEventEmpty(), ecaldqm::nTowers, and mps_fire::result.

Referenced by analyze().

◆ getOrbitFromDcc()

int LaserSorter::getOrbitFromDcc ( const edm::Handle< FEDRawDataCollection > &  rawdata) const
private

Retrieves the orbit ID from DCC headers. The first header found is used. @rawdata the raw data where to read the orbit id.

Returns
the event orbit ID or -1 if it was not found

Definition at line 381 of file LaserSorter.cc.

381  {
382  const int orbit32 = 6;
383  for (int id = ecalDccFedIdMin_; id <= ecalDccFedIdMax_; ++id) {
384  if (!FEDNumbering::inRange(id))
385  continue;
386  const FEDRawData& data = rawdata->FEDData(id);
387  if (data.size() >= 4 * (orbit32 + 1)) {
388  const uint32_t* pData32 = (const uint32_t*)data.data();
389  // cout << "Found a DCC header: "
390  // << pData32[0] << " "
391  // << pData32[1] << " "
392  // << pData32[2] << " "
393  // << pData32[3] << " "
394  // << pData32[4] << " "
395  // << pData32[5] << " "
396  // << pData32[6] << " "
397  // << "\n";
398  return pData32[orbit32];
399  }
400  }
401  return -1;
402 }

References data, ecalDccFedIdMax_, ecalDccFedIdMin_, FEDRawDataCollection::FEDData(), triggerObjects_cff::id, and FEDNumbering::inRange().

Referenced by analyze().

◆ getOutputFedList()

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 942 of file LaserSorter.cc.

944  {
945  fedIds.erase(fedIds.begin(), fedIds.end());
946  for (int id = ecalDccFedIdMin_; id <= ecalDccFedIdMax_; ++id) {
947  size_t dccLen;
948  const FEDRawData& dccEvent = data.FEDData(id);
949  if (!isDccEventEmpty(dccEvent, &dccLen)) {
950  fedIds.push_back(id);
951  }
952  if (dccLen * sizeof(uint64_t) != dccEvent.size()) {
953  edm::LogWarning("LaserSorter") << "Length error in data of FED " << id << " in event " << event.id()
954  << ", Data of this FED dropped.";
955  }
956  }
957  // cout << __FILE__ << ":" << __LINE__ << ": "
958  // << "data.FEDData(" << matacqFedId_ << ").size() = "
959  // << data.FEDData(matacqFedId_).size() << "\n";
960  if (data.FEDData(matacqFedId_).size() > 4) { //matacq block present
961  // cout << __FILE__ << ":" << __LINE__ << ": "
962  // << "Adding matacq to list of FEDs\n";
963  fedIds.push_back(matacqFedId_);
964  }
965 }

References data, ecalDccFedIdMax_, ecalDccFedIdMin_, L1TStage2BMTF_cff::fedIds, triggerObjects_cff::id, isDccEventEmpty(), matacqFedId_, and FEDRawData::size().

Referenced by writeEvent().

◆ getStream()

std::unique_ptr< 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 474 of file LaserSorter.cc.

475  {
476  static std::unique_ptr<LaserSorter::OutStreamRecord> streamNotFound(nullptr);
477 
478  if ((fedId != -1) && (fedId < ecalDccFedIdMin_ || fedId > ecalDccFedIdMax_))
479  fedId = -1;
480 
481  if (verbosity_ > 1)
482  cout << "[LaserSorter " << now() << "] "
483  << "Looking for an opened output file for FED " << fedId << " LB " << lumiBlock << "\n";
484 
485  //first look if stream is already open:
486  for (OutStreamList::iterator it = outStreamList_.begin(); it != outStreamList_.end(); ++it) {
487  if ((*it)->fedId() == fedId && (abs((int)(*it)->startingLumiBlock() - (int)lumiBlock) <= lumiBlockSpan_)) {
488  //stream found!
489  return (*it);
490  }
491  }
492  //stream was not found. Let's create one
493 
494  if (verbosity_)
495  cout << "[LaserSorter " << now() << "] "
496  << "File not yet opened. Opening it.\n";
497 
498  OutStreamList::iterator streamRecord = createOutStream(fedId, lumiBlock);
499  return streamRecord != outStreamList_.end() ? (*streamRecord) : streamNotFound;
500 }

References funct::abs(), gather_cfg::cout, createOutStream(), ecalDccFedIdMax_, l1tstage2_dqm_sourceclient-live_cfg::fedId, createfilelist::int, lumiBlockSpan_, now(), outStreamList_, and verbosity_.

Referenced by analyze(), and restoreStreamsOfLumiBlock().

◆ isDccEventEmpty()

bool LaserSorter::isDccEventEmpty ( const FEDRawData data,
size_t *  dccLen = nullptr,
int *  nTowerBlocks = nullptr 
) 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. @dccLen, if not null filled with the event length read from the DCC header. @nTowerBlocks if not null, filled with number of tower blocks

Returns
true if event is empty, false otherwise

Definition at line 896 of file LaserSorter.cc.

896  {
897  if (nTowerBlocks)
898  *nTowerBlocks = 0;
899  //DCC event is considered empty if it does not contains any Tower block
900  //( = FE data)
901  bool rc = true;
902  if (dccLen)
903  *dccLen = 0;
904  const unsigned nWord32 = data.size() / sizeof(uint32_t);
905  if (nWord32 == 0) {
906  //cout << "[LaserSorter " << now() << "] " << "FED block completly empty\n";
907  return true;
908  }
909  for (unsigned iWord32 = 0; iWord32 < nWord32; iWord32 += 2) {
910  const uint32_t* data32 = ((const uint32_t*)(data.data())) + iWord32;
911  int dataType = (data32[1] >> 28) & 0xF;
912  // cout << hex << "0x" << setfill('0')
913  // << setw(8) << data32[1] << "'" << setw(8) << data32[0]
914  // << " dataType: 0x" << dataType
915  // << dec << setfill(' ') << "\n";
916  if (0 == (dataType >> 2)) { //in DCC header
917  const int dccHeaderId = (data32[1] >> 24) & 0x3F;
918  if (dccHeaderId == 1) {
919  if (dccLen)
920  *dccLen = ((data32[0] >> 0) & 0xFFFFFF);
921  }
922  }
923  if ((dataType >> 2) == 3) { //Tower block
924  rc = false;
925  if (nTowerBlocks) { //number of tower block must be counted
926  ++(*nTowerBlocks);
927  } else {
928  break;
929  }
930  }
931  }
932  // cout << "[LaserSorter " << now() << "] " << "DCC Len: ";
933 
934  // if(dccLen){
935  // cout << (*dccLen) << " event ";
936  // }
937  // cout << (rc?"":"non") << " empty"
938  // << endl;
939  return rc;
940 }

References data, and DTskim_cfg::dataType.

Referenced by getFullyReadoutDccs(), and getOutputFedList().

◆ readFormatVersion()

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 1094 of file LaserSorter.cc.

1094  {
1095  int vers = -1;
1096  streampos p = in.tellg();
1097 
1098  uint32_t data;
1099 
1100  in.read((char*)&data, sizeof(data));
1101 
1102  char magic[4];
1103 
1104  magic[0] = data & 0xFF;
1105  magic[1] = (data >> 8) & 0xFF;
1106  magic[2] = (data >> 16) & 0xFF;
1107  magic[3] = 0;
1108 
1109  const string lmf = string("LMF");
1110 
1111  if (in.good() && lmf == magic) {
1112  vers = (data >> 24) & 0xFF;
1113  }
1114 
1115  if (lmf != magic) {
1116  edm::LogWarning("LaserSorter") << "File " << fileName << "is not an LMF file.\n";
1117  }
1118 
1119  in.clear();
1120  in.seekg(p);
1121  return vers;
1122 }

References data, MillePedeFileConverter_cfg::fileName, recoMuon::in, AlCaHLTBitMon_ParallelJobs::p, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by createOutStream().

◆ readIndexTable()

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 1021 of file LaserSorter.cc.

1021  {
1022  stringstream errMsg;
1023 
1024  ifstream* s = &in;
1025 
1026  //streampos pos = s->tellg();
1027  s->clear();
1028  s->seekg(0);
1029 
1030  uint32_t fileHeader[2];
1031  s->read((char*)&fileHeader[0], sizeof(fileHeader));
1032  uint32_t indexTablePos = fileHeader[1];
1033 
1034  if (s->eof()) {
1035  s->clear();
1036  s->seekg(0);
1037  errMsg << "Failed to read header of file " << inName << ".";
1038  if (err)
1039  *err = errMsg.str();
1040  return false;
1041  }
1042 
1043  s->seekg(indexTablePos);
1044 
1045  uint32_t nevts = 0;
1046  s->read((char*)&nevts, sizeof(nevts));
1047  s->ignore(4);
1048  if (s->bad()) {
1049  errMsg << "Failed to read index table from file " << inName << ".";
1050  if (err)
1051  *err = errMsg.str();
1052  return false;
1053  }
1054  if (nevts > maxEvents_) {
1055  errMsg << "Number of events indicated in event index of file " << inName << " (" << nevts << ") "
1056  << "is unexpectively large.";
1057  if (err)
1058  *err = errMsg.str();
1059  return false;
1060  }
1061  outRcd.indices()->resize(nevts);
1062  s->read((char*)&(*outRcd.indices())[0], nevts * sizeof(IndexRecord));
1063  if (s->bad()) {
1064  outRcd.indices()->clear();
1065  errMsg << "Failed to read index table from file " << inName << ".";
1066  if (err)
1067  *err = errMsg.str();
1068  return false;
1069  }
1070  if (nevts > maxEvents_) {
1071  errMsg << "Number of events indicated in event index of file " << inName << " is unexpectively large.";
1072  if (err)
1073  *err = errMsg.str();
1074  outRcd.indices()->clear();
1075  return false;
1076  }
1077 
1078  if (verbosity_ > 1)
1079  cout << "[LaserSorter " << now() << "] "
1080  << "Orbit IDs of events "
1081  << "already contained in the file " << inName << ":";
1082  for (unsigned i = 0; i < outRcd.indices()->size(); ++i) {
1083  if (verbosity_ > 1) {
1084  cout << " " << setw(9) << (*outRcd.indices())[i].orbit;
1085  }
1086  outRcd.excludedOrbit().insert((*outRcd.indices())[i].orbit);
1087  }
1088  if (verbosity_ > 1)
1089  cout << "\n";
1090 
1091  return true;
1092 }

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

Referenced by createOutStream().

◆ renameAsBackup()

bool LaserSorter::renameAsBackup ( const std::string &  fileName,
std::string &  newFileName 
)
private

Definition at line 591 of file LaserSorter.cc.

591  {
592  int i = 0;
593  int err;
594  // static int maxTries = 100;
595  int maxTries = 20;
596  stringstream newFileName_;
597  do {
598  newFileName_.str("");
599  newFileName_ << fileName << "~";
600  if (i > 0)
601  newFileName_ << i;
602  err = link(fileName.c_str(), newFileName_.str().c_str());
603  if (err == 0) {
604  newFileName = newFileName_.str();
605  err = unlink(fileName.c_str());
606  }
607  ++i;
608  } while ((err != 0) && (errno == EEXIST) && (i < maxTries));
609  return err == 0;
610 }

References submitPVResolutionJobs::err, MillePedeFileConverter_cfg::fileName, mps_fire::i, MainPageGenerator::link, and cmssw_fix_interface::newFileName.

Referenced by createOutStream().

◆ restoreStreamsOfLumiBlock()

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 1139 of file LaserSorter.cc.

1139  {
1140  string dummy;
1141  string fileName;
1142 
1143  for (int fedId = ecalDccFedIdMin_ - 2; fedId <= ecalDccFedIdMax_; ++fedId) {
1144  int fedId_;
1145  if (fedId == ecalDccFedIdMin_ - 2)
1146  fedId_ = -1; //stream for event w/o ECAL data
1147  else
1148  fedId_ = fedId;
1149  streamFileName(fedId_, lumiBlock, dummy, fileName);
1150  struct stat s;
1151  //TODO: could be optimized by adding an option to get stream
1152  //to open only existing file: would avoid double call to streamFileName.
1153  if (stat(fileName.c_str(), &s) == 0) { //file exists
1154  getStream(fedId_, lumiBlock);
1155  }
1156  }
1157 }

References ecalDccFedIdMax_, ecalDccFedIdMin_, l1tstage2_dqm_sourceclient-live_cfg::fedId, MillePedeFileConverter_cfg::fileName, getStream(), alignCSCRings::s, edm_modernize_messagelogger::stat, and streamFileName().

Referenced by analyze().

◆ streamFileName()

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 794 of file LaserSorter.cc.

797  {
798  int iFed;
800  iFed = fedId - ecalDccFedIdMin_ + 1;
801  } else if (fedId < 0) {
802  iFed = -1; //event w/o ECAL data
803  } else {
804  iFed = 0;
805  }
806  if (iFed < -1 || iFed >= (int)fedSubDirs_.size()) {
807  throw cms::Exception("LaserSorter") << "Bug found at " << __FILE__ << ":" << __LINE__
808  << ". FED ID is out of index!";
809  }
810 
811  struct stat fileStat;
812 
813  stringstream buf;
814  buf << outputDir_ << "/" << (iFed < 0 ? "Empty" : fedSubDirs_[iFed]);
815 
816  string dir = buf.str();
817  if (0 == stat(dir.c_str(), &fileStat)) {
818  if (!S_ISDIR(fileStat.st_mode)) {
819  throw cms::Exception("[LaserSorter]") << "File " << dir << " exists but is not a directory "
820  << " as expected.";
821  }
822  } else { //directory does not exists, let's try to create it
823  if (0 != mkdir(dir.c_str(), 0755)) {
824  throw cms::Exception("[LaserSorter]") << "Failed to create directory " << dir << " for writing data.";
825  }
826  }
827 
828  buf.str("");
829  buf << "Run" << runNumber_ << "_LB" << setfill('0') << setw(4) << lumiBlock << ".lmf";
830  string fileName = buf.str();
831  string tmpFileName = fileName + ".part";
832 
833  finalName = dir + "/" + fileName;
834  tmpName = dir + "/" + tmpFileName;
835 
836  if (verbosity_ > 3)
837  cout << "[LaserSorter " << now() << "] "
838  << "File path: " << finalName << "\n";
839 }

References visDQMUpload::buf, gather_cfg::cout, DeadROC_duringRun::dir, ecalDccFedIdMax_, ecalDccFedIdMin_, Exception, l1tstage2_dqm_sourceclient-live_cfg::fedId, fedSubDirs_, MillePedeFileConverter_cfg::fileName, eostools::mkdir(), now(), outputDir_, runNumber_, edm_modernize_messagelogger::stat, and verbosity_.

Referenced by createOutStream(), and restoreStreamsOfLumiBlock().

◆ toString()

std::string LaserSorter::toString ( uint64_t  t)
staticprivate

Help function to format a date

Definition at line 1124 of file LaserSorter.cc.

1124  {
1125  char buf[256];
1126 
1127  time_t tsec = t >> 32;
1128 
1129  uint32_t tusec = t & 0xFFFFFFFF;
1130  strftime(buf, sizeof(buf), "%F %R %S s", localtime(&tsec));
1131  buf[sizeof(buf) - 1] = 0;
1132 
1133  stringstream buf2;
1134  buf2 << (tusec + 500) / 1000;
1135 
1136  return string(buf) + " " + buf2.str() + " ms";
1137 }

References visDQMUpload::buf, AlCaHLTBitMon_QueryRunRegistry::string, and submitPVValidationJobs::t.

Referenced by writeEventHeader().

◆ writeEvent()

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 502 of file LaserSorter.cc.

505  {
506  ofstream& out = *outRcd.out();
507  bool rc = true;
508  vector<unsigned> fedIds;
510 
511  out.clear();
512  uint32_t evtStart = out.tellp();
513  if (out.bad())
514  evtStart = 0;
515  rc &= writeEventHeader(out, event, dtt, fedIds.size());
516 
517  if (orbitZeroTime_.tv_sec == 0 && data.FEDData(matacqFedId_).size() != 0) {
518  struct timeval ts = {0, 0};
519  MatacqRawEvent mre(data.FEDData(matacqFedId_).data(), data.FEDData(matacqFedId_).size());
520  mre.getTimeStamp(ts);
521  uint32_t orb = mre.getOrbitId();
522  if (ts.tv_sec != 0) {
523  div_t dt = div(orb * 89.1, 1000 * 1000); //an orbit lasts 89.1 microseconds
524  orbitZeroTime_.tv_sec = ts.tv_sec - dt.quot;
525  orbitZeroTime_.tv_usec = ts.tv_usec - dt.rem;
526  if (orbitZeroTime_.tv_usec < 0) {
527  orbitZeroTime_.tv_usec += 1000 * 1000;
528  orbitZeroTime_.tv_sec -= 1;
529  }
530  }
531  }
532 
533  for (unsigned iFed = 0; iFed < fedIds.size() && rc; ++iFed) {
534  if (verbosity_ > 3)
535  cout << "[LaserSorter " << now() << "] "
536  << "Writing data block of FED " << fedIds[iFed] << ". Data size: " << data.FEDData(fedIds[iFed]).size()
537  << "\n";
538  rc &= writeFedBlock(out, data.FEDData(fedIds[iFed]));
539  }
540 
541  if (rc) {
542  //update index table for this file:
543  vector<IndexRecord>& indices = *outRcd.indices();
544  if (verbosity_ > 2) {
545  std::cout << "Event "
546  << " written successfully. "
547  << "Orbit: " << orbit_ << "\tFile index: " << evtStart << "\n";
548  }
549  IndexRecord indexRcd = {(uint32_t)orbit_, evtStart};
550  indices.push_back(indexRcd);
551  }
552  return rc;
553 }

References gather_cfg::cout, data, dt, L1TStage2BMTF_cff::fedIds, getOutputFedList(), MatacqRawEvent::getTimeStamp(), dqmdumpme::indices, LaserSorter::OutStreamRecord::indices(), matacqFedId_, now(), orbit_, orbitZeroTime_, MillePedeFileConverter_cfg::out, LaserSorter::OutStreamRecord::out(), verbosity_, writeEventHeader(), and writeFedBlock().

Referenced by analyze().

◆ writeEventHeader()

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 751 of file LaserSorter.cc.

751  {
752  uint32_t data[10];
753  timeval tt = {0, 0};
754  if ((evt.time().value() >> 32)) {
755  tt.tv_usec = evt.time().value() & 0xFFFFFFFF;
756  tt.tv_sec = evt.time().value() >> 32;
757  } else if (orbitZeroTime_.tv_sec) {
758  div_t dt = div(orbit_ * 89.1, 1000 * 1000); //one orbit lasts 89.1 microseconds
759  tt.tv_sec = orbitZeroTime_.tv_sec + dt.quot;
760  tt.tv_usec = orbitZeroTime_.tv_usec + dt.rem;
761  if (tt.tv_usec > 1000 * 1000) {
762  tt.tv_usec -= 1000 * 1000;
763  tt.tv_sec += 1;
764  }
765  }
766 
767  data[0] = tt.tv_usec;
768  data[1] = tt.tv_sec;
769  data[2] = evt.luminosityBlock();
770  data[3] = evt.run();
771  data[4] = orbit_;
772  data[5] = evt.bunchCrossing();
773  data[6] = evt.id().event();
774  data[7] = dtt;
775  data[8] = nFeds;
776  data[9] = 0; //reserved (to be aligned on 64-bits)
777 
778  if (verbosity_ > 1) {
779  cout << "[LaserSorter " << now() << "] "
780  << "Write header of event: "
781  << "Time: " << toString(evt.time().value()) << ", LB: " << evt.luminosityBlock() << ", Run: " << evt.run()
782  << ", Bx: " << evt.bunchCrossing() << ", Event ID: " << evt.id().event() << ", Detailed trigger type: 0x"
783  << hex << dtt << dec << " (" << detailedTrigNames[(dtt >> 8) & 0x7] << ", " << colorNames[(dtt >> 6) & 0x3]
784  << ", DCC " << (dtt & 0x3f) << ", side " << ((dtt >> 10) & 0x1) << ")"
785  << ", number of FEDs: "
786  << "\n";
787  }
788 
789  out.clear();
790  out.write((char*)data, sizeof(data));
791  return !out.bad();
792 }

References edm::EventBase::bunchCrossing(), colorNames, gather_cfg::cout, data, TauDecayModes::dec, detailedTrigNames, dt, edm::EventID::event(), edm::EventBase::id(), edm::EventBase::luminosityBlock(), now(), orbit_, orbitZeroTime_, MillePedeFileConverter_cfg::out, edm::Event::run(), edm::EventBase::time(), toString(), groupFilesInBlocks::tt, edm::Timestamp::value(), and verbosity_.

Referenced by writeEvent().

◆ writeFedBlock()

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 555 of file LaserSorter.cc.

555  {
556  bool rc = false;
557  if (data.size() > 4) {
558  const uint32_t* pData = reinterpret_cast<const uint32_t*>(data.data());
559 
560  uint32_t dccLen64 = pData[2] & 0x00FFFFFF; //in 32-byte unit
561 
562  if (data.size() != dccLen64 * sizeof(uint64_t)) {
563  // throw cms::Exception("Bug") << "Bug found in "
564  // << __FILE__ << ":" << __LINE__ << ".";
565  throw cms::Exception("LaserSorter") << "Mismatch between FED fragment size indicated in header "
566  << "(" << dccLen64 << "*8 Byte) "
567  << "and actual size (" << data.size() << " Byte) "
568  << "for FED ID " << ((pData[0] >> 8) & 0xFFF) << "!\n";
569  }
570 
571  if (verbosity_ > 3)
572  cout << "[LaserSorter " << now() << "] "
573  << "Event fragment size: " << data.size() << " Byte"
574  << "\t From Dcc header: " << dccLen64 * 8 << " Byte\n";
575 
576  const size_t nBytes = data.size();
577  // cout << "[LaserSorter " << now() << "] "
578  // << "Writing " << nBytes << " byte from adress "
579  // << (void*) data.data() << " to file.\n";
580  if (out.fail())
581  cout << "[LaserSorter " << now() << "] "
582  << "Problem with stream!\n";
583  out.write((char*)data.data(), nBytes);
584  rc = true;
585  } else {
586  throw cms::Exception("Bug") << "Bug found in " << __FILE__ << ":" << __LINE__ << ".\n";
587  }
588  return rc;
589 }

References gather_cfg::cout, data, Exception, now(), MillePedeFileConverter_cfg::out, and verbosity_.

Referenced by writeEvent().

◆ writeFileHeader()

void LaserSorter::writeFileHeader ( std::ofstream &  out)
private

Writing file header for an LMF binary file

Parameters
outstream of the output file

Definition at line 735 of file LaserSorter.cc.

735  {
736  out.clear();
737 
738  uint32_t id = 'L' | ('M' << 8) | ('F' << 16) | (formatVersion_ << 24);
739 
740  out.write((char*)&id, sizeof(uint32_t));
741 
742  //index position (to be filled at end of writing)
743  uint32_t zero = 0;
744  out.write((char*)&zero, sizeof(uint32_t));
745 
746  if (out.fail()) {
747  throw cms::Exception("LaserSorter") << "Failed to write file header.\n";
748  }
749 }

References Exception, formatVersion_, MillePedeFileConverter_cfg::out, and SiPixelPI::zero.

Referenced by createOutStream().

◆ writeIndexTable()

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 979 of file LaserSorter.cc.

979  {
980  uint32_t indexTablePos = out.tellp();
981  uint32_t nevts = indices.size();
982 
983  out.clear();
984  out.write((char*)&nevts, sizeof(nevts));
985  const uint32_t reserved = 0;
986  out.write((const char*)&reserved, sizeof(reserved));
987 
988  if (out.bad())
989  return false;
990 
991  sort(indices.begin(), indices.end());
992 
993  for (unsigned i = 0; i < indices.size(); ++i) {
994  uint32_t data[2];
995  data[0] = indices[i].orbit;
996  data[1] = indices[i].filePos;
997  out.write((char*)data, sizeof(data));
998  }
999 
1000  if (out.bad())
1001  return false; //intial 0 valur for index table position
1002  // is left to indicate corrupted table.
1003 
1004  //writes index table position:x
1005  out.clear();
1006  out.seekp(indexOffset32_ * sizeof(uint32_t));
1007  // cout << "[LaserSorter] Index table position: 0x" << hex << indexTablePos
1008  // << dec << "\n";
1009  if (!out.bad())
1010  out.write((char*)&indexTablePos, sizeof(uint32_t));
1011 
1012  bool rc = !out.bad();
1013 
1014  //reposition pointer to eof:
1015  out.seekp(0, ios::end);
1016 
1017  return rc;
1018 }

References data, mps_fire::end, mps_fire::i, indexOffset32_, dqmdumpme::indices, jetmet_cfg::nevts, MillePedeFileConverter_cfg::out, and jetUpdater_cfi::sort.

Referenced by closeOutStream().

Member Data Documentation

◆ detailedTrigType_

int LaserSorter::detailedTrigType_
private

Trigger type of calibration event. -1 if unkown.

Definition at line 298 of file LaserSorter.h.

Referenced by analyze().

◆ disableOutput_

bool LaserSorter::disableOutput_
private

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

Definition at line 335 of file LaserSorter.h.

Referenced by analyze().

◆ doOutputList_

bool LaserSorter::doOutputList_
private

Switch for logging paths of the output files

Definition at line 359 of file LaserSorter.h.

Referenced by closeOutStream(), and LaserSorter().

◆ ecalDccFedIdMax_

const int LaserSorter::ecalDccFedIdMax_ = 654
staticprivate

◆ ecalDccFedIdMin_

const int LaserSorter::ecalDccFedIdMin_ = 601
staticprivate

◆ fedRawDataCollectionTag_

edm::InputTag LaserSorter::fedRawDataCollectionTag_
private

Definition at line 417 of file LaserSorter.h.

Referenced by LaserSorter().

◆ fedRawDataCollectionToken_

edm::EDGetTokenT<FEDRawDataCollection> LaserSorter::fedRawDataCollectionToken_
private

Definition at line 418 of file LaserSorter.h.

Referenced by analyze(), and LaserSorter().

◆ fedSubDirs_

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

Subdirectories for output file of each FED

Definition at line 327 of file LaserSorter.h.

Referenced by LaserSorter(), and streamFileName().

◆ formatVersion_

unsigned char LaserSorter::formatVersion_
private

Data format version of lmf output file

Definition at line 319 of file LaserSorter.h.

Referenced by createOutStream(), and writeFileHeader().

◆ indexOffset32_

const int LaserSorter::indexOffset32_ = 1
staticprivate

Definition at line 426 of file LaserSorter.h.

Referenced by writeIndexTable().

◆ iNoEcalDataMess_

int LaserSorter::iNoEcalDataMess_
private

number of "ECAL DCC data" message in a run

Definition at line 398 of file LaserSorter.h.

Referenced by analyze(), and getDetailedTriggerType().

◆ iNoFullReadoutDccError_

int LaserSorter::iNoFullReadoutDccError_
private

Number of "No fully readout DCC error"

Definition at line 390 of file LaserSorter.h.

Referenced by analyze().

◆ logFile_

std::ofstream LaserSorter::logFile_
private

File for logging

Definition at line 302 of file LaserSorter.h.

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

◆ lumiBlock_

edm::LuminosityBlockNumber_t LaserSorter::lumiBlock_
private

Luminosity block of event under processing

Definition at line 306 of file LaserSorter.h.

Referenced by analyze().

◆ lumiBlockPrev_

edm::LuminosityBlockNumber_t LaserSorter::lumiBlockPrev_
private

Luminosity block of previous processed event

Definition at line 310 of file LaserSorter.h.

Referenced by analyze().

◆ lumiBlockSpan_

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 415 of file LaserSorter.h.

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

◆ matacqFedId_

const int LaserSorter::matacqFedId_ = 655
staticprivate

FED ID associated to Matacq data

Definition at line 422 of file LaserSorter.h.

Referenced by getOutputFedList(), and writeEvent().

◆ maxEvents_

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 431 of file LaserSorter.h.

Referenced by readIndexTable().

◆ maxFullReadoutDccError_

int LaserSorter::maxFullReadoutDccError_
private

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

Definition at line 394 of file LaserSorter.h.

Referenced by analyze().

◆ maxNoEcalDataMess_

int LaserSorter::maxNoEcalDataMess_
private

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

Definition at line 402 of file LaserSorter.h.

Referenced by getDetailedTriggerType().

◆ orbit_

int LaserSorter::orbit_
private

Definition at line 461 of file LaserSorter.h.

Referenced by analyze(), writeEvent(), and writeEventHeader().

◆ orbitCountInALumiBlock_

int LaserSorter::orbitCountInALumiBlock_
private

Length of a lumi block in number of orbits used when overWriteLumiBlockId is set to true; LB = orbit_id / orbitCountInALumiBlock_

Definition at line 459 of file LaserSorter.h.

Referenced by analyze().

◆ orbitZeroTime_

struct timeval LaserSorter::orbitZeroTime_
private

Time stamp offset to use to calculate calibration time from the orbit id. It is obtained from the matacq block (time originates from the PC hosting the laser supervisor). and used in case the event is missing timestamp, in principle for data acquired with the minidaq Calibration event time = orbitZeroTime_ + orbit_ * (89.1 microsec).

Definition at line 470 of file LaserSorter.h.

Referenced by writeEvent(), and writeEventHeader().

◆ outputDir_

std::string LaserSorter::outputDir_
private

Top directory for output files

Definition at line 323 of file LaserSorter.h.

Referenced by LaserSorter(), batchmanager.BatchManager::PrepareJob(), and streamFileName().

◆ outputList_

std::ofstream LaserSorter::outputList_
private

stream where list of output file is listed to

Definition at line 367 of file LaserSorter.h.

Referenced by closeOutStream(), and LaserSorter().

◆ outputListFile_

std::string LaserSorter::outputListFile_
private

name of file where list of output file is listed to

Definition at line 355 of file LaserSorter.h.

Referenced by LaserSorter().

◆ outStreamList_

OutStreamList LaserSorter::outStreamList_
private

List of output stream to write sorted data

Definition at line 315 of file LaserSorter.h.

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

◆ overWriteLumiBlockId_

bool LaserSorter::overWriteLumiBlockId_
private

Switch to recompute and overwrite the lumi block ID

Definition at line 453 of file LaserSorter.h.

Referenced by analyze().

◆ runNumber_

edm::RunNumber_t LaserSorter::runNumber_
private

Run number of event under process

Definition at line 339 of file LaserSorter.h.

Referenced by analyze(), and streamFileName().

◆ stats_

struct LaserSorter::stats_t LaserSorter::stats_
private

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

◆ stats_init

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

Definition at line 449 of file LaserSorter.h.

◆ timeLog_

std::ofstream LaserSorter::timeLog_
private

Output stream to log code timing

Definition at line 347 of file LaserSorter.h.

Referenced by analyze(), and LaserSorter().

◆ timeLogFile_

std::string LaserSorter::timeLogFile_
private

Name of the file to log the processing time

Definition at line 331 of file LaserSorter.h.

Referenced by LaserSorter().

◆ timer_

timeval LaserSorter::timer_
private

Buffer for timing

Definition at line 343 of file LaserSorter.h.

Referenced by analyze(), and LaserSorter().

◆ timing_

bool LaserSorter::timing_
private

Switch for code timing.

Definition at line 351 of file LaserSorter.h.

Referenced by analyze(), and LaserSorter().

◆ verbosity_

int LaserSorter::verbosity_
private
LaserSorter::writeIndexTable
bool writeIndexTable(std::ofstream &out, std::vector< IndexRecord > &indices)
Definition: LaserSorter.cc:979
LaserSorter::restoreStreamsOfLumiBlock
void restoreStreamsOfLumiBlock(int lumiBlock)
Definition: LaserSorter.cc:1139
LaserSorter::maxFullReadoutDccError_
int maxFullReadoutDccError_
Definition: LaserSorter.h:394
MatacqRawEvent::getTimeStamp
time_t getTimeStamp() const
Definition: MatacqRawEvent.h:293
LaserSorter::readIndexTable
bool readIndexTable(std::ifstream &in, std::string &inName, OutStreamRecord &outRcd, std::string *err)
Definition: LaserSorter.cc:1021
LaserSorter::toString
static std::string toString(uint64_t t)
Definition: LaserSorter.cc:1124
LaserSorter::closeOutStream
OutStreamList::iterator closeOutStream(OutStreamList::iterator streamRecord)
Definition: LaserSorter.cc:841
LaserSorter::orbit_
int orbit_
Definition: LaserSorter.h:461
mps_fire.i
i
Definition: mps_fire.py:428
LaserSorter::doOutputList_
bool doOutputList_
Definition: LaserSorter.h:359
LaserSorter::fedRawDataCollectionTag_
edm::InputTag fedRawDataCollectionTag_
Definition: LaserSorter.h:417
edm::EventBase::bunchCrossing
int bunchCrossing() const
Definition: EventBase.h:64
LaserSorter::streamFileName
void streamFileName(int fedId, edm::LuminosityBlockNumber_t lumiBlock, std::string &tmpName, std::string &finalName)
Definition: LaserSorter.cc:794
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
groupFilesInBlocks.tt
int tt
Definition: groupFilesInBlocks.py:144
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
cmssw_fix_interface.newFileName
newFileName
Definition: cmssw_fix_interface.py:46
min
T min(T a, T b)
Definition: MathUtil.h:58
LaserSorter::writeEvent
bool writeEvent(OutStreamRecord &out, const edm::Event &event, int detailedTriggerType, const FEDRawDataCollection &data)
Definition: LaserSorter.cc:502
gather_cfg.cout
cout
Definition: gather_cfg.py:144
LaserSorter::createOutStream
OutStreamList::iterator createOutStream(int fedId, edm::LuminosityBlockNumber_t lumiBlock)
Definition: LaserSorter.cc:612
LaserSorter::formatVersion_
unsigned char formatVersion_
Definition: LaserSorter.h:319
protons_cff.time
time
Definition: protons_cff.py:35
LaserSorter::stats_t::nInvalidDccWeak
double nInvalidDccWeak
Definition: LaserSorter.h:445
LaserSorter::maxNoEcalDataMess_
int maxNoEcalDataMess_
Definition: LaserSorter.h:402
LaserSorter::matacqFedId_
static const int matacqFedId_
Definition: LaserSorter.h:422
edm::Timestamp::value
TimeValue_t value() const
Definition: Timestamp.h:45
SiPixelPI::zero
Definition: SiPixelPayloadInspectorHelper.h:39
nullTime
static const struct timeval nullTime
Definition: LaserSorter.cc:42
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
rename
Definition: rename.py:1
edm::EventBase::time
edm::Timestamp time() const
Definition: EventBase.h:60
edm::Handle< FEDRawDataCollection >
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
LaserSorter::getStream
std::unique_ptr< OutStreamRecord > & getStream(int fedId, edm::LuminosityBlockNumber_t lumiBlock)
Definition: LaserSorter.cc:474
DTskim_cfg.dataType
dataType
Definition: DTskim_cfg.py:56
LaserSorter::stats_t::nRestoredDcc
double nRestoredDcc
number of events whose DCC ID was restored based on FED block sizes
Definition: LaserSorter.h:447
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
LaserSorter::ecalDccFedIdMin_
static const int ecalDccFedIdMin_
Definition: LaserSorter.h:290
FEDRawData
Definition: FEDRawData.h:19
LaserSorter::orbitZeroTime_
struct timeval orbitZeroTime_
Definition: LaserSorter.h:470
detailedTrigNames
static const char *const detailedTrigNames[]
Definition: LaserSorter.cc:44
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
LaserSorter::disableOutput_
bool disableOutput_
Definition: LaserSorter.h:335
dt
float dt
Definition: AMPTWrapper.h:136
LaserSorter::isDccEventEmpty
bool isDccEventEmpty(const FEDRawData &data, size_t *dccLen=nullptr, int *nTowerBlocks=nullptr) const
Definition: LaserSorter.cc:896
LaserSorter::outputList_
std::ofstream outputList_
Definition: LaserSorter.h:367
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
alignCSCRings.s
s
Definition: alignCSCRings.py:92
LaserSorter::runNumber_
edm::RunNumber_t runNumber_
Definition: LaserSorter.h:339
LaserSorter::logFile_
std::ofstream logFile_
Definition: LaserSorter.h:302
LaserSorter::closeAllStreams
void closeAllStreams()
Definition: LaserSorter.cc:448
LaserSorter::stats_init
static const stats_t stats_init
Definition: LaserSorter.h:449
LaserSorter::orbitCountInALumiBlock_
int orbitCountInALumiBlock_
Definition: LaserSorter.h:459
LaserSorter::lumiBlockSpan_
int lumiBlockSpan_
Definition: LaserSorter.h:415
mps_fire.end
end
Definition: mps_fire.py:242
jetmet_cfg.nevts
nevts
Definition: jetmet_cfg.py:3
LaserSorter::writeEventHeader
bool writeEventHeader(std::ofstream &out, const edm::Event &evt, int fedId, unsigned nFeds)
Definition: LaserSorter.cc:751
eostools.mkdir
def mkdir(path)
Definition: eostools.py:251
edm::Event::run
RunNumber_t run() const
Definition: Event.h:109
LaserSorter::closeOldStreams
void closeOldStreams(edm::LuminosityBlockNumber_t lumiBlock)
Definition: LaserSorter.cc:454
LaserSorter::writeFedBlock
bool writeFedBlock(std::ofstream &out, const FEDRawData &data)
Definition: LaserSorter.cc:555
LaserSorter::lumiBlockPrev_
edm::LuminosityBlockNumber_t lumiBlockPrev_
Definition: LaserSorter.h:310
LaserSorter::fedSubDirs_
std::vector< std::string > fedSubDirs_
Definition: LaserSorter.h:327
MatacqRawEvent
Definition: MatacqRawEvent.h:30
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
LaserSorter::indexOffset32_
static const int indexOffset32_
Definition: LaserSorter.h:426
LaserSorter::overWriteLumiBlockId_
bool overWriteLumiBlockId_
Definition: LaserSorter.h:453
LaserSorter::getFullyReadoutDccs
std::vector< int > getFullyReadoutDccs(const FEDRawDataCollection &data) const
Definition: LaserSorter.cc:967
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
LaserSorter::fedRawDataCollectionToken_
edm::EDGetTokenT< FEDRawDataCollection > fedRawDataCollectionToken_
Definition: LaserSorter.h:418
LaserSorter::maxEvents_
static const unsigned maxEvents_
Definition: LaserSorter.h:431
LaserSorter::stats_t::nWritten
double nWritten
number of events written out
Definition: LaserSorter.h:439
edm::EventBase::luminosityBlock
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
LaserSorter::outStreamList_
OutStreamList outStreamList_
Definition: LaserSorter.h:315
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
recoMuon::in
Definition: RecoMuonEnumerators.h:6
LaserSorter::outputListFile_
std::string outputListFile_
Definition: LaserSorter.h:355
LaserSorter::lumiBlock_
edm::LuminosityBlockNumber_t lumiBlock_
Definition: LaserSorter.h:306
edm::EventID::event
EventNumber_t event() const
Definition: EventID.h:40
LaserSorter::timeLogFile_
std::string timeLogFile_
Definition: LaserSorter.h:331
LaserSorter::getDetailedTriggerType
int getDetailedTriggerType(const edm::Handle< FEDRawDataCollection > &rawdata, double *proba=nullptr)
Definition: LaserSorter.cc:404
createfilelist.int
int
Definition: createfilelist.py:10
dtResolutionTest_cfi.inputFile
inputFile
Definition: dtResolutionTest_cfi.py:14
FEDNumbering::inRange
static bool inRange(int)
Definition: FEDNumbering.cc:106
colorNames
static const char *const colorNames[]
Definition: LaserSorter.cc:55
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:89
PixelSLinkDataInputSource_cfi.fedid
fedid
Definition: PixelSLinkDataInputSource_cfi.py:6
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
visDQMUpload.buf
buf
Definition: visDQMUpload.py:160
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
ecaldqm::dccId
unsigned dccId(DetId const &, EcalElectronicsMapping const *)
Definition: EcalDQMCommonUtils.cc:16
mps_merge.newName
string newName
Definition: mps_merge.py:86
LaserSorter::renameAsBackup
bool renameAsBackup(const std::string &fileName, std::string &newFileName)
Definition: LaserSorter.cc:591
LaserSorter::detailedTrigType_
int detailedTrigType_
Definition: LaserSorter.h:298
LaserSorter::outputDir_
std::string outputDir_
Definition: LaserSorter.h:323
LaserSorter::getOrbitFromDcc
int getOrbitFromDcc(const edm::Handle< FEDRawDataCollection > &rawdata) const
Definition: LaserSorter.cc:381
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
LaserSorter::getOutputFedList
void getOutputFedList(const edm::Event &event, const FEDRawDataCollection &data, std::vector< unsigned > &fedIds) const
Definition: LaserSorter.cc:942
Exception
Definition: hltDiff.cc:245
edm::EventBase::id
edm::EventID id() const
Definition: EventBase.h:59
LaserSorter::iNoFullReadoutDccError_
int iNoFullReadoutDccError_
Definition: LaserSorter.h:390
L1TStage2BMTF_cff.fedIds
fedIds
Definition: L1TStage2BMTF_cff.py:10
LaserSorter::verbosity_
int verbosity_
Definition: LaserSorter.h:363
LaserSorter::stats_
struct LaserSorter::stats_t stats_
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
now
static std::string now()
Definition: LaserSorter.cc:60
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
mps_fire.result
result
Definition: mps_fire.py:311
LaserSorter::timer_
timeval timer_
Definition: LaserSorter.h:343
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dummy
Definition: DummySelector.h:38
LaserSorter::timeLog_
std::ofstream timeLog_
Definition: LaserSorter.h:347
dqmdumpme.indices
indices
Definition: dqmdumpme.py:50
LaserSorter::stats_t::nInvalidDccStrict
double nInvalidDccStrict
Definition: LaserSorter.h:442
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
edm_modernize_messagelogger.stat
stat
Definition: edm_modernize_messagelogger.py:27
event
Definition: event.py:1
ecaldqm::nTowers
Definition: EcalDQMCommonUtils.h:114
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
pileupReCalc_HLTpaths.trunc
trunc
Definition: pileupReCalc_HLTpaths.py:143
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
LaserSorter::ecalDccFedIdMax_
static const int ecalDccFedIdMax_
Definition: LaserSorter.h:294
edm::InputTag
Definition: InputTag.h:15
LaserSorter::iNoEcalDataMess_
int iNoEcalDataMess_
Definition: LaserSorter.h:398
LaserSorter::writeFileHeader
void writeFileHeader(std::ofstream &out)
Definition: LaserSorter.cc:735
LaserSorter::stats_t::nRead
double nRead
number of events read out
Definition: LaserSorter.h:437
Majority
Definition: Majority.h:12
LaserSorter::readFormatVersion
int readFormatVersion(std::ifstream &in, const std::string &fileName)
Definition: LaserSorter.cc:1094
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
LaserSorter::timing_
bool timing_
Definition: LaserSorter.h:351
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23