CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CastorRawToDigi Class Reference

#include <CastorRawToDigi.h>

Inheritance diagram for CastorRawToDigi:
edm::stream::EDProducer<>

Public Member Functions

void beginRun (edm::Run const &, edm::EventSetup const &) override
 
 CastorRawToDigi (const edm::ParameterSet &ps)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ~CastorRawToDigi () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

bool complainEmptyData_
 
CastorCtdcUnpacker ctdcunpacker_
 
edm::InputTag dataTag_
 
int expectedOrbitMessageTime_
 
std::vector< int > fedUnpackList_
 
CastorDataFrameFilter filter_
 
int firstFED_
 
std::unique_ptr< HcalElectronicsMapmyEMap
 
bool silent_
 
edm::EDGetTokenT< FEDRawDataCollectiontok_input_
 
edm::ESGetToken< CastorDbService, CastorDbRecordtok_pSetup_
 
CastorUnpacker unpacker_
 
bool unpackTTP_
 
bool unpackZDC_
 
bool usenominalOrbitMessageTime_
 
bool usingctdc_
 
edm::ParameterSet zdcemap
 
ZdcUnpacker zdcunpacker_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

CastorRawToDigi is the EDProducer subclass which runs the Hcal Unpack algorithm.

Author
Alan Campbell
Version
1st Version April 18, 2008

Definition at line 38 of file CastorRawToDigi.h.

Constructor & Destructor Documentation

◆ CastorRawToDigi()

CastorRawToDigi::CastorRawToDigi ( const edm::ParameterSet ps)
explicit

Definition at line 16 of file CastorRawToDigi.cc.

References dataTag_, expectedOrbitMessageTime_, fedUnpackList_, mps_fire::i, FEDNumbering::MAXCASTORFEDID, FEDNumbering::MINCASTORFEDID, CastorUnpacker::setExpectedOrbitMessageTime(), contentValuesCheck::ss, tok_input_, tok_pSetup_, unpacker_, and unpackTTP_.

17  : dataTag_(conf.getParameter<edm::InputTag>("InputLabel")),
18  unpacker_(conf.getParameter<int>("CastorFirstFED"),
19  conf.getParameter<int>("firstSample"),
20  conf.getParameter<int>("lastSample")),
21  zdcunpacker_(conf.getParameter<int>("CastorFirstFED"),
22  conf.getParameter<int>("firstSample"),
23  conf.getParameter<int>("lastSample")),
24  ctdcunpacker_(conf.getParameter<int>("CastorFirstFED"),
25  conf.getParameter<int>("firstSample"),
26  conf.getParameter<int>("lastSample")),
27  filter_(
28  conf.getParameter<bool>("FilterDataQuality"), conf.getParameter<bool>("FilterDataQuality"), false, 0, 0, -1),
29  fedUnpackList_(conf.getUntrackedParameter<std::vector<int> >("FEDs", std::vector<int>())),
30  firstFED_(conf.getParameter<int>("CastorFirstFED")),
31  complainEmptyData_(conf.getUntrackedParameter<bool>("ComplainEmptyData", false)),
32  usingctdc_(conf.getParameter<bool>("CastorCtdc")),
33  unpackTTP_(conf.getParameter<bool>("UnpackTTP")),
34  unpackZDC_(conf.getParameter<bool>("UnpackZDC")),
35  silent_(conf.getUntrackedParameter<bool>("silent", true)),
36  usenominalOrbitMessageTime_(conf.getParameter<bool>("UseNominalOrbitMessageTime")),
37  expectedOrbitMessageTime_(conf.getParameter<int>("ExpectedOrbitMessageTime"))
38 
39 {
40  if (fedUnpackList_.empty()) {
42  fedUnpackList_.push_back(i);
43  }
44 
46  std::ostringstream ss;
47  for (unsigned int i = 0; i < fedUnpackList_.size(); i++)
48  ss << fedUnpackList_[i] << " ";
49  edm::LogInfo("CASTOR") << "CastorRawToDigi will unpack FEDs ( " << ss.str() << ")";
50 
51  // products produced...
52  produces<CastorDigiCollection>();
53  produces<ZDCDigiCollection>();
54  produces<CastorTrigPrimDigiCollection>();
55  produces<HcalUnpackerReport>();
56  if (unpackTTP_)
57  produces<HcalTTPDigiCollection>();
58 
59  tok_input_ = consumes<FEDRawDataCollection>(dataTag_);
60  tok_pSetup_ = esConsumes<CastorDbService, CastorDbRecord>();
61 }
CastorDataFrameFilter filter_
ZdcUnpacker zdcunpacker_
CastorUnpacker unpacker_
CastorCtdcUnpacker ctdcunpacker_
edm::ESGetToken< CastorDbService, CastorDbRecord > tok_pSetup_
std::vector< int > fedUnpackList_
edm::InputTag dataTag_
edm::EDGetTokenT< FEDRawDataCollection > tok_input_
void setExpectedOrbitMessageTime(int time)
Log< level::Info, false > LogInfo
bool usenominalOrbitMessageTime_

