CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Attributes
CSCFileDumper Class Reference

#include <CSCFileDumper.h>

Inheritance diagram for CSCFileDumper:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginJob () override
 
 CSCFileDumper (edm::ParameterSet const &pset)
 
void endJob () override
 
 ~CSCFileDumper (void) override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, 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::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Public Attributes

std::map< int, FILE * > dump_files
 
std::string events
 
std::set< unsigned long > eventsToDump
 
std::string output
 

Private Attributes

std::vector< unsigned int > cscFEDids
 
edm::EDGetTokenT< FEDRawDataCollectioni_token
 Token for consumes interface & access to data. More...
 

Additional Inherited Members

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

Detailed Description

Definition at line 14 of file CSCFileDumper.h.

Constructor & Destructor Documentation

◆ CSCFileDumper()

CSCFileDumper::CSCFileDumper ( edm::ParameterSet const &  pset)

Definition at line 23 of file CSCFileDumper.cc.

References cscFEDids, edmPickEvents::event, events, eventsToDump, i_token, l1ctLayer2EG_cff::id, FEDNumbering::MAXCSCDDUFEDID, FEDNumbering::MINCSCDDUFEDID, muonDTDigis_cfi::pset, AlCaHLTBitMon_QueryRunRegistry::string, and createJobs::tmp.

23  {
24  i_token = consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("source"));
25  // source_ = pset.getUntrackedParameter<std::string>("source","rawDataCollector");
26  output = pset.getUntrackedParameter<std::string>("output");
27  events = pset.getUntrackedParameter<std::string>("events", "");
28 
29  cscFEDids.clear();
30  /*
31  for (unsigned int id=FEDNumbering::MINCSCFEDID;
32  id<=FEDNumbering::MAXCSCFEDID; ++id) // loop over DCCs
33  {
34  cscFEDids.push_back(id);
35  }
36  */
37  for (unsigned int id = FEDNumbering::MINCSCDDUFEDID; id <= FEDNumbering::MAXCSCDDUFEDID; ++id) // loop over DDUs
38  {
39  cscFEDids.push_back(id);
40  }
41  /*
42  for (unsigned int id=FEDNumbering::MINCSCTFFEDID; id<=FEDNumbering::MAXCSCTFFEDID; id++)
43  {
44  cscFEDids.push_back(id);
45  }
46  */
47 
48  if (events.length()) {
49  for (size_t pos1 = 0, pos2 = events.find(',');; pos1 = pos2 + 1, pos2 = events.find(',', pos2 + 1)) {
50  if (pos2 != std::string::npos) {
51  long event = 0;
52  if (sscanf(events.substr(pos1, pos2 - pos1).c_str(), "%ld", &event) == 1 && event >= 0)
53  eventsToDump.insert((unsigned long)event);
54  else
55  edm::LogError("CSCFileDumper") << " cannot parse events (" << events
56  << ") parameter: " << events.substr(pos1, pos2 - pos1);
57  } else {
58  long event = 0;
59  if (sscanf(events.substr(pos1, events.length() - pos1).c_str(), "%ld", &event) == 1 && event >= 0)
60  eventsToDump.insert((unsigned long)event);
61  else
62  edm::LogError("CSCFileDumper") << " cannot parse events (" << events
63  << ") parameter: " << events.substr(pos1, events.length() - pos1);
64  break;
65  }
66  }
67  std::ostringstream tmp;
68  for (std::set<unsigned long>::const_iterator evt = eventsToDump.begin(); evt != eventsToDump.end(); evt++)
69  tmp << *evt << " ";
70  edm::LogInfo("CSCFileDumper") << " Following events will be dumped: " << tmp.str();
71  } else
72  edm::LogInfo("CSCFileDumper") << " All events will be dumped";
73 }
edm::EDGetTokenT< FEDRawDataCollection > i_token
Token for consumes interface & access to data.
Definition: CSCFileDumper.h:35
std::string events
Definition: CSCFileDumper.h:20
Log< level::Error, false > LogError
std::set< unsigned long > eventsToDump
Definition: CSCFileDumper.h:17
std::vector< unsigned int > cscFEDids
Definition: CSCFileDumper.h:28
Log< level::Info, false > LogInfo
Definition: output.py:1
tmp
align.sh
Definition: createJobs.py:716
Definition: event.py:1

