CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
MeasurementTrackerEventProducer Class Reference

#include <MeasurementTrackerEventProducer.h>

Inheritance diagram for MeasurementTrackerEventProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper MeasurementTrackerSiStripRefGetterProducer

Public Member Functions

 MeasurementTrackerEventProducer (const edm::ParameterSet &iConfig)
 
 ~MeasurementTrackerEventProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

void getInactiveStrips (const edm::Event &event, std::vector< uint32_t > &rawInactiveDetIds) const
 
void updatePixels (const edm::Event &, PxMeasurementDetSet &thePxDets, std::vector< bool > &pixelClustersToSkip) const
 
void updateStrips (const edm::Event &, StMeasurementDetSet &theStDets, std::vector< bool > &stripClustersToSkip) const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Protected Attributes

std::string measurementTrackerLabel_
 
const edm::ParameterSetpset_
 
bool selfUpdateSkipClusters_
 
const std::vector< edm::InputTagtheInactivePixelDetectorLabels
 
const std::vector< edm::InputTagtheInactiveStripDetectorLabels
 

Private Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

Definition at line 12 of file MeasurementTrackerEventProducer.h.

Constructor & Destructor Documentation

MeasurementTrackerEventProducer::MeasurementTrackerEventProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 11 of file MeasurementTrackerEventProducer.cc.

References edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), LogDebug, selfUpdateSkipClusters_, and createPayload::skip.

11  :
12  measurementTrackerLabel_(iConfig.getParameter<std::string>("measurementTracker")),
13  pset_(iConfig),
14  theInactivePixelDetectorLabels(iConfig.getParameter<std::vector<edm::InputTag> >("inactivePixelDetectorLabels")),
15  theInactiveStripDetectorLabels(iConfig.getParameter<std::vector<edm::InputTag> >("inactiveStripDetectorLabels"))
16 {
17  //the measurement tracking is set to skip clusters, the other option is set from outside
18  selfUpdateSkipClusters_=iConfig.exists("skipClusters");
20  {
21  edm::InputTag skip=iConfig.getParameter<edm::InputTag>("skipClusters");
22  if (skip==edm::InputTag("")) selfUpdateSkipClusters_=false;
23  }
24  LogDebug("MeasurementTracker")<<"skipping clusters: "<<selfUpdateSkipClusters_;
25 
26  produces<MeasurementTrackerEvent>();
27 }
#define LogDebug(id)
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
const std::vector< edm::InputTag > theInactiveStripDetectorLabels
const std::vector< edm::InputTag > theInactivePixelDetectorLabels
MeasurementTrackerEventProducer::~MeasurementTrackerEventProducer ( )
inline

Definition at line 15 of file MeasurementTrackerEventProducer.h.

15 {}

Member Function Documentation

void MeasurementTrackerEventProducer::getInactiveStrips ( const edm::Event event,
std::vector< uint32_t > &  rawInactiveDetIds 
) const
protected

Definition at line 269 of file MeasurementTrackerEventProducer.cc.

References python.multivaluedict::sort(), and theInactiveStripDetectorLabels.

Referenced by updateStrips(), and MeasurementTrackerSiStripRefGetterProducer::updateStrips().

270 {
271  if (!theInactiveStripDetectorLabels.empty()) {
273  for (std::vector<edm::InputTag>::const_iterator itt = theInactiveStripDetectorLabels.begin(), edt = theInactiveStripDetectorLabels.end();
274  itt != edt; ++itt) {
275  event.getByLabel(*itt, detIds);
276  rawInactiveDetIds.insert(rawInactiveDetIds.end(), detIds->begin(), detIds->end());
277  }
278  if (!rawInactiveDetIds.empty()) std::sort(rawInactiveDetIds.begin(), rawInactiveDetIds.end());
279  }
280 
281 }
const std::vector< edm::InputTag > theInactiveStripDetectorLabels
void MeasurementTrackerEventProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Reimplemented in MeasurementTrackerSiStripRefGetterProducer.

Definition at line 30 of file MeasurementTrackerEventProducer.cc.

