LDMX Software
Public Member Functions | Private Attributes | List of all members
hcal::HcalWABVetoProcessor Class Reference

Public Member Functions

 HcalWABVetoProcessor (const std::string &name, framework::Process &process)
 Constructor.
 
virtual ~HcalWABVetoProcessor ()=default
 Destructor.
 
void configure (framework::config::Parameters &parameters) override
 Configure the processor using the given user specified parameters.
 
void produce (framework::Event &event) override
 Run the processor and create a collection of results which indicate if the event passes/fails the Hcal veto.
 
- Public Member Functions inherited from framework::Producer
 Producer (const std::string &name, Process &process)
 Class constructor.
 
virtual void beforeNewRun (ldmx::RunHeader &header)
 Handle allowing producers to modify run headers before the run begins.
 
- Public Member Functions inherited from framework::EventProcessor
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()
 Class destructor.
 
virtual void onNewRun (const ldmx::RunHeader &runHeader)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
virtual void onProcessStart ()
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
virtual void onProcessEnd ()
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Private Attributes

double maxtotalEnergyCompare_ {1000.}
 
double mintotalEnergyCompare_ {0.}
 
double maxnClusters_ {0.}
 
double maxMeanHitsPerCluster_ {0.}
 
double maxMeanEnergyPerCluster_ {0.}
 
std::string outputCollName_
 
std::string inputHCALClusterCollName_
 
std::string inputHCALHitCollName_
 
std::string inputECALHitCollName_
 

Additional Inherited Members

- Static Public Member Functions inherited from framework::EventProcessor
static void declare (const std::string &classname, int classtype, EventProcessorMaker *)
 Internal function which is part of the PluginFactory machinery.
 
- Static Public Attributes inherited from framework::Producer
static const int CLASSTYPE {1}
 Constant used to track EventProcessor types by the PluginFactory.
 
- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramHelper histograms_
 Interface class for making and filling histograms.
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger theLog_
 The logger for this EventProcessor.
 

Detailed Description

Definition at line 27 of file HcalWABVetoProcessor.h.

Constructor & Destructor Documentation

◆ HcalWABVetoProcessor()

hcal::HcalWABVetoProcessor::HcalWABVetoProcessor ( const std::string &  name,
framework::Process process 
)

Constructor.

Definition at line 18 of file HcalWABVetoProcessor.cxx.

20 : Producer(name, process) {}
Producer(const std::string &name, Process &process)
Class constructor.

Member Function Documentation

◆ configure()

void hcal::HcalWABVetoProcessor::configure ( framework::config::Parameters parameters)
overridevirtual

Configure the processor using the given user specified parameters.

Parameters
parametersSet of parameters used to configure this processor.

Reimplemented from framework::EventProcessor.

Definition at line 22 of file HcalWABVetoProcessor.cxx.

23 {
24 maxtotalEnergyCompare_ =
25 parameters.getParameter<double>("max_total_energy_compare");
26 mintotalEnergyCompare_ =
27 parameters.getParameter<double>("min_total_energy_compare");
28 maxnClusters_ = parameters.getParameter<double>("n_clusters");
29 maxMeanHitsPerCluster_ =
30 parameters.getParameter<double>("mean_hits_per_cluster");
31 maxMeanEnergyPerCluster_ =
32 parameters.getParameter<double>("mean_energy_per_cluster");
33 outputCollName_ = parameters.getParameter<std::string>("outputCollName");
34 inputHCALClusterCollName_ =
35 parameters.getParameter<std::string>("inputHCALClusterCollName");
36 inputHCALHitCollName_ =
37 parameters.getParameter<std::string>("inputHCALHitCollName");
38 inputECALHitCollName_ =
39 parameters.getParameter<std::string>("inputECALHitCollName");
40}
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89

References framework::config::Parameters::getParameter().

◆ produce()

void hcal::HcalWABVetoProcessor::produce ( framework::Event event)
overridevirtual

Run the processor and create a collection of results which indicate if the event passes/fails the Hcal veto.

Parameters
eventThe event to process.

Implements framework::Producer.

Definition at line 42 of file HcalWABVetoProcessor.cxx.

