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 
27 {
28  FEDRawDataCollection_ = consumes<FEDRawDataCollection>(config_.getParameter<edm::InputTag>("inputLabel"));
29  CTPPSPixelDAQMapping_ = esConsumes<CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd>();
30 
31  produces<edm::DetSetVector<CTPPSPixelDigi>>();
32 
33  isRun3_ = config_.getParameter<bool>("isRun3");
34  includeErrors_ = config_.getParameter<bool>("includeErrors");
35  mappingLabel_ = config_.getParameter<std::string>("mappingLabel");
36 
37  if (includeErrors_) {
38  produces<edm::DetSetVector<CTPPSPixelDataError>>();
39  }
40 }
41 
43  edm::LogInfo("CTPPSPixelRawToDigi") << " CTPPSPixelRawToDigi destructor!";
44 }
45 
48  desc.add<bool>("isRun3", true);
49  desc.add<bool>("includeErrors", true);
50  desc.add<edm::InputTag>("inputLabel", edm::InputTag("rawDataCollector"));
51  desc.add<std::string>("mappingLabel", "RPix");
52  descriptions.add("ctppsPixelDigis", desc);
53 }
54 
57  ev.getByToken(FEDRawDataCollection_, buffers);
58 
60 
61  bool data_exist = false;
63  const FEDRawData& tempRawData = buffers->FEDData(fed);
64  if (tempRawData.size() != 0) {
65  data_exist = true;
66  break;
67  }
68  }
70  auto collection = std::make_unique<edm::DetSetVector<CTPPSPixelDigi>>();
71 
72  auto errorcollection = std::make_unique<edm::DetSetVector<CTPPSPixelDataError>>();
73 
74  if (data_exist) {
76 
77  fedIds_ = mapping->fedIds();
78 
80  formatter.setErrorStatus(includeErrors_);
81 
82  bool errorsInEvent = false;
84 
85  for (auto aFed = fedIds_.begin(); aFed != fedIds_.end(); ++aFed) {
86  int fedId = *aFed;
87 
88  edm::LogInfo("CTPPSPixelRawToDigi") << " PRODUCE DIGI FOR FED: " << dec << fedId << endl;
89 
92  const FEDRawData& fedRawData = buffers->FEDData(fedId);
93 
94  formatter.interpretRawData(isRun3_, errorsInEvent, fedId, fedRawData, *collection, errors);
95 
96  if (includeErrors_) {
97  for (auto const& is : errors) {
98  uint32_t errordetid = is.first;
100  if (errordetid == RPixErrorChecker::dummyDetId) {
101  nodeterrors.insert(nodeterrors.end(), errors[errordetid].begin(), errors[errordetid].end());
102  } else {
103  edm::DetSet<CTPPSPixelDataError>& errorDetSet = errorcollection->find_or_insert(errordetid);
104  errorDetSet.data.insert(errorDetSet.data.end(), is.second.begin(), is.second.end());
105  }
106  }
107  }
108  }
109 
110  if (includeErrors_) {
111  errorcollection->find_or_insert(RPixErrorChecker::dummyDetId).data = nodeterrors;
112  }
113  if (errorsInEvent)
114  LogDebug("CTPPSPixelRawToDigi") << "Error words were stored in this event";
115  }
117  ev.put(std::move(collection));
118 
119  if (includeErrors_) {
120  ev.put(std::move(errorcollection));
121  }
122 }
123 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ParameterSet config_
CTPPSPixelRawToDigi(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::vector< CTPPSPixelDataError > DetErrors
Log< level::Info, false > LogInfo
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static constexpr Word32 dummyDetId
collection_type data
Definition: DetSet.h:80
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)