R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
neulandMuon.cxx
Go to the documentation of this file.
1
2/******************************************************************************
3 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
4 * Copyright (C) 2019-2023 Members of R3B Collaboration *
5 * *
6 * This software is distributed under the terms of the *
7 * GNU General Public Licence (GPL) version 3, *
8 * copied verbatim in the file "LICENSE". *
9 * *
10 * In applying this license GSI does not waive the privileges and immunities *
11 * granted to it by virtue of its status as an Intergovernmental Organization *
12 * or submit itself to any jurisdiction. *
13 ******************************************************************************/
14
15#include "FairFileSource.h"
16#include "FairParRootFileIo.h"
17#include "FairRootFileSink.h"
18#include "FairRunAna.h"
19#include "FairRuntimeDb.h"
24#include "R3BDigitizingTamex.h"
25#include "R3BFileSource2.h"
26#include "R3BNeulandHitMon.h"
27#include "R3BProgramOptions.h"
28#include "TRandom3.h"
29#include "TStopwatch.h"
30#include <R3BNeulandDigitizer.h>
31#include <TObjString.h>
32#include <boost/program_options.hpp>
33#include <memory>
34
35namespace Digitizing = R3B::Digitizing;
43
44// auto GetHitPar(const std::string& parName)
45// {
46// return []() { Digitizing::Neuland::Tamex::Channel::GetHitPar("test"); };
47// }
48
49auto main(int argc, char** argv) -> int
50{
51 auto timer = TStopwatch{};
52 timer.Start();
53
54 auto programOptions = R3B::ProgramOptions("options for neuland data analysis");
55 auto help = programOptions.create_option<bool>("help,h", "help message", false);
56 auto paddleName =
57 programOptions.create_option<std::string>("paddle", R"(set the paddle name. e.g. "neuland")", "neuland");
58 auto channelName =
59 programOptions.create_option<std::string>("channel", R"(set the channel name. e.g. "tamex")", "tamex");
60 auto simuFileName =
61 programOptions.create_option<std::string>("simuFile", "set the filename of simulation input", "simu.root");
62 auto paraFileName =
63 programOptions.create_option<std::string>("paraFile", "set the filename of parameter sink", "para.root");
64 auto paraFileName2 =
65 programOptions.create_option<std::string>("paraFile2", "set the filename of the second parameter sink", "");
66 auto digiFileName =
67 programOptions.create_option<std::string>("digiFile", "set the filename of digitization output", "digi.root");
68 auto logLevel = programOptions.create_option<std::string>("logLevel,v", "set log level of fairlog", "error");
69 auto eventNum = programOptions.create_option<int>("eventNum,n", "set total event number", 0);
70 auto hitLevelPar =
71 programOptions.create_option<std::string>("hitLevelPar", "set the name of hit level parameter if needed.", "");
72
73 // Paula: Error not yet used in the code
74 auto errorcal = programOptions.create_option<bool>("errorCal", "usage of errors in calculations", false);
75
76 // Paula:digi option for Caldata
77 auto calData = programOptions.create_option<bool>("calData", "Doing CalData calculations", true);
78
79 if (!programOptions.verify(argc, argv))
80 {
81 return EXIT_FAILURE;
82 }
83
84 if (help())
85 {
86 std::cout << programOptions.get_desc_ref() << std::endl;
87 return 0;
88 }
89
90 //=============================================================================
91 // settings:
94 tamexParameter.fPMTThresh = 1.;
95 tamexParameter.fTimeMin = 1.;
96
97 // Paula: CalData is only implimented in Tamex for now
98 // const auto neulandEngines = std::map<std::pair<const std::string, const std::string>,
99 // std::function<std::unique_ptr<Digitizing::DigitizingEngineInterface>()>>{
100 // { { "neuland", "tamex" },
101 // [&]()
102 // {
103 // return Digitizing::CreateEngine(
104 // UsePaddle<NeulandPaddle>(), UseChannel<TamexChannel>(pileup_strategy, tamexParameter),
105 // channelInit);
106 // } },
107 // { { "neuland", "tacquila" },
108 // []() { return Digitizing::CreateEngine(UsePaddle<NeulandPaddle>(), UseChannel<TacquilaChannel>()); } },
109 // { { "mock", "tamex" },
110 // [&]()
111 // {
112 // return Digitizing::CreateEngine(
113 // UsePaddle<MockPaddle>(), UseChannel<TamexChannel>(pileup_strategy, tamexParameter), channelInit);
114 // } },
115 // { { "neuland", "mock" },
116 // []() { return Digitizing::CreateEngine(UsePaddle<NeulandPaddle>(), UseChannel<MockChannel>()); } },
117 // { { "mock", "mock" },
118 // []() { return Digitizing::CreateEngine(UsePaddle<MockPaddle>(), UseChannel<MockChannel>()); } }
119 // };
120 // Paula:test
121
122 //=============================================================================
123
124 FairLogger::GetLogger()->SetLogScreenLevel(logLevel().c_str());
125
126 auto run = std::make_unique<FairRunAna>();
127 auto filesource = std::make_unique<R3BFileSource2>(simuFileName().c_str());
128 auto filesink = std::make_unique<FairRootFileSink>(digiFileName().c_str());
129 run->SetSource(filesource.release());
130 run->SetSink(filesink.release());
131
132 auto fileio = std::make_unique<FairParRootFileIo>();
133 fileio->open(paraFileName().c_str());
134 run->GetRuntimeDb()->setFirstInput(fileio.release());
135
136 if (const auto& filename = paraFileName2(); not filename.empty())
137 {
138 auto fileio2 = std::make_unique<FairParRootFileIo>();
139 fileio2->open(paraFileName2().c_str());
140 run->GetRuntimeDb()->setSecondInput(fileio2.release());
141 }
142
143 auto hit_par = std::make_unique<R3B::Neuland::Cal2HitPar>();
144
145 auto* hit_par_ptr = hit_par.get();
146
147 run->GetRuntimeDb()->addContainer(hit_par.release());
148
149 const auto neulandEngines = std::map<std::pair<const std::string, const std::string>,
150 std::function<std::unique_ptr<Digitizing::DigitizingEngineInterface>()>>{
151 { { "neuland", "tamex" },
152 [&pileup_strategy, &tamexParameter, hit_par_ptr]()
153 {
155 UseChannel<TamexChannel>(pileup_strategy, tamexParameter, hit_par_ptr));
156 } }
157 };
158
159 // // Paula: par_name hardcoded will change to flag later
160 // auto par_name = std::string_view{ "NeulandCal2HitPar" };
161 // auto* par = dynamic_cast<R3B::Neuland::Cal2HitPar*>(run->GetRuntimeDb()->findContainer(par_name.data()));
162 // if (par == nullptr)
163 // {
164 // par = std::make_unique<R3B::Neuland::Cal2HitPar>(par_name.data()).release();
165 // if (run->GetRuntimeDb()->addContainer(par); par == nullptr)
166 // {
167 // throw R3B::runtime_error("Calibration parameter becomes nullptr!");
168 // }
169 // }
170
171 auto digiNeuland = std::make_unique<R3BNeulandDigitizer>();
172 digiNeuland->EnableCalDataOutput(calData.value());
173 auto neulandEngine = neulandEngines.at({ paddleName(), channelName() });
174 // Paula: If stuff needs to be added here
175 digiNeuland->SetEngine((neulandEngine)());
176 run->AddTask(digiNeuland.release());
177
178 run->Init();
179 run->Run(0, eventNum());
180
181 timer.Stop();
182 auto* sink = run->GetSink();
183 sink->Close();
184 std::cout << "Macro finished successfully." << std::endl;
185 std::cout << "Real time: " << timer.RealTime() << "s, CPU time: " << timer.CpuTime() << "s" << std::endl;
186}
Tamex::Channel TamexChannel
Digitizing::Neuland::MockPaddle MockPaddle
Digitizing::Neuland::NeulandPaddle NeulandPaddle
Digitizing::Neuland::MockChannel MockChannel
Digitizing::Neuland::TacQuila::Channel TacquilaChannel
static auto GetDefaultRandomGen() -> TRandom3 &
auto main() -> int
Definition ex_test.cxx:109
auto CreateEngine(Args &&... args) -> std::unique_ptr< decltype(DigitizingEngine{ std::forward< Args >(args)... })>