References edm::EventSetup::get(), IterativeTracking_cff::MeasurementTrackerEvent, measurementTrackerLabel_, dbtoconf::out, edm::Event::put(), updatePixels(), and updateStrips().

31 {
32  edm::ESHandle<MeasurementTracker> measurementTracker;
33  iSetup.get<CkfComponentsRecord>().get(measurementTrackerLabel_, measurementTracker);
34 
35  // create new data structures from templates
36  std::auto_ptr<StMeasurementDetSet> stripData(new StMeasurementDetSet(measurementTracker->stripDetConditions()));
37  std::auto_ptr<PxMeasurementDetSet> pixelData(new PxMeasurementDetSet(measurementTracker->pixelDetConditions()));
38  //std::cout << "Created new strip data @" << &* stripData << std::endl;
39  std::vector<bool> stripClustersToSkip;
40  std::vector<bool> pixelClustersToSkip;
41 
42  // fill them
43  updateStrips(iEvent, *stripData, stripClustersToSkip);
44  updatePixels(iEvent, *pixelData, pixelClustersToSkip);
45 
46  // put into MTE
47  std::auto_ptr<MeasurementTrackerEvent> out(new MeasurementTrackerEvent(*measurementTracker, stripData.release(), pixelData.release(), stripClustersToSkip, pixelClustersToSkip));
48 
49  // put into event
50  iEvent.put(out);
51 }
void updateStrips(const edm::Event &, StMeasurementDetSet &theStDets, std::vector< bool > &stripClustersToSkip) const
void updatePixels(const edm::Event &, PxMeasurementDetSet &thePxDets, std::vector< bool > &pixelClustersToSkip) const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
tuple out
Definition: dbtoconf.py:99
const T & get() const
Definition: EventSetup.h:55
void MeasurementTrackerEventProducer::updatePixels ( const edm::Event event,
PxMeasurementDetSet thePxDets,
std::vector< bool > &  pixelClustersToSkip 
) const
protected

Definition at line 54 of file MeasurementTrackerEventProducer.cc.

References edmNew::DetSetVector< T >::begin(), edmNew::DetSetVector< T >::dataSize(), edmNew::DetSetVector< T >::empty(), edmNew::DetSetVector< T >::end(), edm::ParameterSet::existsAs(), edm::HandleBase::failedToGet(), lumiContext::fill, PxMeasurementDetSet::find(), edm::Event::getByLabel(), edm::ParameterSet::getParameter(), PxMeasurementDetSet::handle(), i, edmNew::DetSet< T >::id(), edm::HandleBase::id(), PxMeasurementDetSet::id(), PxMeasurementDetSet::isActive(), LogDebug, clustersummaryproducer_cfg::pixelClusters, edm::Handle< T >::product(), pset_, selfUpdateSkipClusters_, PxMeasurementDetSet::setActiveThisEvent(), PxMeasurementDetSet::setEmpty(), PxMeasurementDetSet::size(), python.multivaluedict::sort(), AlCaHLTBitMon_QueryRunRegistry::string, theInactivePixelDetectorLabels, and PxMeasurementDetSet::update().

Referenced by produce(), and MeasurementTrackerSiStripRefGetterProducer::produce().

