CMS 3D CMS Logo

SiPixelRawToDigi.cc
Go to the documentation of this file.
1 // Skip FED40 pilot-blade
2 // Include parameter driven interface to SiPixelQuality for study purposes
3 // exclude ROC(raw) based on bad ROC list in SiPixelQuality
4 // enabled by: process.siPixelDigis.useQualityInfo = True (BY DEFAULT NOT USED)
5 // 20-10-2010 Andrew York (Tennessee)
6 // Jan 2016 Tamas Almos Vami (Tav) (Wigner RCP) -- Cabling Map label option
7 // Jul 2017 Viktor Veszpremi -- added PixelFEDChannel
8 
9 #include <memory>
10 
24 
30 
40 
43 
44 using namespace sipixelconstants;
45 
52 public:
54  explicit SiPixelRawToDigi(const edm::ParameterSet&);
55 
57  ~SiPixelRawToDigi() override;
58 
59  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
60 
62  void produce(edm::Event&, const edm::EventSetup&) override;
63 
64 private:
66  std::unique_ptr<SiPixelFedCablingTree> cabling_;
69  const std::vector<int> tkerrorlist_;
70  const std::vector<int> usererrorlist_;
71  std::vector<unsigned int> fedIds_;
74  // always consumed
77  // consume only if pixel quality is used -> useQuality_
79  // always produced
81  // produce only if error collections are included -> includeErrors_
86  const bool includeErrors_;
87  const bool useQuality_;
88  const bool usePilotBlade_;
89  const bool usePhase1_;
90 };
91 
92 // -----------------------------------------------------------------------------
94  : config_(conf),
95  badPixelInfo_(nullptr),
96  regions_(nullptr),
97  tkerrorlist_(config_.getParameter<std::vector<int>>("ErrorList")),
98  usererrorlist_(config_.getParameter<std::vector<int>>("UserErrorList")),
99  fedRawDataCollectionToken_{consumes<FEDRawDataCollection>(config_.getParameter<edm::InputTag>("InputLabel"))},
100  cablingMapToken_{esConsumes<SiPixelFedCablingMap, SiPixelFedCablingMapRcd>(
101  edm::ESInputTag("", config_.getParameter<std::string>("CablingMapLabel")))},
102  siPixelDigiCollectionToken_{produces<edm::DetSetVector<PixelDigi>>()},
103  includeErrors_(config_.getParameter<bool>("IncludeErrors")),
104  useQuality_(config_.getParameter<bool>("UseQualityInfo")),
105  usePilotBlade_(config_.getParameter<bool>("UsePilotBlade")),
106  usePhase1_(config_.getParameter<bool>("UsePhase1"))
107 
108 {
109  if (useQuality_) {
110  siPixelQualityToken_ = esConsumes<SiPixelQuality, SiPixelQualityRcd>();
111  }
112 
113  // Products
114  if (includeErrors_) {
115  errorPutToken_ = produces<edm::DetSetVector<SiPixelRawDataError>>();
116  tkErrorPutToken_ = produces<DetIdCollection>();
117  userErrorPutToken_ = produces<DetIdCollection>("UserErrorModules");
118  disabledChannelPutToken_ = produces<edmNew::DetSetVector<PixelFEDChannel>>();
119  }
120 
121  // regions
122  if (!config_.getParameter<edm::ParameterSet>("Regions").getParameterNames().empty()) {
123  regions_ = new PixelUnpackingRegions(config_, consumesCollector());
124  }
125 
126  // Control the usage of pilot-blade data, FED=40
127  if (usePilotBlade_)
128  edm::LogInfo("SiPixelRawToDigi") << " Use pilot blade data (FED 40)";
129 
130  // Control the usage of phase1
131  if (usePhase1_)
132  edm::LogInfo("SiPixelRawToDigi") << " Using phase1";
133 }
134 
135 // -----------------------------------------------------------------------------
137  edm::LogInfo("SiPixelRawToDigi") << " HERE ** SiPixelRawToDigi destructor!";
138  if (regions_)
139  delete regions_;
140 }
141 
144  desc.add<bool>("IncludeErrors", true);
145  desc.add<bool>("UseQualityInfo", false);
146  {
147  desc.add<std::vector<int>>("ErrorList", std::vector<int>{29})
148  ->setComment("## ErrorList: list of error codes used by tracking to invalidate modules");
149  }
150  {
151  desc.add<std::vector<int>>("UserErrorList", std::vector<int>{40})
152  ->setComment("## UserErrorList: list of error codes used by Pixel experts for investigation");
153  }
154  desc.add<edm::InputTag>("InputLabel", edm::InputTag("siPixelRawData"));
155  {
157  psd0.addOptional<std::vector<edm::InputTag>>("inputs");
158  psd0.addOptional<std::vector<double>>("deltaPhi");
159  psd0.addOptional<std::vector<double>>("maxZ");
160  psd0.addOptional<edm::InputTag>("beamSpot");
161  desc.add<edm::ParameterSetDescription>("Regions", psd0)
162  ->setComment("## Empty Regions PSet means complete unpacking");
163  }
164  desc.add<bool>("UsePilotBlade", false)->setComment("## Use pilot blades");
165  desc.add<bool>("UsePhase1", false)->setComment("## Use phase1");
166  desc.add<std::string>("CablingMapLabel", "")->setComment("CablingMap label"); //Tav
167  descriptions.add("siPixelRawToDigi", desc);
168 }
169 
170 // -----------------------------------------------------------------------------
171 
172 // -----------------------------------------------------------------------------
174  const uint32_t dummydetid = 0xffffffff;
175 
176  // initialize cabling map or update if necessary
177  if (recordWatcher_.check(es)) {
178  // cabling map, which maps online address (fed->link->ROC->local pixel) to offline (DetId->global pixel)
180  fedIds_ = cablingMap->fedIds();
181  cabling_ = cablingMap->cablingTree();
182  LogDebug("map version:") << cabling_->version();
183  }
184  // initialize quality record or update if necessary
185  if (qualityWatcher_.check(es) && useQuality_) {
186  // quality info for dead pixel modules or ROCs
188  badPixelInfo_ = qualityInfo.product();
189  if (!badPixelInfo_) {
190  edm::LogError("SiPixelQualityNotPresent") << "Configured to use SiPixelQuality, but SiPixelQuality not present";
191  }
192  }
193 
195  ev.getByToken(fedRawDataCollectionToken_, buffers);
196 
197  // create product (digis & errors)
199  // collection->reserve(8*1024);
200  auto errorcollection = edm::DetSetVector<SiPixelRawDataError>{};
201  auto tkerror_detidcollection = DetIdCollection{};
202  auto usererror_detidcollection = DetIdCollection{};
203  auto disabled_channelcollection = edmNew::DetSetVector<PixelFEDChannel>{};
204 
205  PixelDataFormatter formatter(cabling_.get(), usePhase1_); // for phase 1 & 0
206 
207  formatter.setErrorStatus(includeErrors_);
208 
209  if (useQuality_)
210  formatter.setQualityStatus(useQuality_, badPixelInfo_);
211 
212  bool errorsInEvent = false;
213  PixelDataFormatter::DetErrors nodeterrors;
214 
215  if (regions_) {
216  regions_->run(ev, es);
217  formatter.setModulesToUnpack(regions_->modulesToUnpack());
218  LogDebug("SiPixelRawToDigi") << "region2unpack #feds: " << regions_->nFEDs();
219  LogDebug("SiPixelRawToDigi") << "region2unpack #modules (BPIX,EPIX,total): " << regions_->nBarrelModules() << " "
220  << regions_->nForwardModules() << " " << regions_->nModules();
221  }
222 
223  for (auto aFed = fedIds_.begin(); aFed != fedIds_.end(); ++aFed) {
224  int fedId = *aFed;
225 
226  if (!usePilotBlade_ && (fedId == 40))
227  continue; // skip pilot blade data
228 
230  continue;
231 
232  LogDebug("SiPixelRawToDigi") << "PRODUCE DIGI FOR FED:" << fedId;
233 
235 
236  //get event data for this fed
237  const FEDRawData& fedRawData = buffers->FEDData(fedId);
238 
239  //convert data to digi and strip off errors
240  formatter.interpretRawData(errorsInEvent, fedId, fedRawData, collection, errors);
241 
242  //pack errors into collection
243  if (includeErrors_) {
244  formatter.unpackFEDErrors(errors,
245  tkerrorlist_,
247  errorcollection,
248  tkerror_detidcollection,
249  usererror_detidcollection,
250  disabled_channelcollection,
251  nodeterrors);
252  } // if errors to be included in the event
253  } // loop on FED data to be unpacked
254 
255  if (includeErrors_) {
256  edm::DetSet<SiPixelRawDataError>& errorDetSet = errorcollection.find_or_insert(dummydetid);
257  errorDetSet.data = nodeterrors;
258  }
259  if (errorsInEvent)
260  LogDebug("SiPixelRawToDigi") << "Error words were stored in this event";
261 
263  if (includeErrors_) {
264  ev.emplace(errorPutToken_, std::move(errorcollection));
265  ev.emplace(tkErrorPutToken_, std::move(tkerror_detidcollection));
266  ev.emplace(userErrorPutToken_, std::move(usererror_detidcollection));
267  ev.emplace(disabledChannelPutToken_, std::move(disabled_channelcollection));
268  }
269 }
270 // declare this as a framework plugin
ConfigurationDescriptions.h
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
edm::DetSetVector< PixelDigi >
Handle.h
SiPixelRawToDigi::SiPixelRawToDigi
SiPixelRawToDigi(const edm::ParameterSet &)
ctor
Definition: SiPixelRawToDigi.cc:93
edm::ESInputTag
Definition: ESInputTag.h:87
ESTransientHandle.h
MessageLogger.h
SiPixelRawToDigi::useQuality_
const bool useQuality_
Definition: SiPixelRawToDigi.cc:87
SiPixelRawToDigi::regions_
PixelUnpackingRegions * regions_
Definition: SiPixelRawToDigi.cc:68
edm::ESWatcher< SiPixelFedCablingMapRcd >
ESHandle.h
SiPixelRawToDigi::produce
void produce(edm::Event &, const edm::EventSetup &) override
get data, convert to digis attach againe to Event
Definition: SiPixelRawToDigi.cc:173
edm::DetSet
Definition: DetSet.h:23
PixelUnpackingRegions::nModules
unsigned int nModules() const
Definition: PixelUnpackingRegions.h:67
PixelUnpackingRegions::nFEDs
unsigned int nFEDs() const
various informational accessors:
Definition: PixelUnpackingRegions.h:66
PixelDataFormatter::Errors
std::map< cms_uint32_t, DetErrors > Errors
Definition: PixelDataFormatter.h:64
edm::EDGetTokenT< FEDRawDataCollection >
edm::EDPutTokenT
Definition: EDPutToken.h:33
PixelDataFormatter::DetErrors
std::vector< SiPixelRawDataError > DetErrors
Definition: PixelDataFormatter.h:63
PixelFEDChannel.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
SiPixelRawToDigi::fedIds_
std::vector< unsigned int > fedIds_
Definition: SiPixelRawToDigi.cc:71
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PixelUnpackingRegions::mayUnpackFED
bool mayUnpackFED(unsigned int fed_n) const
check whether a FED has to be unpacked
Definition: PixelUnpackingRegions.cc:204
EDProducer.h
SiPixelFedCablingMap.h
SiPixelRawToDigi::badPixelInfo_
const SiPixelQuality * badPixelInfo_
Definition: SiPixelRawToDigi.cc:67
PixelDigi.h
SiPixelFedCablingTree.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
FEDRawData.h
edm::Handle< FEDRawDataCollection >
edm::ParameterSetDescription::addOptional
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:105
SiPixelRawToDigi::usePilotBlade_
const bool usePilotBlade_
Definition: SiPixelRawToDigi.cc:88
ESGetToken.h
SiPixelRawToDigi::tkerrorlist_
const std::vector< int > tkerrorlist_
Definition: SiPixelRawToDigi.cc:69
SiPixelRawToDigi::cabling_
std::unique_ptr< SiPixelFedCablingTree > cabling_
Definition: SiPixelRawToDigi.cc:66
FEDRawData
Definition: FEDRawData.h:19
SiPixelRawToDigi::qualityWatcher_
edm::ESWatcher< SiPixelQualityRcd > qualityWatcher_
Definition: SiPixelRawToDigi.cc:73
PixelDataFormatter
Definition: PixelDataFormatter.h:61
MakerMacros.h
l1t_dqm_sourceclient-live_cfg.fedRawData
fedRawData
Definition: l1t_dqm_sourceclient-live_cfg.py:188
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
SiPixelQualityRcd.h
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::ESHandle< SiPixelFedCablingMap >
sipixelconstants
Definition: SiPixelDigiConstants.h:10
SiPixelRawToDigi::fedRawDataCollectionToken_
const edm::EDGetTokenT< FEDRawDataCollection > fedRawDataCollectionToken_
Definition: SiPixelRawToDigi.cc:75
SiPixelRawToDigi::recordWatcher_
edm::ESWatcher< SiPixelFedCablingMapRcd > recordWatcher_
Definition: SiPixelRawToDigi.cc:72
SiPixelRawToDigi::usePhase1_
const bool usePhase1_
Definition: SiPixelRawToDigi.cc:89
ParameterSetDescription.h
SiPixelRawToDigi::siPixelQualityToken_
edm::ESGetToken< SiPixelQuality, SiPixelQualityRcd > siPixelQualityToken_
Definition: SiPixelRawToDigi.cc:78
PixelUnpackingRegions.h
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
SiPixelFedCablingMap::cablingTree
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
Definition: SiPixelFedCablingMap.cc:103
SiPixelRawToDigi::~SiPixelRawToDigi
~SiPixelRawToDigi() override
dtor
Definition: SiPixelRawToDigi.cc:136
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
SiPixelQuality
Definition: SiPixelQuality.h:27
Event.h
SiPixelFedCablingMapRcd.h
edm::ParameterSet::getParameterNames
std::vector< std::string > getParameterNames() const
Definition: ParameterSet.cc:663
postprocess-scan-build.formatter
formatter
Definition: postprocess-scan-build.py:49
createfilelist.int
int
Definition: createfilelist.py:10
SiPixelRawToDigi::errorPutToken_
edm::EDPutTokenT< edm::DetSetVector< SiPixelRawDataError > > errorPutToken_
Definition: SiPixelRawToDigi.cc:82
SiPixelRawToDigi
Definition: SiPixelRawToDigi.cc:51
universalConfigTemplate.collection
collection
Definition: universalConfigTemplate.py:81
FEDRawDataCollection.h
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
DetSetVector.h
SiPixelRawToDigi::usererrorlist_
const std::vector< int > usererrorlist_
Definition: SiPixelRawToDigi.cc:70
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:89
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
PixelUnpackingRegions::modulesToUnpack
const std::set< unsigned int > * modulesToUnpack() const
full set of module ids to unpack
Definition: PixelUnpackingRegions.h:63
edm::EDCollection< DetId >
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd >
SiPixelRawToDigi::siPixelDigiCollectionToken_
const edm::EDPutTokenT< edm::DetSetVector< PixelDigi > > siPixelDigiCollectionToken_
Definition: SiPixelRawToDigi.cc:80
SiPixelRawToDigi::config_
edm::ParameterSet config_
Definition: SiPixelRawToDigi.cc:65
edmNew::DetSetVector
Definition: DetSetNew.h:13
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
PixelDataFormatter.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
PixelUnpackingRegions
Definition: PixelUnpackingRegions.h:32
ESWatcher.h
ev
bool ev
Definition: Hydjet2Hadronizer.cc:97
SiPixelDigiConstants.h
edm::DetSet::data
collection_type data
Definition: DetSet.h:80
EventSetup.h
SiPixelRawToDigi::includeErrors_
const bool includeErrors_
Definition: SiPixelRawToDigi.cc:86
SiPixelRawDataError.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PixelUnpackingRegions::nForwardModules
unsigned int nForwardModules() const
Definition: PixelUnpackingRegions.cc:220
SiPixelQuality.h
ConsumesCollector.h
ParameterSet.h
SiPixelRawToDigi::disabledChannelPutToken_
edm::EDPutTokenT< edmNew::DetSetVector< PixelFEDChannel > > disabledChannelPutToken_
Definition: SiPixelRawToDigi.cc:85
edm::Event
Definition: Event.h:73
DetSetVectorNew.h
edm::InputTag
Definition: InputTag.h:15
SiPixelRawToDigi::tkErrorPutToken_
edm::EDPutTokenT< DetIdCollection > tkErrorPutToken_
Definition: SiPixelRawToDigi.cc:83
PixelUnpackingRegions::run
void run(const edm::Event &e, const edm::EventSetup &es)
has to be run during each event
Definition: PixelUnpackingRegions.cc:48
DetIdCollection.h
SiPixelRawToDigi::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: SiPixelRawToDigi.cc:142
SiPixelRawToDigi::cablingMapToken_
const edm::ESGetToken< SiPixelFedCablingMap, SiPixelFedCablingMapRcd > cablingMapToken_
Definition: SiPixelRawToDigi.cc:76
SiPixelRawToDigi::userErrorPutToken_
edm::EDPutTokenT< DetIdCollection > userErrorPutToken_
Definition: SiPixelRawToDigi.cc:84
SiPixelFedCablingMap::fedIds
std::vector< unsigned int > fedIds() const
Definition: SiPixelFedCablingMap.cc:114
PixelUnpackingRegions::nBarrelModules
unsigned int nBarrelModules() const
Definition: PixelUnpackingRegions.cc:216
debug_messages_cfi.errors
errors
Definition: debug_messages_cfi.py:54