CMS 3D CMS Logo

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

#include <HcalTBWriter.h>

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

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &es) override
 
void endJob () override
 
 HcalTBWriter (const edm::ParameterSet &pset)
 
 ~HcalTBWriter () override=default
 
- 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 final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const 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
 
bool wantsStreamRuns () const
 
 ~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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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
< FEDRawDataCollection
tok_raw_
 
TTree * tree_
 
int trigChunk_
 

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 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<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

Writes HCAL-style ROOT files from the RawData block

Author
J. Mans - Minnesota

Definition at line 26 of file HcalTBWriter.h.

Constructor & Destructor Documentation

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

Definition at line 11 of file HcalTBWriter.cc.

References blockToName_, eventInfo_, file_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), dqmiolumiharvest::j, mergeVDriftHistosByStation::name, names, pileupDistInMC::num, AlCaHLTBitMon_QueryRunRegistry::string, tok_raw_, and tree_.

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 }
T getUntrackedParameter(std::string const &, T const &) const
CDFEventInfo * eventInfo_
Definition: HcalTBWriter.h:41
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
Definition: HcalTBWriter.h:46
const std::string names[nVars_]
TTree * tree_
Definition: HcalTBWriter.h:40
std::string namePattern_
Definition: HcalTBWriter.h:34
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TFile * file_
Definition: HcalTBWriter.h:39
std::map< int, std::string > blockToName_
Definition: HcalTBWriter.h:36
HcalTBWriter::~HcalTBWriter ( )
overridedefault

Member Function Documentation

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

Implements edm::one::EDAnalyzerBase.

Definition at line 46 of file HcalTBWriter.cc.

References CDFChunk::adoptBuffer(), buildTree(), c, chunkList_, chunkMap_, FEDRawData::data(), extractEventInfo(), file_, alignmentValidation::fname, edm::Event::getByToken(), mps_fire::i, edm::EventBase::id(), namePattern_, CDFChunk::releaseBuffer(), ri_, edm::EventID::run(), CDFRunInfo::setInfo(), FEDRawData::size(), tok_raw_, and tree_.

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 }
RunNumber_t run() const
Definition: EventID.h:38
const edm::EventSetup & c
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
Definition: HcalTBWriter.h:46
void releaseBuffer()
Definition: CDFChunk.h:17
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
void setInfo(const char *key, const char *value)
add some information to the run info
Definition: CDFRunInfo.cc:47
TTree * tree_
Definition: HcalTBWriter.h:40
std::map< int, int > chunkMap_
Definition: HcalTBWriter.h:43
void adoptBuffer(ULong64_t *buffer, Int_t length)
Definition: CDFChunk.h:11
CDFRunInfo ri_
Definition: HcalTBWriter.h:42
std::string namePattern_
Definition: HcalTBWriter.h:34
Log< level::Info, false > LogInfo
CDFChunk * chunkList_[1024]
Definition: HcalTBWriter.h:44
void buildTree(const FEDRawDataCollection &raw)
Definition: HcalTBWriter.cc:78
string fname
main script
void extractEventInfo(const FEDRawDataCollection &raw, const edm::EventID &id)
edm::EventID id() const
Definition: EventBase.h:59
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
TFile * file_
Definition: HcalTBWriter.h:39
void HcalTBWriter::buildTree ( const FEDRawDataCollection raw)
private

Definition at line 78 of file HcalTBWriter.cc.

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

Referenced by analyze().

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 }
const edm::EventSetup & c
CDFEventInfo * eventInfo_
Definition: HcalTBWriter.h:41
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
TTree * tree_
Definition: HcalTBWriter.h:40
std::map< int, int > chunkMap_
Definition: HcalTBWriter.h:43
Global information about an event such as event number and run number.
Definition: CDFEventInfo.h:8
CDFChunk * chunkList_[1024]
Definition: HcalTBWriter.h:44
std::map< int, std::string > blockToName_
Definition: HcalTBWriter.h:36
void HcalTBWriter::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 28 of file HcalTBWriter.cc.

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

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 }
CDFEventInfo * eventInfo_
Definition: HcalTBWriter.h:41
void setInfo(const char *key, const char *value)
add some information to the run info
Definition: CDFRunInfo.cc:47
void store(TFile *toFile)
Definition: CDFRunInfo.cc:67
TTree * tree_
Definition: HcalTBWriter.h:40
std::map< int, int > chunkMap_
Definition: HcalTBWriter.h:43
CDFRunInfo ri_
Definition: HcalTBWriter.h:42
TFile * file_
Definition: HcalTBWriter.h:39
void HcalTBWriter::extractEventInfo ( const FEDRawDataCollection raw,
const edm::EventID id 
)
private

Definition at line 135 of file HcalTBWriter.cc.

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

Referenced by analyze().

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 }
StandardTrgMsgBlk stdBlock
CDFEventInfo * eventInfo_
Definition: HcalTBWriter.h:41
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
CDFChunk * chunkList_[1024]
Definition: HcalTBWriter.h:44

Member Data Documentation

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

Definition at line 36 of file HcalTBWriter.h.

Referenced by buildTree(), and HcalTBWriter().

CDFChunk* HcalTBWriter::chunkList_[1024]
private

Definition at line 44 of file HcalTBWriter.h.

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

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

Definition at line 43 of file HcalTBWriter.h.

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

CDFEventInfo* HcalTBWriter::eventInfo_
private

Definition at line 41 of file HcalTBWriter.h.

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

TFile* HcalTBWriter::file_
private

Definition at line 39 of file HcalTBWriter.h.

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

std::string HcalTBWriter::namePattern_
private

Definition at line 34 of file HcalTBWriter.h.

Referenced by analyze().

CDFRunInfo HcalTBWriter::ri_
private

Definition at line 42 of file HcalTBWriter.h.

Referenced by analyze(), and endJob().

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

Definition at line 46 of file HcalTBWriter.h.

Referenced by analyze(), and HcalTBWriter().

TTree* HcalTBWriter::tree_
private

Definition at line 40 of file HcalTBWriter.h.

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

int HcalTBWriter::trigChunk_
private

Definition at line 45 of file HcalTBWriter.h.

Referenced by buildTree(), and extractEventInfo().