Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-04-29 23:10:16

0001 #ifndef Vx3DHLTAnalyzer_H
0002 #define Vx3DHLTAnalyzer_H
0003 
0004 /*
0005   \File Vx3DHLTAnalyzer.h
0006   \Display Beam-spot monitor entirely based on pixel detector information
0007            the monitoring is based on a 3D fit to the vertex cloud
0008   \Author Mauro Dinardo
0009   \Version $ Revision: 3.5 $
0010   \Date $ Date: 2010/23/02 13:15:00 $
0011 */
0012 
0013 #include <memory>
0014 
0015 #include "FWCore/Framework/interface/Event.h"
0016 #include "FWCore/Framework/interface/MakerMacros.h"
0017 
0018 #include "DQMServices/Core/interface/DQMStore.h"
0019 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0020 
0021 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
0022 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0023 #include "DataFormats/VertexReco/interface/Vertex.h"
0024 
0025 #include <TText.h>
0026 
0027 #include <iostream>
0028 #include <fstream>
0029 #include <vector>
0030 
0031 // #################
0032 // # Fit variables #
0033 // #################
0034 #define DIM 3
0035 typedef struct {
0036   double x;
0037   double y;
0038   double z;
0039   double Covariance[DIM][DIM];
0040 } VertexType;
0041 
0042 class Vx3DHLTAnalyzer : public DQMOneLumiEDAnalyzer<> {
0043 public:
0044   Vx3DHLTAnalyzer(const edm::ParameterSet&);
0045   ~Vx3DHLTAnalyzer() override;
0046 
0047 protected:
0048   double Gauss3DFunc(const double* par);
0049 
0050 private:
0051   void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0052   void dqmBeginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& iSetup) override;
0053   void dqmEndLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& iSetup) override;
0054   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0055 
0056   unsigned int HitCounter(const edm::Event& iEvent);
0057   std::string formatTime(const time_t& t);
0058   int MyFit(std::vector<double>* vals);
0059   void reset(std::string ResetType);
0060   void writeToFile(std::vector<double>* vals,
0061                    edm::TimeValue_t BeginTimeOfFit,
0062                    edm::TimeValue_t EndTimeOfFit,
0063                    unsigned int BeginLumiOfFit,
0064                    unsigned int EndLumiOfFit,
0065                    int dataType);
0066   void printFitParams(const std::vector<double>& fitResults);
0067 
0068   // #######################
0069   // # cfg file parameters #
0070   // #######################
0071   edm::EDGetTokenT<reco::VertexCollection> vertexCollection;
0072   edm::EDGetTokenT<SiPixelRecHitCollection> pixelHitCollection;
0073   bool debugMode;
0074   bool dataFromFit;
0075   unsigned int nLumiFit;
0076   unsigned int maxLumiIntegration;
0077   unsigned int nLumiXaxisRange;
0078   unsigned int minNentries;
0079   double xRange;
0080   double xStep;
0081   double yRange;
0082   double yStep;
0083   double zRange;
0084   double zStep;
0085   double VxErrCorr;  // Coefficient to compensate the under-estimation of the vertex errors
0086   double minVxDoF;
0087   double minVxWgt;
0088   std::string fileName;
0089 
0090   // ##############
0091   // # Histograms #
0092   // ##############
0093   MonitorElement* mXlumi;
0094   MonitorElement* mYlumi;
0095   MonitorElement* mZlumi;
0096 
0097   MonitorElement* sXlumi;
0098   MonitorElement* sYlumi;
0099   MonitorElement* sZlumi;
0100 
0101   MonitorElement* dxdzlumi;
0102   MonitorElement* dydzlumi;
0103 
0104   MonitorElement* Vx_X;
0105   MonitorElement* Vx_Y;
0106   MonitorElement* Vx_Z;
0107 
0108   MonitorElement* Vx_ZX;
0109   MonitorElement* Vx_ZY;
0110   MonitorElement* Vx_XY;
0111 
0112   MonitorElement* Vx_X_Fit;
0113   MonitorElement* Vx_Y_Fit;
0114   MonitorElement* Vx_Z_Fit;
0115 
0116   MonitorElement* Vx_X_Cum;
0117   MonitorElement* Vx_Y_Cum;
0118   MonitorElement* Vx_Z_Cum;
0119 
0120   MonitorElement* Vx_ZX_Cum;
0121   MonitorElement* Vx_ZY_Cum;
0122   MonitorElement* Vx_XY_Cum;
0123 
0124   MonitorElement* goodVxCounter;
0125   MonitorElement* hitCounter;
0126   MonitorElement* statusCounter;
0127 
0128   MonitorElement* reportSummary;
0129   MonitorElement* reportSummaryMap;
0130 
0131   MonitorElement* fitResults;
0132 
0133   // ######################
0134   // # Internal variables #
0135   // ######################
0136   std::ofstream outputFile;
0137   std::ofstream outputDebugFile;
0138   edm::TimeValue_t beginTimeOfFit;
0139   edm::TimeValue_t endTimeOfFit;
0140   unsigned int runNumber;
0141   unsigned int lumiCounter;
0142   unsigned int totalHits;
0143   unsigned int numberGoodFits;
0144   unsigned int numberFits;
0145   unsigned int beginLumiOfFit;
0146   unsigned int endLumiOfFit;
0147   unsigned int lastLumiOfFit;
0148   unsigned int nParams;
0149   bool internalDebug;
0150 
0151   std::vector<VertexType> Vertices;
0152   bool considerVxCovariance;
0153   unsigned int counterVx;   // Counts the number of vertices taken into account for the fit
0154   double maxTransRadius;    // Max transverse radius in which the vertices must be [cm]
0155   double maxLongLength;     // Max longitudinal length in which the vertices must be [cm]
0156   double xPos, yPos, zPos;  // x,y,z approximate positions of the beam spot
0157   double pi;
0158 };
0159 
0160 #endif