Belle II Software  release-05-02-19
SVDBeamBackHitFilterModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <svd/modules/svdBackground/SVDBeamBackHitFilterModule.h>
12 
13 #include <simulation/dataobjects/BeamBackHit.h>
14 
15 #include <framework/datastore/StoreArray.h>
16 
17 using namespace std;
18 using namespace Belle2;
19 using namespace Belle2::SVD;
20 
21 //-----------------------------------------------------------------
22 // Register the Module
23 //-----------------------------------------------------------------
24 REG_MODULE(SVDBeamBackHitFilter);
25 
26 //-----------------------------------------------------------------
27 // Implementation
28 //-----------------------------------------------------------------
29 
30 SVDBeamBackHitFilterModule::SVDBeamBackHitFilterModule() : Module()
31 {
32  //Set module properties
33  setDescription("This module filters out from the BeamBackHits StoreArray the BeamBackHits not related to SVD.");
35 }
36 
38 {
39  //Register collections
40  StoreArray<BeamBackHit> storeBeamBackHits("");
41  storeBeamBackHits.isOptional();
42 }
43 
45 {
46  StoreArray<BeamBackHit> storeBeamBackHits("");
47  // If no BeamBackHits, nothing to do
48  if (!storeBeamBackHits || !storeBeamBackHits.getEntries()) return;
49 
50  // Now we loop over BeamBackHits and only leave SVD-related BeamBackHits.
51  int nBBHits = storeBeamBackHits.getEntries();
52  int lastLeft(0);
53  for (int iHit = 0; iHit < nBBHits; ++iHit) {
54  const BeamBackHit& hit = *storeBeamBackHits[iHit];
55  if (hit.getSubDet() == 2) {
56  // Don't copy to itself
57  if (iHit > lastLeft) *storeBeamBackHits[lastLeft] = hit;
58  lastLeft++;
59  }
60  }
61 
62  //Resize if we omitted one or more elements
63  storeBeamBackHits.getPtr()->ExpandCreate(lastLeft);
64 }
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:216
Belle2::SVD::SVDBeamBackHitFilterModule::event
virtual void event() override
do the sorting
Definition: SVDBeamBackHitFilterModule.cc:44
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module::c_ParallelProcessingCertified
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:82
Belle2::SVD::SVDBeamBackHitFilterModule::initialize
virtual void initialize() override
Initialize the module.
Definition: SVDBeamBackHitFilterModule.cc:37
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::Module::setPropertyFlags
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:210
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SVD
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
Definition: GeoSVDCreator.h:35
Belle2::StoreArray::getPtr
TClonesArray * getPtr() const
Raw access to the underlying TClonesArray.
Definition: StoreArray.h:321
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::BeamBackHit
Class BeamBackHit - Stores hits from beam backgound simulation.
Definition: BeamBackHit.h:39
Belle2::StoreArray::getEntries
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:226