CMS 3D CMS Logo

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 
63  void FitPerBunchCrossing() { fFitPerBunchCrossing = true; }
64  bool runBXFitter();
65  bool runFitter();
66  void resetLSRange() { fbeginLumiOfFit=fendLumiOfFit=-1; }
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();
88  fbeamspot = reco::BeamSpot();
89  fbspotMap.clear();
90  };
91  reco::BeamSpot getBeamSpot() { return fbeamspot; }
92  std::map<int, reco::BeamSpot> getBeamSpotMap() { return fbspotMap; }
93  bool IsFitPerBunchCrossing() { return fFitPerBunchCrossing; }
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  npvsmap_[ pvStore->first ] = (pvStore->second).size();
130 
131  }
132  return npvsmap_;
133  }
134 
135  private:
136 
137  std::map<int, int> npvsmap_;
139  std::map<int,reco::BeamSpot> fbspotMap;
142 
143  std::ofstream fasciiFile;
144 
145  bool debug_;
146  bool do3DFit_;
149 
150  unsigned int maxNrVertices_;
151  unsigned int minNrVertices_;
152  double minVtxNdf_;
154  unsigned int minVtxTracks_;
155  double minVtxWgt_;
156  double maxVtxR_;
157  double maxVtxZ_;
158  double errorScale_;
159  double sigmaCut_;
160  double minSumPt_;
161 
162  std::time_t freftime[2];
163 
164  TH2F* hPVx; TH2F* hPVy;
165 
166  TTree* ftree_;
167 
168  //beam fit results
171  double fwidthX;
172  double fwidthY;
173  double fwidthZ;
174  double fwidthXerr;
175  double fwidthYerr;
176  double fwidthZerr;
177 
178  std::vector<BeamSpotFitPVData> pvStore_; //< cache for PV data
179  std::map< int, std::vector<BeamSpotFitPVData> > bxMap_; // store PV data as a function of bunch crossings
180  double dynamicQualityCut_; //< quality cut for vertices (dynamic adjustment)
181  std::vector<double> pvQualities_; //< working space for PV store adjustement
182 
184 };
185 
186 #endif
double minSumPt_
Definition: PVFitter.h:160
size
Write out results.
std::vector< double > pvQualities_
Definition: PVFitter.h:181
int * getFitLSRange()
Definition: PVFitter.h:94
static AlgebraicMatrix initialize()
void setFitLSRange(int ls0, int ls1)
Definition: PVFitter.h:73
bool debug_
Definition: PVFitter.h:145
double maxVtxNormChi2_
Definition: PVFitter.h:153
std::map< int, std::vector< BeamSpotFitPVData > > bxMap_
Definition: PVFitter.h:179
const std::map< int, int > & getNPVsperBX()
Definition: PVFitter.h:122
double minVtxWgt_
Definition: PVFitter.h:155
bool useOnlyFirstPV_
Definition: PVFitter.h:141
std::map< int, reco::BeamSpot > getBeamSpotMap()
Definition: PVFitter.h:92
double minVtxNdf_
Definition: PVFitter.h:152
void FitPerBunchCrossing()
Definition: PVFitter.h:63
double fwidthY
Definition: PVFitter.h:172
double errorScale_
Definition: PVFitter.h:158
bool do3DFit_
Definition: PVFitter.h:146
double dynamicQualityCut_
Definition: PVFitter.h:180
double fwidthYerr
Definition: PVFitter.h:175
double fwidthZ
Definition: PVFitter.h:173
double fwidthXerr
Definition: PVFitter.h:174
double getWidthX()
Definition: PVFitter.h:54
reco::BeamSpot fbeamspot
Definition: PVFitter.h:138
int iEvent
Definition: GenABIO.cc:230
std::vector< BeamSpotFitPVData > pvStore_
Definition: PVFitter.h:178
void resetLSRange()
Definition: PVFitter.h:66
BeamSpotTreeData theBeamSpotTreeData_
Definition: PVFitter.h:183
std::ofstream fasciiFile
Definition: PVFitter.h:143
bool fFitPerBunchCrossing
Definition: PVFitter.h:140
TH2F * hPVy
Definition: PVFitter.h:164
def pv(vc)
Definition: MetAnalyzer.py:6
double getWidthY()
Definition: PVFitter.h:55
TTree * ftree_
Definition: PVFitter.h:166
std::map< int, reco::BeamSpot > fbspotMap
Definition: PVFitter.h:139
int fbeginLumiOfFit
Definition: PVFitter.h:169
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
Definition: PVFitter.h:147
double maxVtxR_
Definition: PVFitter.h:156
void setRefTime(std::time_t t0, std::time_t t1)
Definition: PVFitter.h:69
double maxVtxZ_
Definition: PVFitter.h:157
unsigned int maxNrVertices_
Definition: PVFitter.h:150
double fwidthZerr
Definition: PVFitter.h:176
void resetRefTime()
Definition: PVFitter.h:67
std::vector< BeamSpotFitPVData > getpvStore()
Definition: PVFitter.h:61
PVFitter()
Definition: PVFitter.h:45
unsigned int minVtxTracks_
Definition: PVFitter.h:154
double getWidthZerr()
Definition: PVFitter.h:59
double getWidthZ()
Definition: PVFitter.h:56
int fendLumiOfFit
Definition: PVFitter.h:170
void resizepvStore(unsigned int rmSize)
Definition: PVFitter.h:109
void resetAll()
Definition: PVFitter.h:80
unsigned int minNrVertices_
Definition: PVFitter.h:151
double sigmaCut_
Definition: PVFitter.h:159
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
fixed size matrix
HLT enums.
time_t * getRefTime()
Definition: PVFitter.h:101
int getNPVs()
Definition: PVFitter.h:120
double fwidthX
Definition: PVFitter.h:171
double getWidthYerr()
Definition: PVFitter.h:58
Definition: tree.py:1
reco::BeamSpot getBeamSpot()
Definition: PVFitter.h:91
std::map< int, int > npvsmap_
Definition: PVFitter.h:137
std::string outputTxt_
Definition: PVFitter.h:148
bool IsFitPerBunchCrossing()
Definition: PVFitter.h:93
double getWidthXerr()
Definition: PVFitter.h:57