55 {
56  // start by clearinng everything
57  thePxDets.setEmpty();
58 
59  bool switchOffPixelsIfEmpty = (!pset_.existsAs<bool>("switchOffPixelsIfEmpty")) ||
60  (pset_.getParameter<bool>("switchOffPixelsIfEmpty"));
61  std::vector<uint32_t> rawInactiveDetIds;
62  if (!theInactivePixelDetectorLabels.empty()) {
64  for (std::vector<edm::InputTag>::const_iterator itt = theInactivePixelDetectorLabels.begin(), edt = theInactivePixelDetectorLabels.end();
65  itt != edt; ++itt) {
66  if (event.getByLabel(*itt, detIds)){
67  rawInactiveDetIds.insert(rawInactiveDetIds.end(), detIds->begin(), detIds->end());
68  }else{
69  static std::atomic<bool> iFailedAlready{false};
70  bool expected = false;
71  if (iFailedAlready.compare_exchange_strong(expected,true,std::memory_order_acq_rel)){
72  edm::LogError("MissingProduct")<<"I fail to get the list of inactive pixel modules, because of 4.2/4.4 event content change.";
73  }
74  }
75  }
76  if (!rawInactiveDetIds.empty()) std::sort(rawInactiveDetIds.begin(), rawInactiveDetIds.end());
77  // mark as inactive if in rawInactiveDetIds
78  int i=0, endDet = thePxDets.size();
79  unsigned int idp=0;
80  for ( auto id : rawInactiveDetIds) {
81  if (id==idp) continue; // skip multiple id
82  idp=id;
83  i=thePxDets.find(id,i);
84  assert(i!=endDet && id == thePxDets.id(i));
85  thePxDets.setActiveThisEvent(i,false);
86  }
87  }
88 
89  // Pixel Clusters
90  std::string pixelClusterProducer = pset_.getParameter<std::string>("pixelClusterProducer");
91  if( pixelClusterProducer.empty() ) { //clusters have not been produced
92  if (switchOffPixelsIfEmpty) {
93  thePxDets.setActiveThisEvent(false);
94  }
95  }else{
96 
98  event.getByLabel(pixelClusterProducer, pixelClusters);
99 
100  const edmNew::DetSetVector<SiPixelCluster>* pixelCollection = pixelClusters.product();
101 
102  if (switchOffPixelsIfEmpty && pixelCollection->empty()) {
103  thePxDets.setActiveThisEvent(false);
104  } else {
105 
106  //std::cout <<"updatePixels "<<pixelCollection->dataSize()<<std::endl;
107  pixelClustersToSkip.resize(pixelCollection->dataSize());
108  std::fill(pixelClustersToSkip.begin(),pixelClustersToSkip.end(),false);
109 
112  //and get the collection of pixel ref to skip
113  event.getByLabel(pset_.getParameter<edm::InputTag>("skipClusters"),pixelClusterMask);
114  LogDebug("MeasurementTracker")<<"getting pxl refs to skip";
115  if (pixelClusterMask.failedToGet())edm::LogError("MeasurementTracker")<<"not getting the pixel clusters to skip";
116  if (pixelClusterMask->refProd().id()!=pixelClusters.id()){
117  edm::LogError("ProductIdMismatch")<<"The pixel masking does not point to the proper collection of clusters: "<<pixelClusterMask->refProd().id()<<"!="<<pixelClusters.id();
118  }
119  pixelClusterMask->copyMaskTo(pixelClustersToSkip);
120  }
121 
122 
123  // FIXME: should check if lower_bound is better
124  int i = 0, endDet = thePxDets.size();
125  for (edmNew::DetSetVector<SiPixelCluster>::const_iterator it = pixelCollection->begin(), ed = pixelCollection->end(); it != ed; ++it) {
127  unsigned int id = set.id();
128  while ( id != thePxDets.id(i)) {
129  ++i;
130  if (endDet==i) throw "we have a problem!!!!";
131  }
132  // push cluster range in det
133  if ( thePxDets.isActive(i) ) {
134  thePxDets.update(i,set);
135  }
136  }
137  }
138  }
139 
140 }
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
size_type dataSize() const
string fill
Definition: lumiContext.py:319
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
ProductID id() const
Definition: HandleBase.cc:15
const edm::Handle< edmNew::DetSetVector< SiPixelCluster > > & handle() const
unsigned int id(int i) const
bool isActive(int i) const
const std::vector< edm::InputTag > theInactivePixelDetectorLabels
void update(int i, const PixelDetSet &detSet)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
bool failedToGet() const
Definition: HandleBase.h:80
T const * product() const
Definition: Handle.h:81
void setActiveThisEvent(bool active)
const_iterator end(bool update=true) const
int find(unsigned int jd, int i=0) const
const_iterator begin(bool update=true) const
void MeasurementTrackerEventProducer::updateStrips ( const edm::Event event,
StMeasurementDetSet theStDets,
std::vector< bool > &  stripClustersToSkip 
) const
protected

Definition at line 143 of file MeasurementTrackerEventProducer.cc.

