Belle II Software  release-08-01-10
TrackTimeEstimatorModule.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #include <tracking/modules/trackTimeEstimator/TrackTimeEstimatorModule.h>
10 #include <framework/logging/Logger.h>
11 #include <framework/core/ModuleParam.templateDetails.h>
12 
13 using namespace Belle2;
14 REG_MODULE(TrackTimeEstimator);
15 
16 TrackTimeEstimatorModule::TrackTimeEstimatorModule() : Module()
17 {
18  setPropertyFlags(c_ParallelProcessingCertified);
19  setDescription(
20  R"DOC(Computes the track time, defined as the difference between the average of SVD clusters time and the SVDEvent T0)DOC");
21 }
22 
23 void TrackTimeEstimatorModule::initialize()
24 {
26  m_tracks.isRequired();
27  m_evtT0.isRequired();
28 
29 }
30 
32 {
33  if (m_evtT0.isValid()) {
34  const auto svdBestT0 = m_evtT0->getBestSVDTemporaryEventT0();
35  if (svdBestT0) { // if SVD eventT0 exists then loop over tracks, don't otherwise and leave their averageTime set at NaN
36  for (auto& track : m_tracks) {
37  // Access related recoTrack
38  const auto& recoTrack = track.getRelatedTo<RecoTrack>();
39 
40  // compute and set Track Time
41  float outgoingArmTime = recoTrack->getOutgoingArmTime();
42  float ingoingArmTime = recoTrack->getIngoingArmTime();
43 
44  // check if recoTrack has both ingoing and outgoing arms
45  if (recoTrack->hasOutgoingArmTime() && recoTrack->hasIngoingArmTime()) {
46  if (outgoingArmTime <= ingoingArmTime) {
47  track.setTrackTime(outgoingArmTime - svdBestT0->eventT0);
48  } else {
49  track.setTrackTime(ingoingArmTime - svdBestT0->eventT0);
50  }
51  } else if (recoTrack->hasOutgoingArmTime() && !recoTrack->hasIngoingArmTime()) { // check if it has only outgoing arm
52  track.setTrackTime(outgoingArmTime - svdBestT0->eventT0);
53  } else if (!recoTrack->hasOutgoingArmTime() && recoTrack->hasIngoingArmTime()) { // check if it has only ingoing arm
54  track.setTrackTime(ingoingArmTime - svdBestT0->eventT0);
55  }
56  }
57  }
58  }
59 }
Base class for Modules.
Definition: Module.h:72
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
float getOutgoingArmTime()
Return the track time of the outgoing arm.
Definition: RecoTrack.h:514
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
void event()
Loop over all Tracks, get related recoTrack, get SVDHitlist, compute average time,...
StoreObjPtr< EventT0 > m_evtT0
Accessing eventT0, as we want SVDEventT0.
StoreArray< Track > m_tracks
Accessing the Tracks.
StoreArray< RecoTrack > m_recoTracks
Accessing the recoTracks, they have the SVD Hits attached.
REG_MODULE(arichBtest)
Register the Module.
Abstract base class for different kinds of events.