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

virtual void analyze (const edm::Event &e, const edm::EventSetup &es)
 
virtual void endJob ()
 
 HcalTBWriter (const edm::ParameterSet &pset)
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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::vector< ModuleDescription const * > &modules, 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 updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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 &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

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 ( const edm::ParameterSet pset)

Definition at line 13 of file HcalTBWriter.cc.

References blockToName_, eventInfo_, file_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), dataset::name, cscdqm::h::names, pileupDistInMC::num, AlCaHLTBitMon_QueryRunRegistry::string, tok_raw_, and tree_.

13  :
14  namePattern_(pset.getUntrackedParameter<std::string>("FilenamePattern","/tmp/HTB_%06d.root"))
15 {
16 
17  tok_raw_ = consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("fedRawDataCollectionTag"));
18 
19  std::vector<edm::ParameterSet> names=pset.getUntrackedParameter<std::vector<edm::ParameterSet> >("ChunkNames");
20  std::vector<edm::ParameterSet>::iterator j;
21  for (j=names.begin(); j!=names.end(); j++) {
22  std::string name=j->getUntrackedParameter<std::string>("Name");
23  int num=j->getUntrackedParameter<int>("Number");
25  }
26 
27  file_=0;
28  tree_=0;
29  eventInfo_=0;
30 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static const HistoName names[]
CDFEventInfo * eventInfo_
Definition: HcalTBWriter.h:38
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
Definition: HcalTBWriter.h:43
TTree * tree_
Definition: HcalTBWriter.h:37
std::string namePattern_
Definition: HcalTBWriter.h:31
TFile * file_
Definition: HcalTBWriter.h:36
std::map< int, std::string > blockToName_
Definition: HcalTBWriter.h:33

Member Function Documentation

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

Definition at line 50 of file HcalTBWriter.cc.

References CDFChunk::adoptBuffer(), buildTree(), EnergyCorrector::c, chunkList_, chunkMap_, FEDRawData::data(), extractEventInfo(), FEDRawDataCollection::FEDData(), 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_.

50  {
52  e.getByToken(tok_raw_, raw);
53 
54  if (file_==0) {
55  char fname[4096];
56  snprintf(fname,4096, namePattern_.c_str(),e.id().run());
57  edm::LogInfo("HCAL") << "Opening " << fname << " for writing HCAL-format file.";
58  file_=new TFile(fname,"RECREATE");
59  ri_.setInfo("OriginalFile",fname);
60  buildTree(*raw);
61  }
62 
63  // adopt the buffers for writing
64  for (std::map<int,int>::const_iterator i=chunkMap_.begin(); i!=chunkMap_.end(); i++) {
65  CDFChunk* c=chunkList_[i->second];
66  const FEDRawData& frd=raw->FEDData(i->first);
67  c->adoptBuffer((ULong64_t*)frd.data(),frd.size()/8);
68  }
69 
70  // copy the event info bits
71  extractEventInfo(*raw,e.id());
72 
73  // fill the tree
74  tree_->Fill();
75  // release all the buffers
76  for (std::map<int,int>::const_iterator i=chunkMap_.begin(); i!=chunkMap_.end(); i++) {
77  CDFChunk* c=chunkList_[i->second];
78  c->releaseBuffer();
79  }
80 
81 }
RunNumber_t run() const
Definition: EventID.h:39
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
Definition: HcalTBWriter.h:43
void releaseBuffer()
Definition: CDFChunk.h:12
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void setInfo(const char *key, const char *value)
add some information to the run info
Definition: CDFRunInfo.cc:46
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
TTree * tree_
Definition: HcalTBWriter.h:37
void adoptBuffer(ULong64_t *buffer, Int_t length)
Definition: CDFChunk.h:11
CDFRunInfo ri_
Definition: HcalTBWriter.h:39
std::string namePattern_
Definition: HcalTBWriter.h:31
std::map< int, int > chunkMap_
Definition: HcalTBWriter.h:40
CDFChunk * chunkList_[1024]
Definition: HcalTBWriter.h:41
void buildTree(const FEDRawDataCollection &raw)
Definition: HcalTBWriter.cc:83
string fname
main script
void extractEventInfo(const FEDRawDataCollection &raw, const edm::EventID &id)
edm::EventID id() const
Definition: EventBase.h:60
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
TFile * file_
Definition: HcalTBWriter.h:36
void HcalTBWriter::buildTree ( const FEDRawDataCollection raw)
private

Definition at line 83 of file HcalTBWriter.cc.

References blockToName_, EnergyCorrector::c, chunkList_, chunkMap_, eventInfo_, FEDRawDataCollection::FEDData(), mps_fire::i, dataset::name, FEDRawData::size(), lumiContext::sname, AlCaHLTBitMon_QueryRunRegistry::string, tree_, and trigChunk_.

Referenced by analyze().

