|
What Names Must Match
|
|
| |
| Working groups |
| Blessed plots and figures |
| Approving new results and publications |
| Approval web pages - new results |
| Approval web pages - new publications |
| Mu2e Acronyn Dictionary |
| Fermilab Meeting Rooms |
| Fermilab Service Desk |
| ReadyTalk : Home |
| ReadyTalk : Help |
| ReadyTalk : Toll Free Numbers |
namespace mu2e {
class MyClass : public art::EDAnalyzer {
public:
explicit MyClass(fhicl::ParameterSet const& pset);
// Compiler generated d'tor is OK.
void analyze( art::Event const& event );
};
MyClass::MyClass(fhicl::ParameterSet const& pset){
// Body of the constructor. You can access information in the parameter set here.
}
void MyClass::analyze(art::Event const& event){
mf::LogVerbatim("test")
<< "Hello, world. From analyze. "
<< event.id();
}
} // end namespace mu2e
using mu2e::MyClass;
DEFINE_ART_MODULE(MyClass);
This example is for an analyzer. To create a producer or a filter module, you must inherit from either
art::EDProducer or art::EDFilter. The last line invokes a macro that inserts additional code into the
.so file ( for the experts: it inserts a factory method to produce an instance of the class and it
inserts and auto-registration object that registers the factory method with art's module registry ).
physics :
{
analyzers:
{
looseCuts : { module_type : MyClass }
# Other analyzer modules listed here ...
}
}
The string looseCuts is called a module label and
is is defined below.
physics: {
producers: {
looseCuts: { module_type : MyClass }
}
}
physics :
{
analyzers:
{
looseCuts :
{
module_type : MyClass
cutLevel : 1
}
tightCuts :
{
module_type : MyClass
cutLevel : 2
}
}
}
The parameter cutLevel is available to the contructor of MyClass via the fhicl::ParameterSet argument.
#include "RecoDataProducts/inc/StrawHitCollection.hh"
art::Handle<StrawHitCollection> hitsHandle;
event.getByLabel("strawHitMaker",hitsHandle);
StrawHitCollection const& hits = *hitsHandle;
In this example, it is presumed that the hits that we want were created by a module with the
label "strawHitMaker".
After a successful call to getByLabel the variable hitsHandle will hold
a valid handle to a collection of StrawHits.
You can read more about handles.
If getByLabel cannot successfully
and uniquely do its job, it will return a handle that points to nothing. If a
user attempts to use such a handle, the handle will throw.
It will throw if any of the following is true:
For beginners: the & in the following:
StrawHitCollection const & hits = *hitsHandle;
makes the variable hits a reference; this means that hits is a compile time alias which imposes
no additional run time cost in either memory or CPU. If you forget the &
the code will compile but the variable hits will be a copy of the hits that are found in the
event; this may create a significant CPU and memory penalty.
There are other ways to get data products from an event.
|
|
|
| Security, Privacy, Legal |
|