10#include "TTreeFormula.h"
15 fIsGlobal = isGlobalCoordinates;
16 LOG(detail) << Form(
"BmnScWallReconstructor: isExp %i; isGlobal %i", fIsExp, fIsGlobal);
21 fRecoCutsFile = reco_cuts_file;
23 LOG(detail) << Form(
"BmnScWallReconstructor: Reco cuts %s", fRecoCutsFile.Data());
29 delete fBmnScWallEvent;
35 fpFairRootMgr = FairRootManager::Instance();
36 (fIsExp) ? fArrayOfDigits = (TClonesArray*)fpFairRootMgr->GetObject(
"ScWallDigi")
37 : fArrayOfDigits = (TClonesArray*)fpFairRootMgr->GetObject(
"ScWallDigit");
39 if (!fArrayOfDigits) {
40 LOG(error) <<
"BmnScWallReconstructor::Init(): branch with Digits not found! Task will be deactivated";
46 fBmnScWallEvent->
reset();
48 fpFairRootMgr->RegisterAny(
"ScWallEvent", fBmnScWallEvent, kTRUE);
50 LOG(debug) <<
"ScWall Reconstructor ready";
56 namespace po = boost::program_options;
58 TString dir = getenv(
"VMCWORKDIR");
59 TString path = dir +
"/parameters/scwall/";
67 po::options_description desc(
"Options");
68 desc.add_options()(
"VERSION.id", po::value<float>(&version),
69 "version identificator")(
"COMMENT.str", po::value<std::string>(&comment),
"comment")(
70 "EXPERIMENT.cut", po::value<std::string>(&cutExp),
71 "cut for Experimental data")(
"SIMULATION.cut", po::value<std::string>(&cutSim),
"cut for Simulated data");
75 std::ifstream config_file((path + fRecoCutsFile).Data(), std::ifstream::in);
76 if (!config_file.is_open()) {
77 LOG(error) << Form(
"BmnScWallReconstructor: Loading Cuts from file: %s - file open error!",
78 fRecoCutsFile.Data());
81 LOG(debug) << Form(
"BmnScWallReconstructor: Loading Cuts from file: %s", fRecoCutsFile.Data());
82 po::store(po::parse_config_file(config_file, desc), vm);
87 fSelectionString = cutExp;
89 fSelectionString = cutSim;
97 for (
auto it : positionMap) {
98 auto unique_address = it.first;
99 if (unique_address == 0)
102 auto this_cell = fBmnScWallEvent->
GetCell(cell_id);
104 this_cell->SetSignal(0.);
106 this_cell->SetPosition(it.second.first);
107 this_cell->SetPositionError(it.second.second);
121 auto digiVector = GetSelectedDigiVector(fSelectionString);
123 for (
auto it : digiVector) {
128 LOG(warning) << Form(
"ScWall digi ignored. Cell %d ", cell_id);
136 fworkTime += sw.RealTime();
139std::vector<TObject*> BmnScWallReconstructor::GetSelectedDigiVector(TString formulaString)
141 TTree* temp_tree =
new TTree(
"temp_tree",
"temp_tree");
142 TString temp_br_name = (fIsExp) ?
"ScWallDigi" :
"ScWallDigit";
143 fSelectedDigiVector.clear();
147 temp_tree->Branch(temp_br_name.Data(), &ptr);
148 for (
int i = 0;
i < fArrayOfDigits->GetEntriesFast();
i++) {
154 temp_tree->Branch(temp_br_name.Data(), &ptr);
155 for (
int i = 0;
i < fArrayOfDigits->GetEntriesFast();
i++) {
161 TTreeFormula* formula =
new TTreeFormula(
"TTreeformula", formulaString.Data(), temp_tree);
162 if (!formula || formula->GetNdim() == 0)
163 LOG(error) << Form(
"BmnScWallReconstructor::GetSelectedDigiVector. Bad cuts. Check formula %s from file %s",
164 formulaString.Data(), fRecoCutsFile.Data());
166 TObject* ThisDigi =
nullptr;
167 temp_tree->SetBranchAddress(temp_br_name.Data(), &ThisDigi);
168 for (
int i = 0;
i < temp_tree->GetEntries();
i++) {
169 temp_tree->GetEntry(
i);
171 if (formula->EvalInstance() > 0)
172 fSelectedDigiVector.push_back(fArrayOfDigits->At(
i));
176 return fSelectedDigiVector;
184 resultTree->Branch(
"ScWallEvent", &fBmnScWallEvent);
190 printf(
"Work time of BmnScWallReconstructor: %4.2f sec.\n", fworkTime);
const auto & GetPositionMap() const
BmnStatus ReadGeometryFromGeoManager(bool getGlobalPosition=true)
static uint32_t GetCellId(uint32_t address)
Return Cell id from address.
void SetSignal(float Signal)
void SetCellId(int CellId)
Position.
Class for experimental data at digi level.
uint32_t GetCellId() const
Class for Bmn ScWall data container in event.
BmnScWallCell * GetCell(uint8_t cell_id)
Cell info.
static const int fgkMaxCells
void reset()
Zero all fields.
virtual InitStatus Init()
~BmnScWallReconstructor()
BmnScWallReconstructor(bool isExp, bool isGlobalCoordinates)
void SetRecoCutsFile(TString reco_cuts_file)
virtual void Exec(Option_t *opt)
virtual void OnlineWrite(const std::unique_ptr< TTree > &resultTree)
Write task resul to tree.