◆ ~CastorRawToDigi()

CastorRawToDigi::~CastorRawToDigi ( )
override

Definition at line 64 of file CastorRawToDigi.cc.

64 {}

Member Function Documentation

◆ beginRun()

void CastorRawToDigi::beginRun ( edm::Run const &  irun,
edm::EventSetup const &  es 
)
override

Definition at line 197 of file CastorRawToDigi.cc.

References expectedOrbitMessageTime_, edm::RunBase::run(), CastorUnpacker::setExpectedOrbitMessageTime(), unpacker_, and usenominalOrbitMessageTime_.

197  {
199  if (irun.run() > 132640) {
201  } else if (irun.run() > 132174) {
203  } else if (irun.run() > 124371) {
205  } else if (irun.run() > 123984) {
207  } else if (irun.run() > 123584) {
209  } else {
211  }
213  }
214 }
CastorUnpacker unpacker_
void setExpectedOrbitMessageTime(int time)
bool usenominalOrbitMessageTime_

◆ produce()

void CastorRawToDigi::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 67 of file CastorRawToDigi.cc.

References CastorDataFrameFilter::active(), castorDigitizer_cfi::castor, CastorRawCollections::castorCont, complainEmptyData_, ctdcunpacker_, MillePedeFileConverter_cfg::e, FEDRawDataCollection::FEDData(), fedUnpackList_, CastorDataFrameFilter::filter(), filter_, CastorDbService::getCastorMapping(), edm::EventSetup::getHandle(), mps_fire::i, eostools::move(), dumpMFGeometry_cfg::prod, edmIntegrityCheck::report, FEDRawData::size(), edm::SortedCollection< T, SORT >::swap(), tok_input_, tok_pSetup_, CastorCtdcUnpacker::unpack(), CastorUnpacker::unpack(), ZdcUnpacker::unpack(), unpacker_, unpackTTP_, unpackZDC_, usingctdc_, hcalSimParameters_cfi::zdc, and zdcunpacker_.

