CMS 3D CMS Logo

CastorDigiToRaw.cc
Go to the documentation of this file.
8 #include <iostream>
9 
12 
13 using namespace std;
14 
16  castorTag_(conf.getParameter<edm::InputTag>("CASTOR")),
17  usingctdc_(conf.getParameter<bool>("CastorCtdc")),
18  tok_input_(consumes<CastorDigiCollection>(castorTag_)),
19  tok_put_(produces<FEDRawDataCollection>())
20 {
21 }
22 
23 // Functions that gets called by framework every event
25 {
26  CastorCollections colls;
27 
28  // Step A: Get Inputs
30  if (!castorTag_.label().empty()) {
31  e.getByToken(tok_input_,castor);
32  colls.castorCont=castor.product();
33  }
34  // get the mapping
36  es.get<CastorDbRecord>().get( pSetup );
37  const CastorElectronicsMap* readoutMap=pSetup->getCastorMapping();
38  // Step B: Create empty output
40 
41  constexpr int ifed_first=FEDNumbering::MINCASTORFEDID; //690
42  constexpr int ifed_last=FEDNumbering::MAXCASTORFEDID; //693
43 
44  int orbitN=e.id().event();
45  int bcnN=2000;
46 
47  // Step C: pack all requested FEDs
48  for (int ifed=ifed_first; ifed<=ifed_last; ++ifed) {
49  FEDRawData& fed = raw.FEDData(ifed);
50  try {
51  if ( usingctdc_ ) {
52  CastorCtdcPacker::pack(ifed,ifed-ifed_first, e.id().event(),
53  orbitN, bcnN, colls, *readoutMap, fed);
54  } else {
55  CastorPacker::pack(ifed,ifed-ifed_first, e.id().event(),
56  orbitN, bcnN, colls, *readoutMap, fed);
57  }
58  } catch (cms::Exception& e) {
59  edm::LogWarning("Unpacking error") << e.what();
60  } catch (...) {
61  edm::LogWarning("Unpacking exception");
62  }
63  }
64 
65  e.emplace(tok_put_,std::move(raw));
66 }
67 
68 
EventNumber_t event() const
Definition: EventID.h:41
const edm::EDGetTokenT< CastorDigiCollection > tok_input_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
char const * what() const override
Definition: Exception.cc:141
const CastorDigiCollection * castorCont
#define constexpr
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 CastorElectronicsMap * getCastorMapping() const
const edm::EDPutTokenT< FEDRawDataCollection > tok_put_
T const * product() const
Definition: Handle.h:81
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:453
static void pack(int fedid, int dccnumber, int nl1a, int orbitn, int bcn, const CastorCollections &inputs, const CastorElectronicsMap &emap, FEDRawData &output)
Definition: CastorPacker.cc:38
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:60
HLT enums.
T get() const
Definition: EventSetup.h:68
void produce(edm::StreamID, edm::Event &e, const edm::EventSetup &c) const override
def move(src, dest)
Definition: eostools.py:511