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 | Static Private Attributes
HcalTBSource Class Reference

#include <HcalTBSource.h>

Inheritance diagram for HcalTBSource:
edm::ProducerSourceFromFiles edm::ProducerSourceBase edm::FromFiles edm::InputSource edm::ProductRegistryHelper

Public Member Functions

 HcalTBSource (const edm::ParameterSet &pset, edm::InputSourceDescription const &desc)
 
virtual ~HcalTBSource ()
 
- Public Member Functions inherited from edm::ProducerSourceFromFiles
virtual bool noFiles () const override
 
 ProducerSourceFromFiles (ParameterSet const &pset, InputSourceDescription const &desc, bool realData)
 
virtual ~ProducerSourceFromFiles ()
 
- Public Member Functions inherited from edm::ProducerSourceBase
EventNumber_t event () const
 
unsigned int eventCreationDelay () const
 
EventID const & eventID () 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
 
 ProducerSourceBase (ParameterSet const &pset, InputSourceDescription const &desc, bool realData)
 
RunNumber_t run () const
 
unsigned int timeBetweenEvents () const
 
virtual ~ProducerSourceBase ()
 
- Public Member Functions inherited from edm::InputSource
std::shared_ptr< ActivityRegistryactReg () const
 Accessor for Activity Registry. More...
 
std::shared_ptr
< BranchIDListHelper const > 
branchIDListHelper () const
 Accessors for branchIDListHelper. More...
 
std::shared_ptr
< BranchIDListHelper > & 
branchIDListHelper ()
 
void closeFile (FileBlock *, bool cleaningUpAfterException)
 close current file More...
 
void doBeginJob ()
 Called by framework at beginning of job. More...
 
void doBeginLumi (LuminosityBlockPrincipal &lbp, ProcessContext const *)
 Called by framework at beginning of lumi block. More...
 
void doBeginRun (RunPrincipal &rp, ProcessContext const *)
 Called by framework at beginning of run. More...
 
void doEndJob ()
 Called by framework at end of job. More...
 
void doEndLumi (LuminosityBlockPrincipal &lbp, bool cleaningUpAfterException, ProcessContext const *)
 Called by framework at end of lumi block. More...
 
void doEndRun (RunPrincipal &rp, bool cleaningUpAfterException, ProcessContext const *)
 Called by framework at end of run. More...
 
void doPostForkReacquireResources (std::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...
 
 InputSource (InputSource const &)=delete
 
void issueReports (EventID const &eventID)
 issue an event report More...
 
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number. More...
 
std::shared_ptr
< LuminosityBlockAuxiliary
luminosityBlockAuxiliary () const
 Called by the framework to merge or insert lumi in principal cache. More...
 
int maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 Advances the source to the next item. More...
 
InputSourceoperator= (InputSource const &)=delete
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessHistoryRegistry const & processHistoryRegistry () const
 Accessors for process history registry. More...
 
ProcessHistoryRegistryprocessHistoryRegistry ()
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
std::shared_ptr
< ProductRegistry const > 
productRegistry () const
 Accessors for product registry. More...
 
std::shared_ptr
< ProductRegistry > & 
productRegistry ()
 
bool randomAccess () const
 
void readAndMergeLumi (LuminosityBlockPrincipal &lbp)
 Read next luminosity block (same as a prior lumi) More...
 
void readAndMergeRun (RunPrincipal &rp)
 Read next run (same as a prior run) More...
 
void readEvent (EventPrincipal &ep, StreamContext &)
 Read next event. More...
 
bool readEvent (EventPrincipal &ep, EventID const &, StreamContext &)
 Read a specific event. More...
 
std::unique_ptr< FileBlockreadFile ()
 Read next file. More...
 
void readLuminosityBlock (LuminosityBlockPrincipal &lumiPrincipal, HistoryAppender &historyAppender)
 Read next luminosity block (new lumi) More...
 
std::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary ()
 Read next luminosity block Auxilary. More...
 
void readRun (RunPrincipal &runPrincipal, HistoryAppender &historyAppender)
 Read next run (new run) More...
 
std::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...
 
SharedResourcesAcquirerresourceSharedWithDelayedReader ()
 Returns nullptr if no resource shared between the Source and a DelayedReader. More...
 
ProcessingController::ReverseState reverseState () const
 
void rewind ()
 Begin again at the first event. More...
 
RunNumber_t run () const
 Accessor for current run number. More...
 
std::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)
 
