CMS 3D CMS Logo

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 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const edm::EDGetTokenT< CastorDigiCollection > tok_input_
void produce(edm::StreamID, edm::Event &e, const edm::EventSetup &c) const override
std::string const & label() const
Definition: InputTag.h:36
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 edm::ESGetToken< CastorDbService, CastorDbRecord > tok_pSetup_
const CastorElectronicsMap * getCastorMapping() const
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
const edm::EDPutTokenT< FEDRawDataCollection > tok_put_
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)
HLT enums.
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511