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{
31 " -------------------------- CDC fudge factor Calibration Algorithm -------------------------\n"
32 );
33}
34
36{
37 B2INFO("Start calibration");
38
39 gROOT->SetBatch(1);
40 gErrorIgnoreLevel = 3001;
41 // We are potentially using data from several runs at once during execution
42 // (which may have different DBObject values). So in general you would need to
43 // average them, or aply them to the correct collector data.
44
45 // However since this is the geometry lets assume it is fixed for now.
46 const auto exprun = getRunList()[0];
47 B2INFO("ExpRun used for DB Geometry : " << exprun.first << " " << exprun.second);
48 updateDBObjPtrs(1, exprun.second, exprun.first);
49
50 // CDCGeometryPar basically constructs a ton of objects and other DB objects.
51 // Normally we'd call updateDBObjPtrs to set the values of the requested DB objects.
52 // But in CDCGeometryPar the DB objects get used during the constructor so they must
53 // be set before/during the constructor.
54
55 //reading data from rootfile
56 auto tree = getObjectPtr<TTree>("tree");
57 auto hEvtT0 = getObjectPtr<TH1F>("hEventT0");
58 auto hExtraCDCHit = getObjectPtr<TH1F>("hExtraCDCHit");
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 if (hExtraCDCHit) hExtraCDCHit->Write();
85
86 if (hPval_pos) hPval_pos->Write();
87 if (hPval_neg) hPval_neg->Write();
88
89 if (hNDF_pos) hNDF_pos->Write();
90 if (hNDF_neg) hNDF_neg->Write();
91
92 if (hnCDC_pos) hnCDC_pos->Write();
93 if (hnCDC_neg) hnCDC_neg->Write();
94
95 if (hdPt) hdPt->Write();
96 if (hdD0) hdD0->Write();
97 if (hdZ0) hdZ0->Write();
98
99 if (hdPt_cm) hdPt_cm->Write();
100 if (hdPtPt_cm) hdPtPt_cm->Write();
101 if (hdPhi0_cm) hdPhi0_cm->Write();
102 if (hdTheta_cm) hdTheta_cm->Write();
103 TTree* newtree = (TTree*)tree->CloneTree();
104 newtree->SetName("dimuon");
105 newtree->Print();
106 // tree->Write(0,TObject::kOverwrite);
107 // tree->Write();
108 fout->Write();
109 delete fout;
110 return c_OK;
111}
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 successfully =0 in Python.
Abstract base class for different kinds of events.
STL namespace.