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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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.

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 }

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

◆ ~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.

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 }

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

◆ produce()

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

Definition at line 67 of file CastorRawToDigi.cc.

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 }

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_, CastorRawCollections::tpCont, CastorRawCollections::ttp, CastorCtdcUnpacker::unpack(), CastorUnpacker::unpack(), ZdcUnpacker::unpack(), unpacker_, unpackTTP_, unpackZDC_, usingctdc_, hcalSimParameters_cfi::zdc, CastorRawCollections::zdcCont, and zdcunpacker_.

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().

FEDNumbering::MAXCASTORFEDID
Definition: FEDNumbering.h:46
CastorRawCollections
Definition: CastorRawCollections.h:16
mps_fire.i
i
Definition: mps_fire.py:428
CastorRawCollections::zdcCont
std::vector< ZDCDataFrame > * zdcCont
Definition: CastorRawCollections.h:21
CastorUnpacker::unpack
void unpack(const FEDRawData &raw, const CastorElectronicsMap &emap, CastorRawCollections &conts, HcalUnpackerReport &report, bool silent=false)
For histograms, no begin and end.
Definition: CastorUnpacker.cc:75
edm::SortedCollection
Definition: SortedCollection.h:49
CastorRawToDigi::filter_
CastorDataFrameFilter filter_
Definition: CastorRawToDigi.h:50
CastorRawToDigi::ctdcunpacker_
CastorCtdcUnpacker ctdcunpacker_
Definition: CastorRawToDigi.h:49
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
CastorRawToDigi::silent_
bool silent_
Definition: CastorRawToDigi.h:57
CastorCtdcUnpacker::unpack
void unpack(const FEDRawData &raw, const CastorElectronicsMap &emap, CastorRawCollections &conts, HcalUnpackerReport &report)
Definition: CastorCtdcUnpacker.cc:25
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
CastorRawToDigi::firstFED_
int firstFED_
Definition: CastorRawToDigi.h:52
FEDRawData
Definition: FEDRawData.h:19
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
CastorRawToDigi::complainEmptyData_
bool complainEmptyData_
Definition: CastorRawToDigi.h:53
edm::SortedCollection::swap
void swap(SortedCollection &other)
Definition: SortedCollection.h:193
CastorUnpacker::setExpectedOrbitMessageTime
void setExpectedOrbitMessageTime(int time)
Definition: CastorUnpacker.h:19
FEDNumbering::MINCASTORFEDID
Definition: FEDNumbering.h:45
CastorRawToDigi::fedUnpackList_
std::vector< int > fedUnpackList_
Definition: CastorRawToDigi.h:51
dumpMFGeometry_cfg.prod
prod
Definition: dumpMFGeometry_cfg.py:24
edm::ESHandle
Definition: DTSurvey.h:22
CastorRawToDigi::expectedOrbitMessageTime_
int expectedOrbitMessageTime_
Definition: CastorRawToDigi.h:59
CastorRawToDigi::tok_input_
edm::EDGetTokenT< FEDRawDataCollection > tok_input_
Definition: CastorRawToDigi.h:61
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
CastorRawToDigi::usingctdc_
bool usingctdc_
Definition: CastorRawToDigi.h:54
CastorRawToDigi::unpackZDC_
bool unpackZDC_
Definition: CastorRawToDigi.h:56
CastorRawToDigi::dataTag_
edm::InputTag dataTag_
Definition: CastorRawToDigi.h:46
CastorRawCollections::castorCont
std::vector< CastorDataFrame > * castorCont
Definition: CastorRawCollections.h:20
CastorRawToDigi::zdcunpacker_
ZdcUnpacker zdcunpacker_
Definition: CastorRawToDigi.h:48
CastorRawToDigi::usenominalOrbitMessageTime_
bool usenominalOrbitMessageTime_
Definition: CastorRawToDigi.h:58
CastorRawToDigi::unpackTTP_
bool unpackTTP_
Definition: CastorRawToDigi.h:55
ZdcUnpacker::unpack
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
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
edmIntegrityCheck.report
report
Definition: edmIntegrityCheck.py:349
hcalSimParameters_cfi.zdc
zdc
Definition: hcalSimParameters_cfi.py:97
eostools.move
def move(src, dest)
Definition: eostools.py:511
CastorDataFrameFilter::active
bool active() const
whether any filters are on
Definition: CastorDataFrameFilter.cc:51
CastorRawToDigi::unpacker_
CastorUnpacker unpacker_
Definition: CastorRawToDigi.h:47
CastorRawCollections::tpCont
std::vector< CastorTriggerPrimitiveDigi > * tpCont
Definition: CastorRawCollections.h:23
CastorElectronicsMap
Definition: CastorElectronicsMap.h:30
CastorDbService::getCastorMapping
const CastorElectronicsMap * getCastorMapping() const
Definition: CastorDbService.cc:183
cms::Exception
Definition: Exception.h:70
CastorRawCollections::ttp
std::vector< HcalTTPDigi > * ttp
Definition: CastorRawCollections.h:24
CastorRawToDigi::tok_pSetup_
edm::ESGetToken< CastorDbService, CastorDbRecord > tok_pSetup_
Definition: CastorRawToDigi.h:63
edm::InputTag
Definition: InputTag.h:15
CastorDataFrameFilter::filter
CastorDigiCollection filter(const CastorDigiCollection &incol, HcalUnpackerReport &r)
filter Castor data frames
Definition: CastorDataFrameFilter.cc:40
castorDigitizer_cfi.castor
castor
Definition: castorDigitizer_cfi.py:9
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37