CMS 3D CMS Logo

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