CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripClusterizer.cc
Go to the documentation of this file.
6 #include "boost/foreach.hpp"
9 
12  : confClusterizer_(conf.getParameter<edm::ParameterSet>("Clusterizer")),
13  inputTags( conf.getParameter<std::vector<edm::InputTag> >("DigiProducersList") ),
14  algorithm( StripClusterizerAlgorithmFactory::create(conf.getParameter<edm::ParameterSet>("Clusterizer")) ) {
15  produces< edmNew::DetSetVector<SiStripCluster> > ();
16  inputTokens = edm::vector_transform( inputTags, [this](edm::InputTag const & tag) { return consumes< edm::DetSetVector<SiStripDigi> >(tag);} );
17  doRefineCluster_ = confClusterizer_.existsAs<bool>("doRefineCluster") ? confClusterizer_.getParameter<bool>("doRefineCluster") : false;
18  occupancyThreshold_ = confClusterizer_.existsAs<double>("occupancyThreshold") ? confClusterizer_.getParameter<double>("occupancyThreshold") : 0.05;
19  widthThreshold_ = confClusterizer_.existsAs<unsigned>("widthThreshold") ? confClusterizer_.getParameter<unsigned>("widthThreshold") : 4;
20 }
21 
24 
25  std::auto_ptr< edmNew::DetSetVector<SiStripCluster> > output(new edmNew::DetSetVector<SiStripCluster>());
26  output->reserve(10000,4*10000);
27 
29 // edm::Handle< edmNew::DetSetVector<SiStripDigi> > inputNew;
30 
31  algorithm->initialize(es);
32 
33  BOOST_FOREACH( const edm::EDGetTokenT< edm::DetSetVector<SiStripDigi> >& token, inputTokens) {
34  if( findInput( token, inputOld, event) ) {
35  algorithm->clusterize(*inputOld, *output);
36  if (doRefineCluster_) refineCluster(inputOld, output);
37  }
38 // else if( findInput( tag, inputNew, event) ) algorithm->clusterize(*inputNew, *output);
39  else edm::LogError("Input Not Found") << "[SiStripClusterizer::produce] ";// << tag;
40  }
41 
42  LogDebug("Output") << output->dataSize() << " clusters from "
43  << output->size() << " modules";
44  output->shrink_to_fit();
45  event.put(output);
46 }
47 
48 template<class T>
49 inline
52  e.getByToken( tag, handle);
53  return handle.isValid();
54 }
55 
58  std::auto_ptr< edmNew::DetSetVector<SiStripCluster> >& output) {
59  if (input->size() == 0) return;
60 
61  // Flag merge-prone clusters for relaxed CPE errors
62  // Criterion is sensor occupancy and cluster width exceeding thresholds
63 
64  for (edmNew::DetSetVector<SiStripCluster>::const_iterator det=output->begin(); det!=output->end(); det++) {
65  uint32_t detId = det->id();
66  // Find the number of good strips in this sensor
67  int nchannideal = SiStripDetCabling_->nApvPairs(detId) * 2 * 128;
68  int nchannreal = 0;
69  for(int strip = 0; strip < nchannideal; ++strip)
70  if(!quality_->IsStripBad(detId,strip)) ++nchannreal;
71 
73  if (digis != input->end()) {
74  int ndigi = digis->size();
75  for (edmNew::DetSet<SiStripCluster>::iterator clust = det->begin(); clust != det->end(); clust++) {
76  if (ndigi > occupancyThreshold_*nchannreal && clust->amplitudes().size() >= widthThreshold_) clust->setMerged(true);
77  else clust->setMerged(false);
78  }
79  // std::cout << "Sensor:strips_occStrips_clust " << nchannreal << " " << ndigi << " " << det->size() << std::endl;
80  }
81  } // traverse sensors
82 }
83 
85  if (doRefineCluster_) {
87  es.get<SiStripQualityRcd>().get("", quality_);
88  }
89 }
#define LogDebug(id)
T getParameter(std::string const &) const
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
SiStripClusterizer(const edm::ParameterSet &conf)
edm::ParameterSet confClusterizer_
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
data_type * iterator
Definition: DetSetNew.h:29
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
bool findInput(const edm::EDGetTokenT< T > &, edm::Handle< T > &, const edm::Event &)
static std::string const input
Definition: EdmProvDump.cc:44
edm::ESHandle< SiStripDetCabling > SiStripDetCabling_
const std::vector< edm::InputTag > inputTags
virtual void produce(edm::Event &, const edm::EventSetup &)
tuple handle
Definition: patZpeak.py:22
edm::ESHandle< SiStripQuality > quality_
void refineCluster(const edm::Handle< edm::DetSetVector< SiStripDigi > > &input, std::auto_ptr< edmNew::DetSetVector< SiStripCluster > > &output)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:76
size_type size() const
Return the number of contained DetSets.
Definition: DetSetVector.h:287
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
tuple conf
Definition: dbtoconf.py:185
std::auto_ptr< StripClusterizerAlgorithm > algorithm
const T & get() const
Definition: EventSetup.h:55
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:108
SurfaceDeformation * create(int type, const std::vector< double > &params)
Definition: Run.h:41