CMS 3D CMS Logo

ESRawToDigi.cc
Go to the documentation of this file.
2 
5 
12 
13 #include <iostream>
14 
16 {
17 
19  ESdigiCollection_ = ps.getParameter<std::string>("ESdigiCollection");
20  regional_ = ps.getUntrackedParameter<bool>("DoRegional",false);
21  edm::InputTag fedsListLabel
22  = ps.getUntrackedParameter<edm::InputTag>("ESFedsListLabel", edm::InputTag(":esfedslist"));
23  debug_ = ps.getUntrackedParameter<bool>("debugMode", false);
24 
25  ESUnpacker_ = new ESUnpacker(ps);
26 
27  produces<ESRawDataCollection>();
28  produces<ESLocalRawDataCollection>();
29  produces<ESDigiCollection>();
30  dataToken_=consumes<FEDRawDataCollection>(sourceTag);
31  if (regional_){
32  fedsToken_=consumes<ESListOfFEDS>(fedsListLabel);
33  }
34 }
35 
37 
38  delete ESUnpacker_;
39 
40 }
41 
44  desc.add<edm::InputTag>("sourceTag",edm::InputTag("rawDataCollector"));
45  desc.addUntracked<bool>("debugMode",false);
46  desc.add<std::string>("InstanceES","");
47  desc.add<edm::FileInPath>("LookupTable",edm::FileInPath("EventFilter/ESDigiToRaw/data/ES_lookup_table.dat"));
48  desc.add<std::string>("ESdigiCollection","");
49  descriptions.add("esRawToDigi",desc);
50 }
51 
53 
54  // Input
56  e.getByToken(dataToken_, rawdata);
57  if (!rawdata.isValid()) {
58  LogDebug("") << "ESRawToDigi : Error! can't get rawdata!" << std::endl;
59  }
60 
61  std::vector<int> esFeds_to_unpack;
62  if (regional_) {
64  e.getByToken(fedsToken_, fedslist);
65  esFeds_to_unpack = fedslist->GetList();
66  }
67 
68  // Output
69  auto productDCC = std::make_unique<ESRawDataCollection>();
70  auto productKCHIP = std::make_unique<ESLocalRawDataCollection>();
71  auto productDigis = std::make_unique<ESDigiCollection>();
72 
73  ESDigiCollection digis;
74 
75  if (regional_) {
76  for (unsigned int i=0; i<esFeds_to_unpack.size(); ++i) {
77 
78  const FEDRawData& fedRawData = rawdata->FEDData(esFeds_to_unpack[i]);
79  ESUnpacker_->interpretRawData(esFeds_to_unpack[i], fedRawData, *productDCC, *productKCHIP, *productDigis);
80 
81  if (debug_) std::cout<<"FED : "<<esFeds_to_unpack[i]<<" Data size : "<<fedRawData.size()<<" (Bytes)"<<std::endl;
82  }
83  } else {
85 
86  const FEDRawData& fedRawData = rawdata->FEDData(fedId);
87  ESUnpacker_->interpretRawData(fedId, fedRawData, *productDCC, *productKCHIP, *productDigis);
88 
89  if (debug_) std::cout<<"FED : "<<fedId<<" Data size : "<<fedRawData.size()<<" (Bytes)"<<std::endl;
90  }
91  }
92 
93  e.put(std::move(productDCC));
94  e.put(std::move(productKCHIP));
95  e.put(std::move(productDigis), ESdigiCollection_);
96 }
97 
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< FEDRawDataCollection > dataToken_
Definition: ESRawToDigi.h:30
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
~ESRawToDigi() override
Definition: ESRawToDigi.cc:36
ESUnpacker * ESUnpacker_
Definition: ESRawToDigi.h:38
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void produce(edm::Event &e, const edm::EventSetup &es) override
Definition: ESRawToDigi.cc:52
ESRawToDigi(const edm::ParameterSet &ps)
Definition: ESRawToDigi.cc:15
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::vector< int > GetList() const
Definition: ESListOfFEDS.h:11
std::string ESdigiCollection_
Definition: ESRawToDigi.h:29
bool regional_
Definition: ESRawToDigi.h:34
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
void interpretRawData(int fedId, const FEDRawData &rawData, ESRawDataCollection &dccs, ESLocalRawDataCollection &kchips, ESDigiCollection &digis)
Definition: ESUnpacker.cc:53
edm::EDGetTokenT< ESListOfFEDS > fedsToken_
Definition: ESRawToDigi.h:31
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: ESRawToDigi.cc:42
def move(src, dest)
Definition: eostools.py:510