CMS 3D CMS Logo

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