CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CSCCLCTDigiValidation.cc
Go to the documentation of this file.
4 
8 
10  : CSCBaseValidation(ps),
11  theNDigisPerChamberPlots(),
12  chambers_(ps.getParameter<std::vector<std::string>>("chambers")),
13  chambersRun3_(ps.getParameter<std::vector<unsigned>>("chambersRun3")),
14  // variables
15  clctVars_(ps.getParameter<std::vector<std::string>>("clctVars")),
16  // binning
17  clctNBin_(ps.getParameter<std::vector<unsigned>>("clctNBin")),
18  clctMinBin_(ps.getParameter<std::vector<double>>("clctMinBin")),
19  clctMaxBin_(ps.getParameter<std::vector<double>>("clctMaxBin")),
20  isRun3_(ps.getParameter<bool>("isRun3")) {
21  const auto &pset = ps.getParameterSet("cscCLCT");
22  inputTag_ = pset.getParameter<edm::InputTag>("inputTag");
24 }
25 
27 
29  iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/CLCT/Occupancy/");
30 
31  theNDigisPerEventPlot = iBooker.book1D(
32  "CSCCLCTDigisPerEvent", "CLCT trigger primitives per event; Number of CLCTs; Entries", 100, 0, 100);
33  for (int i = 1; i <= 10; ++i) {
34  const std::string t2("CSCCLCTDigisPerChamber_" + CSCDetId::chamberName(i));
35  theNDigisPerChamberPlots[i - 1] = iBooker.book1D(
36  t2, "Number of CLCTs per chamber " + CSCDetId::chamberName(i) + ";Number of CLCTs per chamber;Entries", 4, 0, 4);
37  }
38 
39  // do not analyze Run-3 properties in Run-1 and Run-2 eras
40  if (!isRun3_) {
41  clctVars_.resize(5);
42  }
43 
44  // chamber type
45  for (unsigned iType = 0; iType < chambers_.size(); iType++) {
46  // consider CSC+ and CSC- separately
47  for (unsigned iEndcap = 0; iEndcap < 2; iEndcap++) {
48  const std::string eSign(iEndcap == 0 ? "+" : "-");
49  // clct variable
50  for (unsigned iVar = 0; iVar < clctVars_.size(); iVar++) {
51  if (std::find(chambersRun3_.begin(), chambersRun3_.end(), iType) == chambersRun3_.end()) {
52  if (iVar > 4)
53  continue;
54  }
55  const std::string key("clct_" + clctVars_[iVar]);
56  const std::string histName(key + "_" + chambers_[iType] + eSign);
57  const std::string histTitle(chambers_[iType] + eSign + " CLCT " + clctVars_[iVar]);
58  const unsigned iTypeCorrected(iEndcap == 0 ? iType : iType + chambers_.size());
59  chamberHistos[iTypeCorrected][key] =
60  iBooker.book1D(histName, histTitle, clctNBin_[iVar], clctMinBin_[iVar], clctMaxBin_[iVar]);
61  chamberHistos[iTypeCorrected][key]->getTH1()->SetMinimum(0);
62  }
63  }
64  }
65 }
66 
69  e.getByToken(clcts_Token_, clcts);
70  if (!clcts.isValid()) {
71  edm::LogError("CSCDigiDump") << "Cannot get CLCTs by label " << inputTag_.encode();
72  }
73 
74  unsigned nDigisPerEvent = 0;
75 
76  for (auto j = clcts->begin(); j != clcts->end(); j++) {
77  auto beginDigi = (*j).second.first;
78  auto endDigi = (*j).second.second;
79  const CSCDetId &detId((*j).first);
80  int chamberType = detId.iChamberType();
81  int nDigis = endDigi - beginDigi;
82  nDigisPerEvent += nDigis;
83  theNDigisPerChamberPlots[chamberType - 1]->Fill(nDigis);
84 
85  auto range = clcts->get((*j).first);
86  // 1=forward (+Z); 2=backward (-Z)
87  const unsigned typeCorrected(detId.endcap() == 1 ? chamberType - 2 : chamberType - 2 + chambers_.size());
88  for (auto clct = range.first; clct != range.second; clct++) {
89  if (clct->isValid()) {
90  chamberHistos[typeCorrected]["clct_pattern"]->Fill(clct->getPattern());
91  chamberHistos[typeCorrected]["clct_quality"]->Fill(clct->getQuality());
92  chamberHistos[typeCorrected]["clct_halfstrip"]->Fill(clct->getKeyStrip());
93  chamberHistos[typeCorrected]["clct_bend"]->Fill(clct->getBend());
94  chamberHistos[typeCorrected]["clct_bx"]->Fill(clct->getBX());
95  if (isRun3_) {
96  // ignore these fields for chambers that do not enable the Run-3 algorithm
97  if (std::find(chambersRun3_.begin(), chambersRun3_.end(), chamberType - 2) == chambersRun3_.end())
98  continue;
99  chamberHistos[typeCorrected]["clct_run3pattern"]->Fill(clct->getRun3Pattern());
100  chamberHistos[typeCorrected]["clct_quartstrip"]->Fill(clct->getKeyStrip(4));
101  chamberHistos[typeCorrected]["clct_eighthstrip"]->Fill(clct->getKeyStrip(8));
102  chamberHistos[typeCorrected]["clct_slope"]->Fill(clct->getSlope());
103  chamberHistos[typeCorrected]["clct_compcode"]->Fill(clct->getCompCode());
104  }
105  }
106  }
107  }
108  theNDigisPerEventPlot->Fill(nDigisPerEvent);
109 }
MonitorElement * theNDigisPerChamberPlots[10]
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
CSCCLCTDigiValidation(const edm::ParameterSet &ps, edm::ConsumesCollector &&iC)
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::string encode() const
Definition: InputTag.cc:159
const uint16_t range(const Frame &aFrame)
int endcap() const
Definition: CSCDetId.h:85
void Fill(long long x)
std::map< uint32_t, std::map< std::string, MonitorElement * > > chamberHistos
std::vector< double > clctMaxBin_
tuple key
prepare the HTCondor submission files and eventually submit them
unsigned short iChamberType() const
Definition: CSCDetId.h:96
void analyze(const edm::Event &, const edm::EventSetup &) override
bool isValid() const
Definition: HandleBase.h:70
std::vector< std::string > chambers_
std::string chamberName() const
Definition: CSCDetId.cc:92
std::vector< unsigned > chambersRun3_
void bookHistograms(DQMStore::IBooker &)
ParameterSet const & getParameterSet(std::string const &) const
MonitorElement * theNDigisPerEventPlot
std::vector< unsigned > clctNBin_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
virtual TH1 * getTH1() const
std::vector< double > clctMinBin_
edm::EDGetTokenT< CSCCLCTDigiCollection > clcts_Token_
std::vector< std::string > clctVars_