Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:56

0001 #ifndef Alignment_HIPAlignmentAlgorithm_HIPMonitorConfig_h
0002 #define Alignment_HIPAlignmentAlgorithm_HIPMonitorConfig_h
0003 
0004 #include <vector>
0005 #include <string>
0006 #include "TTree.h"
0007 #include <FWCore/ParameterSet/interface/ParameterSet.h>
0008 #include <CondFormats/Alignment/interface/Definitions.h>
0009 
0010 class HIPMonitorVariables {
0011 protected:
0012   TTree* tree;
0013 
0014 public:
0015   HIPMonitorVariables() : tree(nullptr) {}
0016   virtual ~HIPMonitorVariables() {}
0017 
0018   void setTree(TTree* tree_) { tree = tree_; }
0019   virtual void bookBranches() = 0;
0020   virtual void fill() = 0;
0021 };
0022 class HIPTrackMonitorVariables : public HIPMonitorVariables {
0023 public:
0024   const int maxNEvents;
0025   const int maxTracksRcd;
0026   int nEvents;
0027   int nTracks;
0028   int m_Ntracks;
0029   std::vector<float> m_Pt, m_Eta, m_Phi, m_Chi2n, m_P, m_d0, m_dz, m_wt;
0030   std::vector<int> m_Nhits, m_nhPXB, m_nhPXF, m_nhTIB, m_nhTOB, m_nhTID, m_nhTEC;
0031 
0032   HIPTrackMonitorVariables(int maxNEvents_ = -1, int maxTracksRcd_ = -1)
0033       : HIPMonitorVariables(),
0034         maxNEvents(maxNEvents_),
0035         maxTracksRcd(maxTracksRcd_),
0036         nEvents(0),
0037         nTracks(0),
0038         m_Ntracks(0) {}
0039 
0040   void bookBranches() override;
0041   void fill() override;
0042 
0043 protected:
0044   void resetPerEvent() {
0045     // Do not reset nTracks
0046     m_Ntracks = 0;
0047     m_Pt.clear();
0048     m_Eta.clear();
0049     m_Phi.clear();
0050     m_Chi2n.clear();
0051     m_P.clear();
0052     m_d0.clear();
0053     m_dz.clear();
0054     m_wt.clear();
0055     m_Nhits.clear();
0056     m_nhPXB.clear();
0057     m_nhPXF.clear();
0058     m_nhTIB.clear();
0059     m_nhTOB.clear();
0060     m_nhTID.clear();
0061     m_nhTEC.clear();
0062   }
0063   void resizeVectors(int NewSize) {
0064     m_Pt.resize(NewSize);
0065     m_Eta.resize(NewSize);
0066     m_Phi.resize(NewSize);
0067     m_Chi2n.resize(NewSize);
0068     m_P.resize(NewSize);
0069     m_d0.resize(NewSize);
0070     m_dz.resize(NewSize);
0071     m_wt.resize(NewSize);
0072     m_Nhits.resize(NewSize);
0073     m_nhPXB.resize(NewSize);
0074     m_nhPXF.resize(NewSize);
0075     m_nhTIB.resize(NewSize);
0076     m_nhTOB.resize(NewSize);
0077     m_nhTID.resize(NewSize);
0078     m_nhTEC.resize(NewSize);
0079   }
0080 };
0081 class HIPHitMonitorVariables : public HIPMonitorVariables {
0082 public:
0083   const int maxHitsRcd;
0084   int nHits;
0085 
0086   bool m_hasHitProb;
0087   float m_sinTheta, m_hitwt, m_angle, m_probXY, m_probQ;
0088   unsigned int m_rawQualityWord;
0089   align::ID m_detId;
0090 
0091 protected:
0092   void resetPerHit() {
0093     m_hasHitProb = false;
0094     m_sinTheta = 0;
0095     m_hitwt = 1;
0096     m_angle = 0;
0097     m_probXY = -1;
0098     m_probQ = -1;
0099     m_rawQualityWord = 9999;
0100     m_detId = 0;
0101   }
0102 
0103 public:
0104   HIPHitMonitorVariables(int maxHitsRcd_ = -1) : HIPMonitorVariables(), maxHitsRcd(maxHitsRcd_), nHits(0) {
0105     resetPerHit();
0106   }
0107 
0108   void bookBranches() override;
0109   void fill() override;
0110 };
0111 
0112 struct HIPMonitorConfig {
0113   const edm::ParameterSet cfgMonitor;
0114 
0115   const std::string outfilecore;
0116 
0117   const int maxEventsPerJob;
0118 
0119   const bool fillTrackMonitoring;
0120   const int maxTracks;
0121   HIPTrackMonitorVariables trackmonitorvars;
0122 
0123   const bool fillTrackHitMonitoring;
0124   const int maxHits;
0125   HIPHitMonitorVariables hitmonitorvars;
0126 
0127   std::string outfile;
0128 
0129   int eventCounter;
0130   int hitCounter;
0131 
0132   HIPMonitorConfig(const edm::ParameterSet& cfg);
0133   HIPMonitorConfig(const HIPMonitorConfig& other);
0134   ~HIPMonitorConfig() {}
0135 
0136   bool checkNevents();
0137   bool checkNhits();
0138 };
0139 
0140 #endif