Belle II Software development
SVDBeamBackHitFilterModule.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 <svd/modules/svdBackground/SVDBeamBackHitFilterModule.h>
10
11#include <simulation/dataobjects/BeamBackHit.h>
12
13#include <framework/datastore/StoreArray.h>
14
15using namespace std;
16using namespace Belle2;
17using namespace Belle2::SVD;
18
19//-----------------------------------------------------------------
20// Register the Module
21//-----------------------------------------------------------------
22REG_MODULE(SVDBeamBackHitFilter);
23
24//-----------------------------------------------------------------
25// Implementation
26//-----------------------------------------------------------------
27
29{
30 //Set module properties
31 setDescription("This module filters out from the BeamBackHits StoreArray the BeamBackHits not related to SVD.");
33}
34
36{
37 //Register collections
38 StoreArray<BeamBackHit> storeBeamBackHits("");
39 storeBeamBackHits.isOptional();
40}
41
43{
44 StoreArray<BeamBackHit> storeBeamBackHits("");
45 // If no BeamBackHits, nothing to do
46 if (!storeBeamBackHits || !storeBeamBackHits.getEntries()) return;
47
48 // Now we loop over BeamBackHits and only leave SVD-related BeamBackHits.
49 int nBBHits = storeBeamBackHits.getEntries();
50 int lastLeft(0);
51 for (int iHit = 0; iHit < nBBHits; ++iHit) {
52 const BeamBackHit& hit = *storeBeamBackHits[iHit];
53 if (hit.getSubDet() == 2) {
54 // Don't copy to itself
55 if (iHit > lastLeft) *storeBeamBackHits[lastLeft] = hit;
56 lastLeft++;
57 }
58 }
59
60 //Resize if we omitted one or more elements
61 storeBeamBackHits.getPtr()->ExpandCreate(lastLeft);
62}
Class BeamBackHit - Stores hits from beam backgound simulation.
Definition: BeamBackHit.h:28
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ 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:80
virtual void initialize() override
Initialize the module.
virtual void event() override
do the sorting
SVDBeamBackHitFilterModule()
Constructor defining the parameters.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
TClonesArray * getPtr() const
Raw access to the underlying TClonesArray.
Definition: StoreArray.h:311
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Namespace to encapsulate code needed for simulation and reconstrucion of the SVD.
Definition: GeoSVDCreator.h:23
Abstract base class for different kinds of events.
STL namespace.