Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:48

0001 #include "DataFormats/Common/interface/Handle.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "Validation/MuonCSCDigis/interface/CSCWireDigiValidation.h"
0004 
0005 #include "DQMServices/Core/interface/DQMStore.h"
0006 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
0007 #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h"
0008 
0009 CSCWireDigiValidation::CSCWireDigiValidation(const edm::ParameterSet &ps, edm::ConsumesCollector &&iC)
0010     : CSCBaseValidation(ps), theTimeBinPlots(), theNDigisPerLayerPlots() {
0011   const auto &pset = ps.getParameterSet("cscWireDigi");
0012   inputTag_ = pset.getParameter<edm::InputTag>("inputTag");
0013   wires_Token_ = iC.consumes<CSCWireDigiCollection>(inputTag_);
0014 }
0015 
0016 CSCWireDigiValidation::~CSCWireDigiValidation() {}
0017 
0018 void CSCWireDigiValidation::bookHistograms(DQMStore::IBooker &iBooker) {
0019   iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/Wire/Occupancy/");
0020   theNDigisPerEventPlot =
0021       iBooker.book1D("CSCWireDigisPerEvent", "CSC Wire Digis per event;CSC Wire Digis per event;Entries", 100, 0, 100);
0022   for (int i = 1; i <= 10; ++i) {
0023     const std::string t1("CSCWireDigiTime_" + CSCDetId::chamberName(i));
0024     const std::string t2("CSCWireDigisPerLayer_" + CSCDetId::chamberName(i));
0025     theTimeBinPlots[i - 1] =
0026         iBooker.book1D(t1, "Wire Time Bin " + CSCDetId::chamberName(i) + ";Wire Time Bin; Entries", 16, 0, 16);
0027     theNDigisPerLayerPlots[i - 1] = iBooker.book1D(
0028         t2, "Number of Wire Digis " + CSCDetId::chamberName(i) + ";Number of Wire Digis; Entries", 100, 0, 20);
0029   }
0030 
0031   iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/Wire/Resolution/");
0032   for (int i = 1; i <= 10; ++i) {
0033     const std::string t3("CSCWireDigiResolution_" + CSCDetId::chamberName(i));
0034     theResolutionPlots[i - 1] = iBooker.book1D(
0035         t3,
0036         "Wire Y Position Resolution " + CSCDetId::chamberName(i) + ";Wire Y Position Resolution [cm]; Entries",
0037         100,
0038         -10,
0039         10);
0040   }
0041 }
0042 
0043 void CSCWireDigiValidation::analyze(const edm::Event &e, const edm::EventSetup &) {
0044   edm::Handle<CSCWireDigiCollection> wires;
0045 
0046   e.getByToken(wires_Token_, wires);
0047 
0048   if (!wires.isValid()) {
0049     edm::LogError("CSCWireDigiValidation") << "Cannot get wires by label " << inputTag_.encode();
0050   }
0051 
0052   unsigned nDigisPerEvent = 0;
0053 
0054   for (auto j = wires->begin(); j != wires->end(); j++) {
0055     auto beginDigi = (*j).second.first;
0056     auto endDigi = (*j).second.second;
0057     int detId = (*j).first.rawId();
0058 
0059     const CSCLayer *layer = findLayer(detId);
0060     int chamberType = layer->chamber()->specs()->chamberType();
0061     int nDigis = endDigi - beginDigi;
0062     nDigisPerEvent += nDigis;
0063     theNDigisPerLayerPlots[chamberType - 1]->Fill(nDigis);
0064 
0065     for (auto digiItr = beginDigi; digiItr != endDigi; ++digiItr) {
0066       theTimeBinPlots[chamberType - 1]->Fill(digiItr->getTimeBin());
0067     }
0068 
0069     if (doSim_) {
0070       const edm::PSimHitContainer &simHits = theSimHitMap->hits(detId);
0071       if (nDigis == 1 && simHits.size() == 1) {
0072         plotResolution(simHits[0], *beginDigi, layer, chamberType);
0073       }
0074     }
0075   }
0076 
0077   theNDigisPerEventPlot->Fill(nDigisPerEvent);
0078 }
0079 
0080 void CSCWireDigiValidation::plotResolution(const PSimHit &hit,
0081                                            const CSCWireDigi &digi,
0082                                            const CSCLayer *layer,
0083                                            int chamberType) {
0084   double hitX = hit.localPosition().x();
0085   double hitY = hit.localPosition().y();
0086   double digiY = layer->geometry()->yOfWireGroup(digi.getWireGroup(), hitX);
0087   theResolutionPlots[chamberType - 1]->Fill(digiY - hitY);
0088 }