Belle II Software release-09-00-07
ARICHCalibrationChecker.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
9/* Own header. */
10#include <arich/calibration/ARICHCalibrationChecker.h>
11
12/* ARICH headers. */
13#include <arich/utility/ARICHChannelHist.h>
14#include <arich/dbobjects/ARICHChannelMask.h>
15
16/* Belle II headers. */
17#include <framework/database/Database.h>
18#include <framework/database/DBStore.h>
19#include <framework/database/Configuration.h>
20#include <framework/datastore/DataStore.h>
21
22/* ROOT include. */
23#include <TCanvas.h>
24#include <TFile.h>
25#include <TH1F.h>
26#include <TString.h>
27#include <TTree.h>
28
29using namespace Belle2;
30
32 m_experiment(0),
33 m_run(0)
34{
35}
36
38{
39}
40
41void ARICHCalibrationChecker::setExperimentRun(int experiment, int run)
42{
43 m_experiment = experiment;
44 m_run = run;
45 if (m_EventMetaData.isValid()) {
46 m_EventMetaData->setExperiment(experiment);
47 m_EventMetaData->setRun(run);
48 }
49}
50
52{
53 /* Mimic a module initialization. */
55 m_EventMetaData.registerInDataStore();
57 if (!m_EventMetaData.isValid())
58 m_EventMetaData.construct(1, m_run, m_experiment);
59 /* Database instance and configuration. */
60 DBStore& dbStore = DBStore::Instance();
61 dbStore.update();
62 dbStore.updateEvent();
63 auto& dbConfiguration = Conditions::Configuration::getInstance();
64 if ((m_testingPayloadName != "") and (m_GlobalTagName == ""))
65 dbConfiguration.prependTestingPayloadLocation(m_testingPayloadName);
66 else if ((m_testingPayloadName == "") and (m_GlobalTagName != ""))
67 dbConfiguration.prependGlobalTag(m_GlobalTagName);
68 else
69 B2FATAL("Setting both testing payload and Global Tag or setting no one of them.");
70}
71
73{
74 /* Reset both DataStore and Database. */
76 // Database::Instance().reset(false);
77 Database::Instance().reset(true); // keep the configuration
78 DBStore::Instance().reset(false);
79}
80
82{
83 if (modID <= 42) return 1;
84 if (modID <= 90) return 2;
85 if (modID <= 144) return 3;
86 if (modID <= 204) return 4;
87 if (modID <= 270) return 5;
88 if (modID <= 342) return 6;
89 if (modID <= 420) return 7;
90 return 0;
91}
92
94{
95 if (getRing(modID) == 1) return (modID - 1) / 7 + 1;
96 if (getRing(modID) == 2) return (modID - 43) / 8 + 1;
97 if (getRing(modID) == 3) return (modID - 91) / 9 + 1;
98 if (getRing(modID) == 4) return (modID - 145) / 10 + 1;
99 if (getRing(modID) == 5) return (modID - 205) / 11 + 1;
100 if (getRing(modID) == 6) return (modID - 271) / 12 + 1;
101 if (getRing(modID) == 7) return (modID - 343) / 13 + 1;
102 return 0;
103}
104
106{
107 /* Initialize the database. */
109 /* Now we can read the payload. */
110 DBObjPtr<ARICHChannelMask> channelMask;
111 if (!channelMask.isValid())
112 B2FATAL("ARICHChannelMask is not valid.");
113 if (m_GlobalTagName != "")
114 printPayloadInformation(channelMask);
115 /* Create tree with fractions of masked channels in each sector. */
116 float frac_masked_sector[6] = {0.};
117 float frac_masked = 0.;
118 TFile* channelMaskResults =
119 new TFile(m_channelMaskResultsFile.c_str(), "recreate");
120 TTree* maskTree = new TTree("arich_masked", "ARICH channel masking");
121 maskTree->Branch("experiment", &m_experiment, "experiment/I");
122 maskTree->Branch("run", &m_run, "run/I");
123 maskTree->Branch("frac_masked_sector", &frac_masked_sector, "frac_masked_sector[6]/F");
124 maskTree->Branch("frac_masked", &frac_masked, "frac_masked/F");
125
126 for (int mod = 1; mod < 421; mod++) {
127 int sector = getSector(mod);
128 for (int chn = 0; chn < 144; chn++) {
129 if (!channelMask->isActive(mod, chn)) { frac_masked_sector[sector - 1]++; frac_masked++;}
130 }
131 }
132
133 for (int sec = 0; sec < 6; sec++) frac_masked_sector[sec] /= 10080.;
134 frac_masked /= 60480.;
135 maskTree->Fill();
136
137 maskTree->Write();
138 delete maskTree;
139 delete channelMaskResults;
140 /* Reset the database. Needed to avoid mess if we call this method multiple times with different GTs. */
142}
void checkChannelMask()
Check channel mask.
void resetDatabase()
Reset the database.
void initializeDatabase()
Initialize the database.
std::string m_channelMaskResultsFile
Output file for channel mask results.
int getRing(int modID)
Get HAPD ring number.
int getSector(int modID)
Get HAPD sector number.
void setExperimentRun(int experiment, int run)
Set experiment and run numbers.
std::string m_GlobalTagName
Global Tag name.
std::string m_testingPayloadName
Testing payload location.
void printPayloadInformation(DBObjPtr< T > &dbObject)
Print payload information.
StoreObjPtr< EventMetaData > m_EventMetaData
Event metadata.
static Configuration & getInstance()
Get a reference to the instance which will be used when the Database is initialized.
bool isValid() const
Check whether a valid object was obtained from the database.
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Singleton class to cache database objects.
Definition: DBStore.h:31
static DataStore & Instance()
Instance of singleton Store.
Definition: DataStore.cc:54
void setInitializeActive(bool active)
Setter for m_initializeActive.
Definition: DataStore.cc:94
void reset(EDurability durability)
Frees memory occupied by data store items and removes all objects from the map.
Definition: DataStore.cc:86
void reset(bool keepEntries=false)
Invalidate all payloads.
Definition: DBStore.cc:177
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:42
static DBStore & Instance()
Instance of a singleton DBStore.
Definition: DBStore.cc:28
void updateEvent()
Updates all intra-run dependent objects.
Definition: DBStore.cc:142
void update()
Updates all objects that are outside their interval of validity.
Definition: DBStore.cc:79
static void reset(bool keepConfig=false)
Reset the database instance.
Definition: Database.cc:50
Abstract base class for different kinds of events.