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 
size
Write out results.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
int iEvent
Definition: GenABIO.cc:224
StripCompactDigiSimLinksProducer(const edm::ParameterSet &iConfig)
key
prepare the HTCondor submission files and eventually submit them
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HLT enums.
Definition: output.py:1
void produce(edm::Event &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:511