bool skipForForking ()
 
std::shared_ptr
< ThinnedAssociationsHelper
const > 
thinnedAssociationsHelper () const
 Accessors for thinnedAssociationsHelper. More...
 
std::shared_ptr
< ThinnedAssociationsHelper > & 
thinnedAssociationsHelper ()
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
virtual ~InputSource ()
 Destructor. More...
 

Private Member Functions

void openFile (const std::string &filename)
 
virtual void produce (edm::Event &e)
 
virtual bool setRunAndEventInfo (edm::EventID &id, edm::TimeValue_t &time, edm::EventAuxiliary::ExperimentType &)
 
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, IsSynchronize
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::ProducerSourceFromFiles
static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::ProducerSourceBase
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 &)
 
- Protected Member Functions inherited from edm::InputSource
void decreaseRemainingEventsBy (int iSkipped)
 
bool eventCached () const
 
bool newLumi () const
 
bool newRun () const
 
ProcessHistoryRegistryprocessHistoryRegistryForUpdate ()
 
ProductRegistryproductRegistryUpdate ()
 
void reset () const
 
void resetEventCached ()
 
void resetLuminosityBlockAuxiliary (bool isNewLumi=true) const
 
void resetNewLumi ()
 
void resetNewRun ()
 
void resetRunAuxiliary (bool isNewRun=true) const
 
void setEventCached ()
 Called by the framework to merge or ached() const {return eventCached_;}. More...
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
void setNewLumi ()
 
void setNewRun ()
 
void setRunAuxiliary (RunAuxiliary *rp)
 
void setTimestamp (Timestamp const &theTime)
 To set the current time, as seen by the input source. More...
 
ItemType state () const
 

Detailed Description

Note
Notice that there is a hack to renumber events from runs where the first event number was zero.

Definition at line 22 of file HcalTBSource.h.

Constructor & Destructor Documentation

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

Definition at line 16 of file HcalTBSource.cc.

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

Definition at line 46 of file HcalTBSource.cc.

References m_file, and m_tree.

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

Member Function Documentation

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

Definition at line 54 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().

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

Implements edm::ProducerSourceBase.

Definition at line 146 of file HcalTBSource.cc.

References FEDRawData::data(), data, AlCaHLTBitMon_QueryRunRegistry::getData(), CDFChunk::getDataLength(), CDFChunk::getSourceId(), i, m_chunkIds, m_chunks, m_quiet, n_chunks, edm::Event::put(), and FEDRawData::resize().

146  {
147 
148  std::auto_ptr<FEDRawDataCollection> bare_product(new FEDRawDataCollection());
149  for (int i=0; i<n_chunks; i++) {
150  const unsigned char* data=(const unsigned char*)m_chunks[i]->getData();
151  int len=m_chunks[i]->getDataLength()*8;
152 
153  int natId=m_chunks[i]->getSourceId();
154  int id=(m_chunkIds[i]>0)?(m_chunkIds[i]):(natId);
155 
156  FEDRawData& fed=bare_product->FEDData(id);
157  fed.resize(len);
158  memcpy(fed.data(),data,len);
159 
160  // patch the SourceId...
161  if (natId!=id) {
162  unsigned int* header=(unsigned int*)fed.data();
163  header[0]=(header[0]&0xFFF000FFu)|(id<<8);
164  // TODO: patch CRC after this change!
165  }
166  if (!m_quiet)
167  edm::LogInfo("HCAL") << "Reading " << len << " bytes for FED " << id << std::endl;
168  }
169 
170  e.put(bare_product);
171 }
int i
Definition: DBlmapReader.cc:9
int getSourceId() const
Definition: CDFChunk.h:16
void resize(size_t newsize)
Definition: FEDRawData.cc:32
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
CDFChunk * m_chunks[CHUNK_COUNT]
Definition: HcalTBSource.h:37
int m_chunkIds[CHUNK_COUNT]
Definition: HcalTBSource.h:38
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:28
Int_t getDataLength() const
Definition: CDFChunk.h:15
bool HcalTBSource::setRunAndEventInfo ( edm::EventID id,
edm::TimeValue_t time,
edm::EventAuxiliary::ExperimentType  
)
privatevirtual

