CMS 3D CMS Logo

CSCComparatorDigiValidation.cc
Go to the documentation of this file.
5 
7  const edm::InputTag &stripDigiInputTag,
9  : CSCBaseValidation(inputTag),
10  theStripDigi_Token_(iC.consumes<CSCStripDigiCollection>(stripDigiInputTag)),
11  theTimeBinPlots(),
12  theNDigisPerLayerPlots(),
13  theStripDigiPlots(),
14  the3StripPlots() {
16 }
17 
19 
21  theNDigisPerEventPlot = iBooker.book1D("CSCComparatorDigisPerEvent", "CSC Comparator Digis per event", 100, 0, 100);
22  for (int i = 0; i < 10; ++i) {
23  char title1[200], title2[200], title3[200], title4[200];
24  sprintf(title1, "CSCComparatorDigiTimeType%d", i + 1);
25  sprintf(title2, "CSCComparatorDigisPerLayerType%d", i + 1);
26  sprintf(title3, "CSCComparatorStripAmplitudeType%d", i + 1);
27  sprintf(title4, "CSCComparator3StripAmplitudeType%d", i + 1);
28  theTimeBinPlots[i] = iBooker.book1D(title1, title1, 9, 0, 8);
29  theNDigisPerLayerPlots[i] = iBooker.book1D(title2, title2, 100, 0, 20);
30  theStripDigiPlots[i] = iBooker.book1D(title3, title3, 100, 0, 1000);
31  the3StripPlots[i] = iBooker.book1D(title4, title4, 100, 0, 1000);
32  }
33 }
34 
38 
39  e.getByToken(comparators_Token_, comparators);
40  if (!comparators.isValid()) {
41  edm::LogError("CSCDigiDump") << "Cannot get comparators by label " << theInputTag.encode();
42  }
43  e.getByToken(theStripDigi_Token_, stripDigis);
44  if (!stripDigis.isValid()) {
45  edm::LogError("CSCDigiDump") << "Cannot get comparators by label " << theInputTag.encode();
46  }
47 
48  unsigned nDigisPerEvent = 0;
49 
50  for (CSCComparatorDigiCollection::DigiRangeIterator j = comparators->begin(); j != comparators->end(); j++) {
51  std::vector<CSCComparatorDigi>::const_iterator digiItr = (*j).second.first;
52  std::vector<CSCComparatorDigi>::const_iterator last = (*j).second.second;
53 
54  CSCDetId detId((*j).first);
55  const CSCLayer *layer = findLayer(detId.rawId());
56  int chamberType = layer->chamber()->specs()->chamberType();
57 
58  CSCStripDigiCollection::Range stripRange = stripDigis->get(detId);
59 
60  theNDigisPerLayerPlots[chamberType - 1]->Fill(last - digiItr);
61 
62  for (; digiItr != last; ++digiItr) {
63  ++nDigisPerEvent;
64  theTimeBinPlots[chamberType - 1]->Fill(digiItr->getTimeBin());
65 
66  int strip = digiItr->getStrip();
67  for (std::vector<CSCStripDigi>::const_iterator stripItr = stripRange.first; stripItr != stripRange.second;
68  ++stripItr) {
69  if (stripItr->getStrip() == strip) {
70  std::vector<int> adc = stripItr->getADCCounts();
71  float pedc = 0.5 * (adc[0] + adc[1]);
72  float amp = adc[4] - pedc;
73  theStripDigiPlots[chamberType - 1]->Fill(amp);
74  // check neighbors
75  if (stripItr != stripRange.first && stripItr != stripRange.second - 1) {
76  std::vector<int> adcl = (stripItr - 1)->getADCCounts();
77  std::vector<int> adcr = (stripItr + 1)->getADCCounts();
78  float pedl = 0.5 * (adcl[0] + adcl[1]);
79  float pedr = 0.5 * (adcr[0] + adcr[1]);
80  float three = adcl[4] - pedl + adcr[4] - pedr + amp;
81  the3StripPlots[chamberType - 1]->Fill(three);
82  }
83  }
84  }
85  }
86  }
87 
88  theNDigisPerEventPlot->Fill(nDigisPerEvent);
89 }
edm::InputTag theInputTag
edm::EDGetTokenT< CSCStripDigiCollection > theStripDigi_Token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
std::string encode() const
Definition: InputTag.cc:159
void Fill(long long x)
void analyze(const edm::Event &, const edm::EventSetup &) override
const CSCChamberSpecs * specs() const
Definition: CSCChamber.h:42
edm::EDGetTokenT< CSCComparatorDigiCollection > comparators_Token_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
void bookHistograms(DQMStore::IBooker &)
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
bool isValid() const
Definition: HandleBase.h:74
int chamberType() const
CSCComparatorDigiValidation(const edm::InputTag &inputTag, const edm::InputTag &stripDigiInputTag, edm::ConsumesCollector &&iC)
std::pair< const_iterator, const_iterator > Range
const CSCChamber * chamber() const
Definition: CSCLayer.h:52
const CSCLayer * findLayer(int detId) const