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