CMS 3D CMS Logo

BeamFitter.h
Go to the documentation of this file.
1 #ifndef BeamFitter_H
2 #define BeamFitter_H
3 
29 
30 // ROOT
31 #include "TFile.h"
32 #include "TTree.h"
33 #include "TH1F.h"
34 
35 #include <fstream>
36 
37 namespace edm {
38  class ConsumesCollector;
39 }
40 
41 class BeamFitter {
42 public:
44  BeamFitter(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iColl);
45  virtual ~BeamFitter();
46 
48 
49  void readEvent(const edm::Event &iEvent);
50 
51  bool runFitter();
52  bool runBeamWidthFitter();
53  bool runPVandTrkFitter();
54  bool runFitterNoTxt();
55 
57  void runAllFitter();
58  void resetTrkVector() { fBSvector.clear(); }
59  void resetTotTrk() { ftotal_tracks = 0; }
61  void resetRefTime() { freftime[0] = freftime[1] = 0; }
62  void setRefTime(time_t t0, time_t t1) {
63  freftime[0] = t0;
64  freftime[1] = t1;
65  // Make sure the string representation of the time
66  // is up-to-date
67  updateBTime();
68  }
69 
70  std::pair<time_t, time_t> getRefTime() { return std::make_pair(freftime[0], freftime[1]); }
71 
73 
74  //---these are added to fasciliate BeamMonitor stuff for DIP
75  std::size_t getPVvectorSize() { return (MyPVFitter->getpvStore()).size(); }
76  //sc
77  void resizeBSvector(unsigned int nsize) { fBSvector.erase(fBSvector.begin(), fBSvector.begin() + nsize); }
78 
79  //ssc
80  void resizePVvector(unsigned int npvsize) { MyPVFitter->resizepvStore(npvsize); }
81 
82  //ssc
83  void SetPVInfo(const std::vector<float> &v1_) {
84  ForDIPPV_.clear();
85  ForDIPPV_.assign(v1_.begin(), v1_.end());
86  }
87 
88  //----------------
89 
90  void dumpTxtFile(std::string &, bool);
91  void dumpBWTxtFile(std::string &);
92  void write2DB();
94  std::map<int, reco::BeamSpot> getBeamSpotMap() { return fbspotPVMap; }
95  std::vector<BSTrkParameters> getBSvector() { return fBSvector; }
96  TH1F *getCutFlow() { return h1cutFlow; }
97  void subtractFromCutFlow(const TH1F *toSubtract) {
98  h1cutFlow->Add(toSubtract, -1.0);
99  for (unsigned int i = 0; i < sizeof(countPass) / sizeof(countPass[0]); i++) {
100  countPass[i] = h1cutFlow->GetBinContent(i + 1);
101  }
102  }
103 
104  void resetCutFlow() {
105  h1cutFlow->Reset();
106  ftotal_tracks = 0;
107  for (unsigned int i = 0; i < sizeof(countPass) / sizeof(countPass[0]); i++)
108  countPass[i] = 0;
109  }
110 
111  //ssc
112  int getRunNumber() { return frun; }
113 
114  std::pair<int, int> getFitLSRange() { return std::make_pair(fbeginLumiOfFit, fendLumiOfFit); }
115  void setFitLSRange(int ls0, int ls1) {
116  fbeginLumiOfFit = ls0;
117  fendLumiOfFit = ls1;
118  }
119  void setRun(int run) { frun = run; }
120 
121  int getNTracks() { return fBSvector.size(); }
122  int getNPVs() { return MyPVFitter->getNPVs(); }
123  const std::map<int, int> &getNPVsperBX() { return MyPVFitter->getNPVsperBX(); }
124 
125 private:
126  // Update the fbeginTimeOfFit etc from the refTime
127  void updateBTime();
128  std::vector<BSTrkParameters> fBSvector;
131  std::map<int, reco::BeamSpot> fbspotPVMap;
132  // BSFitter *fmyalgo;
133  std::ofstream fasciiFile;
134  std::ofstream fasciiDIP;
135 
136  bool debug_;
141  bool writeTxt_;
146  double trk_MinpT_;
147  double trk_MaxZ_;
148  double trk_MaxEta_;
149  double trk_MaxIP_;
153  std::vector<std::string> trk_Algorithm_;
154  std::vector<std::string> trk_Quality_;
155  std::vector<reco::TrackBase::TrackQuality> quality_;
156  std::vector<reco::TrackBase::TrackAlgorithm> algorithm_;
158  double convergence_;
161  bool isMuon_;
162  bool fitted_;
164 
165  //ssc
166  std::vector<float> ForDIPPV_;
167 
168  // ntuple
169  TH1F *h1z;
174  TFile *file_;
175  TTree *ftree_;
176  double ftheta;
177  double fpt;
178  double feta;
179  int fcharge;
180  double fnormchi2;
181  double fphi0;
182  double fd0;
183  double fd0bs;
184  double fsigmad0;
185  double fz0;
186  double fsigmaz0;
196  // double fd0phi_chi2;
197  // double fd0phi_d0;
198  double fcov[7][7];
199  double fvx;
200  double fvy;
201  int frun;
202  int flumi;
203  bool fquality;
204  bool falgo;
205  bool fpvValid;
206  double fpvx, fpvy, fpvz;
207  std::time_t freftime[2];
208 
209  //beam fit results
210  TTree *ftreeFit_;
211  int frunFit;
214  char fbeginTimeOfFit[32];
215  char fendTimeOfFit[32];
216  double fx;
217  double fy;
218  double fz;
219  double fsigmaZ;
220  double fdxdz;
221  double fdydz;
222  double fxErr;
223  double fyErr;
224  double fzErr;
225  double fsigmaZErr;
226  double fdxdzErr;
227  double fdydzErr;
228  double fwidthX;
229  double fwidthY;
230  double fwidthXErr;
231  double fwidthYErr;
232 
233  TH1F *h1ntrks;
234  TH1F *h1vz_event;
235  TH1F *h1cutFlow;
236  int countPass[9];
237 
239  TTree *fPVTree_;
240 };
241 
242 #endif
PVFitter.h
BeamFitter::beamSpotToken_
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
Definition: BeamFitter.h:140
BeamFitter::fd0bs
double fd0bs
Definition: BeamFitter.h:183
PVFitter::resizepvStore
void resizepvStore(unsigned int rmSize)
Definition: PVFitter.h:112
BeamFitter::frunFit
int frunFit
Definition: BeamFitter.h:211
BeamFitter::getNPVs
int getNPVs()
Definition: BeamFitter.h:122
BeamFitter::runPVandTrkFitter
bool runPVandTrkFitter()
Definition: BeamFitter.cc:449
BeamFitter::fnTotLayerMeas
int fnTotLayerMeas
Definition: BeamFitter.h:187
BeamFitter::resetRefTime
void resetRefTime()
Definition: BeamFitter.h:61
BeamFitter::fwidthY
double fwidthY
Definition: BeamFitter.h:229
BeamFitter::trk_MaxIP_
double trk_MaxIP_
Definition: BeamFitter.h:149
mps_fire.i
i
Definition: mps_fire.py:428
BeamFitter::fasciiFile
std::ofstream fasciiFile
Definition: BeamFitter.h:133
BeamFitter::resetPVFitter
void resetPVFitter()
Definition: BeamFitter.h:72
BeamFitter::getBeamWidth
reco::BeamSpot getBeamWidth()
Definition: BeamFitter.h:56
BeamFitter::resetTrkVector
void resetTrkVector()
Definition: BeamFitter.h:58
BeamFitter::quality_
std::vector< reco::TrackBase::TrackQuality > quality_
Definition: BeamFitter.h:155
BeamFitter::fz0
double fz0
Definition: BeamFitter.h:185
BeamFitter::updateBTime
void updateBTime()
Definition: BeamFitter.cc:29
BeamFitter::fyErr
double fyErr
Definition: BeamFitter.h:223
BeamFitter::trk_MaxEta_
double trk_MaxEta_
Definition: BeamFitter.h:148
TrackCandidateCollection.h
BeamFitter::ftotal_tracks
int ftotal_tracks
Definition: BeamFitter.h:159
BeamFitter::subtractFromCutFlow
void subtractFromCutFlow(const TH1F *toSubtract)
Definition: BeamFitter.h:97
BeamFitter::vertexToken_
edm::EDGetTokenT< edm::View< reco::Vertex > > vertexToken_
Definition: BeamFitter.h:139
edm::EDGetTokenT< reco::TrackCollection >
TrackBase.h
edm
HLT enums.
Definition: AlignableModifier.h:19
PVFitter::resetAll
void resetAll()
Definition: PVFitter.h:83
BeamFitter::fzErr
double fzErr
Definition: BeamFitter.h:224
BeamFitter::feta
double feta
Definition: BeamFitter.h:178
BeamFitter::fsigmaZ
double fsigmaZ
Definition: BeamFitter.h:219
BeamFitter::writeTxt_
bool writeTxt_
Definition: BeamFitter.h:141
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
BeamFitter::fasciiDIP
std::ofstream fasciiDIP
Definition: BeamFitter.h:134
BeamFitter::saveBeamFit_
bool saveBeamFit_
Definition: BeamFitter.h:171
BeamFitter::fpvx
double fpvx
Definition: BeamFitter.h:206
BeamFitter::readEvent
void readEvent(const edm::Event &iEvent)
Definition: BeamFitter.cc:261
BeamFitter::getRefTime
std::pair< time_t, time_t > getRefTime()
Definition: BeamFitter.h:70
BeamFitter::fBSvector
std::vector< BSTrkParameters > fBSvector
Definition: BeamFitter.h:128
BeamFitter::fpt
double fpt
Definition: BeamFitter.h:177
BeamFitter::frun
int frun
Definition: BeamFitter.h:201
BSTrkParameters.h
BeamFitter::fxErr
double fxErr
Definition: BeamFitter.h:222
BeamFitter::h1vz_event
TH1F * h1vz_event
Definition: BeamFitter.h:234
BeamFitter::min_Ntrks_
int min_Ntrks_
Definition: BeamFitter.h:160
BeamFitter::falgo
bool falgo
Definition: BeamFitter.h:204
BeamFitter::fbeamWidthFit
reco::BeamSpot fbeamWidthFit
Definition: BeamFitter.h:130
BeamFitter::fdydz
double fdydz
Definition: BeamFitter.h:221
BeamFitter::trk_MinNTotLayers_
int trk_MinNTotLayers_
Definition: BeamFitter.h:150
BeamFitter::fphi0
double fphi0
Definition: BeamFitter.h:181
BeamFitter::outputfilename_
std::string outputfilename_
Definition: BeamFitter.h:173
BeamFitter::fbeginLumiOfFit
int fbeginLumiOfFit
Definition: BeamFitter.h:212
BeamFitter::fbeginTimeOfFit
char fbeginTimeOfFit[32]
Definition: BeamFitter.h:214
BeamFitter::flumi
int flumi
Definition: BeamFitter.h:202
BeamFitter::runFitter
bool runFitter()
Definition: BeamFitter.cc:609
BeamFitter::ftree_
TTree * ftree_
Definition: BeamFitter.h:175
PVFitter::getNPVsperBX
const std::map< int, int > & getNPVsperBX()
Definition: PVFitter.h:122
BeamFitter::countPass
int countPass[9]
Definition: BeamFitter.h:236
PVFitter::getpvStore
std::vector< BeamSpotFitPVData > getpvStore()
Definition: PVFitter.h:65
BeamFitter::MyPVFitter
PVFitter * MyPVFitter
Definition: BeamFitter.h:238
BeamFitter::outputTxt_
std::string outputTxt_
Definition: BeamFitter.h:144
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
BeamFitter::file_
TFile * file_
Definition: BeamFitter.h:174
Track.h
BeamFitter::dumpBWTxtFile
void dumpBWTxtFile(std::string &)
Definition: BeamFitter.cc:656
TrackFwd.h
BeamSpot.h
BeamFitter::saveNtuple_
bool saveNtuple_
Definition: BeamFitter.h:170
BeamFitter::convergence_
double convergence_
Definition: BeamFitter.h:158
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition: FrontierCondition_GT_autoExpress_cfi.py:149
BeamFitter::fbeamspot
reco::BeamSpot fbeamspot
Definition: BeamFitter.h:129
BeamFitter::ffilename_changed
bool ffilename_changed
Definition: BeamFitter.h:163
BeamFitter::fd0
double fd0
Definition: BeamFitter.h:182
BeamFitter::fillDescription
static void fillDescription(edm::ParameterSetDescription &)
Definition: BeamFitter.cc:224
reco::BeamSpot
Definition: BeamSpot.h:21
BeamFitter::fcharge
int fcharge
Definition: BeamFitter.h:179
BeamFitter::resizeBSvector
void resizeBSvector(unsigned int nsize)
Definition: BeamFitter.h:77
BeamFitter::fquality
bool fquality
Definition: BeamFitter.h:203
BeamFitter::fvy
double fvy
Definition: BeamFitter.h:200
BeamFitter::h1z
TH1F * h1z
Definition: BeamFitter.h:169
BeamFitter::trk_Quality_
std::vector< std::string > trk_Quality_
Definition: BeamFitter.h:154
BeamFitter::savePVVertices_
bool savePVVertices_
Definition: BeamFitter.h:172
BeamFitter::runBeamWidthFitter
bool runBeamWidthFitter()
Definition: BeamFitter.cc:620
BeamFitter::resetTotTrk
void resetTotTrk()
Definition: BeamFitter.h:59
ParameterSetDescription.h
BeamFitter
Definition: BeamFitter.h:41
BeamFitter::fnPXBLayerMeas
int fnPXBLayerMeas
Definition: BeamFitter.h:194
BeamFitter::outputDIPTxt_
std::string outputDIPTxt_
Definition: BeamFitter.h:145
BeamFitter::getBeamSpot
reco::BeamSpot getBeamSpot()
Definition: BeamFitter.h:93
BeamFitter::setRun
void setRun(int run)
Definition: BeamFitter.h:119
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BeamFitter::setRefTime
void setRefTime(time_t t0, time_t t1)
Definition: BeamFitter.h:62
BeamFitter::getBeamSpotMap
std::map< int, reco::BeamSpot > getBeamSpotMap()
Definition: BeamFitter.h:94
BeamFitter::fx
double fx
Definition: BeamFitter.h:216
BeamFitter::appendRunTxt_
bool appendRunTxt_
Definition: BeamFitter.h:137
BeamFitter::fitted_
bool fitted_
Definition: BeamFitter.h:162
BeamFitter::fnStripLayerMeas
int fnStripLayerMeas
Definition: BeamFitter.h:189
BeamFitter::writeDIPTxt_
bool writeDIPTxt_
Definition: BeamFitter.h:142
BeamFitter::~BeamFitter
virtual ~BeamFitter()
Definition: BeamFitter.cc:197
BeamFitter::h1ntrks
TH1F * h1ntrks
Definition: BeamFitter.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
Timestamp.h
BeamFitter::fdydzErr
double fdydzErr
Definition: BeamFitter.h:227
PVFitter::getNPVs
int getNPVs()
Definition: PVFitter.h:120
Event.h
BeamFitter::fPVTree_
TTree * fPVTree_
Definition: BeamFitter.h:239
BeamFitter::fpvy
double fpvy
Definition: BeamFitter.h:206
BeamFitter::trk_MaxNormChi2_
double trk_MaxNormChi2_
Definition: BeamFitter.h:152
BeamFitter::fsigmaZErr
double fsigmaZErr
Definition: BeamFitter.h:225
BeamFitter::fwidthX
double fwidthX
Definition: BeamFitter.h:228
BeamFitter::fz
double fz
Definition: BeamFitter.h:218
BeamFitter::fdxdz
double fdxdz
Definition: BeamFitter.h:220
BeamFitter::freftime
std::time_t freftime[2]
Definition: BeamFitter.h:207
iEvent
int iEvent
Definition: GenABIO.cc:224
BeamFitter::algorithm_
std::vector< reco::TrackBase::TrackAlgorithm > algorithm_
Definition: BeamFitter.h:156
PVFitter
Definition: PVFitter.h:45
BeamFitter::resetLSRange
void resetLSRange()
Definition: BeamFitter.h:60
BeamFitter::getNTracks
int getNTracks()
Definition: BeamFitter.h:121
BeamFitter::runFitterNoTxt
bool runFitterNoTxt()
Definition: BeamFitter.cc:546
BeamFitter::write2DB
void write2DB()
Definition: BeamFitter.cc:746
BeamFitter::dumpTxtFile
void dumpTxtFile(std::string &, bool)
Definition: BeamFitter.cc:668
BeamFitter::fnTIDLayerMeas
int fnTIDLayerMeas
Definition: BeamFitter.h:191
BeamFitter::resetCutFlow
void resetCutFlow()
Definition: BeamFitter.h:104
BeamFitter::tracksToken_
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
Definition: BeamFitter.h:138
BeamFitter::trk_Algorithm_
std::vector< std::string > trk_Algorithm_
Definition: BeamFitter.h:153
BeamFitter::fsigmad0
double fsigmad0
Definition: BeamFitter.h:184
BeamFitter::fnTIBLayerMeas
int fnTIBLayerMeas
Definition: BeamFitter.h:190
BeamFitter::fnormchi2
double fnormchi2
Definition: BeamFitter.h:180
BeamFitter::fy
double fy
Definition: BeamFitter.h:217
BeamFitter::h1cutFlow
TH1F * h1cutFlow
Definition: BeamFitter.h:235
BeamFitter::debug_
bool debug_
Definition: BeamFitter.h:136
BeamFitter::ftheta
double ftheta
Definition: BeamFitter.h:176
BeamFitter::fpvValid
bool fpvValid
Definition: BeamFitter.h:205
BeamFitter::fnPixelLayerMeas
int fnPixelLayerMeas
Definition: BeamFitter.h:188
BeamFitter::isMuon_
bool isMuon_
Definition: BeamFitter.h:161
BeamFitter::getPVvectorSize
std::size_t getPVvectorSize()
Definition: BeamFitter.h:75
BeamFitter::setFitLSRange
void setFitLSRange(int ls0, int ls1)
Definition: BeamFitter.h:115
BeamFitter::fnTOBLayerMeas
int fnTOBLayerMeas
Definition: BeamFitter.h:192
writedatasetfile.run
run
Definition: writedatasetfile.py:27
BeamFitter::fvx
double fvx
Definition: BeamFitter.h:199
BeamFitter::fcov
double fcov[7][7]
Definition: BeamFitter.h:198
BeamFitter::fsigmaz0
double fsigmaz0
Definition: BeamFitter.h:186
BeamFitter::getCutFlow
TH1F * getCutFlow()
Definition: BeamFitter.h:96
BeamFitter::trk_MaxZ_
double trk_MaxZ_
Definition: BeamFitter.h:147
BeamFitter::SetPVInfo
void SetPVInfo(const std::vector< float > &v1_)
Definition: BeamFitter.h:83
BeamFitter::fendTimeOfFit
char fendTimeOfFit[32]
Definition: BeamFitter.h:215
BeamFitter::getFitLSRange
std::pair< int, int > getFitLSRange()
Definition: BeamFitter.h:114
BeamFitter::resizePVvector
void resizePVvector(unsigned int npvsize)
Definition: BeamFitter.h:80
BeamFitter::trk_MinNPixLayers_
int trk_MinNPixLayers_
Definition: BeamFitter.h:151
BeamFitter::fnPXFLayerMeas
int fnPXFLayerMeas
Definition: BeamFitter.h:195
BeamFitter::getRunNumber
int getRunNumber()
Definition: BeamFitter.h:112
BeamFitter::fnTECLayerMeas
int fnTECLayerMeas
Definition: BeamFitter.h:193
BeamFitter::ForDIPPV_
std::vector< float > ForDIPPV_
Definition: BeamFitter.h:166
BeamFitter::fwidthYErr
double fwidthYErr
Definition: BeamFitter.h:231
BeamFitter::fdxdzErr
double fdxdzErr
Definition: BeamFitter.h:226
ParameterSet.h
BeamFitter::BeamFitter
BeamFitter()
Definition: BeamFitter.h:43
TrackCandidate.h
BeamFitter::trk_MinpT_
double trk_MinpT_
Definition: BeamFitter.h:146
BSFitter.h
BeamFitter::getNPVsperBX
const std::map< int, int > & getNPVsperBX()
Definition: BeamFitter.h:123
BeamFitter::fbspotPVMap
std::map< int, reco::BeamSpot > fbspotPVMap
Definition: BeamFitter.h:131
edm::Event
Definition: Event.h:73
BeamFitter::getBSvector
std::vector< BSTrkParameters > getBSvector()
Definition: BeamFitter.h:95
BeamFitter::fendLumiOfFit
int fendLumiOfFit
Definition: BeamFitter.h:213
BeamFitter::inputBeamWidth_
double inputBeamWidth_
Definition: BeamFitter.h:157
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
BeamFitter::fwidthXErr
double fwidthXErr
Definition: BeamFitter.h:230
BeamFitter::fpvz
double fpvz
Definition: BeamFitter.h:206
BeamFitter::ftreeFit_
TTree * ftreeFit_
Definition: BeamFitter.h:210
BeamFitter::writeDIPBadFit_
bool writeDIPBadFit_
Definition: BeamFitter.h:143
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
BeamFitter::runAllFitter
void runAllFitter()
Definition: BeamFitter.cc:784