42 {
43 // Get the collection of sim particles from the event
44 // HCAL:
45 const std::vector<ldmx::HcalHit> hcalRecHits =
46 event.getCollection<ldmx::HcalHit>(inputHCALHitCollName_);
47 // ECAL:
48 const std::vector<ldmx::EcalHit> ecalRecHits =
49 event.getCollection<ldmx::EcalHit>(inputECALHitCollName_);
50 // Clusters:
51 const std::vector<ldmx::HcalCluster> hcalClusters =
52 event.getCollection<ldmx::HcalCluster>(inputHCALClusterCollName_);
53
54 // Loop over all of the Hcal hits and calculate to total photoelectrons
55 // in the event.
56 float totalHCALEnergy{0};
57 float totalECALEnergy{0};
58 float maxPE{-1000};
59 const ldmx::HcalHit *maxPEHit = nullptr;
60 for (const ldmx::HcalHit &hcalHit : hcalRecHits) {
61 if (hcalHit.isNoise() == 0) {
62 totalHCALEnergy += hcalHit.getPE();
63 }
64
65 // Find the maximum PE in the list
66 if (maxPE < hcalHit.getPE()) {
67 maxPE = hcalHit.getPE();
68 maxPEHit = const_cast<ldmx::HcalHit *>(&hcalHit);
69 }
70 }
71
72 for (const ldmx::EcalHit &ecalHit : ecalRecHits) {
73 if (ecalHit.isNoise() == 0) {
74 totalECALEnergy += ecalHit.getEnergy();
75 }
76 }
77 std::vector<double> nhits;
78 std::vector<double> energies;
79 unsigned int nClusters = 0;
80 for (const ldmx::HcalCluster &hcalCluster : hcalClusters) {
81 nClusters += 1;
82 energies.push_back(hcalCluster.getEnergy());
83 nhits.push_back(hcalCluster.getNHits());
84 }
85
86 double meanEnergy =
87 std::accumulate(energies.begin(), energies.end(), 0.0) / energies.size();
88 double meanNhits =
89 std::accumulate(nhits.begin(), nhits.end(), 0.0) / nhits.size();
90 bool passesEnergyCombo =
91 (((totalECALEnergy + totalHCALEnergy) < maxtotalEnergyCompare_));
92 bool passesnClusters = (nClusters < maxnClusters_);
93 bool passesNHits = ((meanNhits < maxMeanHitsPerCluster_) or isnan(meanNhits));
94 bool passesEnergy =
95 ((meanEnergy < maxMeanEnergyPerCluster_) or isnan(meanEnergy));
96
97 // total veto:
98 bool passesVeto =
99 (passesEnergyCombo and passesnClusters and passesNHits and passesEnergy);
100 // set result:
102 result.setVetoResult(passesVeto);
103 result.setMaxPEHit(*maxPEHit);
104 if (passesVeto) {
106
107 } else {
109 }
110
111 event.add(outputCollName_, result);
112}
void setStorageHint(framework::StorageControl::Hint hint)
Mark the current event as having the given storage control hint from this module.
float getEnergy() const
Get the calorimetric energy of the hit, corrected for sampling factors [MeV].
Stores reconstructed hit information from the ECAL.
Definition EcalHit.h:19
Stores cluster information from the HCal.
Definition HcalCluster.h:21
Stores reconstructed hit information from the HCAL.
Definition HcalHit.h:23
float getPE() const
Get the number of photoelectrons estimated for this hit.
Definition HcalHit.h:50
void setVetoResult(const bool &passesVeto=true)
Sets whether the Hcal veto was passed or not.
void setMaxPEHit(const ldmx::HcalHit maxPEHit)
Set the maximum PE hit.
constexpr StorageControl::Hint hint_shouldKeep
storage control hint alias for backwards compatibility
constexpr StorageControl::Hint hint_shouldDrop
storage control hint alias for backwards compatibility

References ldmx::CalorimeterHit::getEnergy(), ldmx::HcalHit::getPE(), framework::hint_shouldDrop, framework::hint_shouldKeep, ldmx::HcalVetoResult::setMaxPEHit(), framework::EventProcessor::setStorageHint(), and ldmx::HcalVetoResult::setVetoResult().

Member Data Documentation

◆ inputECALHitCollName_

std::string hcal::HcalWABVetoProcessor::inputECALHitCollName_
private

Definition at line 64 of file HcalWABVetoProcessor.h.

◆ inputHCALClusterCollName_

std::string hcal::HcalWABVetoProcessor::inputHCALClusterCollName_
private

Definition at line 62 of file HcalWABVetoProcessor.h.

◆ inputHCALHitCollName_

std::string hcal::HcalWABVetoProcessor::inputHCALHitCollName_
private

Definition at line 63 of file HcalWABVetoProcessor.h.

◆ maxMeanEnergyPerCluster_

double hcal::HcalWABVetoProcessor::maxMeanEnergyPerCluster_ {0.}
private

Definition at line 60 of file HcalWABVetoProcessor.h.

60{0.};

◆ maxMeanHitsPerCluster_

double hcal::HcalWABVetoProcessor::maxMeanHitsPerCluster_ {0.}
private

Definition at line 58 of file HcalWABVetoProcessor.h.

58{0.};

◆ maxnClusters_

double hcal::HcalWABVetoProcessor::maxnClusters_ {0.}
private

Definition at line 56 of file HcalWABVetoProcessor.h.

56{0.};

◆ maxtotalEnergyCompare_

double hcal::HcalWABVetoProcessor::maxtotalEnergyCompare_ {1000.}
private

Definition at line 52 of file HcalWABVetoProcessor.h.

52{1000.};

◆ mintotalEnergyCompare_

double hcal::HcalWABVetoProcessor::mintotalEnergyCompare_ {0.}
private

Definition at line 54 of file HcalWABVetoProcessor.h.

54{0.};

◆ outputCollName_

std::string hcal::HcalWABVetoProcessor::outputCollName_
private

Definition at line 61 of file HcalWABVetoProcessor.h.


The documentation for this class was generated from the following files: