CMS 3D CMS Logo

CTPPSPixelRawToDigi.cc
Go to the documentation of this file.
1 /*
2  * adapting to CTPPS pixel detector March 2017 - F.Ferro
3  */
4 
6 
10 
12 
17 
19 
21 
22 using namespace std;
23 
25  : config_(conf),
26  eSummary_("CTPPSPixelDataFormatter", "[ctppsPixelRawToDigi]", edm::isDebugEnabled())
27 
28 {
29  FEDRawDataCollection_ = consumes<FEDRawDataCollection>(config_.getParameter<edm::InputTag>("inputLabel"));
30  CTPPSPixelDAQMapping_ = esConsumes<CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd>();
31 
32  produces<edm::DetSetVector<CTPPSPixelDigi>>();
33 
34  isRun3_ = config_.getParameter<bool>("isRun3");
35  includeErrors_ = config_.getParameter<bool>("includeErrors");
36  mappingLabel_ = config_.getParameter<std::string>("mappingLabel");
37 
38  if (includeErrors_) {
39  produces<edm::DetSetVector<CTPPSPixelDataError>>();
40  }
41 }
42 
44  edm::LogInfo("CTPPSPixelRawToDigi") << " CTPPSPixelRawToDigi destructor!";
45 }
46 
49  desc.add<bool>("isRun3", true);
50  desc.add<bool>("includeErrors", true);
51  desc.add<edm::InputTag>("inputLabel", edm::InputTag("rawDataCollector"));
52  desc.add<std::string>("mappingLabel", "RPix");
53  descriptions.add("ctppsPixelDigis", desc);
54 }
55 
58  ev.getByToken(FEDRawDataCollection_, buffers);
59 
61 
62  bool data_exist = false;
64  const FEDRawData& tempRawData = buffers->FEDData(fed);
65  if (tempRawData.size() != 0) {
66  data_exist = true;
67  break;
68  }
69  }
71  auto collection = std::make_unique<edm::DetSetVector<CTPPSPixelDigi>>();
72 
73  auto errorcollection = std::make_unique<edm::DetSetVector<CTPPSPixelDataError>>();
74 
75  if (data_exist) {
77 
78  fedIds_ = mapping->fedIds();
79 
81  formatter.setErrorStatus(includeErrors_);
82 
83  bool errorsInEvent = false;
85 
86  for (auto aFed = fedIds_.begin(); aFed != fedIds_.end(); ++aFed) {
87  int fedId = *aFed;
88 
89  edm::LogInfo("CTPPSPixelRawToDigi") << " PRODUCE DIGI FOR FED: " << dec << fedId << endl;
90 
93  const FEDRawData& fedRawData = buffers->FEDData(fedId);
94 
95  formatter.interpretRawData(isRun3_, errorsInEvent, fedId, fedRawData, *collection, errors);
96 
97  if (includeErrors_) {
98  for (auto const& is : errors) {
99  uint32_t errordetid = is.first;
101  if (errordetid == RPixErrorChecker::dummyDetId) {
102  nodeterrors.insert(nodeterrors.end(), errors[errordetid].begin(), errors[errordetid].end());
103  } else {
104  edm::DetSet<CTPPSPixelDataError>& errorDetSet = errorcollection->find_or_insert(errordetid);
105  errorDetSet.data.insert(errorDetSet.data.end(), is.second.begin(), is.second.end());
106  }
107  }
108  }
109  }
110 
111  if (includeErrors_) {
112  errorcollection->find_or_insert(RPixErrorChecker::dummyDetId).data = nodeterrors;
113  }
114  if (errorsInEvent)
115  LogDebug("CTPPSPixelRawToDigi") << "Error words were stored in this event";
116  }
118  ev.put(std::move(collection));
119 
120  if (includeErrors_) {
121  ev.put(std::move(errorcollection));
122  }
123 }
124 
126 
bool isDebugEnabled()
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ParameterSet config_
CTPPSPixelRawToDigi(const edm::ParameterSet &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::map< uint32_t, DetErrors > Errors
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
std::set< unsigned int > fedIds_
edm::ESGetToken< CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd > CTPPSPixelDAQMapping_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::vector< CTPPSPixelDataError > DetErrors
Log< level::Info, false > LogInfo
CTPPSPixelErrorSummary eSummary_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static constexpr Word32 dummyDetId
collection_type data
Definition: DetSet.h:80
HLT enums.
void produce(edm::Event &, const edm::EventSetup &) override
get data, convert to digis attach againe to Event
Definition: errors.py:1
edm::EDGetTokenT< FEDRawDataCollection > FEDRawDataCollection_
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)