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