Belle II Software development
FudgeFactorCalibrationAlgorithm.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <cdc/calibration/FudgeFactorCalibrationAlgorithm.h>
9#include <calibration/CalibrationAlgorithm.h>
10#include <TError.h>
11#include <TROOT.h>
12#include <TH1F.h>
13#include <TH2F.h>
14#include <TFile.h>
15#include <TTree.h>
16#include <TStopwatch.h>
17
18#include <framework/database/DBObjPtr.h>
19#include <framework/database/IntervalOfValidity.h>
20#include <framework/logging/Logger.h>
21
22//#include "getSigma68WithUncertainty.h"
23
24using namespace std;
25using namespace Belle2;
26using namespace CDC;
27
29{
30
32 " -------------------------- T0 Calibration Algorithm -------------------------\n"
33 );
34}
35
37{
38 B2INFO("Start calibration");
39
40 gROOT->SetBatch(1);
41 gErrorIgnoreLevel = 3001;
42 // We are potentially using data from several runs at once during execution
43 // (which may have different DBObject values). So in general you would need to
44 // average them, or aply them to the correct collector data.
45
46 // However since this is the geometry lets assume it is fixed for now.
47 const auto exprun = getRunList()[0];
48 B2INFO("ExpRun used for DB Geometry : " << exprun.first << " " << exprun.second);
49 updateDBObjPtrs(1, exprun.second, exprun.first);
50
51 // CDCGeometryPar basically constructs a ton of objects and other DB objects.
52 // Normally we'd call updateDBObjPtrs to set the values of the requested DB objects.
53 // But in CDCGeometryPar the DB objects get used during the constructor so they must
54 // be set before/during the constructor.
55
56 //reading data from rootfile
57 auto tree = getObjectPtr<TTree>("tree");
58 auto hEvtT0 = getObjectPtr<TH1F>("hEventT0");
59 auto hNDF_pos = getObjectPtr<TH1F>("hNDF_pos");
60 auto hNDF_neg = getObjectPtr<TH1F>("hNDF_neg");
61 auto hPval_pos = getObjectPtr<TH1F>("hPval_pos");
62 auto hPval_neg = getObjectPtr<TH1F>("hPval_neg");
63
64 auto hnCDC_pos = getObjectPtr<TH1F>("hnCDC_pos");
65 auto hnCDC_neg = getObjectPtr<TH1F>("hnCDC_neg");
66
67
68 auto hdPt = getObjectPtr<TH1F>("hdPt");
69 auto hdD0 = getObjectPtr<TH1F>("hdD0");
70 auto hdZ0 = getObjectPtr<TH1F>("hdZ0");
71
72 auto hdPt_cm = getObjectPtr<TH1F>("hdPt_cm");
73 auto hdPtPt_cm = getObjectPtr<TH2F>("hdPtPt_cm");
74 auto hdTheta_cm = getObjectPtr<TH1F>("hdTheta_cm");
75 auto hdPhi0_cm = getObjectPtr<TH1F>("hdPhi0_cm");
76
77
78 B2INFO("Storing histograms");
79 TFile* fout = new TFile(m_histName.c_str(), "RECREATE");
80 fout->cd();
81 // TDirectory* top = gDirectory;
82 // if(tree) tree->Write();
83 if (hEvtT0) hEvtT0->Write();
84
85 if (hPval_pos) hPval_pos->Write();
86 if (hPval_neg) hPval_neg->Write();
87
88 if (hNDF_pos) hNDF_pos->Write();
89 if (hNDF_neg) hNDF_neg->Write();
90
91 if (hnCDC_pos) hnCDC_pos->Write();
92 if (hnCDC_neg) hnCDC_neg->Write();
93
94 if (hdPt) hdPt->Write();
95 if (hdD0) hdD0->Write();
96 if (hdZ0) hdZ0->Write();
97
98 if (hdPt_cm) hdPt_cm->Write();
99 if (hdPtPt_cm) hdPtPt_cm->Write();
100 if (hdPhi0_cm) hdPhi0_cm->Write();
101 if (hdTheta_cm) hdTheta_cm->Write();
102 TTree* newtree = tree->CloneTree();
103 newtree->SetName("tree_dimuon");
104 newtree->Write();
105 fout->Write();
106 fout->Close();
107 return c_OK;
108}
Base class for calibration algorithms.
void updateDBObjPtrs(const unsigned int event, const int run, const int experiment)
Updates any DBObjPtrs by calling update(event) for DBStore.
void setDescription(const std::string &description)
Set algorithm description (in constructor)
const std::vector< Calibration::ExpRun > & getRunList() const
Get the list of runs for which calibration is called.
EResult
The result of calibration.
@ c_OK
Finished successfuly =0 in Python.
Abstract base class for different kinds of events.
STL namespace.