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 
5 
7 
11 
13 
18 
20 
22 
23 using namespace std;
24 
25 
27  : config_(conf)
28 
29 {
30 
31  FEDRawDataCollection_ = consumes <FEDRawDataCollection> (config_.getParameter<edm::InputTag>("inputLabel"));
32 
33 
34  produces< edm::DetSetVector<CTPPSPixelDigi> >();
35 
36  includeErrors_ = config_.getParameter<bool> ("includeErrors");
37  mappingLabel_ = config_.getParameter<std::string> ("mappingLabel");
38 
39  if(includeErrors_){
40  produces< edm::DetSetVector<CTPPSPixelDataError> >();
41  }
42 }
43 
44 
46  edm::LogInfo("CTPPSPixelRawToDigi") << " CTPPSPixelRawToDigi destructor!";
47 
48 }
49 
52  desc.add<bool>("includeErrors",true);
53  desc.add<edm::InputTag>("inputLabel",edm::InputTag("rawDataCollector"));
54  desc.add<std::string>("mappingLabel","RPix");
55  descriptions.add("ctppsPixelDigis", desc);
56 }
57 
58 
60  const edm::EventSetup& es)
61 {
62 
64  ev.getByToken(FEDRawDataCollection_, buffers);
65 
67 
68  bool data_exist=false;
70  const FEDRawData& tempRawData = buffers->FEDData( fed );
71  if(tempRawData.size()!=0){
72  data_exist=true;
73  break;
74  }
75  }
77  auto collection = std::make_unique<edm::DetSetVector<CTPPSPixelDigi>>();
78 
79  auto errorcollection = std::make_unique<edm::DetSetVector<CTPPSPixelDataError>>();
80 
81  if(data_exist){
82  es.get<CTPPSPixelDAQMappingRcd>().get( mapping);
83 
84  fedIds_ = mapping->fedIds();
85 
86  CTPPSPixelDataFormatter formatter(mapping->ROCMapping);
87  formatter.setErrorStatus(includeErrors_);
88 
89  bool errorsInEvent = false;
91 
92 
93  for (auto aFed = fedIds_.begin(); aFed != fedIds_.end(); ++aFed) {
94  int fedId = *aFed;
95 
96  edm::LogInfo("CTPPSPixelRawToDigi")<< " PRODUCE DIGI FOR FED: " << dec <<fedId << endl;
97 
100  const FEDRawData& fedRawData = buffers->FEDData( fedId );
101 
102  formatter.interpretRawData( errorsInEvent, fedId, fedRawData, *collection, errors);
103 
104  if(includeErrors_) {
105  for(auto const &is : errors){
106  uint32_t errordetid = is.first;
108  if (errordetid==RPixErrorChecker::dummyDetId) {
109  nodeterrors.insert( nodeterrors.end(), errors[errordetid].begin(), errors[errordetid].end() );
110  } else {
111  edm::DetSet<CTPPSPixelDataError>& errorDetSet = errorcollection->find_or_insert(errordetid);
112  errorDetSet.data.insert(errorDetSet.data.end(), is.second.begin(), is.second.end());
113  }
114  }
115  }
116  }
117 
118  if(includeErrors_) {
119  errorcollection->find_or_insert(RPixErrorChecker::dummyDetId).data = nodeterrors;
120  }
121  if (errorsInEvent) LogDebug("CTPPSPixelRawToDigi") << "Error words were stored in this event";
122  }
124  ev.put(std::move(collection));
125 
126  if(includeErrors_){
127  ev.put(std::move(errorcollection));
128  }
129 }
130 
#define LogDebug(id)
void setErrorStatus(bool theErrorStatus)
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
std::set< unsigned int > fedIds() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
edm::ParameterSet config_
CTPPSPixelRawToDigi(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::map< uint32_t, DetErrors > Errors
bool ev
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
static constexpr Word32 dummyDetId
std::set< unsigned int > fedIds_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< CTPPSPixelDataError > DetErrors
std::map< CTPPSPixelFramePosition, CTPPSPixelROCInfo > ROCMapping
void interpretRawData(bool &errorsInEvent, int fedId, const FEDRawData &data, Collection &digis, Errors &errors)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
collection_type data
Definition: DetSet.h:78
T get() const
Definition: EventSetup.h:62
void produce(edm::Event &, const edm::EventSetup &) override
get data, convert to digis attach againe to Event
edm::EDGetTokenT< FEDRawDataCollection > FEDRawDataCollection_
def move(src, dest)
Definition: eostools.py:511