CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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_
 
edm::InputTag fedRawDataCollectionTag_
 
TFile * file_
 
std::string namePattern_
 
CDFRunInfo ri_
 
TTree * tree_
 
int trigChunk_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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

Date:
2012/09/27 15:40:32
Revision:
1.3
Author
J. Mans - Minnesota

Definition at line 27 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::getUntrackedParameter(), j, mergeVDriftHistosByStation::name, cscdqm::h::names, AlCaHLTBitMon_QueryRunRegistry::string, and tree_.

13  :
14  namePattern_(pset.getUntrackedParameter<std::string>("FilenamePattern","/tmp/HTB_%06d.root")),
15  fedRawDataCollectionTag_(pset.getParameter<edm::InputTag>("fedRawDataCollectionTag"))
16 {
17 
18  std::vector<edm::ParameterSet> names=pset.getUntrackedParameter<std::vector<edm::ParameterSet> >("ChunkNames");
19  std::vector<edm::ParameterSet>::iterator j;
20  for (j=names.begin(); j!=names.end(); j++) {
21  std::string name=j->getUntrackedParameter<std::string>("Name");
22  int num=j->getUntrackedParameter<int>("Number");
24  }
25 
26  file_=0;
27  tree_=0;
28  eventInfo_=0;
29 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag fedRawDataCollectionTag_
Definition: HcalTBWriter.h:45
static const HistoName names[]
CDFEventInfo * eventInfo_
Definition: HcalTBWriter.h:40
TTree * tree_
Definition: HcalTBWriter.h:39
int j
Definition: DBlmapReader.cc:9
std::string namePattern_
Definition: HcalTBWriter.h:33
long long int num
Definition: procUtils.cc:71
TFile * file_
Definition: HcalTBWriter.h:38
std::map< int, std::string > blockToName_
Definition: HcalTBWriter.h:35

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 49 of file HcalTBWriter.cc.

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

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

Definition at line 82 of file HcalTBWriter.cc.

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

Referenced by analyze().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 31 of file HcalTBWriter.cc.

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

31  {
32  char buffer[1024];
33  if (file_!=0) {
34  file_->Write();
35 
36  ri_.setInfo("DAQSofwareRelease","UNKNOWN -- HcalTBWriter");
37  gethostname(buffer,1024);
38  ri_.setInfo("WriterHostname",buffer);
39  ri_.store(file_);
40 
41  file_->Close();
42  file_=0;
43  tree_=0;
44  chunkMap_.clear();
45  eventInfo_=0;
46  }
47 }
CDFEventInfo * eventInfo_
Definition: HcalTBWriter.h:40
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:39
CDFRunInfo ri_
Definition: HcalTBWriter.h:41
std::map< int, int > chunkMap_
Definition: HcalTBWriter.h:42
TFile * file_
Definition: HcalTBWriter.h:38
void HcalTBWriter::extractEventInfo ( const FEDRawDataCollection raw,
const edm::EventID id 
)
private

Definition at line 136 of file HcalTBWriter.cc.

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

Referenced by analyze().

136  {
137  int runno=id.run();
138  const char* seqid="";
139  int eventNo=id.event();
140  int l1aNo=eventNo;
141  int orbitNo=0;
142  int bunchNo=0;
143 
144  if (trigChunk_>=0) {
145  const newExtendedTrgMsgBlk* tinfo=(const newExtendedTrgMsgBlk*)(chunkList_[trigChunk_]->getData()+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:40
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:43

Member Data Documentation

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

Definition at line 35 of file HcalTBWriter.h.

Referenced by buildTree(), and HcalTBWriter().

CDFChunk* HcalTBWriter::chunkList_[1024]
private

Definition at line 43 of file HcalTBWriter.h.

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

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

Definition at line 42 of file HcalTBWriter.h.

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

CDFEventInfo* HcalTBWriter::eventInfo_
private

Definition at line 40 of file HcalTBWriter.h.

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

edm::InputTag HcalTBWriter::fedRawDataCollectionTag_
private

Definition at line 45 of file HcalTBWriter.h.

Referenced by analyze().

TFile* HcalTBWriter::file_
private

Definition at line 38 of file HcalTBWriter.h.

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

std::string HcalTBWriter::namePattern_
private

Definition at line 33 of file HcalTBWriter.h.

Referenced by analyze().

CDFRunInfo HcalTBWriter::ri_
private

Definition at line 41 of file HcalTBWriter.h.

Referenced by analyze(), and endJob().

TTree* HcalTBWriter::tree_
private

Definition at line 39 of file HcalTBWriter.h.

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

int HcalTBWriter::trigChunk_
private

Definition at line 44 of file HcalTBWriter.h.

Referenced by buildTree(), and extractEventInfo().