Belle II Software development
PXDBeamBackHitFilterModule.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 <pxd/modules/pxdBackground/PXDBeamBackHitFilterModule.h>
10
11#include <simulation/dataobjects/BeamBackHit.h>
12#include <framework/datastore/StoreArray.h>
13
14using namespace std;
15using namespace Belle2;
16using namespace Belle2::PXD;
17
18//-----------------------------------------------------------------
19// Register the Module
20//-----------------------------------------------------------------
21REG_MODULE(PXDBeamBackHitFilter);
22
23//-----------------------------------------------------------------
24// Implementation
25//-----------------------------------------------------------------
26
28{
29 //Set module properties
30 setDescription("This module filters out from the BeamBackHits StoreArray the BeamBackHits not related to PXD.");
32}
33
35{
36 //Register collections
37 StoreArray<BeamBackHit> storeBeamBackHits("");
38 storeBeamBackHits.isOptional();
39}
40
42{
43 StoreArray<BeamBackHit> storeBeamBackHits("");
44 // If no BeamBackHits, nothing to do
45 if (!storeBeamBackHits || !storeBeamBackHits.getEntries()) return;
46
47 // Now we loop over BeamBackHits and only leave PXD-related BeamBackHits.
48 int nBBHits = storeBeamBackHits.getEntries();
49 int lastLeft(0);
50 for (int iHit = 0; iHit < nBBHits; ++iHit) {
51 const BeamBackHit& hit = *storeBeamBackHits[iHit];
52 if (hit.getSubDet() == 1) {
53 // Don't copy to itself
54 if (iHit > lastLeft) *storeBeamBackHits[lastLeft] = hit;
55 lastLeft++;
56 }
57 }
58
59 //Resize if we omitted one or more elements
60 storeBeamBackHits.getPtr()->ExpandCreate(lastLeft);
61}
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
PXDBeamBackHitFilterModule()
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 PXD.
Abstract base class for different kinds of events.
STL namespace.