CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
Muc/MucCalibAlg/MucCalibAlg-00-02-16/MucCalibAlg/MucCalibMgr.h
Go to the documentation of this file.
1//------------------------------------------------------------------------------|
2// [File ]: MucCalibMgr.h |
3// [Brief ]: Header file of MucCalibMgr class for encapsulation |
4// [Author]: Xie Yuguang, <[email protected]> |
5// [Date ]: Mar 28, 2006 |
6//------------------------------------------------------------------------------|
7
8#ifndef MUC_CALIB_MGR_H
9#define MUC_CALIB_MGR_H
10
11#include <iostream>
12#include <vector>
13#include <fstream>
14#include <time.h>
15
16#include "GaudiKernel/IDataProviderSvc.h"
17#include "GaudiKernel/IMessageSvc.h"
18#include "GaudiKernel/IAIDATupleSvc.h"
19#include "GaudiKernel/INTupleSvc.h"
20#include "GaudiKernel/NTuple.h"
21#include "GaudiKernel/MsgStream.h"
22
23#include "TCanvas.h"
24#include "TGraphErrors.h"
25#include "TH1F.h"
26#include "TH2F.h"
27#include "TF1.h"
28#include "TFile.h"
29#include "TFolder.h"
30#include "TTree.h"
31#include "TObjArray.h"
32#include "TDirectory.h"
33
34#include "MucCalibAlg/MucStructConst.h"
35#include "MucCalibAlg/MucBoxCal.h"
36#include "MucCalibAlg/MucStripCal.h"
37#include "MucCalibAlg/MucMark.h"
38#include "MucCalibAlg/MucIdTransform.h"
39
40using namespace std;
41
42class MucCalibMgr {
43
44 public:
45 MucCalibMgr( std::vector<double> jobInfo, std::vector<int> configInfo, std::string outputFile );
47
48 // for initialize
49 StatusCode InitNtuple();
50 StatusCode InitHisto();
51 StatusCode InitArea();
52
53 // for execute
54 StatusCode DimuSelect();
55 StatusCode ReadEvent();
56 StatusCode CheckEvent();
57 StatusCode FillEvent();
58
59 // for finalize
60 StatusCode AnalyseEffAndNoise();
61 StatusCode AnalyseCluster();
62 StatusCode AnalyseRes();
63
64 StatusCode SaveConst();
65 StatusCode EndRun();
66
67 protected:
68
69 StatusCode InitOnlineHisto();
70 StatusCode InitHistoLV0();
71 StatusCode InitHistoLV1();
72 StatusCode InitHistoLV2();
73 StatusCode Init2DEffHisto();
74 StatusCode InitClusterHisto();
75 StatusCode InitResHisto();
76 StatusCode InitConstTree();
77
78 StatusCode FillDigi( int part, int segment, int layer, int strip );
79 StatusCode FillExpHit( int part, int segment, int layer, int strip );
80 StatusCode FillEffHit( int part, int segment, int layer, int strip );
81 StatusCode FillNosHit( int part, int segment, int layer, int strip );
82 StatusCode FillCluster( int part, int segment, int layer, int size );
83
84 StatusCode EffAndNoiseLV0();
85 StatusCode EffAndNoiseLV1();
86 StatusCode EffAndNoiseLV2();
87 StatusCode PadEff();
88
89 StatusCode ClearOnlineHisto();
90 StatusCode ClearHistoLV0();
91 StatusCode ClearHistoLV1();
92 StatusCode ClearHistoLV2();
93 StatusCode Clear2DEffHisto();
94 StatusCode ClearClusterHisto();
95 StatusCode ClearResHisto();
96 StatusCode ClearConstTree();
97
98 public:
99 IMessageSvc* msgSvc;
100 INTupleSvc* ntupleSvc;
101 IDataProviderSvc* eventSvc;
102
103 private:
104 double m_vs; // BOSS version
105 double m_hv; // high voltage, default = 7200V
106 double m_th; // threshold, default = 75mV
107 double m_er; // event rate, default = 4000Hz
108 double m_tag; // input event type 0:Anything(default), 1:Dimu,
109 // 2:RandomTrg, 3:Cosmic ray, 4:Ppjuu, 5:Other
110 int m_recMode; // rec mode flag, 0:ExtTrk(default), 1:SelfTrk, 2: combine
111 int m_usePad; // calculate pad eff flag, 0: no(default), other: yes
112 int m_effWindow; // eff window for tracking in eff calibration, default = 4
113 int m_clusterMode; // flag for cluster building method, 0: no build, 1: basic(default), 2/3: other
114 int m_clusterSave; // flag for cluster output, 0: no save(default), 1: save
115 int m_checkEvent; // flag for checking event or not, 0: not check(default), 1: check
116 int m_dimuSelect; // flag for selecting dimu event or not, 0: no(default), 1: yes
117 int m_dimuOnly; // flag for using dimu event only or not, 0: no(default), 1: yes
118
119 string m_outputFile; // calibration constants output file name
120 ofstream* m_fdata; // cluster data output file, enable if m_clusterMode != 0
121 clock_t m_jobStart, m_jobFinish; // for time assumption, start at constructor, end at SaveConst()
122 clock_t m_evtBegin, m_evtEnd; // for event processing time, start at ReadEvent(), end at FillEvent()
123
124 // Calibration results for total events
125 // 0-efficiency, 1-eff err, 2-noise, 3-area(cm^2), 4-Cluster(number of strip), 5-track number
126 double m_layerResults[6][LAYER_MAX];
127 double m_boxResults[6][BOX_MAX];
128 double m_stripResults[6][STRIP_MAX];
129
130 int m_currentRun;
131 long m_currentEvent;
132 int m_eventTag; // tag of event 0: all(default), 1: dimu
133 // Digi and hit container for total events
134 // 0-digi number, 1-rec track number, 2-efficiency hit number,
135 // 3-incidental and noise hit number, 4-rec/fit hit number
136 long m_record[PART_MAX][SEGMENT_MAX][LAYER_MAX][STRIP_INBOX_MAX][5];
137
138 // Digi or hit mark collection for one event
139 MucMark* m_ptrMucMark;
140 mark_col m_digiCol; // container of digis in an event
141 mark_col m_expHitCol; // container of fitting hits in all rec tracks in an event
142 mark_col m_calHitCol; // container of fired hits in a rec track,fresh each track
143 mark_col m_effHitCol; // container of fired hits in all rec tracks in an event
144 mark_col m_nosHitCol; // container of digis not in all rec tracks in an event
145
146 mark_col m_segDigiCol[PART_MAX][SEGMENT_MAX]; // container of digis in segment of part
147 vector< mark_col > m_clusterCol; // container of clusters in all digits of an event
148 vector<float> m_lineResCol; // container of residual by line fit
149 vector<float> m_quadResCol; // container of residual by quad fit
150 vector<float> m_extrResCol; // container of residual by extrapolation
151
152 // Muc id transformer
153 MucIdTransform* m_ptrIdTr;
154
155 // TGraph for eff with error bar
156 TGraphErrors* m_geLayerEff;
157 TGraphErrors* m_geBoxEff;
158 TGraphErrors* m_geStripEff;
159 TCanvas* m_cv[CALIB_LV_MAX];
160
161 // Histogram containers for efficiency and lost
162 // Hit map for online check
163 TH1F* m_hHitMapBarrel_Lay[B_LAY_NUM]; // fill according to layer(map per layer)
164 TH1F* m_hHitMapEndcap_Lay[2][E_LAY_NUM];
165 TH1F* m_hHitMapBarrel_Seg[B_SEG_NUM]; // fill according to segmemt(map per segment)
166 TH1F* m_hHitMapEndcap_Seg[2][E_SEG_NUM];
167
168 // Nhit vs event for online check
169 TH1F* m_hHitVsEvent;
170
171 // Distance between Ext track hit and Muc track hit on the first inner layer for online check
172 TH1F* m_hTrackDistance;
173
174 // Diff of phi angles of two tracks(dimuon event)
175 TH1F* m_hTrackPosPhiDiff;
176 TH1F* m_hTrackMomPhiDiff;
177 // Diff of theta angles of two tracks(dimuon event)
178 TH1F* m_hTrackPosThetaDiff;
179 TH1F* m_hTrackMomThetaDiff;
180
181 // PhiDiff VS ThetaDiff for dimuon event
182 TH2F* m_hDimuTracksPosDiff;
183 TH2F* m_hDimuTracksMomDiff;
184
185 // Phi VS costheta for online check
186 TH2F* m_hPhiCosTheta;
187
188 // Spacial resolution
189 TH1F* m_hBarrelResDist[B_LAY_NUM]; // barrel spacial resolution
190 TH1F* m_hEndcapResDist[E_LAY_NUM]; // endcap spacial resolution
191 TH1F* m_hBarrelResComp[2]; // barrel spacial resolution vs layer
192 TH1F* m_hEndcapResComp[2]; // ebdcao soacuak resikytuib vs layer
193
194 // 2D histogram for eff map
195 TH2F* m_h2DExpMap[PART_MAX][SEGMENT_MAX][LAYER_MAX];
196 TH2F* m_h2DHitMap[PART_MAX][SEGMENT_MAX][LAYER_MAX];
197 TH2F* m_h2DEffMap[PART_MAX][SEGMENT_MAX][LAYER_MAX];
198 TObjArray* m_histArray;
199
200
201 // LV0
202 TH1F* m_hBrLayerFire; // only barrel
203 TH1F* m_hEcLayerFire; // only endcap
204
205 TH1F* m_hLayerFire; // all
206 TH1F* m_hLayerExpHit;
207 TH1F* m_hLayerEffHit;
208 TH1F* m_hLayerNosHit;
209 TH1F* m_hLayerEff;
210 TH1F* m_hLayerNosRatio;
211 TH1F* m_hLayerArea;
212 TH1F* m_hLayerNos;
213 TH1F* m_hLayerCnt;
214
215 // LV1
216 TH1F* m_hBoxFire;
217 TH1F* m_hBoxExpHit;
218 TH1F* m_hBoxEffHit;
219 TH1F* m_hBoxNosHit;
220 TH1F* m_hBoxEff;
221 TH1F* m_hBoxNosRatio;
222 TH1F* m_hBoxArea;
223 TH1F* m_hBoxNos;
224 TH1F* m_hBoxCnt;
225
226 // LV2
227 TH1F* m_hStripFireMap[BOX_MAX];
228 TH1F* m_hStripExpHitMap[BOX_MAX];
229 TH1F* m_hStripEffHitMap[BOX_MAX];
230 TH1F* m_hStripNosHitMap[BOX_MAX];
231 TH1F* m_hStripEffMap[BOX_MAX];
232 TH1F* m_hStripNosRatioMap[BOX_MAX];
233 TH1F* m_hStripFire;
234 TH1F* m_hStripExpHit;
235 TH1F* m_hStripEffHit;
236 TH1F* m_hStripNosHit;
237 TH1F* m_hStripEff;
238 TH1F* m_hStripNosRatio;
239 TH1F* m_hStripArea;
240 TH1F* m_hStripNos;
241 TH1F* m_hStripCnt;
242
243 // Histograms for cluster
244 TH1F* m_hLayerCluster[LAYER_MAX];
245 TH1F* m_hLayerClusterCmp;
246 TH1F* m_hBoxCluster[BOX_MAX];
247 TH1F* m_hBoxClusterCmp;
248
249 //Tree for constant root file
250 TTree* m_tJobLog;
251 TTree* m_tStatLog;
252 TTree* m_tLayConst;
253 TTree* m_tBoxConst;
254 TTree* m_tStrConst;
255
256 // Job log tree
257 int m_fStartRun; // the id of run start
258 int m_fEndRun; // the id of run end
259 double m_fTotalDAQTime; // total DAQ time
260 double m_fTotalJobTime; // total job time
261 double m_fCalibLayerNum; // the number of layers calibrated
262 double m_fCalibBoxNum; // the number of boxes calibrated
263 double m_fCalibStripNum; // the number of strips calibrated
264 double m_fTotalEvent; // total events
265 double m_fTotalDigi; // total MUC digis
266 double m_fTotalExpHit; // total rec hits
267 double m_fTotalEffHit; // total eff hits
268 double m_fTotalNosHit; // total incidental/noise hits
269 double m_fTotalClstNum; // total number of clusters
270 double m_fTotalStripArea; // total area of strips
271 double m_fLayerCoverage; // layer calibrated coverage
272 double m_fBoxCoverage; // layer calibrated coverage
273 double m_fStripCoverage; // layer calibrated coverage
274
275 // Layer constants tree, level 0
276 double m_fLayerId;
277 double m_fLayerEff;
278 double m_fLayerEffErr;
279 double m_fLayerNosRatio;
280 double m_fLayerDigi;
281 double m_fLayerNos;
282 double m_fLayerCnt;
283 double m_fLayerExpHit;
284 double m_fLayerEffHit;
285 double m_fLayerNosHit;
286 double m_fLayerCluster;
287 double m_fLayerTrkNum;
288
289 // Box constants tree, level 1
290 double m_fBoxId;
291 double m_fBoxPart;
292 double m_fBoxSegment;
293 double m_fBoxLayer;
294 double m_fBoxEff;
295 double m_fBoxEffErr;
296 double m_fBoxNosRatio;
297 double m_fBoxDigi;
298 double m_fBoxNos;
299 double m_fBoxCnt;
300 double m_fBoxExpHit;
301 double m_fBoxEffHit;
302 double m_fBoxNosHit;
303 double m_fBoxCluster;
304 double m_fBoxTrkNum;
305
306 // Strip constants tree, level 2
307 double m_fStripId;
308 double m_fStripPart;
309 double m_fStripSegment;
310 double m_fStripLayer;
311 double m_fStripEff;
312 double m_fStripEffErr;
313 double m_fStripNosRatio;
314 double m_fStripDigi;
315 double m_fStripNos;
316 double m_fStripCnt;
317 double m_fStripExpHit;
318 double m_fStripEffHit;
319 double m_fStripNosHit;
320 double m_fStripTrkNum;
321
322 // N-tuple
323 NTuple::Tuple* m_eventLogTuple; // Event info
324 NTuple::Item<double> m_ntEventId;
325 NTuple::Item<double> m_ntEventTag;
326 NTuple::Item<double> m_ntEsTime;
327 NTuple::Item<double> m_ntDigiNum;
328 NTuple::Item<double> m_ntTrackNum;
329 NTuple::Item<double> m_ntExpHitNum;
330 NTuple::Item<double> m_ntEffHitNum;
331 NTuple::Item<double> m_ntNosHitNum;
332 NTuple::Item<double> m_ntClusterNum;
333 NTuple::Item<double> m_ntEventTime; // run time of a event
334
335 NTuple::Tuple* m_mdcTrkInfoTuple; // Mdc track info
336 NTuple::Item<long> m_charge;
337 NTuple::Item<double> m_mdcpx;
338 NTuple::Item<double> m_mdcpy;
339 NTuple::Item<double> m_mdcpz;
340 NTuple::Item<double> m_mdcpt;
341 NTuple::Item<double> m_mdcpp;
342 NTuple::Item<double> m_mdcphi;
343 NTuple::Item<double> m_mdctheta;
344
345 NTuple::Tuple* m_trackInfoTuple; // Track info
346 NTuple::Item<double> m_ntTrackEvent;
347 NTuple::Item<double> m_ntTrackTag;
348 NTuple::Item<double> m_ntTrackHits;
349 NTuple::Item<double> m_ntTrackSegFly;
350 NTuple::Item<double> m_ntTrackLayFlyA;
351 NTuple::Item<double> m_ntTrackLayFlyB;
352 NTuple::Item<double> m_ntTrackLayFlyC;
353 NTuple::Item<double> m_trkRecMode;
354 NTuple::Item<double> m_chi2;
355 NTuple::Item<double> m_px;
356 NTuple::Item<double> m_py;
357 NTuple::Item<double> m_pz;
358 NTuple::Item<double> m_pt;
359 NTuple::Item<double> m_pp;
360 NTuple::Item<double> m_r;
361 NTuple::Item<double> m_cosTheta;
362 NTuple::Item<double> m_theta;
363 NTuple::Item<double> m_phi;
364 NTuple::Item<double> m_depth;
365 NTuple::Item<double> m_brLastLayer;
366 NTuple::Item<double> m_ecLastLayer;
367 NTuple::Item<double> m_totalHits;
368 NTuple::Item<double> m_totalLayers;
369 NTuple::Item<double> m_maxHitsInLayer;
370
371 NTuple::Tuple* m_trackDiffTuple; // Track collinearity
372 NTuple::Item<double> m_ntDimuTag;
373 NTuple::Item<double> m_ntPosPhiDiff;
374 NTuple::Item<double> m_ntPosThetaDiff;
375 NTuple::Item<double> m_ntMomPhiDiff;
376 NTuple::Item<double> m_ntMomThetaDiff;
377
378 NTuple::Tuple* m_clusterSizeTuple; // Cluster size total
379 NTuple::Item<double> m_ntClusterSize;
380
381 NTuple::Tuple* m_effWindowTuple; // EFF_WINDOW
382 NTuple::Item<double> m_ntEffWindow;
383
384/*
385 NTuple::Tuple* m_resInfoTuple; // Res info
386 NTuple::Item<long> m_nExpNum;
387 NTuple::Array<double> m_res;
388 NTuple::Array<long> m_resPart;
389 NTuple::Array<long> m_resSegment;
390 NTuple::Array<long> m_resLayer;
391 NTuple::Array<bool> m_resFired;
392*/
393
394 NTuple::Tuple* m_resInfoTuple; // Res info
395 NTuple::Item<double> m_lineRes;
396 NTuple::Item<double> m_quadRes;
397 NTuple::Item<double> m_extrRes;
398 NTuple::Item<long> m_resPart;
399 NTuple::Item<long> m_resSegment;
400 NTuple::Item<long> m_resLayer;
401 NTuple::Item<long> m_resFired;
402 NTuple::Item<long> m_resMode;
403
404};
405
406#endif
StatusCode ClearHistoLV2()
StatusCode InitResHisto()
StatusCode FillEffHit(int part, int segment, int layer, int strip)
StatusCode DimuSelect()
StatusCode InitOnlineHisto()
StatusCode Init2DEffHisto()
StatusCode SaveConst()
StatusCode FillExpHit(int part, int segment, int layer, int strip)
StatusCode ClearResHisto()
StatusCode ClearHistoLV0()
StatusCode ClearClusterHisto()
StatusCode AnalyseCluster()
StatusCode ClearHistoLV1()
StatusCode PadEff()
StatusCode InitHistoLV1()
StatusCode InitHistoLV2()
StatusCode InitClusterHisto()
StatusCode FillCluster(int part, int segment, int layer, int size)
StatusCode ClearOnlineHisto()
StatusCode InitHisto()
StatusCode FillEvent()
StatusCode EffAndNoiseLV2()
MucCalibMgr(std::vector< double > jobInfo, std::vector< int > configInfo, std::string outputFile)
StatusCode InitHistoLV0()
StatusCode EndRun()
StatusCode ReadEvent()
StatusCode EffAndNoiseLV1()
StatusCode AnalyseRes()
StatusCode CheckEvent()
StatusCode FillNosHit(int part, int segment, int layer, int strip)
StatusCode EffAndNoiseLV0()
StatusCode InitConstTree()
StatusCode ClearConstTree()
StatusCode InitArea()
StatusCode AnalyseEffAndNoise()
StatusCode InitNtuple()
StatusCode Clear2DEffHisto()
StatusCode FillDigi(int part, int segment, int layer, int strip)