Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-25 23:40:03

0001 #ifndef SiStripMonitorTrack_H
0002 #define SiStripMonitorTrack_H
0003 
0004 // system include files
0005 #include <memory>
0006 #include <fstream>
0007 #include <iostream>
0008 #include <vector>
0009 #include <string>
0010 #include <unordered_set>
0011 
0012 // user include files
0013 #include "FWCore/Utilities/interface/EDGetToken.h"
0014 #include "FWCore/Framework/interface/Frameworkfwd.h"
0015 #include "FWCore/Framework/interface/Event.h"
0016 #include "FWCore/Framework/interface/MakerMacros.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 #include "FWCore/Utilities/interface/ESGetToken.h"
0019 #include "FWCore/Utilities/interface/InputTag.h"
0020 #include "FWCore/ServiceRegistry/interface/Service.h"
0021 
0022 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0023 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0024 #include "Geometry/CommonTopologies/interface/StripTopology.h"
0025 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
0026 
0027 #include "DataFormats/Common/interface/Handle.h"
0028 #include "DataFormats/Common/interface/DetSetVector.h"
0029 #include "DataFormats/Common/interface/DetSetNew.h"
0030 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0031 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0032 #include "DataFormats/TrackReco/interface/Track.h"
0033 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
0034 
0035 #include "RecoLocalTracker/SiStripClusterizer/interface/SiStripClusterInfo.h"
0036 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0037 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
0038 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
0039 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
0040 #include "CalibFormats/SiStripObjects/interface/SiStripGain.h"
0041 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
0042 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
0043 #include "DQMServices/Core/interface/DQMStore.h"
0044 
0045 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
0046 
0047 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0048 #include "CalibTracker/SiStripCommon/interface/TkDetMap.h"
0049 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0050 
0051 //******** Single include for the TkMap *************/
0052 #include "DQM/SiStripCommon/interface/TkHistoMap.h"
0053 //***************************************************/
0054 
0055 #include <DQMServices/Core/interface/DQMEDAnalyzer.h>
0056 
0057 class SiStripDCSStatus;
0058 class GenericTriggerEventFlag;
0059 
0060 //
0061 // class declaration
0062 //
0063 
0064 class SiStripMonitorTrack : public DQMEDAnalyzer {
0065 public:
0066   typedef TrackingRecHit::ConstRecHitPointer ConstRecHitPointer;
0067   enum RecHitType { Single = 0, Matched = 1, Projected = 2, Null = 3 };
0068   explicit SiStripMonitorTrack(const edm::ParameterSet&);
0069   ~SiStripMonitorTrack() override;
0070   void dqmBeginRun(const edm::Run& run, const edm::EventSetup&) override;
0071   void analyze(const edm::Event&, const edm::EventSetup&) override;
0072   void bookHistograms(DQMStore::IBooker&, edm::Run const&, const edm::EventSetup&) override;
0073 
0074 private:
0075   enum ClusterFlags { OffTrack, OnTrack };
0076 
0077   struct Det2MEs;
0078 
0079   //booking
0080   void book(DQMStore::IBooker&, const TrackerTopology* tTopo, const TkDetMap* tkDetMap);
0081   void bookModMEs(DQMStore::IBooker&, const uint32_t);
0082   void bookLayerMEs(DQMStore::IBooker&, const uint32_t, std::string&);
0083   void bookRing(DQMStore::IBooker&, const uint32_t, std::string&);
0084   MonitorElement* handleBookMEs(DQMStore::IBooker&, std::string&, std::string&, std::string&, std::string&);
0085   void bookRingMEs(DQMStore::IBooker&, const uint32_t, std::string&);
0086   void bookSubDetMEs(DQMStore::IBooker&, std::string& name);
0087   MonitorElement* bookME1D(DQMStore::IBooker&, const char*, const char*);
0088   MonitorElement* bookME2D(DQMStore::IBooker&, const char*, const char*);
0089   MonitorElement* bookME3D(DQMStore::IBooker&, const char*, const char*);
0090   MonitorElement* bookMEProfile(DQMStore::IBooker&, const char*, const char*);
0091   MonitorElement* bookMETrend(DQMStore::IBooker&, const char*);
0092   // internal evaluation of monitorables
0093   void AllClusters(const edm::Event& ev);
0094   void trackStudyFromTrack(edm::Handle<reco::TrackCollection> trackCollectionHandle,
0095                            const edm::DetSetVector<SiStripDigi>& digilist,
0096                            const edm::Event& ev);
0097   void trackStudyFromTrajectory(edm::Handle<reco::TrackCollection> trackCollectionHandle,
0098                                 const edm::DetSetVector<SiStripDigi>& digilist,
0099                                 const edm::Event& ev);
0100   void trajectoryStudy(const reco::Track& track,
0101                        const edm::DetSetVector<SiStripDigi>& digilist,
0102                        const edm::Event& ev,
0103                        bool track_ok);
0104   void trackStudy(const edm::Event& ev);
0105   bool trackFilter(const reco::Track& track);
0106   //  LocalPoint project(const GeomDet *det,const GeomDet* projdet,LocalPoint position,LocalVector trackdirection)const;
0107   void hitStudy(const edm::Event& ev,
0108                 const edm::DetSetVector<SiStripDigi>& digilist,
0109                 const ProjectedSiStripRecHit2D* projhit,
0110                 const SiStripMatchedRecHit2D* matchedhit,
0111                 const SiStripRecHit2D* hit2D,
0112                 const SiStripRecHit1D* hit1D,
0113                 LocalVector localMomentum,
0114                 const bool track_ok);
0115   bool clusterInfos(SiStripClusterInfo* cluster,
0116                     const uint32_t detid,
0117                     enum ClusterFlags flags,
0118                     bool track_ok,
0119                     LocalVector LV,
0120                     const Det2MEs& MEs,
0121                     const TrackerTopology* tTopo,
0122                     const SiStripGain* stripGain,
0123                     const SiStripQuality* stripQuality,
0124                     const edm::DetSetVector<SiStripDigi>& digilist,
0125                     float clustZ,
0126                     float clustPhi);
0127   template <class T>
0128   void RecHitInfo(const T* tkrecHit,
0129                   LocalVector LV,
0130                   const edm::DetSetVector<SiStripDigi>& digilist,
0131                   const edm::Event& ev,
0132                   bool track_ok);
0133 
0134   bool fillControlViewHistos(const edm::Event& ev);
0135   void return2DME(MonitorElement* input1, MonitorElement* input2, int binx, int biny, double value);
0136 
0137   // fill monitorables
0138   //  void fillModMEs(SiStripClusterInfo* cluster,std::string name, float cos, const uint32_t detid, const LocalVector LV);
0139   //  void fillMEs(SiStripClusterInfo*,const uint32_t detid, float,enum ClusterFlags,  const LocalVector LV, const Det2MEs& MEs);
0140 
0141   inline void fillME(MonitorElement* ME, float value1) {
0142     if (ME != nullptr)
0143       ME->Fill(value1);
0144   }
0145   inline void fillME(MonitorElement* ME, float value1, float value2) {
0146     if (ME != nullptr)
0147       ME->Fill(value1, value2);
0148   }
0149   inline void fillME(MonitorElement* ME, float value1, float value2, float value3) {
0150     if (ME != nullptr)
0151       ME->Fill(value1, value2, value3);
0152   }
0153   inline void fillME(MonitorElement* ME, float value1, float value2, float value3, float value4) {
0154     if (ME != nullptr)
0155       ME->Fill(value1, value2, value3, value4);
0156   }
0157 
0158   Det2MEs findMEs(const TrackerTopology* tTopo, const uint32_t detid);
0159 
0160   // ----------member data ---------------------------
0161 private:
0162   edm::ParameterSet conf_;
0163   std::string histname;
0164   LocalVector LV;
0165   float iOrbitSec, iLumisection;
0166 
0167   std::string topFolderName_;
0168 
0169   SiStripClusterInfo siStripClusterInfo_;
0170 
0171   //******* TkHistoMaps*/
0172   std::unique_ptr<TkHistoMap> tkhisto_StoNCorrOnTrack, tkhisto_NumOnTrack, tkhisto_NumOffTrack;
0173   std::unique_ptr<TkHistoMap> tkhisto_ClChPerCMfromOrigin, tkhisto_ClChPerCMfromTrack;
0174   std::unique_ptr<TkHistoMap> tkhisto_NumMissingHits, tkhisto_NumberInactiveHits, tkhisto_NumberValidHits;
0175   std::unique_ptr<TkHistoMap> tkhisto_NoiseOnTrack, tkhisto_NoiseOffTrack, tkhisto_ClusterWidthOnTrack,
0176       tkhisto_ClusterWidthOffTrack;
0177   //******** TkHistoMaps*/
0178   int numTracks;
0179 
0180   struct ModMEs {
0181     MonitorElement* ClusterStoNCorr = nullptr;
0182     MonitorElement* ClusterGain = nullptr;
0183     MonitorElement* ClusterCharge = nullptr;
0184     MonitorElement* ClusterChargeRaw = nullptr;
0185     MonitorElement* ClusterChargeCorr = nullptr;
0186     MonitorElement* ClusterWidth = nullptr;
0187     MonitorElement* ClusterPos = nullptr;
0188     MonitorElement* ClusterPGV = nullptr;
0189     MonitorElement* ClusterChargePerCMfromTrack = nullptr;
0190     MonitorElement* ClusterChargePerCMfromOrigin = nullptr;
0191   };
0192 
0193   struct LayerMEs {
0194     MonitorElement* ClusterGain = nullptr;
0195     MonitorElement* ClusterStoNCorrOnTrack = nullptr;
0196     MonitorElement* ClusterChargeCorrOnTrack = nullptr;
0197     MonitorElement* ClusterChargeOnTrack = nullptr;
0198     MonitorElement* ClusterChargeOffTrack = nullptr;
0199     MonitorElement* ClusterChargeRawOnTrack = nullptr;
0200     MonitorElement* ClusterChargeRawOffTrack = nullptr;
0201     MonitorElement* ClusterNoiseOnTrack = nullptr;
0202     MonitorElement* ClusterNoiseOffTrack = nullptr;
0203     MonitorElement* ClusterWidthOnTrack = nullptr;
0204     MonitorElement* ClusterWidthOffTrack = nullptr;
0205     MonitorElement* ClusterPosOnTrack = nullptr;
0206     MonitorElement* ClusterPosOnTrack2D = nullptr;
0207     MonitorElement* ClusterPosOffTrack = nullptr;
0208     MonitorElement* ClusterChargePerCMfromTrack = nullptr;
0209     MonitorElement* ClusterChargePerCMfromOriginOnTrack = nullptr;
0210     MonitorElement* ClusterChargePerCMfromOriginOffTrack = nullptr;
0211   };
0212   struct RingMEs {
0213     MonitorElement* ClusterGain = nullptr;
0214     MonitorElement* ClusterStoNCorrOnTrack = nullptr;
0215     MonitorElement* ClusterChargeCorrOnTrack = nullptr;
0216     MonitorElement* ClusterChargeOnTrack = nullptr;
0217     MonitorElement* ClusterChargeOffTrack = nullptr;
0218     MonitorElement* ClusterChargeRawOnTrack = nullptr;
0219     MonitorElement* ClusterChargeRawOffTrack = nullptr;
0220     MonitorElement* ClusterNoiseOnTrack = nullptr;
0221     MonitorElement* ClusterNoiseOffTrack = nullptr;
0222     MonitorElement* ClusterWidthOnTrack = nullptr;
0223     MonitorElement* ClusterWidthOffTrack = nullptr;
0224     MonitorElement* ClusterPosOnTrack = nullptr;
0225     MonitorElement* ClusterPosOnTrack2D = nullptr;
0226     MonitorElement* ClusterPosOffTrack = nullptr;
0227     MonitorElement* ClusterChargePerCMfromTrack = nullptr;
0228     MonitorElement* ClusterChargePerCMfromOriginOnTrack = nullptr;
0229     MonitorElement* ClusterChargePerCMfromOriginOffTrack = nullptr;
0230   };
0231   struct SubDetMEs {
0232     int totNClustersOnTrack = 0;
0233     int totNClustersOffTrack = 0;
0234     MonitorElement* nClustersOnTrack = nullptr;
0235     MonitorElement* nClustersTrendOnTrack = nullptr;
0236     MonitorElement* nClustersOffTrack = nullptr;
0237     MonitorElement* nClustersTrendOffTrack = nullptr;
0238     MonitorElement* ClusterGain = nullptr;
0239     MonitorElement* ClusterStoNCorrOnTrack = nullptr;
0240     MonitorElement* ClusterStoNCorrThinOnTrack = nullptr;
0241     MonitorElement* ClusterStoNCorrThickOnTrack = nullptr;
0242     MonitorElement* ClusterChargeCorrOnTrack = nullptr;
0243     MonitorElement* ClusterChargeCorrThinOnTrack = nullptr;
0244     MonitorElement* ClusterChargeCorrThickOnTrack = nullptr;
0245     MonitorElement* ClusterChargeOnTrack = nullptr;
0246     MonitorElement* ClusterChargeOffTrack = nullptr;
0247     MonitorElement* ClusterChargeRawOnTrack = nullptr;
0248     MonitorElement* ClusterChargeRawOffTrack = nullptr;
0249     MonitorElement* ClusterStoNOffTrack = nullptr;
0250     MonitorElement* ClusterChargePerCMfromTrack = nullptr;
0251     MonitorElement* ClusterChargePerCMfromOriginOnTrack = nullptr;
0252     MonitorElement* ClusterChargePerCMfromOriginOffTrack = nullptr;
0253   };
0254   std::map<std::string, ModMEs> ModMEsMap;
0255   std::map<std::string, LayerMEs> LayerMEsMap;
0256   std::map<std::string, RingMEs> RingMEsMap;
0257   std::map<std::string, SubDetMEs> SubDetMEsMap;
0258 
0259   struct Det2MEs {
0260     struct LayerMEs* iLayer;
0261     struct RingMEs* iRing;
0262     struct SubDetMEs* iSubdet;
0263   };
0264 
0265   edm::ParameterSet Parameters;
0266   edm::InputTag Cluster_src_;
0267 
0268   edm::EDGetTokenT<edm::DetSetVector<SiStripDigi> > digiToken_;
0269   edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > clusterToken_;
0270   edm::EDGetTokenT<reco::TrackCollection> trackToken_;
0271 
0272   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeometryToken_;
0273   edm::ESGetToken<SiStripDetCabling, SiStripDetCablingRcd> siStripDetCablingToken_;
0274   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> trackerTopologyRunToken_;
0275   edm::ESGetToken<TkDetMap, TrackerTopologyRcd> tkDetMapToken_;
0276   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> trackerTopologyEventToken_;
0277 
0278   const TrackerGeometry* tkgeom_ = nullptr;
0279   const SiStripDetCabling* siStripDetCabling_ = nullptr;
0280   const TrackerTopology* trackerTopology_ = nullptr;
0281 
0282   bool Mod_On_;
0283   bool Trend_On_;
0284   bool OffHisto_On_;
0285   bool HistoFlag_On_;
0286   bool ring_flag;
0287   bool TkHistoMap_On_;
0288   bool clchCMoriginTkHmap_On_;
0289 
0290   std::string TrackProducer_;
0291   std::string TrackLabel_;
0292 
0293   std::unordered_set<const SiStripCluster*> vPSiStripCluster;
0294   bool tracksCollection_in_EventTree;
0295   bool trackAssociatorCollection_in_EventTree;
0296   edm::EventNumber_t eventNb;
0297   int firstEvent;
0298 
0299   bool applyClusterQuality_;
0300   double sToNLowerLimit_;
0301   double sToNUpperLimit_;
0302   double widthLowerLimit_;
0303   double widthUpperLimit_;
0304 
0305   SiStripDCSStatus* dcsStatus_;
0306   GenericTriggerEventFlag* genTriggerEventFlag_;
0307   SiStripFolderOrganizer folderOrganizer_;
0308 
0309   // control view plots
0310   MonitorElement* ClusterStoNCorr_OnTrack_TIBTID = nullptr;
0311   MonitorElement* ClusterStoNCorr_OnTrack_TOB = nullptr;
0312   MonitorElement* ClusterStoNCorr_OnTrack_TECM = nullptr;
0313   MonitorElement* ClusterStoNCorr_OnTrack_TECP = nullptr;
0314   MonitorElement* ClusterStoNCorr_OnTrack_FECCratevsFECSlot = nullptr;
0315   MonitorElement* ClusterStoNCorr_OnTrack_FECSlotVsFECRing_TIBTID = nullptr;
0316   MonitorElement* ClusterStoNCorr_OnTrack_FECSlotVsFECRing_TOB = nullptr;
0317   MonitorElement* ClusterStoNCorr_OnTrack_FECSlotVsFECRing_TECM = nullptr;
0318   MonitorElement* ClusterStoNCorr_OnTrack_FECSlotVsFECRing_TECP = nullptr;
0319 
0320   MonitorElement* ClusterCount_OnTrack_FECCratevsFECSlot = nullptr;
0321   MonitorElement* ClusterCount_OnTrack_FECSlotVsFECRing_TIBTID = nullptr;
0322   MonitorElement* ClusterCount_OnTrack_FECSlotVsFECRing_TOB = nullptr;
0323   MonitorElement* ClusterCount_OnTrack_FECSlotVsFECRing_TECM = nullptr;
0324   MonitorElement* ClusterCount_OnTrack_FECSlotVsFECRing_TECP = nullptr;
0325 };
0326 #endif