CMS 3D CMS Logo

PreMixingCSCWorker.cc
Go to the documentation of this file.
3 
7 
8 // Specialize put for CSC strip
9 template <>
11  auto merged = std::make_unique<CSCStripDigiCollection>();
12  for (const auto &elem : *accumulated_) {
13  // The layerId
14  const CSCDetId &layerId = elem.first;
15 
16  // Get the iterators over the digis associated with this LayerId
17  const CSCStripDigiCollection::Range &range = elem.second;
18 
19  std::vector<CSCStripDigi> NewDigiList;
20 
21  std::vector<int> StripList;
22  std::vector<CSCStripDigiCollection::const_iterator> StripPointer;
23 
24  for (CSCStripDigiCollection::const_iterator dtdigi = range.first; dtdigi != range.second; ++dtdigi) {
25  StripList.push_back((*dtdigi).getStrip());
26  StripPointer.push_back(dtdigi);
27  }
28 
29  int PrevStrip = -1;
30  std::vector<int> DuplicateList;
31 
32  std::vector<CSCStripDigiCollection::const_iterator>::const_iterator StripPtr = StripPointer.begin();
33 
34  for (std::vector<int>::const_iterator istrip = StripList.begin(); istrip != StripList.end(); ++istrip) {
35  const int CurrentStrip = *(istrip);
36 
37  if (CurrentStrip > PrevStrip) {
38  PrevStrip = CurrentStrip;
39 
40  int dupl_count;
41  dupl_count = std::count(StripList.begin(), StripList.end(), CurrentStrip);
42  if (dupl_count > 1) {
43  std::vector<int>::const_iterator duplicate = istrip;
44  ++duplicate;
45  std::vector<CSCStripDigiCollection::const_iterator>::const_iterator DuplPointer = StripPtr;
46  ++DuplPointer;
47  for (; duplicate != StripList.end(); ++duplicate) {
48  if ((*duplicate) == CurrentStrip) {
49  DuplicateList.push_back(CurrentStrip);
50 
51  std::vector<int> pileup_adc = (**DuplPointer).getADCCounts();
52  std::vector<int> signal_adc = (**StripPtr).getADCCounts();
53 
54  std::vector<int>::const_iterator minplace;
55 
56  minplace = std::min_element(pileup_adc.begin(), pileup_adc.end());
57 
58  int minvalue = (*minplace);
59 
60  std::vector<int> new_adc;
61 
62  std::vector<int>::const_iterator newsig = signal_adc.begin();
63 
64  for (std::vector<int>::const_iterator ibin = pileup_adc.begin(); ibin != pileup_adc.end(); ++ibin) {
65  new_adc.push_back((*newsig) + (*ibin) - minvalue);
66 
67  ++newsig;
68  }
69 
70  CSCStripDigi newDigi(CurrentStrip, new_adc);
71  NewDigiList.push_back(newDigi);
72  }
73  ++DuplPointer;
74  }
75  } else {
76  NewDigiList.push_back(**StripPtr);
77  }
78  } // if strips monotonically increasing... Haven't hit duplicates yet
79  else { // reached end of signal digis, or there was no overlap
80  PrevStrip = 1000; // now into pileup signals, stop looking forward for
81  // duplicates
82 
83  // check if this digi was in the duplicate list
84  int check;
85  check = std::count(DuplicateList.begin(), DuplicateList.end(), CurrentStrip);
86  if (check == 0)
87  NewDigiList.push_back(**StripPtr);
88  }
89  ++StripPtr;
90  }
91 
92  CSCStripDigiCollection::Range stripRange(NewDigiList.begin(), NewDigiList.end());
93 
94  merged->put(stripRange, layerId);
95  }
96 
97  iEvent.put(std::move(merged), collectionDM_);
98  accumulated_.reset();
99 }
100 
101 // CSC has three digi collections
103 public:
105  : stripWorker_(ps.getParameter<edm::ParameterSet>("strip"), producer, iC),
106  wireWorker_(ps.getParameter<edm::ParameterSet>("wire"), producer, iC),
107  comparatorWorker_(ps.getParameter<edm::ParameterSet>("comparator"), producer, iC) {}
108  ~PreMixingCSCWorker() override = default;
109 
110  void initializeEvent(edm::Event const &iEvent, edm::EventSetup const &iSetup) override {}
111 
112  void addSignals(edm::Event const &iEvent, edm::EventSetup const &iSetup) override {
113  stripWorker_.addSignals(iEvent, iSetup);
114  wireWorker_.addSignals(iEvent, iSetup);
115  comparatorWorker_.addSignals(iEvent, iSetup);
116  }
117 
118  void addPileups(PileUpEventPrincipal const &pep, edm::EventSetup const &iSetup) override {
119  stripWorker_.addPileups(pep, iSetup);
120  wireWorker_.addPileups(pep, iSetup);
121  comparatorWorker_.addPileups(pep, iSetup);
122  }
123 
125  edm::EventSetup const &iSetup,
126  std::vector<PileupSummaryInfo> const &ps,
127  int bunchSpacing) override {
128  stripWorker_.put(iEvent);
129  wireWorker_.put(iEvent);
130  comparatorWorker_.put(iEvent);
131  }
132 
133 private:
137 };
138 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void put(edm::Event &iEvent, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bunchSpacing) override
std::unique_ptr< DigiCollection > accumulated_
void addSignals(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
void put(edm::Event &iEvent, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bunchSpacing) override
int iEvent
Definition: GenABIO.cc:224
PreMixingMuonWorker< CSCStripDigiCollection > stripWorker_
void addPileups(PileUpEventPrincipal const &pep, edm::EventSetup const &iSetup) override
void initializeEvent(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
PreMixingCSCWorker(const edm::ParameterSet &ps, edm::ProducerBase &producer, edm::ConsumesCollector &&iC)
def elem(elemtype, innerHTML='', html_class='', kwargs)
Definition: HTMLExport.py:19
PreMixingMuonWorker< CSCWireDigiCollection > wireWorker_
std::vector< DigiType >::const_iterator const_iterator
HLT enums.
std::pair< const_iterator, const_iterator > Range
def check(config)
Definition: trackerTree.py:14
#define DEFINE_PREMIXING_WORKER(TYPE)
PreMixingMuonWorker< CSCComparatorDigiCollection > comparatorWorker_
def move(src, dest)
Definition: eostools.py:511