CMS 3D CMS Logo

PVFitter.h
Go to the documentation of this file.
1 #ifndef PVFitter_H
2 #define PVFitter_H
3 
24 
27 
29 
30 // ROOT
31 #include "TFile.h"
32 #include "TTree.h"
33 #include "TH2F.h"
34 
35 #include <fstream>
36 
37 namespace edm {
38  class ConsumesCollector;
39 }
40 
41 namespace reco {
42  class Vertex;
43 }
44 
45 class PVFitter {
46 public:
47  PVFitter() {}
48  PVFitter(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iColl);
49  PVFitter(const edm::ParameterSet& iConfig, edm::ConsumesCollector& iColl);
50  virtual ~PVFitter();
51 
53 
54  void initialize(const edm::ParameterSet& iConfig, edm::ConsumesCollector& iColl);
55  void readEvent(const edm::Event& iEvent);
56  void setTree(TTree* tree);
57 
58  double getWidthX() { return fwidthX; }
59  double getWidthY() { return fwidthY; }
60  double getWidthZ() { return fwidthZ; }
61  double getWidthXerr() { return fwidthXerr; }
62  double getWidthYerr() { return fwidthYerr; }
63  double getWidthZerr() { return fwidthZerr; }
64  //ssc
65  std::vector<BeamSpotFitPVData> getpvStore() { return pvStore_; }
66 
68  bool runBXFitter();
69  bool runFitter();
71  void resetRefTime() { freftime[0] = freftime[1] = 0; }
72  //ssc
73  void setRefTime(std::time_t t0, std::time_t t1) {
74  freftime[0] = t0;
75  freftime[1] = t1;
76  }
77  void setFitLSRange(int ls0, int ls1) {
78  fbeginLumiOfFit = ls0;
79  fendLumiOfFit = ls1;
80  }
81 
82  void dumpTxtFile();
83  void resetAll() {
84  resetLSRange();
85  resetRefTime();
86  pvStore_.clear();
87  bxMap_.clear();
88  dynamicQualityCut_ = 1.e30;
89  hPVx->Reset();
90  hPVy->Reset();
92  fbspotMap.clear();
93  };
95  std::map<int, reco::BeamSpot> getBeamSpotMap() { return fbspotMap; }
97  int* getFitLSRange() {
98  int* tmp = new int[2];
99  tmp[0] = fbeginLumiOfFit;
100  tmp[1] = fendLumiOfFit;
101  return tmp;
102  }
103  //ssc
104  time_t* getRefTime() {
105  time_t* tmptime = new time_t[2];
106  tmptime[0] = freftime[0];
107  tmptime[1] = freftime[1];
108  return tmptime;
109  }
110 
111  //ssc
112  void resizepvStore(unsigned int rmSize) { pvStore_.erase(pvStore_.begin(), pvStore_.begin() + rmSize); }
113 
115  void compressStore();
117  double pvQuality(const reco::Vertex& pv) const;
119  double pvQuality(const BeamSpotFitPVData& pv) const;
120  int getNPVs() { return pvStore_.size(); }
121 
122  const std::map<int, int>& getNPVsperBX() {
123  npvsmap_.clear();
124 
125  for (std::map<int, std::vector<BeamSpotFitPVData> >::const_iterator pvStore = bxMap_.begin();
126  pvStore != bxMap_.end();
127  ++pvStore) {
128  npvsmap_[pvStore->first] = (pvStore->second).size();
129  }
130  return npvsmap_;
131  }
132 
133 private:
134  std::map<int, int> npvsmap_;
136  std::map<int, reco::BeamSpot> fbspotMap;
139 
140  std::ofstream fasciiFile;
141 
142  bool debug_;
143  bool do3DFit_;
146 
147  unsigned int maxNrVertices_;
148  unsigned int minNrVertices_;
149  double minVtxNdf_;
151  unsigned int minVtxTracks_;
152  double minVtxWgt_;
153  double maxVtxR_;
154  double maxVtxZ_;
155  double errorScale_;
156  double sigmaCut_;
157  double minSumPt_;
158 
159  std::time_t freftime[2];
160 
161  std::unique_ptr<TH2F> hPVx;
162  std::unique_ptr<TH2F> hPVy;
163 
164  TTree* ftree_;
165 
166  //beam fit results
169  double fwidthX;
170  double fwidthY;
171  double fwidthZ;
172  double fwidthXerr;
173  double fwidthYerr;
174  double fwidthZerr;
175 
176  std::vector<BeamSpotFitPVData> pvStore_; //< cache for PV data
177  std::map<int, std::vector<BeamSpotFitPVData> > bxMap_; // store PV data as a function of bunch crossings
178  double dynamicQualityCut_; //< quality cut for vertices (dynamic adjustment)
179  std::vector<double> pvQualities_; //< working space for PV store adjustement
180 
182 };
183 
184 #endif
double minSumPt_
Definition: PVFitter.h:157
size
Write out results.
std::vector< double > pvQualities_
Definition: PVFitter.h:179
int * getFitLSRange()
Definition: PVFitter.h:97
void setFitLSRange(int ls0, int ls1)
Definition: PVFitter.h:77
bool debug_
Definition: PVFitter.h:142
double maxVtxNormChi2_
Definition: PVFitter.h:150
void setTree(TTree *tree)
Definition: PVFitter.cc:206
const std::map< int, int > & getNPVsperBX()
Definition: PVFitter.h:122
void initialize(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iColl)
Definition: PVFitter.cc:56
std::map< int, std::vector< BeamSpotFitPVData > > bxMap_
Definition: PVFitter.h:177
void compressStore()
reduce size of primary vertex cache by increasing quality limit
Definition: PVFitter.cc:487
double minVtxWgt_
Definition: PVFitter.h:152
bool useOnlyFirstPV_
Definition: PVFitter.h:138
std::map< int, reco::BeamSpot > getBeamSpotMap()
Definition: PVFitter.h:95
double minVtxNdf_
Definition: PVFitter.h:149
void FitPerBunchCrossing()
Definition: PVFitter.h:67
double fwidthY
Definition: PVFitter.h:170
double errorScale_
Definition: PVFitter.h:155
bool do3DFit_
Definition: PVFitter.h:143
double dynamicQualityCut_
Definition: PVFitter.h:178
double fwidthYerr
Definition: PVFitter.h:173
double fwidthZ
Definition: PVFitter.h:171
double fwidthXerr
Definition: PVFitter.h:172
double getWidthX()
Definition: PVFitter.h:58
double pvQuality(const reco::Vertex &pv) const
vertex quality measure
Definition: PVFitter.cc:518
reco::BeamSpot fbeamspot
Definition: PVFitter.h:135
int iEvent
Definition: GenABIO.cc:224
std::vector< BeamSpotFitPVData > pvStore_
Definition: PVFitter.h:176
void readEvent(const edm::Event &iEvent)
Definition: PVFitter.cc:120
std::unique_ptr< TH2F > hPVx
Definition: PVFitter.h:161
void resetLSRange()
Definition: PVFitter.h:70
BeamSpotTreeData theBeamSpotTreeData_
Definition: PVFitter.h:181
std::ofstream fasciiFile
Definition: PVFitter.h:140
bool fFitPerBunchCrossing
Definition: PVFitter.h:137
def pv(vc)
Definition: MetAnalyzer.py:7
double getWidthY()
Definition: PVFitter.h:59
TTree * ftree_
Definition: PVFitter.h:164
int fbeginLumiOfFit
Definition: PVFitter.h:167
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
Definition: PVFitter.h:144
std::map< int, reco::BeamSpot > fbspotMap
Definition: PVFitter.h:136
double maxVtxR_
Definition: PVFitter.h:153
void setRefTime(std::time_t t0, std::time_t t1)
Definition: PVFitter.h:73
double maxVtxZ_
Definition: PVFitter.h:154
unsigned int maxNrVertices_
Definition: PVFitter.h:147
double fwidthZerr
Definition: PVFitter.h:174
void resetRefTime()
Definition: PVFitter.h:71
std::time_t freftime[2]
Definition: PVFitter.h:159
std::vector< BeamSpotFitPVData > getpvStore()
Definition: PVFitter.h:65
static void fillDescription(edm::ParameterSetDescription &)
Definition: PVFitter.cc:97
PVFitter()
Definition: PVFitter.h:47
unsigned int minVtxTracks_
Definition: PVFitter.h:151
double getWidthZerr()
Definition: PVFitter.h:63
std::unique_ptr< TH2F > hPVy
Definition: PVFitter.h:162
double getWidthZ()
Definition: PVFitter.h:60
int fendLumiOfFit
Definition: PVFitter.h:168
void resizepvStore(unsigned int rmSize)
Definition: PVFitter.h:112
bool runFitter()
Definition: PVFitter.cc:330
void resetAll()
Definition: PVFitter.h:83
unsigned int minNrVertices_
Definition: PVFitter.h:148
bool runBXFitter()
Definition: PVFitter.cc:211
double sigmaCut_
Definition: PVFitter.h:156
fixed size matrix
HLT enums.
time_t * getRefTime()
Definition: PVFitter.h:104
virtual ~PVFitter()
Definition: PVFitter.cc:95
int getNPVs()
Definition: PVFitter.h:120
double fwidthX
Definition: PVFitter.h:169
double getWidthYerr()
Definition: PVFitter.h:62
Definition: tree.py:1
void dumpTxtFile()
Definition: PVFitter.cc:485
reco::BeamSpot getBeamSpot()
Definition: PVFitter.h:94
std::map< int, int > npvsmap_
Definition: PVFitter.h:134
tmp
align.sh
Definition: createJobs.py:716
std::string outputTxt_
Definition: PVFitter.h:145
bool IsFitPerBunchCrossing()
Definition: PVFitter.h:96
double getWidthXerr()
Definition: PVFitter.h:61