CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CastorDigiToRaw.cc
Go to the documentation of this file.
6 #include <iostream>
7 
10 
11 using namespace std;
12 
14  : castorTag_(conf.getParameter<edm::InputTag>("CASTOR")),
15  usingctdc_(conf.getParameter<bool>("CastorCtdc")),
16  tok_input_(consumes<CastorDigiCollection>(castorTag_)),
17  tok_put_(produces<FEDRawDataCollection>()),
18  tok_pSetup_(esConsumes<CastorDbService, CastorDbRecord>()) {}
19 
20 // Functions that gets called by framework every event
22  CastorCollections colls;
23 
24  // Step A: Get Inputs
26  if (!castorTag_.label().empty()) {
27  e.getByToken(tok_input_, castor);
28  colls.castorCont = castor.product();
29  }
30  // get the mapping
32  const CastorElectronicsMap* readoutMap = pSetup->getCastorMapping();
33  // Step B: Create empty output
35 
36  constexpr int ifed_first = FEDNumbering::MINCASTORFEDID; //690
37  constexpr int ifed_last = FEDNumbering::MAXCASTORFEDID; //693
38 
39  int orbitN = e.id().event();
40  int bcnN = 2000;
41 
42  // Step C: pack all requested FEDs
43  for (int ifed = ifed_first; ifed <= ifed_last; ++ifed) {
44  FEDRawData& fed = raw.FEDData(ifed);
45  try {
46  if (usingctdc_) {
47  CastorCtdcPacker::pack(ifed, ifed - ifed_first, e.id().event(), orbitN, bcnN, colls, *readoutMap, fed);
48  } else {
49  CastorPacker::pack(ifed, ifed - ifed_first, e.id().event(), orbitN, bcnN, colls, *readoutMap, fed);
50  }
51  } catch (cms::Exception& e) {
52  edm::LogWarning("Unpacking error") << e.what();
53  } catch (...) {
54  edm::LogWarning("Unpacking exception");
55  }
56  }
57 
58  e.emplace(tok_put_, std::move(raw));
59 }
EventNumber_t event() const
Definition: EventID.h:40
const edm::EDGetTokenT< CastorDigiCollection > tok_input_
void produce(edm::StreamID, edm::Event &e, const edm::EventSetup &c) const override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
const CastorDigiCollection * castorCont
static void pack(int fedid, int dccnumber, int nl1a, int orbitn, int bcn, const CastorCollections &inputs, const CastorElectronicsMap &emap, FEDRawData &output)
const bool usingctdc_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
const edm::ESGetToken< CastorDbService, CastorDbRecord > tok_pSetup_
def move
Definition: eostools.py:511
char const * what() const noexceptoverride
Definition: Exception.cc:103
const edm::EDPutTokenT< FEDRawDataCollection > tok_put_
T const * product() const
Definition: Handle.h:70
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:433
static void pack(int fedid, int dccnumber, int nl1a, int orbitn, int bcn, const CastorCollections &inputs, const CastorElectronicsMap &emap, FEDRawData &output)
Definition: CastorPacker.cc:41
const edm::InputTag castorTag_
CastorDigiToRaw(const edm::ParameterSet &ps)
std::string const & label() const
Definition: InputTag.h:36
edm::EventID id() const
Definition: EventBase.h:59
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
Log< level::Warning, false > LogWarning
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283