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