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
int getNPVs()
Definition: BeamFitter.h:122
size
Write out results.
double trk_MaxZ_
Definition: BeamFitter.h:147
double trk_MaxEta_
Definition: BeamFitter.h:148
reco::BeamSpot fbeamspot
Definition: BeamFitter.h:129
double fwidthXErr
Definition: BeamFitter.h:230
double fwidthX
Definition: BeamFitter.h:228
std::vector< std::string > trk_Algorithm_
Definition: BeamFitter.h:153
const std::map< int, int > & getNPVsperBX()
Definition: BeamFitter.h:123
int fendLumiOfFit
Definition: BeamFitter.h:213
double fwidthY
Definition: BeamFitter.h:229
int countPass[9]
Definition: BeamFitter.h:236
int getNTracks()
Definition: BeamFitter.h:121
const std::map< int, int > & getNPVsperBX()
Definition: PVFitter.h:122
bool isMuon_
Definition: BeamFitter.h:161
bool runPVandTrkFitter()
Definition: BeamFitter.cc:449
void write2DB()
Definition: BeamFitter.cc:746
char fendTimeOfFit[32]
Definition: BeamFitter.h:215
void setRun(int run)
Definition: BeamFitter.h:119
double fdxdz
Definition: BeamFitter.h:220
std::vector< BSTrkParameters > getBSvector()
Definition: BeamFitter.h:95
double fx
Definition: BeamFitter.h:216
double fnormchi2
Definition: BeamFitter.h:180
bool ffilename_changed
Definition: BeamFitter.h:163
std::map< int, reco::BeamSpot > fbspotPVMap
Definition: BeamFitter.h:131
bool debug_
Definition: BeamFitter.h:136
void subtractFromCutFlow(const TH1F *toSubtract)
Definition: BeamFitter.h:97
bool runBeamWidthFitter()
Definition: BeamFitter.cc:620
TH1F * h1z
Definition: BeamFitter.h:169
int fnTOBLayerMeas
Definition: BeamFitter.h:192
std::size_t getPVvectorSize()
Definition: BeamFitter.h:75
double feta
Definition: BeamFitter.h:178
std::vector< std::string > trk_Quality_
Definition: BeamFitter.h:154
double convergence_
Definition: BeamFitter.h:158
double trk_MaxNormChi2_
Definition: BeamFitter.h:152
void dumpBWTxtFile(std::string &)
Definition: BeamFitter.cc:656
void resetTrkVector()
Definition: BeamFitter.h:58
double fsigmaZErr
Definition: BeamFitter.h:225
TH1F * h1vz_event
Definition: BeamFitter.h:234
double fvy
Definition: BeamFitter.h:200
int fnPixelLayerMeas
Definition: BeamFitter.h:188
void readEvent(const edm::Event &iEvent)
Definition: BeamFitter.cc:261
reco::BeamSpot getBeamWidth()
Definition: BeamFitter.h:56
double fphi0
Definition: BeamFitter.h:181
std::ofstream fasciiDIP
Definition: BeamFitter.h:134
std::map< int, reco::BeamSpot > getBeamSpotMap()
Definition: BeamFitter.h:94
reco::BeamSpot fbeamWidthFit
Definition: BeamFitter.h:130
std::time_t freftime[2]
Definition: BeamFitter.h:207
PVFitter * MyPVFitter
Definition: BeamFitter.h:238
std::vector< BSTrkParameters > fBSvector
Definition: BeamFitter.h:128
int fnTotLayerMeas
Definition: BeamFitter.h:187
std::string outputTxt_
Definition: BeamFitter.h:144
double fpvx
Definition: BeamFitter.h:206
int iEvent
Definition: GenABIO.cc:224
double fdxdzErr
Definition: BeamFitter.h:226
double trk_MaxIP_
Definition: BeamFitter.h:149
bool runFitter()
Definition: BeamFitter.cc:609
bool runFitterNoTxt()
Definition: BeamFitter.cc:546
TFile * file_
Definition: BeamFitter.h:174
TTree * ftree_
Definition: BeamFitter.h:175
double fyErr
Definition: BeamFitter.h:223
bool falgo
Definition: BeamFitter.h:204
int ftotal_tracks
Definition: BeamFitter.h:159
int min_Ntrks_
Definition: BeamFitter.h:160
TH1F * h1cutFlow
Definition: BeamFitter.h:235
double fdydz
Definition: BeamFitter.h:221
TTree * fPVTree_
Definition: BeamFitter.h:239
std::vector< reco::TrackBase::TrackAlgorithm > algorithm_
Definition: BeamFitter.h:156
TH1F * h1ntrks
Definition: BeamFitter.h:233
char fbeginTimeOfFit[32]
Definition: BeamFitter.h:214
double fpvz
Definition: BeamFitter.h:206
double fz0
Definition: BeamFitter.h:185
double ftheta
Definition: BeamFitter.h:176
void setFitLSRange(int ls0, int ls1)
Definition: BeamFitter.h:115
double fd0
Definition: BeamFitter.h:182
bool fquality
Definition: BeamFitter.h:203
double fy
Definition: BeamFitter.h:217
void resetLSRange()
Definition: BeamFitter.h:60
int fnStripLayerMeas
Definition: BeamFitter.h:189
double fwidthYErr
Definition: BeamFitter.h:231
double fxErr
Definition: BeamFitter.h:222
bool appendRunTxt_
Definition: BeamFitter.h:137
int fnTIDLayerMeas
Definition: BeamFitter.h:191
void SetPVInfo(const std::vector< float > &v1_)
Definition: BeamFitter.h:83
bool saveNtuple_
Definition: BeamFitter.h:170
std::vector< BeamSpotFitPVData > getpvStore()
Definition: PVFitter.h:65
double fsigmaZ
Definition: BeamFitter.h:219
int fbeginLumiOfFit
Definition: BeamFitter.h:212
std::string outputfilename_
Definition: BeamFitter.h:173
bool writeTxt_
Definition: BeamFitter.h:141
int getRunNumber()
Definition: BeamFitter.h:112
double fsigmad0
Definition: BeamFitter.h:184
std::string outputDIPTxt_
Definition: BeamFitter.h:145
bool fpvValid
Definition: BeamFitter.h:205
double fdydzErr
Definition: BeamFitter.h:227
virtual ~BeamFitter()
Definition: BeamFitter.cc:197
void dumpTxtFile(std::string &, bool)
Definition: BeamFitter.cc:668
std::vector< float > ForDIPPV_
Definition: BeamFitter.h:166
void resizeBSvector(unsigned int nsize)
Definition: BeamFitter.h:77
double inputBeamWidth_
Definition: BeamFitter.h:157
bool savePVVertices_
Definition: BeamFitter.h:172
void resizepvStore(unsigned int rmSize)
Definition: PVFitter.h:112
void updateBTime()
Definition: BeamFitter.cc:29
void runAllFitter()
Definition: BeamFitter.cc:783
void resetAll()
Definition: PVFitter.h:83
bool writeDIPTxt_
Definition: BeamFitter.h:142
double fvx
Definition: BeamFitter.h:199
double fpt
Definition: BeamFitter.h:177
std::pair< time_t, time_t > getRefTime()
Definition: BeamFitter.h:70
TH1F * getCutFlow()
Definition: BeamFitter.h:96
double fcov[7][7]
Definition: BeamFitter.h:198
HLT enums.
void resetPVFitter()
Definition: BeamFitter.h:72
std::vector< reco::TrackBase::TrackQuality > quality_
Definition: BeamFitter.h:155
void resizePVvector(unsigned int npvsize)
Definition: BeamFitter.h:80
double fsigmaz0
Definition: BeamFitter.h:186
int trk_MinNPixLayers_
Definition: BeamFitter.h:151
int fnTIBLayerMeas
Definition: BeamFitter.h:190
TTree * ftreeFit_
Definition: BeamFitter.h:210
int getNPVs()
Definition: PVFitter.h:120
void resetCutFlow()
Definition: BeamFitter.h:104
double fd0bs
Definition: BeamFitter.h:183
std::pair< int, int > getFitLSRange()
Definition: BeamFitter.h:114
static void fillDescription(edm::ParameterSetDescription &)
Definition: BeamFitter.cc:224
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
Definition: BeamFitter.h:138
void setRefTime(time_t t0, time_t t1)
Definition: BeamFitter.h:62
double trk_MinpT_
Definition: BeamFitter.h:146
bool writeDIPBadFit_
Definition: BeamFitter.h:143
std::ofstream fasciiFile
Definition: BeamFitter.h:133
double fzErr
Definition: BeamFitter.h:224
int fnPXBLayerMeas
Definition: BeamFitter.h:194
reco::BeamSpot getBeamSpot()
Definition: BeamFitter.h:93
double fpvy
Definition: BeamFitter.h:206
bool saveBeamFit_
Definition: BeamFitter.h:171
edm::EDGetTokenT< edm::View< reco::Vertex > > vertexToken_
Definition: BeamFitter.h:139
double fz
Definition: BeamFitter.h:218
bool fitted_
Definition: BeamFitter.h:162
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
Definition: BeamFitter.h:140
int fnPXFLayerMeas
Definition: BeamFitter.h:195
void resetTotTrk()
Definition: BeamFitter.h:59
int fnTECLayerMeas
Definition: BeamFitter.h:193
int trk_MinNTotLayers_
Definition: BeamFitter.h:150
void resetRefTime()
Definition: BeamFitter.h:61