Implements edm::ProducerSourceBase.

Definition at line 108 of file HcalTBSource.cc.

References edm::FromFiles::fileNames(), CDFEventInfo::getEventNumber(), CDFEventInfo::getRunNumber(), edm::ProducerSourceBase::luminosityBlock(), m_eventInfo, m_eventNumberOffset, m_file, m_fileCounter, m_i, m_tree, openFile(), edm::ProducerSourceBase::presentTime(), findQualityFiles::size, and edm::ProducerSourceBase::timeBetweenEvents().

108  {
109  bool is_new=false;
110 
111  while (m_tree==0 || m_i==m_tree->GetEntries()) {
112  m_fileCounter++;
113  if (m_file!=0) {
114  m_file->Close();
115  m_file=0;
116  m_tree=0;
117  }
118  if (m_fileCounter>=int(fileNames().size())) return false; // nothing good
120  is_new=true;
121  }
122 
123  if (m_tree==0 || m_i==m_tree->GetEntries()) return false; //nothing good
124 
125  m_tree->GetEntry(m_i);
126  m_i++;
127 
128  if (m_eventInfo!=0) {
129  if (is_new) {
131  else m_eventNumberOffset=0;
132  }
133  // ZERO is unacceptable for a run number from a technical point of view
135  } else {
136  id = EventID(m_fileCounter+10, id.luminosityBlock(), m_i+1);
137  }
138  // time is a hack
139  edm::TimeValue_t present_time = presentTime();
140  unsigned long time_between_events = timeBetweenEvents();
141 
142  time = present_time + time_between_events;
143  return true;
144 }
TFile * m_file
Definition: HcalTBSource.h:32
int m_eventNumberOffset
Definition: HcalTBSource.h:41
std::vector< std::string > const & fileNames() const
Definition: FromFiles.h:22
TTree * m_tree
Definition: HcalTBSource.h:31
void openFile(const std::string &filename)
Definition: HcalTBSource.cc:54
unsigned int timeBetweenEvents() const
unsigned long long TimeValue_t
Definition: Timestamp.h:28
UInt_t getRunNumber() const
get the run number
Definition: CDFEventInfo.h:12
TimeValue_t presentTime() const
LuminosityBlockNumber_t luminosityBlock() const
CDFEventInfo * m_eventInfo
Definition: HcalTBSource.h:40
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 30 of file HcalTBSource.cc.

References i, m_sourceIdRemap, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Member Data Documentation

const int HcalTBSource::CHUNK_COUNT =64
staticprivate

Definition at line 36 of file HcalTBSource.h.

int HcalTBSource::m_chunkIds[CHUNK_COUNT]
private

Definition at line 38 of file HcalTBSource.h.

Referenced by openFile(), and produce().

CDFChunk* HcalTBSource::m_chunks[CHUNK_COUNT]
private

Definition at line 37 of file HcalTBSource.h.

Referenced by openFile(), and produce().

CDFEventInfo* HcalTBSource::m_eventInfo
private

Definition at line 40 of file HcalTBSource.h.

Referenced by openFile(), and setRunAndEventInfo().

int HcalTBSource::m_eventNumberOffset
private

Definition at line 41 of file HcalTBSource.h.

Referenced by setRunAndEventInfo().

TFile* HcalTBSource::m_file
private

Definition at line 32 of file HcalTBSource.h.

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

int HcalTBSource::m_fileCounter
private

Definition at line 33 of file HcalTBSource.h.

Referenced by setRunAndEventInfo().

int HcalTBSource::m_i
private

Definition at line 33 of file HcalTBSource.h.

Referenced by openFile(), and setRunAndEventInfo().

bool HcalTBSource::m_onlyRemapped
private

Definition at line 34 of file HcalTBSource.h.

Referenced by openFile().

bool HcalTBSource::m_quiet
private

Definition at line 34 of file HcalTBSource.h.

Referenced by openFile(), and produce().

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

Definition at line 39 of file HcalTBSource.h.

Referenced by openFile(), and unpackSetup().

TTree* HcalTBSource::m_tree
private

Definition at line 31 of file HcalTBSource.h.

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

int HcalTBSource::n_chunks
private

Definition at line 35 of file HcalTBSource.h.

Referenced by openFile(), and produce().