Project

General

Profile

Support #4555

Email to Jason Brodsky regarding trouble putting ROOT objects into art data products.

Added by Christopher Green over 7 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
Category:
I/O
Target version:
-
Start date:
08/19/2013
Due date:
% Done:

100%

Estimated time:
Spent time:
Scope:
Internal
Experiment:
DarkSide
SSI Package:
Duration:

TH1DataProducer_module.cc (1.82 KB) TH1DataProducer_module.cc Example producer module. Christopher Green, 08/20/2013 08:10 AM

History

#1 Updated by Christopher Green over 7 years ago

Sent the following mail:

Hi,

I think the best thing I can do at this point is explain to you the test I just ran. In a test directory of the art package, I defined the following files:

  • TH1Data.h:
    #ifndef test_TestObjects_TH1Data_h
    #define test_TestObjects_TH1Data_h
    
    #include "TH1D.h" 
    
    namespace arttest {
      struct TH1Data;
    }
    
    struct arttest::TH1Data {
      TH1Data();
      TH1D data;
    };
    
    #endif /* test_TestObjects_TH1Data_h */
    
    // Local Variables:
    // mode: c++
    // End:
  • TH1Data.cc:
    #include "test/TestObjects/TH1Data.h" 
    arttest::TH1Data::TH1Data()
     :
      data()
    {
    }
  • classes_def.xml (note the presence of TH1D: this is necessary to define the reflex dictionary, as opposed the the CINT dictionary which already exists):
    <lcgdict>
    ...
     <class name="arttest::TH1Data" ClassVersion="10">
      <version ClassVersion="10" checksum="3907138095"/>
     </class>
     <class name="TH1D"/>
    ...
     <class name="art::Wrapper<arttest::TH1Data>"/>
    ...
    </lcgdict>
  • classes.h:
    ...
    #include "test/TestObjects/TH1Data.h" 
    ...
    template class art::Wrapper<arttest::TH1Data>;
    ...

Note I have neither a ClassDef() declaration nor a linkdef file.

Then, in CMakeLists.txt, I have:

art_make_library(SOURCE TH1Data.cc
  LIBRARIES ${ROOT_HIST} ${ROOT_CORE} NO_INSTALL
  )

art_dictionary(DICTIONARY_LIBRARIES
  test_TestObjects
  NO_INSTALL
  )
Using artmod, I generated a module TH1DataProducer_module.cc (attached). The relevant entries in the CMakeLists.txt file are:
simple_plugin(TH1DataProducer "module" NO_INSTALL test_TestObjects)
Finally, I created a FHiCL configuration file:
process_name: DEVEL

source:
{
  module_type: EmptyEvent
  maxEvents: 250
}

physics:
{
  producers:
  {
    th1d:
    {
      module_type: TH1DataProducer
    }
  }

  p1: [ th1d ]
  e1: [ o1 ]
}

outputs:
{
  o1:
  {
    module_type: RootOutput
    fileName: "out.root" 
  }
}

Upon invoking the program, I got a data file containing an art data product whose only data member was a TH1D, as filled by me.

One should note that I built this using the standard cetbuildtools build system. The fact that I built it in the art package should be immaterial.

I hope this helps you work out what you're missing. If not, I think the next step is for you to send me the corresponding snippets of code, CMake and configuration and we can take a look. As you can see, there appears to be no fundamental reason why this should not work for you.

Let me know how your next steps fare.

Best,
Chris.

#2 Updated by Christopher Green about 7 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF