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 
19 {
20  tok_input_ = consumes<CastorDigiCollection>(castorTag_);
21  produces<FEDRawDataCollection>();
22 }
23 
24 // Virtual destructor needed.
26 
27 // Functions that gets called by framework every event
29 {
30  CastorCollections colls;
31 
32  // Step A: Get Inputs
34  if (!castorTag_.label().empty()) {
35  e.getByToken(tok_input_,castor);
36  colls.castorCont=castor.product();
37  }
38  // get the mapping
40  es.get<CastorDbRecord>().get( pSetup );
41  const CastorElectronicsMap* readoutMap=pSetup->getCastorMapping();
42  // Step B: Create empty output
43  auto raw = std::make_unique<FEDRawDataCollection>();
44 
45  const int ifed_first=FEDNumbering::MINCASTORFEDID; //690
46  const int ifed_last=FEDNumbering::MAXCASTORFEDID; //693
47 
48  int orbitN=e.id().event();
49  int bcnN=2000;
50 
51  // Step C: pack all requested FEDs
52  for (int ifed=ifed_first; ifed<=ifed_last; ++ifed) {
53  FEDRawData& fed = raw->FEDData(ifed);
54  try {
55  if ( usingctdc_ ) {
56  ctdcpacker_.pack(ifed,ifed-ifed_first, e.id().event(),
57  orbitN, bcnN, colls, *readoutMap, fed);
58  } else {
59  packer_.pack(ifed,ifed-ifed_first, e.id().event(),
60  orbitN, bcnN, colls, *readoutMap, fed); }
61  } catch (cms::Exception& e) {
62  edm::LogWarning("Unpacking error") << e.what();
63  } catch (...) {
64  edm::LogWarning("Unpacking exception");
65  }
66  }
67 
68  e.put(std::move(raw));
69 }
70 
71 
EventNumber_t event() const
Definition: EventID.h:41
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
virtual ~CastorDigiToRaw()
CastorCtdcPacker ctdcpacker_
edm::InputTag castorTag_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
char const * what() const override
Definition: Exception.cc:141
const CastorDigiCollection * castorCont
void pack(int fedid, int dccnumber, int nl1a, int orbitn, int bcn, const CastorCollections &inputs, const CastorElectronicsMap &emap, FEDRawData &output)
const CastorElectronicsMap * getCastorMapping() const
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:55
void pack(int fedid, int dccnumber, int nl1a, int orbitn, int bcn, const CastorCollections &inputs, const CastorElectronicsMap &emap, FEDRawData &output)
Definition: CastorPacker.cc:36
edm::EDGetTokenT< CastorDigiCollection > tok_input_
CastorDigiToRaw(const edm::ParameterSet &ps)
std::string const & label() const
Definition: InputTag.h:36
edm::EventID id() const
Definition: EventBase.h:60
HLT enums.
virtual void produce(edm::Event &e, const edm::EventSetup &c)
CastorPacker packer_
def move(src, dest)
Definition: eostools.py:510