CMS 3D CMS Logo

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

#include <HcalTBSource.h>

Inheritance diagram for HcalTBSource:
edm::ExternalInputSource edm::ConfigurableInputSource edm::InputSource edm::ProductRegistryHelper

Public Member Functions

 HcalTBSource (const edm::ParameterSet &pset, edm::InputSourceDescription const &desc)
 
virtual ~HcalTBSource ()
 
- Public Member Functions inherited from edm::ExternalInputSource
InputFileCatalogcatalog ()
 
 ExternalInputSource (ParameterSet const &pset, InputSourceDescription const &desc, bool realData=true)
 
std::vector< std::string > const & fileNames () const
 
std::vector< std::string > const & logicalFileNames () const
 
virtual ~ExternalInputSource ()
 
- Public Member Functions inherited from edm::ConfigurableInputSource
 ConfigurableInputSource (ParameterSet const &pset, InputSourceDescription const &desc, bool realData=true)
 
EventNumber_t event () const
 
unsigned int eventCreationDelay () const
 
LuminosityBlockNumber_t luminosityBlock () const
 
unsigned int numberEventsInLumi () const
 
unsigned int numberEventsInRun () const
 
unsigned int numberEventsInThisLumi () const
 
unsigned int numberEventsInThisRun () const
 
TimeValue_t presentTime () const
 
RunNumber_t run () const
 
unsigned int timeBetweenEvents () const
 
virtual ~ConfigurableInputSource ()
 
- Public Member Functions inherited from edm::InputSource
boost::shared_ptr
< ActivityRegistry
actReg () const
 Accessor for Activity Registry. More...
 
void closeFile (boost::shared_ptr< FileBlock >, bool cleaningUpAfterException)
 close current file More...
 
void doBeginJob ()
 Called by framework at beginning of job. More...
 
void doBeginLumi (LuminosityBlockPrincipal &lbp)
 Called by framework at beginning of lumi block. More...
 
void doBeginRun (RunPrincipal &rp)
 Called by framework at beginning of run. More...
 
void doEndJob ()
 Called by framework at end of job. More...
 
void doEndLumi (LuminosityBlockPrincipal &lbp, bool cleaningUpAfterException)
 Called by framework at end of lumi block. More...
 
void doEndRun (RunPrincipal &rp, bool cleaningUpAfterException)
 Called by framework at end of run. More...
 
void doPostForkReacquireResources (boost::shared_ptr< multicore::MessageReceiverForSource >)
 
void doPreForkReleaseResources ()
 Called by the framework before forking the process. More...
 
ProcessingController::ForwardState forwardState () const
 