◆ ~CSCFileDumper()

CSCFileDumper::~CSCFileDumper ( void  )
override

Definition at line 75 of file CSCFileDumper.cc.

References dump_files, and cms::cuda::stream.

75  {
76  std::map<int, FILE *>::const_iterator stream = dump_files.begin();
77  while (stream != dump_files.end()) {
78  fclose(stream->second);
79  stream++;
80  }
81 }
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
std::map< int, FILE * > dump_files
Definition: CSCFileDumper.h:16

Member Function Documentation

◆ analyze()

void CSCFileDumper::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overridevirtual

Take a reference to this FED's data

Implements edm::one::EDAnalyzerBase.

Definition at line 83 of file CSCFileDumper.cc.

References visDQMUpload::buf, cscFEDids, FEDRawData::data(), dump_files, MillePedeFileConverter_cfg::e, eventsToDump, FEDRawDataCollection::FEDData(), geometryDiff::file, mps_fire::i, i_token, l1ctLayer2EG_cff::id, Skims_PA_cff::name, FEDRawData::size(), findQualityFiles::size, and cms::cuda::stream.

83  {
84  // Get a handle to the FED data collection
86  e.getByToken(i_token, rawdata);
87 
88  // Get a handle to the FED data collection
89 
90  for (unsigned int i = 0; i < cscFEDids.size(); i++) //for each of our DCCs
91  {
92  unsigned int id = cscFEDids[i];
93  std::map<int, FILE *>::const_iterator stream = dump_files.find(id);
95  const FEDRawData &fedData = rawdata->FEDData(id);
96  unsigned short int length = fedData.size();
97 
98  if (length && (eventsToDump.empty() || (eventsToDump.find((unsigned long)e.id().event()) != eventsToDump.end()))) {
99  if (stream == dump_files.end()) {
100  std::ostringstream name;
101  name << output << "_FED" << id << ".raw" << std::ends;
102  FILE *file;
103  if ((file = fopen(name.str().c_str(), "wt")) == nullptr) {
104  edm::LogError("CSCFileDumper") << "Cannot open the file: " << name.str();
105  continue;
106  } else
107  dump_files[id] = file;
108  stream = dump_files.find(id);
109  }
110 
111  // Event buffer
112  size_t size = length / 2;
113  const unsigned short *buf = (unsigned short *)fedData.data();
114  fwrite(buf, 2, size, stream->second);
115  }
116  }
117 }
edm::EDGetTokenT< FEDRawDataCollection > i_token
Token for consumes interface & access to data.
Definition: CSCFileDumper.h:35
size
Write out results.
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:48
Log< level::Error, false > LogError
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
std::set< unsigned long > eventsToDump
Definition: CSCFileDumper.h:17
std::vector< unsigned int > cscFEDids
Definition: CSCFileDumper.h:28
std::map< int, FILE * > dump_files
Definition: CSCFileDumper.h:16
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
Definition: output.py:1

◆ beginJob()

void CSCFileDumper::beginJob ( void  )
inlineoverridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 26 of file CSCFileDumper.h.

26 {};

◆ endJob()

void CSCFileDumper::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 28 of file CSCFileDumper.h.

28 {};

Member Data Documentation

◆ cscFEDids

std::vector<unsigned int> CSCFileDumper::cscFEDids
private

Definition at line 28 of file CSCFileDumper.h.

Referenced by analyze(), and CSCFileDumper().

◆ dump_files

std::map<int, FILE*> CSCFileDumper::dump_files

Definition at line 16 of file CSCFileDumper.h.

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

◆ events

std::string CSCFileDumper::events

◆ eventsToDump

std::set<unsigned long> CSCFileDumper::eventsToDump

Definition at line 17 of file CSCFileDumper.h.

Referenced by analyze(), and CSCFileDumper().

◆ i_token

edm::EDGetTokenT<FEDRawDataCollection> CSCFileDumper::i_token
private

Token for consumes interface & access to data.

Definition at line 35 of file CSCFileDumper.h.

Referenced by analyze(), and CSCFileDumper().

◆ output

std::string CSCFileDumper::output

Definition at line 20 of file CSCFileDumper.h.

Referenced by collectionMerger.collectionMerger::analyze().