Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:38

0001 
0002 #include <JANA/JEventSourceGenerator.h>
0003 #include "MyFileReader.h"
0004 
0005 
0006 class MyFileReaderGenerator : public JEventSourceGenerator {
0007 
0008     JEventSource* MakeJEventSource(std::string resource_name) override {
0009 
0010         auto source = new MyFileReader;
0011         source->SetResourceName(resource_name);
0012 
0013         // Check if the string "timeslices" appears anywhere in our filename. 
0014         // If so, we assume the file contains timeslices, otherwise it contains physics events.
0015         // Another approach might be to peek at the file's contents
0016         if (resource_name.find("timeslices") != std::string::npos)  {
0017             source->SetLevel(JEventLevel::Timeslice);
0018         }
0019         else {
0020             source->SetLevel(JEventLevel::PhysicsEvent);
0021         }
0022         return source;
0023     }
0024 
0025     double CheckOpenable(std::string resource_name) override {
0026         // In theory, we should check whether PODIO can open the file and 
0027         // whether it contains an 'events' or 'timeslices' tree. If not, return 0.
0028         if (resource_name.find(".root") != std::string::npos) {
0029             return 0.01;
0030         }
0031         else {
0032             return 0;
0033         }
0034     }
0035 };
0036 
0037