bool goToEvent (EventID const &eventID)
 
 InputSource (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
void issueReports (EventID const &eventID)
 issue an event report More...
 
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
luminosityBlockAuxiliary () const
 Called by the framework to merge or insert lumi in principal cache. More...
 
int markLumi ()
 Mark lumi as read. More...
 
int markRun ()
 Mark run as read. More...
 
int maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 
bool primary () const
 Accessor for primary input source flag. More...
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
boost::shared_ptr
< ProductRegistry const > 
productRegistry () const
 Accessor for product registry. More...
 
bool randomAccess () const
 
void readAndCacheLumi (bool merge, HistoryAppender &historyAppender)
 Read next luminosity block. More...
 
void readAndCacheRun (bool merge, HistoryAppender &historyAppender)
 Read next run. More...
 
EventPrincipalreadEvent (boost::shared_ptr< LuminosityBlockPrincipal > lbCache)
 
EventPrincipalreadEvent (EventID const &)
 Read a specific event. More...
 
boost::shared_ptr< FileBlockreadFile ()
 Read next file. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary ()
 Read next luminosity block Auxilary. More...
 
boost::shared_ptr< RunAuxiliaryreadRunAuxiliary ()
 Read next run Auxiliary. More...
 
ProcessHistoryID const & reducedProcessHistoryID () const
 
void registerProducts ()
 Register any produced products. More...
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void repeat ()
 Reset the remaining number of events/lumis to the maximum number. More...
 
ProcessingController::ReverseState reverseState () const
 
void rewind ()
 Begin again at the first event. More...
 
RunNumber_t run () const
 Accessor for current run number. More...
 
boost::shared_ptr< RunAuxiliaryrunAuxiliary () const
 Called by the framework to merge or insert run in principal cache. More...
 
void setLuminosityBlockNumber_t (LuminosityBlockNumber_t lb)
 Set the luminosity block ID. More...
 
void setRunNumber (RunNumber_t r)
 Set the run number. More...
 
void skipEvents (int offset)
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
virtual ~InputSource ()
 Destructor. More...
 

Protected Member Functions

virtual bool produce (edm::Event &e)
 
virtual void setRunAndEventInfo ()
 
- Protected Member Functions inherited from edm::ExternalInputSource
void incrementFileIndex ()
 
- Protected Member Functions inherited from edm::ConfigurableInputSource
void reallyReadEvent ()
 
void setEventNumber (EventNumber_t e)
 
void setTime (TimeValue_t t)
 
- Protected Member Functions inherited from edm::InputSource
void decreaseRemainingEventsBy (int iSkipped)
 
EventPrincipaleventPrincipalCache ()
 
boost::shared_ptr
< LuminosityBlockPrincipal >
const 
luminosityBlockPrincipal () const
 
PrincipalCache const & principalCache () const
 
PrincipalCacheprincipalCache ()
 
ProductRegistryproductRegistryUpdate () const
 
void reset () const
 
void resetLuminosityBlockAuxiliary () const
 
void resetRunAuxiliary () const
 
boost::shared_ptr
< RunPrincipal > const 
runPrincipal () const
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
void setRunAuxiliary (RunAuxiliary *rp)
 
void setTimestamp (Timestamp const &theTime)
 To set the current time, as seen by the input source. More...
 
ItemType state () const
 

Private Member Functions

void openFile (const std::string &filename)
 
void unpackSetup (const std::vector< std::string > &params)
 

Private Attributes

int m_chunkIds [CHUNK_COUNT]
 
CDFChunkm_chunks [CHUNK_COUNT]
 
CDFEventInfom_eventInfo
 
int m_eventNumberOffset
 
TFile * m_file
 
int m_fileCounter
 
int m_i
 
bool m_onlyRemapped
 
bool m_quiet
 
std::map< std::string, int > m_sourceIdRemap
 
TTree * m_tree
 
int n_chunks
 

Static Private Attributes

static const int CHUNK_COUNT =64
 

Additional Inherited Members

- Public Types inherited from edm::InputSource
enum  ItemType {
  IsInvalid, IsStop, IsFile, IsRun,
  IsLumi, IsEvent, IsRepeat
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::ExternalInputSource
static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::ConfigurableInputSource
static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::InputSource
static const std::string & baseType ()
 
static void fillDescription (ParameterSetDescription &desc)
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

Note
Notice that there is a hack to renumber events from runs where the first event number was zero.
Date:
2008/10/16 08:09:12
Revision:
1.7
Author
J. Mans - Minnesota

Definition at line 27 of file HcalTBSource.h.

Constructor & Destructor Documentation

HcalTBSource::HcalTBSource ( const edm::ParameterSet pset,
edm::InputSourceDescription const &  desc 
)
explicit

Definition at line 17 of file HcalTBSource.cc.

17  :
18  edm::ExternalInputSource(pset,desc),
19  m_quiet( pset.getUntrackedParameter<bool>("quiet",true)),
20  m_onlyRemapped( pset.getUntrackedParameter<bool>("onlyRemapped",false))
21 {
22  m_tree=0;
23  m_fileCounter=-1;
24  m_file=0;
25  m_i=0;
26 
27  unpackSetup(pset.getUntrackedParameter<std::vector<std::string> >("streams",std::vector<std::string>()));
28  produces<FEDRawDataCollection>();
29 }
T getUntrackedParameter(std::string const &, T const &) const
TFile * m_file
Definition: HcalTBSource.h:38
TTree * m_tree
Definition: HcalTBSource.h:37
bool m_onlyRemapped
Definition: HcalTBSource.h:40
void unpackSetup(const std::vector< std::string > &params)
Definition: HcalTBSource.cc:31
HcalTBSource::~HcalTBSource ( )
virtual

Definition at line 47 of file HcalTBSource.cc.

References m_file, and m_tree.

47  {
48  if (m_file!=0) {
49  m_file->Close();
50  m_file=0;
51  m_tree=0;
52  }
53 }
TFile * m_file
Definition: HcalTBSource.h:38
TTree * m_tree
Definition: HcalTBSource.h:37

Member Function Documentation

void HcalTBSource::openFile ( const std::string &  filename)
private

Definition at line 55 of file HcalTBSource.cc.

References b, i, m_chunkIds, m_chunks, m_eventInfo, m_file, m_i, m_onlyRemapped, m_quiet, m_sourceIdRemap, m_tree, and n_chunks.

Referenced by setRunAndEventInfo().

55  {
56  if (m_file!=0) {
57  m_file->Close();
58  m_file=0;
59  m_tree=0;
60  }
61 
62  // try {
63  m_file=TFile::Open(filename.c_str());
64  if (m_file==0) {
65  edm::LogError("HCAL") << "Unable to open " << filename << endl;
66  m_tree=0;
67  return;
68  }
69 
70  m_tree=(TTree*)m_file->Get("CMSRAW");
71 
72  if (m_tree==0) {
73  m_file->Close();
74  m_file=0;
75  edm::LogError("HCAL") << "Unable to find CMSRAW tree" << endl;
76  return;
77  }
78 
79  if (!m_quiet) {
80  edm::LogInfo("HCAL") << "Opening '" << filename << "' with " << m_tree->GetEntries() << " events.\n";
81  }
82 
83  TObjArray* lb=m_tree->GetListOfBranches();
84  n_chunks=0;
85  for (int i=0; i<lb->GetSize(); i++) {
86  TBranch* b=(TBranch*)lb->At(i);
87  if (b==0) continue;
88  if (!strcmp(b->GetClassName(),"CDFEventInfo")) {
89  m_eventInfo=0;
90  b->SetAddress(&m_eventInfo);
91  } else {
92  if (strcmp(b->GetClassName(),"CDFChunk")) continue;
93  if (m_sourceIdRemap.find(b->GetName())==m_sourceIdRemap.end()) {
94  if (m_onlyRemapped) continue;
95  m_sourceIdRemap.insert(std::pair<std::string,int>(b->GetName(),-1));
96  if (!m_quiet)
97  edm::LogInfo("HCAL") << "Also reading branch " << b->GetName();
98  }
99 
100  m_chunks[n_chunks]=0; // allow ROOT to allocate
101  b->SetAddress(&(m_chunks[n_chunks]));
102  m_chunkIds[n_chunks]=m_sourceIdRemap[b->GetName()];
103  n_chunks++;
104  }
105  }
106  m_i=0;
107 }
int i
Definition: DBlmapReader.cc:9
TFile * m_file
Definition: HcalTBSource.h:38
TTree * m_tree
Definition: HcalTBSource.h:37
bool m_onlyRemapped
Definition: HcalTBSource.h:40
CDFChunk * m_chunks[CHUNK_COUNT]
Definition: HcalTBSource.h:43
int m_chunkIds[CHUNK_COUNT]
Definition: HcalTBSource.h:44
double b
Definition: hdecay.h:120
tuple filename
Definition: lut2db_cfg.py:20
CDFEventInfo * m_eventInfo
Definition: HcalTBSource.h:46
std::map< std::string, int > m_sourceIdRemap
Definition: HcalTBSource.h:45
bool HcalTBSource::produce ( edm::Event e)
protectedvirtual

Implements edm::ConfigurableInputSource.

Definition at line 148 of file HcalTBSource.cc.

References FEDRawData::data(), data, edm::ExternalInputSource::fileNames(), AlCaHLTBitMon_QueryRunRegistry::getData(), CDFChunk::getDataLength(), CDFChunk::getSourceId(), errorMatrix2Lands::header, i, m_chunkIds, m_chunks, m_fileCounter, m_quiet, m_tree, n_chunks, edm::Event::put(), FEDRawData::resize(), and findQualityFiles::size.

148  {
149 
150  if (m_fileCounter>=int(fileNames().size())) return false; // all done!
151 
152  if (m_tree==0) {
153  edm::LogError("HCAL") << "Null TTree";
154  return false;
155  }
156 
157  std::auto_ptr<FEDRawDataCollection> bare_product(new FEDRawDataCollection());
158  for (int i=0; i<n_chunks; i++) {
159  const unsigned char* data=(const unsigned char*)m_chunks[i]->getData();
160  int len=m_chunks[i]->getDataLength()*8;
161 
162  int natId=m_chunks[i]->getSourceId();
163  int id=(m_chunkIds[i]>0)?(m_chunkIds[i]):(natId);
164 
165  FEDRawData& fed=bare_product->FEDData(id);
166  fed.resize(len);
167  memcpy(fed.data(),data,len);
168 
169  // patch the SourceId...
170  if (natId!=id) {
171  unsigned int* header=(unsigned int*)fed.data();
172  header[0]=(header[0]&0xFFF000FFu)|(id<<8);
173  // TODO: patch CRC after this change!
174  }
175  if (!m_quiet)
176  edm::LogInfo("HCAL") << "Reading " << len << " bytes for FED " << id << std::endl;
177  }
178 
179  e.put(bare_product);
180 
181  return true;
182 }
int i
Definition: DBlmapReader.cc:9
int getSourceId() const
Definition: CDFChunk.h:15
TTree * m_tree
Definition: HcalTBSource.h:37
void resize(size_t newsize)
Definition: FEDRawData.cc:33
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
CDFChunk * m_chunks[CHUNK_COUNT]
Definition: HcalTBSource.h:43
int m_chunkIds[CHUNK_COUNT]
Definition: HcalTBSource.h:44
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
Int_t getDataLength() const
Definition: CDFChunk.h:14
std::vector< std::string > const & fileNames() const
tuple size
Write out results.
void HcalTBSource::setRunAndEventInfo ( )
protectedvirtual

Reimplemented from edm::ConfigurableInputSource.

Definition at line 109 of file HcalTBSource.cc.

References edm::ExternalInputSource::fileNames(), CDFEventInfo::getEventNumber(), CDFEventInfo::getRunNumber(), m_eventInfo, m_eventNumberOffset, m_file, m_fileCounter, m_i, m_tree, openFile(), edm::ConfigurableInputSource::presentTime(), edm::ConfigurableInputSource::setEventNumber(), edm::InputSource::setRunNumber(), edm::ConfigurableInputSource::setTime(), findQualityFiles::size, and edm::ConfigurableInputSource::timeBetweenEvents().

109  {
110  bool is_new=false;
111 
112  while (m_tree==0 || m_i==m_tree->GetEntries()) {
113  m_fileCounter++;
114  if (m_file!=0) {
115  m_file->Close();
116  m_file=0;
117  m_tree=0;
118  }
119  if (m_fileCounter>=int(fileNames().size())) return; // nothing good
121  is_new=true;
122  }
123 
124  if (m_tree==0 || m_i==m_tree->GetEntries()) return; //nothing good
125 
126  m_tree->GetEntry(m_i);
127  m_i++;
128 
129  if (m_eventInfo!=0) {
130  if (is_new) {
132  else m_eventNumberOffset=0;
133  }
134  if (m_eventInfo->getRunNumber()==0) setRunNumber(1); // ZERO is unacceptable from a technical point of view
137  } else {
139  setEventNumber(m_i+1);
140  }
141  // time is a hack
142  edm::TimeValue_t present_time = presentTime();
143  unsigned long time_between_events = timeBetweenEvents();
144 
145  setTime(present_time + time_between_events);
146 }
TFile * m_file
Definition: HcalTBSource.h:38
int m_eventNumberOffset
Definition: HcalTBSource.h:47
TTree * m_tree
Definition: HcalTBSource.h:37
void openFile(const std::string &filename)
Definition: HcalTBSource.cc:55
unsigned long long TimeValue_t
Definition: Timestamp.h:27
UInt_t getRunNumber() const
get the run number
Definition: CDFEventInfo.h:12
void setRunNumber(RunNumber_t r)
Set the run number.
Definition: InputSource.h:143
void setEventNumber(EventNumber_t e)
unsigned int timeBetweenEvents() const
CDFEventInfo * m_eventInfo
Definition: HcalTBSource.h:46
std::vector< std::string > const & fileNames() const
ULong64_t getEventNumber() const
get the event number
Definition: CDFEventInfo.h:16
tuple size
Write out results.
void HcalTBSource::unpackSetup ( const std::vector< std::string > &  params)
private

Definition at line 31 of file HcalTBSource.cc.

References i, m_sourceIdRemap, and pos.

31  {
32  for (std::vector<std::string>::const_iterator i=params.begin(); i!=params.end(); i++) {
33  unsigned long pos=i->find(':');
34  std::string streamName=i->substr(0,pos);
35  int remapTo=-1;
36  if (pos!=std::string::npos)
37  remapTo=atoi(i->c_str()+pos+1);
38 
39  m_sourceIdRemap.insert(std::pair<std::string,int>(streamName,remapTo));
40  if (remapTo!=-1)
41  edm::LogInfo("HCAL") << streamName << " --> " << remapTo << endl;
42  else
43  edm::LogInfo("HCAL") << streamName << " using fedid in file" << endl;
44  }
45 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, int > m_sourceIdRemap
Definition: HcalTBSource.h:45

Member Data Documentation

const int HcalTBSource::CHUNK_COUNT =64
staticprivate

Definition at line 42 of file HcalTBSource.h.

int HcalTBSource::m_chunkIds[CHUNK_COUNT]
private

Definition at line 44 of file HcalTBSource.h.

Referenced by openFile(), and produce().

CDFChunk* HcalTBSource::m_chunks[CHUNK_COUNT]
private

Definition at line 43 of file HcalTBSource.h.

Referenced by openFile(), and produce().

CDFEventInfo* HcalTBSource::m_eventInfo
private

Definition at line 46 of file HcalTBSource.h.

Referenced by openFile(), and setRunAndEventInfo().

int HcalTBSource::m_eventNumberOffset
private

Definition at line 47 of file HcalTBSource.h.

Referenced by setRunAndEventInfo().

TFile* HcalTBSource::m_file
private

Definition at line 38 of file HcalTBSource.h.

Referenced by openFile(), setRunAndEventInfo(), and ~HcalTBSource().

int HcalTBSource::m_fileCounter
private

Definition at line 39 of file HcalTBSource.h.

Referenced by produce(), and setRunAndEventInfo().

int HcalTBSource::m_i
private

Definition at line 39 of file HcalTBSource.h.

Referenced by openFile(), and setRunAndEventInfo().

bool HcalTBSource::m_onlyRemapped
private

Definition at line 40 of file HcalTBSource.h.

Referenced by openFile().

bool HcalTBSource::m_quiet
private

Definition at line 40 of file HcalTBSource.h.

Referenced by openFile(), and produce().

std::map<std::string,int> HcalTBSource::m_sourceIdRemap
private

Definition at line 45 of file HcalTBSource.h.

Referenced by openFile(), and unpackSetup().

TTree* HcalTBSource::m_tree
private

Definition at line 37 of file HcalTBSource.h.

Referenced by openFile(), produce(), setRunAndEventInfo(), and ~HcalTBSource().

int HcalTBSource::n_chunks
private

Definition at line 41 of file HcalTBSource.h.

Referenced by openFile(), and produce().