CMS 3D CMS Logo

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

#include <HcalTBWriter.h>

Inheritance diagram for HcalTBWriter:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &es) override
 
void endJob () override
 
 HcalTBWriter (const edm::ParameterSet &pset)
 
- 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 Member Functions

void buildTree (const FEDRawDataCollection &raw)
 
void extractEventInfo (const FEDRawDataCollection &raw, const edm::EventID &id)
 

Private Attributes

std::map< int, std::string > blockToName_
 
CDFChunkchunkList_ [1024]
 
std::map< int, int > chunkMap_
 
CDFEventInfoeventInfo_
 
TFile * file_
 
std::string namePattern_
 
CDFRunInfo ri_
 
edm::EDGetTokenT< FEDRawDataCollectiontok_raw_
 
TTree * tree_
 
int trigChunk_
 

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

Writes HCAL-style ROOT files from the RawData block

Author
J. Mans - Minnesota

Definition at line 25 of file HcalTBWriter.h.

Constructor & Destructor Documentation

◆ HcalTBWriter()

HcalTBWriter::HcalTBWriter ( const edm::ParameterSet pset)

Definition at line 11 of file HcalTBWriter.cc.

12  : namePattern_(pset.getUntrackedParameter<std::string>("FilenamePattern", "/tmp/HTB_%06d.root")) {
13  tok_raw_ = consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("fedRawDataCollectionTag"));
14 
15  std::vector<edm::ParameterSet> names = pset.getUntrackedParameter<std::vector<edm::ParameterSet> >("ChunkNames");
16  std::vector<edm::ParameterSet>::iterator j;
17  for (j = names.begin(); j != names.end(); j++) {
18  std::string name = j->getUntrackedParameter<std::string>("Name");
19  int num = j->getUntrackedParameter<int>("Number");
21  }
22 
23  file_ = nullptr;
24  tree_ = nullptr;
25  eventInfo_ = nullptr;
26 }

References blockToName_, eventInfo_, file_, dqmiolumiharvest::j, Skims_PA_cff::name, names, EgammaValidation_cff::num, muonDTDigis_cfi::pset, AlCaHLTBitMon_QueryRunRegistry::string, tok_raw_, and tree_.

Member Function Documentation

◆ analyze()

void HcalTBWriter::analyze ( const edm::Event e,
const edm::EventSetup es 
)
overridevirtual

Implements edm::EDAnalyzer.

Definition at line 46 of file HcalTBWriter.cc.

46  {
48  e.getByToken(tok_raw_, raw);
49 
50  if (file_ == nullptr) {
51  char fname[4096];
52  snprintf(fname, 4096, namePattern_.c_str(), e.id().run());
53  edm::LogInfo("HCAL") << "Opening " << fname << " for writing HCAL-format file.";
54  file_ = new TFile(fname, "RECREATE");
55  ri_.setInfo("OriginalFile", fname);
56  buildTree(*raw);
57  }
58 
59  // adopt the buffers for writing
60  for (std::map<int, int>::const_iterator i = chunkMap_.begin(); i != chunkMap_.end(); i++) {
61  CDFChunk* c = chunkList_[i->second];
62  const FEDRawData& frd = raw->FEDData(i->first);
63  c->adoptBuffer((ULong64_t*)frd.data(), frd.size() / 8);
64  }
65 
66  // copy the event info bits
67  extractEventInfo(*raw, e.id());
68 
69  // fill the tree
70  tree_->Fill();
71  // release all the buffers
72  for (std::map<int, int>::const_iterator i = chunkMap_.begin(); i != chunkMap_.end(); i++) {
73  CDFChunk* c = chunkList_[i->second];
74  c->releaseBuffer();
75  }
76 }

References buildTree(), c, chunkList_, chunkMap_, FEDRawData::data(), MillePedeFileConverter_cfg::e, extractEventInfo(), FEDRawDataCollection::FEDData(), file_, alignmentValidation::fname, mps_fire::i, namePattern_, ri_, CDFRunInfo::setInfo(), FEDRawData::size(), tok_raw_, and tree_.

◆ buildTree()

void HcalTBWriter::buildTree ( const FEDRawDataCollection raw)
private

Definition at line 78 of file HcalTBWriter.cc.