67  {
68  // Step A: Get Inputs
70  e.getByToken(tok_input_, rawraw);
71  // get the mapping
72  edm::ESHandle<CastorDbService> pSetup = es.getHandle(tok_pSetup_);
73  const CastorElectronicsMap* readoutMap = pSetup->getCastorMapping();
74 
75  // Step B: Create empty output : three vectors for three classes...
76  std::vector<CastorDataFrame> castor;
77  std::vector<ZDCDataFrame> zdc;
78  std::vector<HcalTTPDigi> ttp;
79  std::vector<CastorTriggerPrimitiveDigi> htp;
80 
81  auto report = std::make_unique<HcalUnpackerReport>();
82 
84  colls.castorCont = &castor;
85  colls.zdcCont = &zdc;
86  if (unpackTTP_)
87  colls.ttp = &ttp;
88  colls.tpCont = &htp;
89 
90  // Step C: unpack all requested FEDs
91  const FEDRawData& fed722 = rawraw->FEDData(722);
92  const int fed722size = fed722.size();
93  const FEDRawData& fed693 = rawraw->FEDData(693);
94  const int fed693size = fed693.size();
95  for (std::vector<int>::const_iterator i = fedUnpackList_.begin(); i != fedUnpackList_.end(); i++) {
96  const FEDRawData& fed = rawraw->FEDData(*i);
97  //std::cout<<"Fed number "<<*i<<"is being worked on"<<std::endl;
98  if (*i == 693 && fed693size == 0 && fed722size != 0)
99  continue;
100  if (*i == 722 && fed722size == 0 && fed693size != 0)
101  continue;
102 
103  if (*i != 693 && *i != 722) {
104  if (fed.size() == 0) {
105  if (complainEmptyData_) {
106  edm::LogWarning("EmptyData") << "No data for FED " << *i;
107  report->addError(*i);
108  }
109  } else if (fed.size() < 8 * 3) {
110  edm::LogWarning("EmptyData") << "Tiny data " << fed.size() << " for FED " << *i;
111  report->addError(*i);
112  } else {
113  try {
114  if (usingctdc_) {
115  ctdcunpacker_.unpack(fed, *readoutMap, colls, *report);
116  } else {
117  unpacker_.unpack(fed, *readoutMap, colls, *report);
118  }
119  report->addUnpacked(*i);
120  } catch (cms::Exception& e) {
121  edm::LogWarning("Unpacking error") << e.what();
122  report->addError(*i);
123  } catch (...) {
124  edm::LogWarning("Unpacking exception");
125  report->addError(*i);
126  }
127  }
128  }
129 
130  if (*i == 693 && unpackZDC_) {
131  if (fed.size() == 0) {
132  if (complainEmptyData_) {
133  edm::LogWarning("EmptyData") << "No data for FED " << *i;
134  report->addError(*i);
135  }
136  }
137  if (fed.size() != 0) {
138  zdcunpacker_.unpack(fed, *readoutMap, colls, *report);
139  report->addUnpacked(*i);
140  }
141  }
142 
143  if (*i == 722 && unpackZDC_) {
144  if (fed.size() == 0) {
145  if (complainEmptyData_) {
146  edm::LogWarning("EmptyData") << "No data for FED " << *i;
147  report->addError(*i);
148  }
149  }
150  if (fed.size() != 0) {
151  zdcunpacker_.unpack(fed, *readoutMap, colls, *report);
152  report->addUnpacked(*i);
153  }
154  }
155 
156  } //end of loop over feds
157 
158  // Step B: encapsulate vectors in actual collections
159  auto castor_prod = std::make_unique<CastorDigiCollection>();
160  auto htp_prod = std::make_unique<CastorTrigPrimDigiCollection>();
161 
162  castor_prod->swap_contents(castor);
163  htp_prod->swap_contents(htp);
164 
165  // Step C2: filter FEDs, if required
166  if (filter_.active()) {
167  CastorDigiCollection filtered_castor = filter_.filter(*castor_prod, *report);
168 
169  castor_prod->swap(filtered_castor);
170  }
171 
172  // Step D: Put outputs into event
173  // just until the sorting is proven
174  castor_prod->sort();
175  htp_prod->sort();
176 
177  if (unpackZDC_) {
178  auto zdc_prod = std::make_unique<ZDCDigiCollection>();
179  zdc_prod->swap_contents(zdc);
180 
181  zdc_prod->sort();
182  e.put(std::move(zdc_prod));
183  }
184 
185  e.put(std::move(castor_prod));
186  e.put(std::move(htp_prod));
187 
188  if (unpackTTP_) {
189  auto prod = std::make_unique<HcalTTPDigiCollection>();
190  prod->swap_contents(ttp);
191 
192  prod->sort();
193  e.put(std::move(prod));
194  }
195  e.put(std::move(report));
196 }
CastorDataFrameFilter filter_
ZdcUnpacker zdcunpacker_
CastorDigiCollection filter(const CastorDigiCollection &incol, HcalUnpackerReport &r)
filter Castor data frames
CastorUnpacker unpacker_
void swap(SortedCollection &other)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
CastorCtdcUnpacker ctdcunpacker_
edm::ESGetToken< CastorDbService, CastorDbRecord > tok_pSetup_
std::vector< int > fedUnpackList_
void unpack(const FEDRawData &raw, const CastorElectronicsMap &emap, CastorRawCollections &conts, HcalUnpackerReport &report, bool silent=false)
For histograms, no begin and end.
edm::EDGetTokenT< FEDRawDataCollection > tok_input_
bool active() const
whether any filters are on
void unpack(const FEDRawData &raw, const CastorElectronicsMap &emap, CastorRawCollections &conts, HcalUnpackerReport &report)
std::vector< CastorDataFrame > * castorCont
const CastorElectronicsMap * getCastorMapping() const
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void unpack(const FEDRawData &raw, const CastorElectronicsMap &emap, CastorRawCollections &conts, HcalUnpackerReport &report, bool silent=false)
For histograms, no begin and end.
Definition: ZdcUnpacker.cc:108
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ complainEmptyData_

