CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PVFitter.h
Go to the documentation of this file.
1 #ifndef PVFitter_H
2 #define PVFitter_H
3 
24 
27 
28 // ROOT
29 #include "TFile.h"
30 #include "TTree.h"
31 #include "TH2F.h"
32 
33 #include <fstream>
34 
35 namespace reco {
36  class Vertex;
37 }
38 
39 class PVFitter {
40  public:
41  PVFitter() {}
42  PVFitter(const edm::ParameterSet& iConfig);
43  virtual ~PVFitter();
44 
45  void readEvent(const edm::Event& iEvent);
46  void setTree(TTree* tree);
47 
48  double getWidthX() { return fwidthX; }
49  double getWidthY() { return fwidthY; }
50  double getWidthZ() { return fwidthZ; }
51  double getWidthXerr() { return fwidthXerr; }
52  double getWidthYerr() { return fwidthYerr; }
53  double getWidthZerr() { return fwidthZerr; }
54  //ssc
55  std::vector<BeamSpotFitPVData> getpvStore() { return pvStore_; }
56 
58  bool runBXFitter();
59  bool runFitter();
61  void resetRefTime() { freftime[0] = freftime[1] = 0; }
62  //ssc
63  void setRefTime(std::time_t t0,std::time_t t1) {
64  freftime[0] = t0;
65  freftime[1] = t1;
66  }
67  void setFitLSRange(int ls0,int ls1) {
68  fbeginLumiOfFit = ls0;
69  fendLumiOfFit = ls1;
70  }
71 
72 
73  void dumpTxtFile();
74  void resetAll() {
75  resetLSRange();
76  resetRefTime();
77  pvStore_.clear();
78  bxMap_.clear();
79  dynamicQualityCut_ = 1.e30;
80  hPVx->Reset();
81  hPVy->Reset();
83  fbspotMap.clear();
84  };
86  std::map<int, reco::BeamSpot> getBeamSpotMap() { return fbspotMap; }
88  int* getFitLSRange() {
89  int *tmp=new int[2];
90  tmp[0] = fbeginLumiOfFit;
91  tmp[1] = fendLumiOfFit;
92  return tmp;
93  }
94  //ssc
95  time_t* getRefTime(){
96  time_t *tmptime=new time_t[2];
97  tmptime[0]=freftime[0];
98  tmptime[1]=freftime[1];
99  return tmptime;
100  }
101 
102 //ssc
103  void resizepvStore(unsigned int rmSize ){
104  pvStore_.erase(pvStore_.begin(), pvStore_.begin()+rmSize);
105  }
106 
107 
109  void compressStore ();
111  double pvQuality (const reco::Vertex& pv) const;
113  double pvQuality (const BeamSpotFitPVData& pv) const;
114  int getNPVs() { return pvStore_.size(); }
115 
116  const std::map<int, int> &getNPVsperBX() {
117 
118  npvsmap_.clear();
119 
120  for ( std::map<int,std::vector<BeamSpotFitPVData> >::const_iterator pvStore = bxMap_.begin();
121  pvStore!=bxMap_.end(); ++pvStore) {
122 
123  //std::cout << "bx " << pvStore->first << " NPVs = " << (pvStore->second).size() << std::endl;
124  npvsmap_[ pvStore->first ] = (pvStore->second).size();
125 
126  }
127  return npvsmap_;
128  }
129 
130  private:
131 
132  std::map<int, int> npvsmap_;
134  std::map<int,reco::BeamSpot> fbspotMap;
136 
137  std::ofstream fasciiFile;
138 
139  bool debug_;
140  bool do3DFit_;
142  bool writeTxt_;
143  std::string outputTxt_;
144 
145  unsigned int maxNrVertices_;
146  unsigned int minNrVertices_;
147  double minVtxNdf_;
149  unsigned int minVtxTracks_;
150  double minVtxWgt_;
151  double maxVtxR_;
152  double maxVtxZ_;
153  double errorScale_;
154  double sigmaCut_;
155 
156  int frun;
157  int flumi;
158  std::time_t freftime[2];
159 
160  TH2F* hPVx; TH2F* hPVy;
161 
162  TTree* ftree_;
163  //bool saveNtuple_;
164  //bool saveBeamFit_;
165  //std::string outputfilename_;
166  //TFile* file_;
167  //TTree* ftree_;
168 
169  //beam fit results
170  //TTree* ftreeFit_;
171  int frunFit;
174  char fbeginTimeOfFit[32];
175  char fendTimeOfFit[32];
176  double fwidthX;
177  double fwidthY;
178  double fwidthZ;
179  double fwidthXerr;
180  double fwidthYerr;
181  double fwidthZerr;
182 
183  double fx;
184  double fy;
185  double fz;
186  double fsigmaZ;
187  double fdxdz;
188  double fdydz;
189  double fxErr;
190  double fyErr;
191  double fzErr;
192  double fsigmaZErr;
193  double fdxdzErr;
194  double fdydzErr;
195 
196  std::vector<BeamSpotFitPVData> pvStore_; //< cache for PV data
197  std::map< int, std::vector<BeamSpotFitPVData> > bxMap_; // store PV data as a function of bunch crossings
198  double dynamicQualityCut_; //< quality cut for vertices (dynamic adjustment)
199  std::vector<double> pvQualities_; //< working space for PV store adjustement
200 
202 };
203 
204 #endif
double fx
Definition: PVFitter.h:183
std::vector< double > pvQualities_
Definition: PVFitter.h:199
int * getFitLSRange()
Definition: PVFitter.h:88
double fxErr
Definition: PVFitter.h:189
void setFitLSRange(int ls0, int ls1)
Definition: PVFitter.h:67
bool debug_
Definition: PVFitter.h:139
double fdydz
Definition: PVFitter.h:188
double fsigmaZErr
Definition: PVFitter.h:192
double maxVtxNormChi2_
Definition: PVFitter.h:148
void setTree(TTree *tree)
Definition: PVFitter.cc:180
std::map< int, std::vector< BeamSpotFitPVData > > bxMap_
Definition: PVFitter.h:197
const std::map< int, int > & getNPVsperBX()
Definition: PVFitter.h:116
edm::InputTag vertexLabel_
Definition: PVFitter.h:141
void compressStore()
reduce size of primary vertex cache by increasing quality limit
Definition: PVFitter.cc:514
double fyErr
Definition: PVFitter.h:190
double minVtxWgt_
Definition: PVFitter.h:150
std::map< int, reco::BeamSpot > getBeamSpotMap()
Definition: PVFitter.h:86
double minVtxNdf_
Definition: PVFitter.h:147
void FitPerBunchCrossing()
Definition: PVFitter.h:57
double fdxdz
Definition: PVFitter.h:187
double fwidthY
Definition: PVFitter.h:177
double errorScale_
Definition: PVFitter.h:153
bool do3DFit_
Definition: PVFitter.h:140
double dynamicQualityCut_
Definition: PVFitter.h:198
double fwidthYerr
Definition: PVFitter.h:180
double fwidthZ
Definition: PVFitter.h:178
double fwidthXerr
Definition: PVFitter.h:179
dictionary map
Definition: Association.py:205
double getWidthX()
Definition: PVFitter.h:48
bool writeTxt_
Definition: PVFitter.h:142
reco::BeamSpot fbeamspot
Definition: PVFitter.h:133
int iEvent
Definition: GenABIO.cc:243
std::vector< BeamSpotFitPVData > pvStore_
Definition: PVFitter.h:196
void readEvent(const edm::Event &iEvent)
Definition: PVFitter.cc:83
void resetLSRange()
Definition: PVFitter.h:60
BeamSpotTreeData theBeamSpotTreeData_
Definition: PVFitter.h:201
double fsigmaZ
Definition: PVFitter.h:186
std::ofstream fasciiFile
Definition: PVFitter.h:137
bool fFitPerBunchCrossing
Definition: PVFitter.h:135
TH2F * hPVy
Definition: PVFitter.h:160
double getWidthY()
Definition: PVFitter.h:49
TTree * ftree_
Definition: PVFitter.h:162
std::map< int, reco::BeamSpot > fbspotMap
Definition: PVFitter.h:134
double fz
Definition: PVFitter.h:185
int fbeginLumiOfFit
Definition: PVFitter.h:172
double pvQuality(const reco::Vertex &pv) const
vertex quality measure
Definition: PVFitter.cc:546
double maxVtxR_
Definition: PVFitter.h:151
void setRefTime(std::time_t t0, std::time_t t1)
Definition: PVFitter.h:63
double maxVtxZ_
Definition: PVFitter.h:152
unsigned int maxNrVertices_
Definition: PVFitter.h:145
double fdydzErr
Definition: PVFitter.h:194
double fwidthZerr
Definition: PVFitter.h:181
void resetRefTime()
Definition: PVFitter.h:61
std::time_t freftime[2]
Definition: PVFitter.h:158
std::vector< BeamSpotFitPVData > getpvStore()
Definition: PVFitter.h:55
int frun
Definition: PVFitter.h:156
PVFitter()
Definition: PVFitter.h:41
unsigned int minVtxTracks_
Definition: PVFitter.h:149
double getWidthZerr()
Definition: PVFitter.h:53
double getWidthZ()
Definition: PVFitter.h:50
int fendLumiOfFit
Definition: PVFitter.h:173
char fendTimeOfFit[32]
Definition: PVFitter.h:175
void resizepvStore(unsigned int rmSize)
Definition: PVFitter.h:103
bool runFitter()
Definition: PVFitter.cc:319
TH2F * hPVx
Definition: PVFitter.h:160
void resetAll()
Definition: PVFitter.h:74
unsigned int minNrVertices_
Definition: PVFitter.h:146
double fy
Definition: PVFitter.h:184
bool runBXFitter()
Definition: PVFitter.cc:185
double sigmaCut_
Definition: PVFitter.h:154
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
time_t * getRefTime()
Definition: PVFitter.h:95
char fbeginTimeOfFit[32]
Definition: PVFitter.h:174
virtual ~PVFitter()
Definition: PVFitter.cc:78
int getNPVs()
Definition: PVFitter.h:114
double fwidthX
Definition: PVFitter.h:176
double getWidthYerr()
Definition: PVFitter.h:52
double fzErr
Definition: PVFitter.h:191
void dumpTxtFile()
Definition: PVFitter.cc:471
reco::BeamSpot getBeamSpot()
Definition: PVFitter.h:85
double fdxdzErr
Definition: PVFitter.h:193
std::map< int, int > npvsmap_
Definition: PVFitter.h:132
std::string outputTxt_
Definition: PVFitter.h:143
int flumi
Definition: PVFitter.h:157
int frunFit
Definition: PVFitter.h:171
tuple size
Write out results.
bool IsFitPerBunchCrossing()
Definition: PVFitter.h:87
double getWidthXerr()
Definition: PVFitter.h:51