78  {
79  tree_ = new TTree("CMSRAW", "CMS Common Data Format Tree");
80  chunkMap_.clear();
81  trigChunk_ = -1;
82  int j = 0;
83  for (int i = 0; i < 2048; i++) {
84  const FEDRawData& frd = raw.FEDData(i);
85  if (frd.size() < 16)
86  continue; // it's empty... like
87 
89  if (blockToName_.find(i) != blockToName_.end())
90  name = blockToName_[i];
91  else {
92  char sname[64];
93  snprintf(sname, 64, "Chunk%03d", i);
94  name = sname;
95  }
96 
97  CDFChunk* c = new CDFChunk(name.c_str());
98  chunkList_[j] = c;
99  tree_->Branch(name.c_str(), "CDFChunk", &(chunkList_[j]));
100  chunkMap_[i] = j;
101 
102  if (name == "HCAL_Trigger" || name == "SliceTest_Trigger")
103  trigChunk_ = j;
104 
105  j++;
106  }
107  eventInfo_ = new CDFEventInfo();
108  tree_->Branch("CDFEventInfo", "CDFEventInfo", &eventInfo_, 16000, 2);
109 }

References blockToName_, c, chunkList_, chunkMap_, eventInfo_, FEDRawDataCollection::FEDData(), mps_fire::i, dqmiolumiharvest::j, Skims_PA_cff::name, FEDRawData::size(), AlCaHLTBitMon_QueryRunRegistry::string, tree_, and trigChunk_.

Referenced by analyze().

◆ endJob()

void HcalTBWriter::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 28 of file HcalTBWriter.cc.

28  {
29  char buffer[1024];
30  if (file_ != nullptr) {
31  file_->Write();
32 
33  ri_.setInfo("DAQSofwareRelease", "UNKNOWN -- HcalTBWriter");
34  gethostname(buffer, 1024);
35  ri_.setInfo("WriterHostname", buffer);
36  ri_.store(file_);
37 
38  file_->Close();
39  file_ = nullptr;
40  tree_ = nullptr;
41  chunkMap_.clear();
42  eventInfo_ = nullptr;
43  }
44 }

References edmScanValgrind::buffer, chunkMap_, eventInfo_, file_, ri_, CDFRunInfo::setInfo(), CDFRunInfo::store(), and tree_.

◆ extractEventInfo()

void HcalTBWriter::extractEventInfo ( const FEDRawDataCollection raw,
const edm::EventID id 
)
private

Definition at line 135 of file HcalTBWriter.cc.

135  {
136  int runno = id.run();
137  const char* seqid = "";
138  int eventNo = id.event();
139  int l1aNo = eventNo;
140  int orbitNo = 0;
141  int bunchNo = 0;
142 
143  if (trigChunk_ >= 0) {
145  2); // assume 2 64-bit words for the CDF header
146  orbitNo = tinfo->stdBlock.orbitNumber;
147  seqid = tinfo->runNumberSequenceId;
148  FEDHeader head((const unsigned char*)chunkList_[trigChunk_]->getData());
149  bunchNo = head.bxID();
150  l1aNo = head.lvl1ID();
151  }
152 
153  eventInfo_->Set(runno, seqid, eventNo, l1aNo, orbitNo, bunchNo);
154 }

References FEDHeader::bxID(), chunkList_, eventInfo_, printContent_cfi::getData, FEDHeader::lvl1ID(), StandardTrgMsgBlkStruct::orbitNumber, visualization-live-secondInstance_cfg::runno, newExtendedTrgMsgBlkStruct::runNumberSequenceId, CDFEventInfo::Set(), newExtendedTrgMsgBlkStruct::stdBlock, and trigChunk_.

Referenced by analyze().

Member Data Documentation

◆ blockToName_

std::map<int, std::string> HcalTBWriter::blockToName_
private

Definition at line 34 of file HcalTBWriter.h.

Referenced by buildTree(), and HcalTBWriter().

◆ chunkList_

CDFChunk* HcalTBWriter::chunkList_[1024]
private

Definition at line 42 of file HcalTBWriter.h.

Referenced by analyze(), buildTree(), and extractEventInfo().

◆ chunkMap_

std::map<int, int> HcalTBWriter::chunkMap_
private

Definition at line 41 of file HcalTBWriter.h.

Referenced by analyze(), buildTree(), and endJob().

◆ eventInfo_

CDFEventInfo* HcalTBWriter::eventInfo_
private

