sipm-characterisation 0.1.0
SiPM characterisation for ePIC — IV/DCR/gain, laser, readout, irradiation
Loading...
Searching...
No Matches
maketxt_to_tgraphs.C
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <filesystem>
4
5void maketxt_to_tgraphs(std::string input_directory, std::string signal_channel, std::string timing_channel, std::string file_name, std::string output_file = "tgraphs.root")
6{
7 auto n_zero = 5;
8 std::map<std::string, TGraph *> _TGraph;
9 auto timing_channel_graphs = -1;
10 auto signal_channel_graphs = -1;
11 TFile *fout = new TFile(output_file.c_str(), "RECREATE");
12 while (true)
13 {
14 timing_channel_graphs++;
15 signal_channel_graphs++;
16 auto timing_progressive = std::string(n_zero - std::min(n_zero, (int)(std::to_string(timing_channel_graphs).length())), '0') + std::to_string(timing_channel_graphs);
17 auto signal_progressive = std::string(n_zero - std::min(n_zero, (int)(std::to_string(signal_channel_graphs).length())), '0') + std::to_string(signal_channel_graphs);
18 _TGraph[Form("timing_%d", timing_channel_graphs)] = new TGraph((input_directory + timing_channel + file_name + timing_progressive + ".txt").c_str(), "%lg,%lg");
19 _TGraph[Form("signal_%d", signal_channel_graphs)] = new TGraph((input_directory + signal_channel + file_name + signal_progressive + ".txt").c_str(), "%lg,%lg");
20 if (_TGraph[Form("timing_%d", timing_channel_graphs)]->IsZombie() || _TGraph[Form("signal_%d", signal_channel_graphs)]->IsZombie())
21 break;
22 if (timing_channel_graphs % 1000 == 0)
23 cout << "timing_channel_graphs: " << timing_channel_graphs << endl;
24 for (auto [label, graph] : _TGraph)
25 if (!graph->IsZombie())
26 graph->Write(label.c_str());
27 _TGraph.clear();
28 }
29 fout->Close();
30}
void maketxt_to_tgraphs(std::string input_directory, std::string signal_channel, std::string timing_channel, std::string file_name, std::string output_file="tgraphs.root")
Definition maketxt_to_tgraphs.C:5