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 // ROOT
30 #include "TFile.h"
31 #include "TTree.h"
32 #include "TH2F.h"
33 
34 #include <fstream>
35 
36 namespace edm {
37  class ConsumesCollector;
38 }
39 
40 namespace reco {
41  class Vertex;
42 }
43 
44 class PVFitter {
45 public:
46  PVFitter() {}
47  PVFitter(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iColl);
48  PVFitter(const edm::ParameterSet& iConfig, edm::ConsumesCollector& iColl);
49  virtual ~PVFitter();
50 
51  void initialize(const edm::ParameterSet& iConfig, edm::ConsumesCollector& iColl);
52  void readEvent(const edm::Event& iEvent);
53  void setTree(TTree* tree);
54 
55  double getWidthX() { return fwidthX; }
56  double getWidthY() { return fwidthY; }
57  double getWidthZ() { return fwidthZ; }
58  double getWidthXerr() { return fwidthXerr; }
59  double getWidthYerr() { return fwidthYerr; }
60  double getWidthZerr() { return fwidthZerr; }
61  //ssc
62  std::vector<BeamSpotFitPVData> getpvStore() { return pvStore_; }
63 
65  bool runBXFitter();
66  bool runFitter();
68  void resetRefTime() { freftime[0] = freftime[1] = 0; }
69  //ssc
70  void setRefTime(std::time_t t0, std::time_t t1) {
71  freftime[0] = t0;
72  freftime[1] = t1;
73  }
74  void setFitLSRange(int ls0, int ls1) {
75  fbeginLumiOfFit = ls0;
76  fendLumiOfFit = ls1;
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) { pvStore_.erase(pvStore_.begin(), pvStore_.begin() + rmSize); }
110 
112  void compressStore();
114  double pvQuality(const reco::Vertex& pv) const;
116  double pvQuality(const BeamSpotFitPVData& pv) const;
117  int getNPVs() { return pvStore_.size(); }
118 
119  const std::map<int, int>& getNPVsperBX() {
120  npvsmap_.clear();
121 
122  for (std::map<int, std::vector<BeamSpotFitPVData> >::const_iterator pvStore = bxMap_.begin();
123  pvStore != bxMap_.end();
124  ++pvStore) {
125  npvsmap_[pvStore->first] = (pvStore->second).size();
126  }
127  return npvsmap_;
128  }
129 
130 private:
131  std::map<int, int> npvsmap_;
133  std::map<int, reco::BeamSpot> fbspotMap;
136 
137  std::ofstream fasciiFile;
138 
139  bool debug_;
140  bool do3DFit_;
143 
144  unsigned int maxNrVertices_;
145  unsigned int minNrVertices_;
146  double minVtxNdf_;
148  unsigned int minVtxTracks_;
149  double minVtxWgt_;
150  double maxVtxR_;
151  double maxVtxZ_;
152  double errorScale_;
153  double sigmaCut_;
154  double minSumPt_;
155 
156  std::time_t freftime[2];
157 
158  std::unique_ptr<TH2F> hPVx;
159  std::unique_ptr<TH2F> hPVy;
160 
161  TTree* ftree_;
162 
163  //beam fit results
166  double fwidthX;
167  double fwidthY;
168  double fwidthZ;
169  double fwidthXerr;
170  double fwidthYerr;
171  double fwidthZerr;
172 
173  std::vector<BeamSpotFitPVData> pvStore_; //< cache for PV data
174  std::map<int, std::vector<BeamSpotFitPVData> > bxMap_; // store PV data as a function of bunch crossings
175  double dynamicQualityCut_; //< quality cut for vertices (dynamic adjustment)
176  std::vector<double> pvQualities_; //< working space for PV store adjustement
177 
179 };
180 
181 #endif
PVFitter::getWidthZerr
double getWidthZerr()
Definition: PVFitter.h:60
PVFitter::hPVx
std::unique_ptr< TH2F > hPVx
Definition: PVFitter.h:158
PVFitter::minVtxNdf_
double minVtxNdf_
Definition: PVFitter.h:146
PVFitter::resizepvStore
void resizepvStore(unsigned int rmSize)
Definition: PVFitter.h:109
PVFitter::minVtxTracks_
unsigned int minVtxTracks_
Definition: PVFitter.h:148
PVFitter::maxVtxNormChi2_
double maxVtxNormChi2_
Definition: PVFitter.h:147
PVFitter::fwidthX
double fwidthX
Definition: PVFitter.h:166
BeamSpotFitPVData.h
PVFitter::getWidthX
double getWidthX()
Definition: PVFitter.h:55
PVFitter::minSumPt_
double minSumPt_
Definition: PVFitter.h:154
PVFitter::fwidthXerr
double fwidthXerr
Definition: PVFitter.h:169
align::BeamSpot
Definition: StructureType.h:89
edm::EDGetTokenT< reco::VertexCollection >
TrackBase.h
edm
HLT enums.
Definition: AlignableModifier.h:19
PVFitter::resetAll
void resetAll()
Definition: PVFitter.h:80
PVFitter::PVFitter
PVFitter()
Definition: PVFitter.h:46
tree
Definition: tree.py:1
PVFitter::setFitLSRange
void setFitLSRange(int ls0, int ls1)
Definition: PVFitter.h:74
PVFitter::getWidthZ
double getWidthZ()
Definition: PVFitter.h:57
PVFitter::theBeamSpotTreeData_
BeamSpotTreeData theBeamSpotTreeData_
Definition: PVFitter.h:178
BSTrkParameters.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
PVFitter::outputTxt_
std::string outputTxt_
Definition: PVFitter.h:142
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
PVFitter::FitPerBunchCrossing
void FitPerBunchCrossing()
Definition: PVFitter.h:64
PVFitter::getNPVsperBX
const std::map< int, int > & getNPVsperBX()
Definition: PVFitter.h:119
PVFitter::getpvStore
std::vector< BeamSpotFitPVData > getpvStore()
Definition: PVFitter.h:62
PVFitter::maxVtxZ_
double maxVtxZ_
Definition: PVFitter.h:151
PVFitter::getRefTime
time_t * getRefTime()
Definition: PVFitter.h:101
PVFitter::dynamicQualityCut_
double dynamicQualityCut_
Definition: PVFitter.h:175
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
PVFitter::fwidthZ
double fwidthZ
Definition: PVFitter.h:168
PVFitter::fwidthY
double fwidthY
Definition: PVFitter.h:167
BeamSpot.h
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition: FrontierCondition_GT_autoExpress_cfi.py:148
BeamSpotTreeData.h
PVFitter::readEvent
void readEvent(const edm::Event &iEvent)
Definition: PVFitter.cc:97
PVFitter::getBeamSpotMap
std::map< int, reco::BeamSpot > getBeamSpotMap()
Definition: PVFitter.h:92
reco::BeamSpot
Definition: BeamSpot.h:21
PVFitter::sigmaCut_
double sigmaCut_
Definition: PVFitter.h:153
PVFitter::npvsmap_
std::map< int, int > npvsmap_
Definition: PVFitter.h:131
BeamSpotTreeData
Definition: BeamSpotTreeData.h:8
PVFitter::getWidthXerr
double getWidthXerr()
Definition: PVFitter.h:58
PVFitter::fendLumiOfFit
int fendLumiOfFit
Definition: PVFitter.h:165
PVFitter::fbeamspot
reco::BeamSpot fbeamspot
Definition: PVFitter.h:132
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PVFitter::pvQuality
double pvQuality(const reco::Vertex &pv) const
vertex quality measure
Definition: PVFitter.cc:495
PVFitter::hPVy
std::unique_ptr< TH2F > hPVy
Definition: PVFitter.h:159
PVFitter::fwidthZerr
double fwidthZerr
Definition: PVFitter.h:171
PVFitter::freftime
std::time_t freftime[2]
Definition: PVFitter.h:156
edm::ParameterSet
Definition: ParameterSet.h:36
Timestamp.h
PVFitter::getNPVs
int getNPVs()
Definition: PVFitter.h:117
Event.h
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
iEvent
int iEvent
Definition: GenABIO.cc:224
PVFitter
Definition: PVFitter.h:44
PVFitter::fbeginLumiOfFit
int fbeginLumiOfFit
Definition: PVFitter.h:164
PVFitter::resetLSRange
void resetLSRange()
Definition: PVFitter.h:67
PVFitter::runBXFitter
bool runBXFitter()
Definition: PVFitter.cc:188
PVFitter::setRefTime
void setRefTime(std::time_t t0, std::time_t t1)
Definition: PVFitter.h:70
PVFitter::fwidthYerr
double fwidthYerr
Definition: PVFitter.h:170
PVFitter::bxMap_
std::map< int, std::vector< BeamSpotFitPVData > > bxMap_
Definition: PVFitter.h:174
PVFitter::~PVFitter
virtual ~PVFitter()
Definition: PVFitter.cc:95
VertexFwd.h
PVFitter::vertexToken_
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
Definition: PVFitter.h:141
PVFitter::IsFitPerBunchCrossing
bool IsFitPerBunchCrossing()
Definition: PVFitter.h:93
PVFitter::pvQualities_
std::vector< double > pvQualities_
Definition: PVFitter.h:176
PVFitter::getWidthYerr
double getWidthYerr()
Definition: PVFitter.h:59
HltBtagValidation_cff.Vertex
Vertex
Definition: HltBtagValidation_cff.py:32
PVFitter::dumpTxtFile
void dumpTxtFile()
Definition: PVFitter.cc:462
PVFitter::useOnlyFirstPV_
bool useOnlyFirstPV_
Definition: PVFitter.h:135
PVFitter::fFitPerBunchCrossing
bool fFitPerBunchCrossing
Definition: PVFitter.h:134
PVFitter::fbspotMap
std::map< int, reco::BeamSpot > fbspotMap
Definition: PVFitter.h:133
PVFitter::initialize
void initialize(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iColl)
Definition: PVFitter.cc:54
PVFitter::minNrVertices_
unsigned int minNrVertices_
Definition: PVFitter.h:145
PVFitter::getFitLSRange
int * getFitLSRange()
Definition: PVFitter.h:94
genParticles_cff.map
map
Definition: genParticles_cff.py:11
PVFitter::debug_
bool debug_
Definition: PVFitter.h:139
PVFitter::fasciiFile
std::ofstream fasciiFile
Definition: PVFitter.h:137
ParameterSet.h
PVFitter::runFitter
bool runFitter()
Definition: PVFitter.cc:307
BSFitter.h
PVFitter::errorScale_
double errorScale_
Definition: PVFitter.h:152
edm::Event
Definition: Event.h:73
PVFitter::minVtxWgt_
double minVtxWgt_
Definition: PVFitter.h:149
PVFitter::ftree_
TTree * ftree_
Definition: PVFitter.h:161
PVFitter::compressStore
void compressStore()
reduce size of primary vertex cache by increasing quality limit
Definition: PVFitter.cc:464
PVFitter::maxNrVertices_
unsigned int maxNrVertices_
Definition: PVFitter.h:144
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
PVFitter::do3DFit_
bool do3DFit_
Definition: PVFitter.h:140
PVFitter::pvStore_
std::vector< BeamSpotFitPVData > pvStore_
Definition: PVFitter.h:173
reco::Vertex
Definition: Vertex.h:35
PVFitter::getBeamSpot
reco::BeamSpot getBeamSpot()
Definition: PVFitter.h:91
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
PVFitter::resetRefTime
void resetRefTime()
Definition: PVFitter.h:68
PVFitter::setTree
void setTree(TTree *tree)
Definition: PVFitter.cc:183
BeamSpotFitPVData
Definition: BeamSpotFitPVData.h:7
PVFitter::getWidthY
double getWidthY()
Definition: PVFitter.h:56
PVFitter::maxVtxR_
double maxVtxR_
Definition: PVFitter.h:150