Skip to content
Snippets Groups Projects
Commit dad62f6e authored by Daniele Brugnara's avatar Daniele Brugnara
Browse files

Adds files that were removed by mistake for the lut_optimizer

parent 8bc59bbc
No related branches found
No related tags found
No related merge requests found
Pipeline #210543 passed
#include "UserConf.h"
UserConf::UserConf() : Conf("USER_CONF") {
parD.emplace("EXAMPLE",
Conf::Property<double&>{example, "mm",
"Example of configuration value"});
parVS.emplace("HISTO",
Conf::Property<std::vector<std::string>&>{histoList, "#",
"Histogram to be optimized"});
parS.emplace("DETECTOR",
Conf::Property<std::string&>{detector, "#", "Name of detector to optimize"});
}
......@@ -7,5 +7,6 @@ class UserConf : public Conf {
UserConf();
public:
double example{0};
std::vector<std::string> histoList{""};
std::string detector{"SPIDER"};
};
\ No newline at end of file
#include "UserSelector.h"
#include "CoincidenceAnalysis/CoincidenceAnalysis.h"
void UserSelector::SlaveBegin(TTree* treeToRead) {
AgataSelector::SlaveBegin(treeToRead);
......@@ -43,4 +45,51 @@ Bool_t UserSelector::Process(Long64_t entry) {
void UserSelector::SlaveTerminate() {
AgataSelector::SlaveTerminate();
// User terminate
CoincidenceAnalysis* coincAnalysis{nullptr};
for (const auto& it: detectorAnaList){
if(conf.user.detector == "SPIDER"){
coincAnalysis = dynamic_cast<AgataSpiderAnalysis*>(it);
} else if (conf.user.detector == "EUCLIDES") {
coincAnalysis = dynamic_cast<AgataEuclidesAnalysis*>(it);
}
if(coincAnalysis != nullptr) break;
}
std::vector<TH2D const*> histos;
for(const auto& it: conf.user.histoList){
auto h = coincAnalysis->GetHisto<TH2D>(it);
if (h == nullptr)
throw std::runtime_error("The provided histogram "+it+" does not exist or is not a TH2D\n");
histos.push_back(h);
}
outFile.mkdir("User","User's custom analysis");
outFile.cd("User");
UserHistograms& hu = userHistograms;
auto convertTH2DtoTH1Ds = [](TH2D const* in, std::vector<TH1D*>& out){
for(int x{0}; x<in->GetNbinsX(); ++x){
out.emplace_back(new TH1D{ Form("h_EDC_%i", x),
Form("Energy doppler corrected of Spider with ID %i", x),
in->GetNbinsY(),
in->GetYaxis()->GetXmin(),
in->GetYaxis()->GetXmax()});
for(int y{0}; y<in->GetNbinsY(); ++y){
out.back()->SetBinContent(y, in->GetBinContent(x,y));
}
}
};
for(const auto& it: histos){
convertTH2DtoTH1Ds(it, hu.histos[it->GetName()]);
}
//Write histograms
for(const auto& it: hu.histos){
for(const auto& it2: it.second){
it2->Write();
}
}
}
......@@ -16,8 +16,7 @@ class UserSelector : public AgataSelector {
struct UserHistograms {
std::vector<TObject*> ptrs;
TDirectory* dir{nullptr};
// TH1D *h_agataCR = nullptr;
TDirectory *dir{nullptr};
std::map<std::string, std::vector<TH1D*>> histos;
} userHistograms;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment