CMS 3D CMS Logo

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