Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:33:39

0001 // -*- C++ -*-
0002 //
0003 /**\class SiOuterTracker Phase2OTValidateTTStub.cc
0004  Description: [one line class summary]
0005 
0006  Implementation:
0007      [Notes on implementation]
0008 */
0009 //
0010 // Original Author:
0011 //
0012 
0013 // system include files
0014 #include <memory>
0015 #include <numeric>
0016 #include <vector>
0017 
0018 // user include files
0019 #include "FWCore/Framework/interface/ESHandle.h"
0020 #include "FWCore/Framework/interface/Event.h"
0021 #include "FWCore/Framework/interface/Frameworkfwd.h"
0022 #include "FWCore/Framework/interface/MakerMacros.h"
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 #include "FWCore/ServiceRegistry/interface/Service.h"
0026 #include "FWCore/Utilities/interface/EDGetToken.h"
0027 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0029 
0030 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0031 #include "DataFormats/L1TrackTrigger/interface/TTTypes.h"
0032 #include "DataFormats/L1TrackTrigger/interface/TTStub.h"
0033 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0034 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0035 
0036 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0037 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0038 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0039 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
0040 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0041 
0042 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0043 #include "DQMServices/Core/interface/DQMStore.h"
0044 
0045 class Phase2OTValidateTTStub : public DQMEDAnalyzer {
0046 public:
0047   explicit Phase2OTValidateTTStub(const edm::ParameterSet &);
0048   ~Phase2OTValidateTTStub() override;
0049   void analyze(const edm::Event &, const edm::EventSetup &) override;
0050   void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0051   void dqmBeginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) override;
0052   static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
0053   // TTStub stacks
0054   // Global position of the stubs
0055   MonitorElement *Stub_RZ = nullptr;  // TTStub #rho vs. z
0056 
0057 private:
0058   edm::ParameterSet conf_;
0059   edm::EDGetTokenT<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>> tagTTStubsToken_;
0060   std::string topFolderName_;
0061   const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;
0062   const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> topoToken_;
0063   const TrackerGeometry *tkGeom_ = nullptr;
0064   const TrackerTopology *tTopo_ = nullptr;
0065 };
0066 
0067 // constructors and destructor
0068 Phase2OTValidateTTStub::Phase2OTValidateTTStub(const edm::ParameterSet &iConfig)
0069     : conf_(iConfig),
0070       geomToken_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord, edm::Transition::BeginRun>()),
0071       topoToken_(esConsumes<TrackerTopology, TrackerTopologyRcd, edm::Transition::BeginRun>()) {
0072   // now do what ever initialization is needed
0073   topFolderName_ = conf_.getParameter<std::string>("TopFolderName");
0074   tagTTStubsToken_ =
0075       consumes<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>>(conf_.getParameter<edm::InputTag>("TTStubs"));
0076 }
0077 
0078 Phase2OTValidateTTStub::~Phase2OTValidateTTStub() {
0079   // do anything here that needs to be done at desctruction time
0080   // (e.g. close files, deallocate resources etc.)
0081 }
0082 
0083 void Phase2OTValidateTTStub::dqmBeginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) {
0084   tkGeom_ = &(iSetup.getData(geomToken_));
0085   tTopo_ = &(iSetup.getData(topoToken_));
0086 }
0087 // member functions
0088 
0089 // ------------ method called for each event  ------------
0090 void Phase2OTValidateTTStub::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
0091   /// Track Trigger Stubs
0092   edm::Handle<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>> Phase2TrackerDigiTTStubHandle;
0093   iEvent.getByToken(tagTTStubsToken_, Phase2TrackerDigiTTStubHandle);
0094 
0095   /// Loop over input Stubs
0096   typename edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>::const_iterator inputIter;
0097   typename edmNew::DetSet<TTStub<Ref_Phase2TrackerDigi_>>::const_iterator contentIter;
0098   // Adding protection
0099   if (!Phase2TrackerDigiTTStubHandle.isValid())
0100     return;
0101 
0102   for (inputIter = Phase2TrackerDigiTTStubHandle->begin(); inputIter != Phase2TrackerDigiTTStubHandle->end();
0103        ++inputIter) {
0104     for (contentIter = inputIter->begin(); contentIter != inputIter->end(); ++contentIter) {
0105       /// Make reference stub
0106       edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>, TTStub<Ref_Phase2TrackerDigi_>> tempStubRef =
0107           edmNew::makeRefTo(Phase2TrackerDigiTTStubHandle, contentIter);
0108 
0109       /// Get det ID (place of the stub)
0110       //  tempStubRef->getDetId() gives the stackDetId, not rawId
0111       DetId detIdStub = tkGeom_->idToDet((tempStubRef->clusterRef(0))->getDetId())->geographicalId();
0112 
0113       /// Get trigger displacement/offset
0114       //double rawBend = tempStubRef->rawBend();
0115       //double bendOffset = tempStubRef->bendOffset();
0116 
0117       /// Define position stub by position inner cluster
0118       MeasurementPoint mp = (tempStubRef->clusterRef(0))->findAverageLocalCoordinates();
0119       const GeomDet *theGeomDet = tkGeom_->idToDet(detIdStub);
0120       Global3DPoint posStub = theGeomDet->surface().toGlobal(theGeomDet->topology().localPosition(mp));
0121 
0122       Stub_RZ->Fill(posStub.z(), posStub.perp());
0123     }
0124   }
0125 }  // end of method
0126 
0127 // ------------ method called when starting to processes a run  ------------
0128 void Phase2OTValidateTTStub::bookHistograms(DQMStore::IBooker &iBooker,
0129                                             edm::Run const &run,
0130                                             edm::EventSetup const &es) {
0131   std::string HistoName;
0132   iBooker.setCurrentFolder(topFolderName_);
0133   edm::ParameterSet psTTStub_RZ = conf_.getParameter<edm::ParameterSet>("TH2TTStub_RZ");
0134   HistoName = "Stub_RZ";
0135   Stub_RZ = iBooker.book2D(HistoName,
0136                            HistoName,
0137                            psTTStub_RZ.getParameter<int32_t>("Nbinsx"),
0138                            psTTStub_RZ.getParameter<double>("xmin"),
0139                            psTTStub_RZ.getParameter<double>("xmax"),
0140                            psTTStub_RZ.getParameter<int32_t>("Nbinsy"),
0141                            psTTStub_RZ.getParameter<double>("ymin"),
0142                            psTTStub_RZ.getParameter<double>("ymax"));
0143 }
0144 
0145 void Phase2OTValidateTTStub::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
0146   // Phase2OTValidateTTStub
0147   edm::ParameterSetDescription desc;
0148   {
0149     edm::ParameterSetDescription psd0;
0150     psd0.add<int>("Nbinsx", 900);
0151     psd0.add<double>("xmax", 300);
0152     psd0.add<double>("xmin", -300);
0153     psd0.add<int>("Nbinsy", 900);
0154     psd0.add<double>("ymax", 120);
0155     psd0.add<double>("ymin", 0);
0156     desc.add<edm::ParameterSetDescription>("TH2TTStub_RZ", psd0);
0157   }
0158   desc.add<std::string>("TopFolderName", "TrackerPhase2OTStubV");
0159   desc.add<edm::InputTag>("TTStubs", edm::InputTag("TTStubsFromPhase2TrackerDigis", "StubAccepted"));
0160   descriptions.add("Phase2OTValidateTTStub", desc);
0161   // or use the following to generate the label from the module's C++ type
0162   //descriptions.addWithDefaultLabel(desc);
0163 }
0164 DEFINE_FWK_MODULE(Phase2OTValidateTTStub);