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 
30  produces<edm::DetSetVector<CTPPSPixelDigi>>();
31 
32  includeErrors_ = config_.getParameter<bool>("includeErrors");
33  mappingLabel_ = config_.getParameter<std::string>("mappingLabel");
34 
35  if (includeErrors_) {
36  produces<edm::DetSetVector<CTPPSPixelDataError>>();
37  }
38 }
39 
41  edm::LogInfo("CTPPSPixelRawToDigi") << " CTPPSPixelRawToDigi destructor!";
42 }
43 
46  desc.add<bool>("includeErrors", true);
47  desc.add<edm::InputTag>("inputLabel", edm::InputTag("rawDataCollector"));
48  desc.add<std::string>("mappingLabel", "RPix");
49  descriptions.add("ctppsPixelDigis", desc);
50 }
51 
54  ev.getByToken(FEDRawDataCollection_, buffers);
55 
57 
58  bool data_exist = false;
60  const FEDRawData& tempRawData = buffers->FEDData(fed);
61  if (tempRawData.size() != 0) {
62  data_exist = true;
63  break;
64  }
65  }
67  auto collection = std::make_unique<edm::DetSetVector<CTPPSPixelDigi>>();
68 
69  auto errorcollection = std::make_unique<edm::DetSetVector<CTPPSPixelDataError>>();
70 
71  if (data_exist) {
73 
74  fedIds_ = mapping->fedIds();
75 
76  CTPPSPixelDataFormatter formatter(mapping->ROCMapping);
77  formatter.setErrorStatus(includeErrors_);
78 
79  bool errorsInEvent = false;
81 
82  for (auto aFed = fedIds_.begin(); aFed != fedIds_.end(); ++aFed) {
83  int fedId = *aFed;
84 
85  edm::LogInfo("CTPPSPixelRawToDigi") << " PRODUCE DIGI FOR FED: " << dec << fedId << endl;
86 
89  const FEDRawData& fedRawData = buffers->FEDData(fedId);
90 
91  formatter.interpretRawData(errorsInEvent, fedId, fedRawData, *collection, errors);
92 
93  if (includeErrors_) {
94  for (auto const& is : errors) {
95  uint32_t errordetid = is.first;
97  if (errordetid == RPixErrorChecker::dummyDetId) {
98  nodeterrors.insert(nodeterrors.end(), errors[errordetid].begin(), errors[errordetid].end());
99  } else {
100  edm::DetSet<CTPPSPixelDataError>& errorDetSet = errorcollection->find_or_insert(errordetid);
101  errorDetSet.data.insert(errorDetSet.data.end(), is.second.begin(), is.second.end());
102  }
103  }
104  }
105  }
106 
107  if (includeErrors_) {
108  errorcollection->find_or_insert(RPixErrorChecker::dummyDetId).data = nodeterrors;
109  }
110  if (errorsInEvent)
111  LogDebug("CTPPSPixelRawToDigi") << "Error words were stored in this event";
112  }
114  ev.put(std::move(collection));
115 
116  if (includeErrors_) {
117  ev.put(std::move(errorcollection));
118  }
119 }
120 
CTPPSPixelRawToDigi::FEDRawDataCollection_
edm::EDGetTokenT< FEDRawDataCollection > FEDRawDataCollection_
Definition: CTPPSPixelRawToDigi.h:35
FEDNumbering.h
CTPPSPixelRawToDigi::config_
edm::ParameterSet config_
Definition: CTPPSPixelRawToDigi.h:33
Handle.h
CTPPSPixelRawToDigi::mappingLabel_
std::string mappingLabel_
Definition: CTPPSPixelRawToDigi.h:41
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
MessageLogger.h
RPixErrorChecker::dummyDetId
static constexpr Word32 dummyDetId
Definition: RPixErrorChecker.h:39
ESHandle.h
edm::DetSet
Definition: DetSet.h:23
CTPPSPixelDataFormatter::setErrorStatus
void setErrorStatus(bool theErrorStatus)
Definition: CTPPSPixelDataFormatter.cc:58
edm::LogInfo
Definition: MessageLogger.h:254
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
MessageLogger_cfi.errors
errors
Definition: MessageLogger_cfi.py:18
CTPPSPixelDataFormatter.h
FEDRawData.h
edm::Handle
Definition: AssociativeIterator.h:50
FEDRawData
Definition: FEDRawData.h:19
CTPPSPixelDataFormatter::Errors
std::map< uint32_t, DetErrors > Errors
Definition: CTPPSPixelDataFormatter.h:61
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
l1t_dqm_sourceclient-live_cfg.fedRawData
fedRawData
Definition: l1t_dqm_sourceclient-live_cfg.py:182
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
errors
Definition: errors.py:1
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::ESHandle
Definition: DTSurvey.h:22
CTPPSPixelRawToDigi::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: CTPPSPixelRawToDigi.cc:44
CTPPSPixelRawToDigi::CTPPSPixelRawToDigi
CTPPSPixelRawToDigi(const edm::ParameterSet &)
Definition: CTPPSPixelRawToDigi.cc:24
CTPPSPixelDAQMappingRcd
Definition: CTPPSPixelDAQMappingRcd.h:23
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CTPPSPixelRawToDigi::fedIds_
std::set< unsigned int > fedIds_
Definition: CTPPSPixelRawToDigi.h:37
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
CTPPSPixelRawToDigi::includeErrors_
bool includeErrors_
Definition: CTPPSPixelRawToDigi.h:43
universalConfigTemplate.collection
collection
Definition: universalConfigTemplate.py:81
FEDRawDataCollection.h
CTPPSPixelRawToDigi.h
edm::EventSetup
Definition: EventSetup.h:57
DetSetVector.h
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:82
get
#define get
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
CTPPSPixelDigi.h
FEDNumbering::MAXCTPPSPixelsFEDID
Definition: FEDNumbering.h:122
CTPPSPixelDataFormatter
Definition: CTPPSPixelDataFormatter.h:53
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
CTPPSPixelRawToDigi::produce
void produce(edm::Event &, const edm::EventSetup &) override
get data, convert to digis attach againe to Event
Definition: CTPPSPixelRawToDigi.cc:52
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
CTPPSPixelRawToDigi::~CTPPSPixelRawToDigi
~CTPPSPixelRawToDigi() override
Definition: CTPPSPixelRawToDigi.cc:40
edm::DetSet::data
collection_type data
Definition: DetSet.h:80
ConsumesCollector.h
CTPPSPixelDataFormatter::DetErrors
std::vector< CTPPSPixelDataError > DetErrors
Definition: CTPPSPixelDataFormatter.h:60
edm::Event
Definition: Event.h:73
FEDNumbering::MINCTPPSPixelsFEDID
Definition: FEDNumbering.h:121
CTPPSPixelDataFormatter::interpretRawData
void interpretRawData(bool &errorsInEvent, int fedId, const FEDRawData &data, Collection &digis, Errors &errors)
Definition: CTPPSPixelDataFormatter.cc:63
taus_updatedMVAIds_cff.mapping
mapping
Definition: taus_updatedMVAIds_cff.py:28
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
edm::InputTag
Definition: InputTag.h:15
CTPPSPixelRawToDigi
Definition: CTPPSPixelRawToDigi.h:21