References edm::RegionIndex< T >::begin(), edm::RegionIndex< T >::end(), edm::hlt::Exception, edm::HandleBase::failedToGet(), StMeasurementDetSet::find(), getInactiveStrips(), edm::ParameterSet::getParameter(), StMeasurementDetSet::handle(), i, edm::HandleBase::id(), StMeasurementDetSet::id(), getHLTprescales::index, StMeasurementDetSet::isActive(), StMeasurementDetSet::isRegional(), j, LogDebug, edm::Handle< T >::product(), pset_, StMeasurementDetSet::regionalHandle(), selfUpdateSkipClusters_, StMeasurementDetSet::setActiveThisEvent(), StMeasurementDetSet::setEmpty(), StMeasurementDetSet::size(), AlCaHLTBitMon_QueryRunRegistry::string, and StMeasurementDetSet::update().

Referenced by produce().

144 {
145  typedef edmNew::DetSet<SiStripCluster> StripDetSet;
146 
147  std::vector<uint32_t> rawInactiveDetIds;
148  getInactiveStrips(event,rawInactiveDetIds);
149 
150  // Strip Clusters
151  std::string stripClusterProducer = pset_.getParameter<std::string>("stripClusterProducer");
152  //first clear all of them
153  theStDets.setEmpty();
154 
155 
156  if( !stripClusterProducer.compare("") ) return; //clusters have not been produced
157 
158  const int endDet = theStDets.size();
159 
160 
161  // mark as inactive if in rawInactiveDetIds
162  int i=0;
163  unsigned int idp=0;
164  for ( auto id : rawInactiveDetIds) {
165  if (id==idp) continue; // skip multiple id
166  idp=id;
167  i=theStDets.find(id,i);
168  assert(i!=endDet && id == theStDets.id(i));
169  theStDets.setActiveThisEvent(i,false);
170  }
171 
172  //========= actually load cluster =============
173  if(!theStDets.isRegional()){
175  event.getByLabel(stripClusterProducer, clusterHandle);
176  const edmNew::DetSetVector<SiStripCluster>* clusterCollection = clusterHandle.product();
177 
178 
181  //and get the collection of pixel ref to skip
182  LogDebug("MeasurementTracker")<<"getting strp refs to skip";
183  event.getByLabel(pset_.getParameter<edm::InputTag>("skipClusters"),stripClusterMask);
184  if (stripClusterMask.failedToGet()) edm::LogError("MeasurementTracker")<<"not getting the strip clusters to skip";
185  if (stripClusterMask->refProd().id()!=clusterHandle.id()){
186  edm::LogError("ProductIdMismatch")<<"The strip masking does not point to the proper collection of clusters: "<<stripClusterMask->refProd().id()<<"!="<<clusterHandle.id();
187  }
188  stripClusterMask->copyMaskTo(stripClustersToSkip);
189  }
190 
191  theStDets.handle() = clusterHandle;
192  int i=0;
193  // cluster and det and in order (both) and unique so let's use set intersection
194  for ( auto j = 0U; j< (*clusterCollection).size(); ++j) {
195  unsigned int id = (*clusterCollection).id(j);
196  while ( id != theStDets.id(i)) { // eventually change to lower_bound
197  ++i;
198  if (endDet==i) throw "we have a problem in strips!!!!";
199  }
200 
201  // push cluster range in det
202  if ( theStDets.isActive(i) )
203  theStDets.update(i,j);
204  }
205 
206  }else{ // regional
207  throw cms::Exception("NotSupported") << "Regional non-on-demand unpacking is not supported." << std::endl;
208 #if 0
209  //then set the not-empty ones only
211  event.getByLabel(stripClusterProducer, refClusterHandle);
212 
213  std::string lazyGetter = pset_.getParameter<std::string>("stripLazyGetterProducer");
215  event.getByLabel(lazyGetter,lazyClusterHandle);
216 
219  LogDebug("MeasurementTracker")<<"getting reg strp refs to skip";
220  event.getByLabel(pset_.getParameter<edm::InputTag>("skipClusters"),stripClusterMask);
221  if (stripClusterMask.failedToGet())edm::LogError("MeasurementTracker")<<"not getting the strip clusters to skip";
222  if (stripClusterMask->refProd().id()!=lazyClusterHandle.id()){
223  edm::LogError("ProductIdMismatch")<<"The strip masking does not point to the proper collection of clusters: "<<stripClusterMask->refProd().id()<<"!="<<lazyClusterHandle.id();
224  }
225  stripClusterMask->copyMaskTo(stripClustersToSkip);
226  }
227 
228  theStDets.regionalHandle() = lazyClusterHandle;
229 
230  uint32_t tmpId=0;
231  std::vector<SiStripCluster>::const_iterator beginIterator;
232  edm::RefGetter<SiStripCluster>::const_iterator iregion = refClusterHandle->begin();
233  for(;iregion!=refClusterHandle->end();++iregion) {
234  const edm::RegionIndex<SiStripCluster>& region = *iregion;
235  std::vector<SiStripCluster>::const_iterator icluster = region.begin();
236  const std::vector<SiStripCluster>::const_iterator endIterator = region.end();
237  tmpId = icluster->geographicalId();
238  beginIterator = icluster;
239 
240  //std::cout << "== tmpId ad inizio loop dentro region: " << tmpId << std::endl;
241 
242  for (;icluster!=endIterator;icluster++) {
243  //std::cout << "===== cluster id,pos "
244  // << icluster->geographicalId() << " , " << icluster->barycenter()
245  // << std::endl;
246  //std::cout << "=====making ref in recHits() " << std::endl;
247  if( icluster->geographicalId() != tmpId){
248  //std::cout << "geo!=tmpId" << std::endl;
249 
250  //cannot we avoid to update the det with detId of itself?? (sure we can!, done!)
251  theStDets.update(concreteDetUpdatable(tmpId)->index(),beginIterator,icluster);
252 
253  tmpId = icluster->geographicalId();
254  beginIterator = icluster;
255  if( icluster == (endIterator-1)){
256  theStDets.update(concreteDetUpdatable(tmpId)->index(),icluster,endIterator);
257  }
258  }else if( icluster == (endIterator-1)){
259  theStDets.update(concreteDetUpdatable(tmpId)->index(),beginIterator,endIterator);
260  }
261  }//end loop cluster in one ragion
262  }
263 #endif
264  }//end of block for updating with regional clusters
265 
266 }
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
ProductID id() const
Definition: HandleBase.cc:15
const_iterator end() const
Get off the end iterator.
Definition: LazyGetter.h:191
edm::Handle< edm::LazyGetter< SiStripCluster > > & regionalHandle()
void update(int i, const StripDetset &detSet)
unsigned int id(int i) const
int find(unsigned int jd, int i=0) const
void setActiveThisEvent(int i, bool active)
Turn on/off the module for reconstruction for one events. This per-event flag is cleared by any call ...
void getInactiveStrips(const edm::Event &event, std::vector< uint32_t > &rawInactiveDetIds) const
int j
Definition: DBlmapReader.cc:9
const_iterator begin() const
Get begin iterator.
Definition: LazyGetter.h:182
bool failedToGet() const
Definition: HandleBase.h:80
boost::indirect_iterator< typename collection_type::const_iterator > const_iterator
Definition: RefGetter.h:25
T const * product() const
Definition: Handle.h:81
bool isActive(int i) const
edm::Handle< edmNew::DetSetVector< SiStripCluster > > & handle()

Member Data Documentation

std::string MeasurementTrackerEventProducer::measurementTrackerLabel_
protected
const edm::ParameterSet& MeasurementTrackerEventProducer::pset_
protected
bool MeasurementTrackerEventProducer::selfUpdateSkipClusters_
protected
const std::vector<edm::InputTag> MeasurementTrackerEventProducer::theInactivePixelDetectorLabels
protected

Definition at line 28 of file MeasurementTrackerEventProducer.h.

Referenced by updatePixels().

const std::vector<edm::InputTag> MeasurementTrackerEventProducer::theInactiveStripDetectorLabels
protected

Definition at line 29 of file MeasurementTrackerEventProducer.h.

Referenced by getInactiveStrips().