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
PVFitter::getWidthZerr
double getWidthZerr()
Definition: PVFitter.h:63
PVFitter::hPVx
std::unique_ptr< TH2F > hPVx
Definition: PVFitter.h:161
PVFitter::minVtxNdf_
double minVtxNdf_
Definition: PVFitter.h:149
PVFitter::resizepvStore
void resizepvStore(unsigned int rmSize)
Definition: PVFitter.h:112
PVFitter::minVtxTracks_
unsigned int minVtxTracks_
Definition: PVFitter.h:151
PVFitter::maxVtxNormChi2_
double maxVtxNormChi2_
Definition: PVFitter.h:150
PVFitter::fwidthX
double fwidthX
Definition: PVFitter.h:169
BeamSpotFitPVData.h
PVFitter::getWidthX
double getWidthX()
Definition: PVFitter.h:58
PVFitter::minSumPt_
double minSumPt_
Definition: PVFitter.h:157
PVFitter::fwidthXerr
double fwidthXerr
Definition: PVFitter.h:172
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:83
PVFitter::PVFitter
PVFitter()
Definition: PVFitter.h:47
tree
Definition: tree.py:1
PVFitter::setFitLSRange
void setFitLSRange(int ls0, int ls1)
Definition: PVFitter.h:77
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PVFitter::getWidthZ
double getWidthZ()
Definition: PVFitter.h:60
PVFitter::theBeamSpotTreeData_
BeamSpotTreeData theBeamSpotTreeData_
Definition: PVFitter.h:181
BSTrkParameters.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
PVFitter::outputTxt_
std::string outputTxt_
Definition: PVFitter.h:145
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
PVFitter::FitPerBunchCrossing
void FitPerBunchCrossing()
Definition: PVFitter.h:67
PVFitter::getNPVsperBX
const std::map< int, int > & getNPVsperBX()
Definition: PVFitter.h:122
PVFitter::getpvStore
std::vector< BeamSpotFitPVData > getpvStore()
Definition: PVFitter.h:65
PVFitter::maxVtxZ_
double maxVtxZ_
Definition: PVFitter.h:154
PVFitter::getRefTime
time_t * getRefTime()
Definition: PVFitter.h:104
PVFitter::fillDescription
static void fillDescription(edm::ParameterSetDescription &)
Definition: PVFitter.cc:97
PVFitter::dynamicQualityCut_
double dynamicQualityCut_
Definition: PVFitter.h:178
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
PVFitter::fwidthZ
double fwidthZ
Definition: PVFitter.h:171
PVFitter::fwidthY
double fwidthY
Definition: PVFitter.h:170
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:120
PVFitter::getBeamSpotMap
std::map< int, reco::BeamSpot > getBeamSpotMap()
Definition: PVFitter.h:95
reco::BeamSpot
Definition: BeamSpot.h:21
PVFitter::sigmaCut_
double sigmaCut_
Definition: PVFitter.h:156
PVFitter::npvsmap_
std::map< int, int > npvsmap_
Definition: PVFitter.h:134
BeamSpotTreeData
Definition: BeamSpotTreeData.h:8
PVFitter::getWidthXerr
double getWidthXerr()
Definition: PVFitter.h:61
ParameterSetDescription.h
PVFitter::fendLumiOfFit
int fendLumiOfFit
Definition: PVFitter.h:168
PVFitter::fbeamspot
reco::BeamSpot fbeamspot
Definition: PVFitter.h:135
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PVFitter::pvQuality
double pvQuality(const reco::Vertex &pv) const
vertex quality measure
Definition: PVFitter.cc:518
PVFitter::hPVy
std::unique_ptr< TH2F > hPVy
Definition: PVFitter.h:162
PVFitter::fwidthZerr
double fwidthZerr
Definition: PVFitter.h:174
PVFitter::freftime
std::time_t freftime[2]
Definition: PVFitter.h:159
edm::ParameterSet
Definition: ParameterSet.h:47
Timestamp.h
PVFitter::getNPVs
int getNPVs()
Definition: PVFitter.h:120
Event.h
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
iEvent
int iEvent
Definition: GenABIO.cc:224
PVFitter
Definition: PVFitter.h:45
PVFitter::fbeginLumiOfFit
int fbeginLumiOfFit
Definition: PVFitter.h:167
PVFitter::resetLSRange
void resetLSRange()
Definition: PVFitter.h:70
PVFitter::runBXFitter
bool runBXFitter()
Definition: PVFitter.cc:211
PVFitter::setRefTime
void setRefTime(std::time_t t0, std::time_t t1)
Definition: PVFitter.h:73
PVFitter::fwidthYerr
double fwidthYerr
Definition: PVFitter.h:173
PVFitter::bxMap_
std::map< int, std::vector< BeamSpotFitPVData > > bxMap_
Definition: PVFitter.h:177
PVFitter::~PVFitter
virtual ~PVFitter()
Definition: PVFitter.cc:95
VertexFwd.h
PVFitter::vertexToken_
edm::EDGetTokenT< reco::VertexCollection > vertexToken_
Definition: PVFitter.h:144
PVFitter::IsFitPerBunchCrossing
bool IsFitPerBunchCrossing()
Definition: PVFitter.h:96
PVFitter::pvQualities_
std::vector< double > pvQualities_
Definition: PVFitter.h:179
PVFitter::getWidthYerr
double getWidthYerr()
Definition: PVFitter.h:62
HltBtagValidation_cff.Vertex
Vertex
Definition: HltBtagValidation_cff.py:32
PVFitter::dumpTxtFile
void dumpTxtFile()
Definition: PVFitter.cc:485
PVFitter::useOnlyFirstPV_
bool useOnlyFirstPV_
Definition: PVFitter.h:138
PVFitter::fFitPerBunchCrossing
bool fFitPerBunchCrossing
Definition: PVFitter.h:137
PVFitter::fbspotMap
std::map< int, reco::BeamSpot > fbspotMap
Definition: PVFitter.h:136
PVFitter::initialize
void initialize(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iColl)
Definition: PVFitter.cc:56
PVFitter::minNrVertices_
unsigned int minNrVertices_
Definition: PVFitter.h:148
PVFitter::getFitLSRange
int * getFitLSRange()
Definition: PVFitter.h:97
genParticles_cff.map
map
Definition: genParticles_cff.py:11
PVFitter::debug_
bool debug_
Definition: PVFitter.h:142
PVFitter::fasciiFile
std::ofstream fasciiFile
Definition: PVFitter.h:140
ParameterSet.h
PVFitter::runFitter
bool runFitter()
Definition: PVFitter.cc:330
BSFitter.h
PVFitter::errorScale_
double errorScale_
Definition: PVFitter.h:155
edm::Event
Definition: Event.h:73
PVFitter::minVtxWgt_
double minVtxWgt_
Definition: PVFitter.h:152
PVFitter::ftree_
TTree * ftree_
Definition: PVFitter.h:164
PVFitter::compressStore
void compressStore()
reduce size of primary vertex cache by increasing quality limit
Definition: PVFitter.cc:487
PVFitter::maxNrVertices_
unsigned int maxNrVertices_
Definition: PVFitter.h:147
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
PVFitter::do3DFit_
bool do3DFit_
Definition: PVFitter.h:143
PVFitter::pvStore_
std::vector< BeamSpotFitPVData > pvStore_
Definition: PVFitter.h:176
reco::Vertex
Definition: Vertex.h:35
PVFitter::getBeamSpot
reco::BeamSpot getBeamSpot()
Definition: PVFitter.h:94
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
PVFitter::resetRefTime
void resetRefTime()
Definition: PVFitter.h:71
PVFitter::setTree
void setTree(TTree *tree)
Definition: PVFitter.cc:206
BeamSpotFitPVData
Definition: BeamSpotFitPVData.h:7
PVFitter::getWidthY
double getWidthY()
Definition: PVFitter.h:59
PVFitter::maxVtxR_
double maxVtxR_
Definition: PVFitter.h:153