83  {
84  tree_=new TTree("CMSRAW","CMS Common Data Format Tree");
85  chunkMap_.clear();
86  trigChunk_=-1;
87  int j=0;
88  for (int i=0; i<2048; i++) {
89  const FEDRawData& frd=raw.FEDData(i);
90  if (frd.size()<16) continue; // it's empty... like
91 
93  if (blockToName_.find(i)!=blockToName_.end()) name=blockToName_[i];
94  else {
95  char sname[64];
96  snprintf(sname,64,"Chunk%03d",i);
97  name=sname;
98  }
99 
100  CDFChunk* c=new CDFChunk(name.c_str());
101  chunkList_[j]=c;
102  tree_->Branch(name.c_str(),"CDFChunk",&(chunkList_[j]));
103  chunkMap_[i]=j;
104 
105  if (name=="HCAL_Trigger" || name=="SliceTest_Trigger") trigChunk_=j;
106 
107  j++;
108  }
109  eventInfo_=new CDFEventInfo();
110  tree_->Branch("CDFEventInfo","CDFEventInfo",&eventInfo_,16000,2);
111 }
CDFEventInfo * eventInfo_
Definition: HcalTBWriter.h:38
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
TTree * tree_
Definition: HcalTBWriter.h:37
Global information about an event such as event number and run number.
Definition: CDFEventInfo.h:8
std::map< int, int > chunkMap_
Definition: HcalTBWriter.h:40
CDFChunk * chunkList_[1024]
Definition: HcalTBWriter.h:41
std::map< int, std::string > blockToName_
Definition: HcalTBWriter.h:33
void HcalTBWriter::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 32 of file HcalTBWriter.cc.

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

32  {
33  char buffer[1024];
34  if (file_!=0) {
35  file_->Write();
36 
37  ri_.setInfo("DAQSofwareRelease","UNKNOWN -- HcalTBWriter");
38  gethostname(buffer,1024);
39  ri_.setInfo("WriterHostname",buffer);
40  ri_.store(file_);
41 
42  file_->Close();
43  file_=0;
44  tree_=0;
45  chunkMap_.clear();
46  eventInfo_=0;
47  }
48 }
CDFEventInfo * eventInfo_
Definition: HcalTBWriter.h:38
void setInfo(const char *key, const char *value)
add some information to the run info
Definition: CDFRunInfo.cc:46
void store(TFile *toFile)
Definition: CDFRunInfo.cc:66
TTree * tree_
Definition: HcalTBWriter.h:37
CDFRunInfo ri_
Definition: HcalTBWriter.h:39
std::map< int, int > chunkMap_
Definition: HcalTBWriter.h:40
TFile * file_
Definition: HcalTBWriter.h:36
void HcalTBWriter::extractEventInfo ( const FEDRawDataCollection raw,
const edm::EventID id 
)
private

Definition at line 137 of file HcalTBWriter.cc.

References FEDHeader::bxID(), chunkList_, DEFINE_FWK_MODULE, eventInfo_, AlCaHLTBitMon_QueryRunRegistry::getData(), FEDHeader::lvl1ID(), StandardTrgMsgBlkStruct::orbitNumber, lumiregperbunch::runno, newExtendedTrgMsgBlkStruct::runNumberSequenceId, CDFEventInfo::Set(), newExtendedTrgMsgBlkStruct::stdBlock, and trigChunk_.

Referenced by analyze().

137  {
138  int runno=id.run();
139  const char* seqid="";
140  int eventNo=id.event();
141  int l1aNo=eventNo;
142  int orbitNo=0;
143  int bunchNo=0;
144 
145  if (trigChunk_>=0) {
146  const newExtendedTrgMsgBlk* tinfo=(const newExtendedTrgMsgBlk*)(chunkList_[trigChunk_]->getData()+2); // assume 2 64-bit words for the CDF header
147  orbitNo=tinfo->stdBlock.orbitNumber;
148  seqid=tinfo->runNumberSequenceId;
149  FEDHeader head((const unsigned char*)chunkList_[trigChunk_]->getData());
150  bunchNo=head.bxID();
151  l1aNo=head.lvl1ID();
152  }
153 
154  eventInfo_->Set(runno,seqid,eventNo,l1aNo,orbitNo,bunchNo);
155 }
StandardTrgMsgBlk stdBlock
CDFEventInfo * eventInfo_
Definition: HcalTBWriter.h:38
def getData(doc, options, dataset, site)
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:41

Member Data Documentation

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

Definition at line 33 of file HcalTBWriter.h.

Referenced by buildTree(), and HcalTBWriter().

CDFChunk* HcalTBWriter::chunkList_[1024]
private

Definition at line 41 of file HcalTBWriter.h.

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

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

Definition at line 40 of file HcalTBWriter.h.

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

CDFEventInfo* HcalTBWriter::eventInfo_
private

Definition at line 38 of file HcalTBWriter.h.

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

TFile* HcalTBWriter::file_
private

Definition at line 36 of file HcalTBWriter.h.

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

std::string HcalTBWriter::namePattern_
private

Definition at line 31 of file HcalTBWriter.h.

Referenced by analyze().

CDFRunInfo HcalTBWriter::ri_
private

Definition at line 39 of file HcalTBWriter.h.

Referenced by analyze(), and endJob().

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

Definition at line 43 of file HcalTBWriter.h.

Referenced by analyze(), and HcalTBWriter().

TTree* HcalTBWriter::tree_
private

Definition at line 37 of file HcalTBWriter.h.

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

int HcalTBWriter::trigChunk_
private

Definition at line 42 of file HcalTBWriter.h.

Referenced by buildTree(), and extractEventInfo().