CMS 3D CMS Logo

StripCompactDigiSimLinksProducer.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 
4 // user include files
7 
10 
12 
16 
17 #ifdef SCDSL_DEBUG
18 #define DEBUG(X) X
19 #else
20 #define DEBUG(X)
21 #endif
22 
24 public:
27 
28  void produce(edm::Event &, const edm::EventSetup &) override;
29 
30 private:
32  uint32_t maxHoleSize_;
33 };
34 
36  : src_(iConfig.getParameter<edm::InputTag>("src")), maxHoleSize_(iConfig.getParameter<uint32_t>("maxHoleSize")) {
37  produces<StripCompactDigiSimLinks>();
38 }
39 
41 
43  using namespace edm;
45  iEvent.getByLabel(src_, src);
46 
48 
49  int previousStrip; // previous strip with at least one link (might not be the
50  // strip of the previous link there are overlapping
51  // clusters)
52  int previousLinkStrip; // strip of the previous link (can be the same as the
53  // one of this link if there are overlapping clusters)
54  std::vector<StripCompactDigiSimLinks::key_type> thisStripSignals; // particles on this strip
55  std::vector<StripCompactDigiSimLinks::key_type> previousStripSignals; // particles on the previous strip
56 
57  for (auto const &det : *src) {
58  DEBUG(std::cerr << "\n\nProcessing detset " << det.detId() << ", size = " << det.size() << std::endl;)
59  previousStrip = -2; // previous strip with at least one link (might not be the strip of
60  // the previous link there are overlapping clusters)
61  previousLinkStrip = -2; // strip of the previous link (can be the same as the one of this
62  // link if there are overlapping clusters)
63  thisStripSignals.clear();
64  previousStripSignals.clear();
65  for (DetSet<StripDigiSimLink>::const_iterator it = det.begin(), ed = det.end(); it != ed; ++it) {
66  DEBUG(std::cerr << " processing digiSimLink on strip " << it->channel() << " left by particle "
67  << it->SimTrackId() << ", event " << it->eventId().rawId() << std::endl;)
68  if (int(it->channel()) != previousLinkStrip) {
69  previousStrip = previousLinkStrip;
70  DEBUG(std::cerr << " strip changed!" << std::endl;)
71  swap(thisStripSignals, previousStripSignals);
72  thisStripSignals.clear();
73  }
74  DEBUG(std::cerr << " previous strip " << previousStrip << ", previous link strip " << previousLinkStrip
75  << std::endl;)
76  // DEBUG(std::cerr << " on previous strip: "; for(auto const& k :
77  // previousStripSignals) { std::cerr << "(ev " << k.first.rawId() << ", id
78  // " << k.second << ") "; } std::cerr << std::endl;) DEBUG(std::cerr << "
79  // on this strip: "; for(auto const& k : thisStripSignals) {
80  // std::cerr << "(ev " << k.first.rawId() << ", id " << k.second << ") ";
81  // } std::cerr << std::endl;)
82  StripCompactDigiSimLinks::key_type key(it->eventId(), it->SimTrackId());
83  bool alreadyClusterized = false;
84  if (int(it->channel()) == previousStrip + 1) {
85  DEBUG(std::cerr << " on next strip" << std::endl;)
86  if (std::find(previousStripSignals.begin(), previousStripSignals.end(), key) != previousStripSignals.end()) {
87  alreadyClusterized = true;
88  DEBUG(std::cerr << " and part of previous cluster" << std::endl;)
89  }
90  }
91  if (!alreadyClusterized) {
92  DEBUG(std::cerr << " clusterize!" << std::endl;)
93  unsigned int size = 1;
94  int myLastStrip = it->channel(); // last known strip with signals from this particle
95  for (DetSet<StripDigiSimLink>::const_iterator it2 = it + 1; it2 < ed; ++it2) {
96  DEBUG(std::cerr << " digiSimLink on strip " << it2->channel() << " left by particle " << it2->SimTrackId()
97  << ", event " << it2->eventId().rawId() << std::endl;)
98  if ((it2->channel() - myLastStrip) > maxHoleSize_ + 1) {
99  DEBUG(std::cerr << " found hole of size " << (it2->channel() - myLastStrip) << ", stopping."
100  << std::endl;)
101  break;
102  }
103  if ((it2->eventId() == key.first) && (it2->SimTrackId() == key.second)) {
104  size++;
105  DEBUG(std::cerr << " extending cluster, now size = " << size << std::endl;)
106  myLastStrip = it2->channel();
107  }
108  }
109  output.insert(key, StripCompactDigiSimLinks::HitRecord(det.detId(), it->channel(), size));
110  }
111  if (int(it->channel()) != previousLinkStrip) {
112  previousLinkStrip = it->channel();
113  }
114  thisStripSignals.push_back(key);
115  DEBUG(std::cerr << " ending state " << previousStrip << ", previous link strip " << previousLinkStrip
116  << std::endl;)
117  // DEBUG(std::cerr << " on previous strip: "; for(auto const& k :
118  // previousStripSignals) { std::cerr << "(ev " << k.first.rawId() << ", id
119  // " << k.second << ") "; } std::cerr << std::endl;) DEBUG(std::cerr << "
120  // on this strip: "; for(auto const& k : thisStripSignals) {
121  // std::cerr << "(ev " << k.first.rawId() << ", id " << k.second << ") ";
122  // } std::cerr << std::endl;)
123  DEBUG(std::cerr << std::endl;)
124  }
125  }
126 
127  std::unique_ptr<StripCompactDigiSimLinks> ptr(new StripCompactDigiSimLinks(output));
128  iEvent.put(std::move(ptr));
129 }
130 
StripCompactDigiSimLinksProducer::src_
edm::InputTag src_
Definition: StripCompactDigiSimLinksProducer.cc:31
EDProducer.h
StripCompactDigiSimLinksProducer::StripCompactDigiSimLinksProducer
StripCompactDigiSimLinksProducer(const edm::ParameterSet &iConfig)
Definition: StripCompactDigiSimLinksProducer.cc:35
edm::DetSet
Definition: DetSet.h:23
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::swap
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
edm::DetSet::begin
iterator begin()
Definition: DetSet.h:57
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
edm::one::EDProducer
Definition: EDProducer.h:30
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle
Definition: AssociativeIterator.h:50
StripCompactDigiSimLinksProducer
Definition: StripCompactDigiSimLinksProducer.cc:23
DEBUG
#define DEBUG(X)
Definition: StripCompactDigiSimLinksProducer.cc:20
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
StripCompactDigiSimLinksProducer::maxHoleSize_
uint32_t maxHoleSize_
Definition: StripCompactDigiSimLinksProducer.cc:32
edm::ParameterSet
Definition: ParameterSet.h:47
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
DetSetVector.h
StripCompactDigiSimLinksProducer::~StripCompactDigiSimLinksProducer
~StripCompactDigiSimLinksProducer() override
Definition: StripCompactDigiSimLinksProducer.cc:40
eostools.move
def move(src, dest)
Definition: eostools.py:511
Frameworkfwd.h
StripCompactDigiSimLinksProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: StripCompactDigiSimLinksProducer.cc:42
ParameterSet.h
edm::Event
Definition: Event.h:73
crabWrapper.key
key
Definition: crabWrapper.py:19
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
edm::InputTag
Definition: InputTag.h:15
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443