bool CastorRawToDigi::complainEmptyData_
private

Definition at line 53 of file CastorRawToDigi.h.

Referenced by produce().

◆ ctdcunpacker_

CastorCtdcUnpacker CastorRawToDigi::ctdcunpacker_
private

Definition at line 49 of file CastorRawToDigi.h.

Referenced by produce().

◆ dataTag_

edm::InputTag CastorRawToDigi::dataTag_
private

Definition at line 46 of file CastorRawToDigi.h.

Referenced by CastorRawToDigi().

◆ expectedOrbitMessageTime_

int CastorRawToDigi::expectedOrbitMessageTime_
private

Definition at line 59 of file CastorRawToDigi.h.

Referenced by beginRun(), and CastorRawToDigi().

◆ fedUnpackList_

std::vector<int> CastorRawToDigi::fedUnpackList_
private

Definition at line 51 of file CastorRawToDigi.h.

Referenced by CastorRawToDigi(), and produce().

◆ filter_

CastorDataFrameFilter CastorRawToDigi::filter_
private

Definition at line 50 of file CastorRawToDigi.h.

Referenced by produce().

◆ firstFED_

int CastorRawToDigi::firstFED_
private

Definition at line 52 of file CastorRawToDigi.h.

◆ myEMap

std::unique_ptr<HcalElectronicsMap> CastorRawToDigi::myEMap
private

Definition at line 60 of file CastorRawToDigi.h.

◆ silent_

bool CastorRawToDigi::silent_
private

Definition at line 57 of file CastorRawToDigi.h.

◆ tok_input_

edm::EDGetTokenT<FEDRawDataCollection> CastorRawToDigi::tok_input_
private

Definition at line 61 of file CastorRawToDigi.h.

Referenced by CastorRawToDigi(), and produce().

◆ tok_pSetup_

edm::ESGetToken<CastorDbService, CastorDbRecord> CastorRawToDigi::tok_pSetup_
private

Definition at line 63 of file CastorRawToDigi.h.

Referenced by CastorRawToDigi(), and produce().

◆ unpacker_

CastorUnpacker CastorRawToDigi::unpacker_
private

Definition at line 47 of file CastorRawToDigi.h.

Referenced by beginRun(), CastorRawToDigi(), and produce().

◆ unpackTTP_

bool CastorRawToDigi::unpackTTP_
private

Definition at line 55 of file CastorRawToDigi.h.

Referenced by CastorRawToDigi(), and produce().

◆ unpackZDC_

bool CastorRawToDigi::unpackZDC_
private

Definition at line 56 of file CastorRawToDigi.h.

Referenced by produce().

◆ usenominalOrbitMessageTime_

bool CastorRawToDigi::usenominalOrbitMessageTime_
private

Definition at line 58 of file CastorRawToDigi.h.

Referenced by beginRun().

◆ usingctdc_

bool CastorRawToDigi::usingctdc_
private

Definition at line 54 of file CastorRawToDigi.h.

Referenced by produce().

◆ zdcemap

edm::ParameterSet CastorRawToDigi::zdcemap
private

Definition at line 62 of file CastorRawToDigi.h.

◆ zdcunpacker_

ZdcUnpacker CastorRawToDigi::zdcunpacker_
private

Definition at line 48 of file CastorRawToDigi.h.

Referenced by produce().