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 hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () 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_
 
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 34 of file CastorRawToDigi.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file CastorRawToDigi.cc.

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

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

Definition at line 65 of file CastorRawToDigi.cc.

65 {}

Member Function Documentation

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

Definition at line 199 of file CastorRawToDigi.cc.

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

199  {
201  if (irun.run() > 132640) {
203  } else if (irun.run() > 132174) {
205  } else if (irun.run() > 124371) {
207  } else if (irun.run() > 123984) {
209  } else if (irun.run() > 123584) {
211  } else {
213  }
215  }
216 }
CastorUnpacker unpacker_
void setExpectedOrbitMessageTime(int time)
bool usenominalOrbitMessageTime_
void CastorRawToDigi::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 68 of file CastorRawToDigi.cc.

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

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

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

Member Data Documentation

bool CastorRawToDigi::complainEmptyData_
private

Definition at line 49 of file CastorRawToDigi.h.

Referenced by produce().

CastorCtdcUnpacker CastorRawToDigi::ctdcunpacker_
private

Definition at line 45 of file CastorRawToDigi.h.

Referenced by produce().

edm::InputTag CastorRawToDigi::dataTag_
private

Definition at line 42 of file CastorRawToDigi.h.

Referenced by CastorRawToDigi().

int CastorRawToDigi::expectedOrbitMessageTime_
private

Definition at line 55 of file CastorRawToDigi.h.

Referenced by beginRun(), and CastorRawToDigi().

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

Definition at line 47 of file CastorRawToDigi.h.

Referenced by CastorRawToDigi(), and produce().

CastorDataFrameFilter CastorRawToDigi::filter_
private

Definition at line 46 of file CastorRawToDigi.h.

Referenced by produce().

int CastorRawToDigi::firstFED_
private

Definition at line 48 of file CastorRawToDigi.h.

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

Definition at line 56 of file CastorRawToDigi.h.

bool CastorRawToDigi::silent_
private

Definition at line 53 of file CastorRawToDigi.h.

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

Definition at line 57 of file CastorRawToDigi.h.

Referenced by CastorRawToDigi(), and produce().

CastorUnpacker CastorRawToDigi::unpacker_
private

Definition at line 43 of file CastorRawToDigi.h.

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

bool CastorRawToDigi::unpackTTP_
private

Definition at line 51 of file CastorRawToDigi.h.

Referenced by CastorRawToDigi(), and produce().

bool CastorRawToDigi::unpackZDC_
private

Definition at line 52 of file CastorRawToDigi.h.

Referenced by produce().

bool CastorRawToDigi::usenominalOrbitMessageTime_
private

Definition at line 54 of file CastorRawToDigi.h.

Referenced by beginRun().

bool CastorRawToDigi::usingctdc_
private

Definition at line 50 of file CastorRawToDigi.h.

Referenced by produce().

edm::ParameterSet CastorRawToDigi::zdcemap
private

Definition at line 58 of file CastorRawToDigi.h.

ZdcUnpacker CastorRawToDigi::zdcunpacker_
private

Definition at line 44 of file CastorRawToDigi.h.

Referenced by produce().