Definition at line 39 of file HcalTBWriter.h.

Referenced by buildTree(), endJob(), extractEventInfo(), and HcalTBWriter().

◆ file_

TFile* HcalTBWriter::file_
private

Definition at line 37 of file HcalTBWriter.h.

Referenced by analyze(), endJob(), and HcalTBWriter().

◆ namePattern_

std::string HcalTBWriter::namePattern_
private

Definition at line 32 of file HcalTBWriter.h.

Referenced by analyze().

◆ ri_

CDFRunInfo HcalTBWriter::ri_
private

Definition at line 40 of file HcalTBWriter.h.

Referenced by analyze(), and endJob().

◆ tok_raw_

edm::EDGetTokenT<FEDRawDataCollection> HcalTBWriter::tok_raw_
private

Definition at line 44 of file HcalTBWriter.h.

Referenced by analyze(), and HcalTBWriter().

◆ tree_

TTree* HcalTBWriter::tree_
private

Definition at line 38 of file HcalTBWriter.h.

Referenced by analyze(), buildTree(), endJob(), and HcalTBWriter().

◆ trigChunk_

int HcalTBWriter::trigChunk_
private

Definition at line 43 of file HcalTBWriter.h.

Referenced by buildTree(), and extractEventInfo().

HcalTBWriter::tree_
TTree * tree_
Definition: HcalTBWriter.h:38
mps_fire.i
i
Definition: mps_fire.py:428
HcalTBWriter::blockToName_
std::map< int, std::string > blockToName_
Definition: HcalTBWriter.h:34
HcalTBWriter::ri_
CDFRunInfo ri_
Definition: HcalTBWriter.h:40
HcalTBWriter::namePattern_
std::string namePattern_
Definition: HcalTBWriter.h:32
StandardTrgMsgBlkStruct::orbitNumber
uint32_t orbitNumber
Definition: HcalTBWriter.cc:112
HcalTBWriter::chunkList_
CDFChunk * chunkList_[1024]
Definition: HcalTBWriter.h:42
HcalTBWriter::extractEventInfo
void extractEventInfo(const FEDRawDataCollection &raw, const edm::EventID &id)
Definition: HcalTBWriter.cc:135
CDFRunInfo::store
void store(TFile *toFile)
Definition: CDFRunInfo.cc:67
HcalTBWriter::tok_raw_
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
Definition: HcalTBWriter.h:44
printContent_cfi.getData
getData
Definition: printContent_cfi.py:16
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle< FEDRawDataCollection >
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
newExtendedTrgMsgBlkStruct::runNumberSequenceId
char runNumberSequenceId[16]
Definition: HcalTBWriter.cc:131
FEDRawData
Definition: FEDRawData.h:19
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
HcalTBWriter::trigChunk_
int trigChunk_
Definition: HcalTBWriter.h:43
HcalTBWriter::file_
TFile * file_
Definition: HcalTBWriter.h:37
CDFChunk
Definition: CDFChunk.h:7
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
newExtendedTrgMsgBlkStruct::stdBlock
StandardTrgMsgBlk stdBlock
Definition: HcalTBWriter.cc:125
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
visualization-live-secondInstance_cfg.runno
runno
Definition: visualization-live-secondInstance_cfg.py:79
CDFEventInfo::Set
void Set(UInt_t runNo, const char *seqid, ULong64_t eventNo, UInt_t l1aNo, ULong64_t orbitNo, UInt_t bunchNo)
setter routine
Definition: CDFEventInfo.h:24
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
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:33
CDFEventInfo
Global information about an event such as event number and run number.
Definition: CDFEventInfo.h:8
HcalTBWriter::eventInfo_
CDFEventInfo * eventInfo_
Definition: HcalTBWriter.h:39
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
newExtendedTrgMsgBlkStruct
Definition: HcalTBWriter.cc:124
HcalTBWriter::buildTree
void buildTree(const FEDRawDataCollection &raw)
Definition: HcalTBWriter.cc:78
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
FEDHeader
Definition: FEDHeader.h:14
HcalTBWriter::chunkMap_
std::map< int, int > chunkMap_
Definition: HcalTBWriter.h:41
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
CDFRunInfo::setInfo
void setInfo(const char *key, const char *value)
add some information to the run info
Definition: CDFRunInfo.cc:47
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37