24void alpideResponse(
const std::string& inpath,
const std::string& outpath,
const std::string& chip_name)
27 if (gSystem->AccessPathName(inpath.c_str())) {
28 throw std::invalid_argument(
"Input path does not exist or is inaccessible: " + inpath);
32 if (gSystem->AccessPathName(outpath.c_str(), kWritePermission)) {
33 throw std::invalid_argument(
"Output path is not writable: " + outpath);
38 if (chip_name ==
"Alpide") {
41 }
else if (chip_name ==
"APTS") {
46 throw std::invalid_argument(
"Unknown chip name: " + chip_name);
49 std::string output_file = outpath +
"/" + chip_name +
"ResponseData.root";
50 auto file = TFile::Open(output_file.c_str(),
"recreate");
52 if (!file || file->IsZombie()) {
53 throw std::runtime_error(
"Failed to create output file: " + output_file);
54 }
else if (chip_name ==
"Alpide") {
55 file->WriteObjectAny(&resp0,
"o2::itsmft::AlpideSimResponse",
"response0");
57 file->WriteObjectAny(&resp1,
"o2::itsmft::AlpideSimResponse",
"response1");
62int main(
int argc,
const char* argv[])
65 bpo::variables_map vm;
66 bpo::options_description options(
"Alpide response generator options");
67 options.add_options()(
"inputdir,i", bpo::value<std::string>()->default_value(
"./"),
"Path where Vbb-0.0V and Vbb-3.0V are located.")(
"outputdir,o", bpo::value<std::string>()->default_value(
"./"),
"Path where to store the output.")(
"chip,c", bpo::value<std::string>()->default_value(
"Alpide"),
"Chip name (Alpide or APTS).");
70 bpo::store(parse_command_line(argc, argv, options), vm);
72 if (vm.count(
"help")) {
73 std::cout << options << std::endl;
78 }
catch (
const bpo::error& e) {
79 std::cerr << e.what() <<
"\n\n";
80 std::cerr <<
"Error parsing command line arguments. Available options:\n";
81 std::cerr << options << std::endl;
86 std::cout <<
"Generating response for chip: " << vm[
"chip"].as<std::string>() << std::endl;
87 std::cout <<
"Input directory: " << vm[
"inputdir"].as<std::string>() << std::endl;
88 std::cout <<
"Output directory: " << vm[
"outputdir"].as<std::string>() << std::endl;
91 vm[
"outputdir"].as<std::string>(),
92 vm[
"chip"].as<std::string>());
93 std::cout <<
"Response file generated successfully." << std::endl;
94 }
catch (
const std::exception& e) {
95 std::cerr <<
"Error: " << e.what() << std::endl;