CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  std::auto_ptr<FEDRawDataCollection> raw=std::auto_ptr<FEDRawDataCollection>(new 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(raw);
69 }
70 
71 
virtual char const * what() const
Definition: Exception.cc:141
EventNumber_t event() const
Definition: EventID.h:41
virtual ~CastorDigiToRaw()
CastorCtdcPacker ctdcpacker_
edm::InputTag castorTag_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
const CastorDigiCollection * castorCont
void pack(int fedid, int dccnumber, int nl1a, int orbitn, int bcn, const CastorCollections &inputs, const CastorElectronicsMap &emap, FEDRawData &output)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
tuple conf
Definition: dbtoconf.py:185
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:56
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:43
edm::EventID id() const
Definition: EventBase.h:60
virtual void produce(edm::Event &e, const edm::EventSetup &c)
CastorPacker packer_