8#include "Trigger/Event/TrigCaloCluster.h"
9#include "Trigger/Event/TrigParticle.h"
14 spCollName_ = ps.
getParameter<std::string>(
"scoringPlaneCollName");
15 clusterCollName_ = ps.
getParameter<std::string>(
"clusterCollName");
16 eleCollName_ = ps.
getParameter<std::string>(
"eleCollName");
17 propMapName_ = ps.
getParameter<std::string>(
"propMapName");
21 if (!event.
exists(clusterCollName_))
return;
23 event.getObject<TrigCaloClusterCollection>(clusterCollName_)};
25 if (!event.
exists(spCollName_))
return;
26 const std::vector<ldmx::SimTrackerHit> TargetSPHit =
31 for (
const auto& hit : TargetSPHit) {
32 if (hit.getTrackID() != 1)
continue;
33 if (!(abs(hit.getPdgID()) == 11))
continue;
35 if (xyz[2] < 0 || xyz[2] > 1)
continue;
43 TrigParticleCollection eles;
44 for (
const auto& clus : ecalClusters) {
58 clus.e() / (184.103 / clus.e() + 0.753756);
71 float pred_px = clus.z() > 0
72 ? getPx(calib_e, (240. / clus.z()) * (clus.x() - xT))
75 clus.z() > 0 ? getPy(calib_e, (240. / clus.z()) * (clus.y() - yT)) : 0;
80 std::max(pow(calib_e, 2) - (pow(pred_px, 2) + pow(pred_py, 2)), 0.));
83 Point targ(xT, yT, 0);
84 LorentzVector p4(pred_px, pred_py, pred_pz, calib_e);
85 eles.emplace_back(p4, targ, 11);
86 Point calo(clus.x(), clus.y(),
88 eles.back().setEndPoint(
90 eles.back().setClusEnergy(clus.e());
91 eles.back().setClusTP(clus.nTP());
92 eles.back().setClusDepth(clus.depth());
102 event.add(eleCollName_, eles);
105void TrigElectronProducer::setupMaps(
bool isX) {
106 TProfile2D* prof = isX ? propMapx_ : propMapy_;
107 const int N = prof->GetXaxis()->GetNbins();
108 for (
int i = 1; i <= N; i++) {
109 TF1* func =
new TF1(
"func",
"pol1", -20, 20);
110 TProfile* proj = prof->ProfileY(
"h", i, i);
111 proj->Fit(
"func",
"q",
"", -1, 1);
117 c.SaveAs(TString::Format(
"debugFit_%d_%d.pdf",
int(isX), i));
121 fitsX_.push_back(func);
123 fitsY_.push_back(func);
129float TrigElectronProducer::getP(
bool isX,
float e,
float d) {
130 if (fabs(d) > 300)
return 0;
131 const bool debug =
false;
132 TProfile2D* prof = isX ? propMapx_ : propMapy_;
134 if (debug) std::cout <<
"null pointer" << std::endl;
137 int bin1{-9999}, bin2{-9999};
138 bin1 = prof->GetXaxis()->FindBin(e);
139 float frac = e - prof->GetXaxis()->GetBinCenter(bin1);
140 float diff = fabs(prof->GetXaxis()->GetBinCenter(bin1) -
141 prof->GetXaxis()->GetBinCenter(bin2));
142 bin2 = diff > 0 ? bin1 + 1 : bin1 - 1;
143 bin1 = std::max(1, std::min(bin1, prof->GetXaxis()->GetNbins()));
144 bin2 = std::max(1, std::min(bin2, prof->GetXaxis()->GetNbins()));
147 res1 = fitsX_[bin1 - 1]->GetX(d);
148 res2 = fitsX_[bin2 - 1]->GetX(d);
150 res1 = fitsY_[bin1 - 1]->GetX(d);
151 res2 = fitsY_[bin2 - 1]->GetX(d);
155 printf(
"%f %f %f %f :: %f %f %f \n", d, e,
156 prof->GetXaxis()->GetBinCenter(bin1),
157 prof->GetXaxis()->GetBinCenter(bin2), res1, res2,
158 abs(frac / diff) * res2 + (1 - abs(frac / diff)) * res1);
159 return e * (abs(frac / diff) * res2 + (1 - abs(frac / diff)) * res1);
163 ldmx_log(debug) <<
"Process starts!";
165 TFile* f =
new TFile(propMapName_.c_str(),
"read");
166 propMapx_ = (TProfile2D*)f->Get(
"profx");
167 propMapx_->SetDirectory(0);
168 propMapy_ = (TProfile2D*)f->Get(
"profy");
169 propMapy_->SetDirectory(0);
179 ldmx_log(debug) <<
"Process ends!";
182 for (
int i = 0; i < fitsX_.size(); i++)
delete fitsX_[i];
183 for (
int i = 0; i < fitsY_.size(); i++)
delete fitsY_[i];
Class that translates raw positions of ECal module hits into cells in a hexagonal readout.
#define DECLARE_PRODUCER_NS(NS, CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class which encapsulates information from a hit in a simulated tracking detector.
Trigger electron reconstruction algorithm.
Implements an event buffer system for storing event data.
bool exists(const std::string &name, const std::string &passName="", bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
Class encapsulating parameters for configuring a processor.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Represents a simulated tracker hit in the simulation.
std::vector< float > getPosition() const
Get the XYZ position of the hit [mm].
virtual void onProcessStart()
Callback for the EventProcessor to take any necessary action when the processing of events starts,...
virtual void produce(framework::Event &event)
Process the event and put new data products into it.
virtual void onProcessEnd()
Callback for the EventProcessor to take any necessary action when the processing of events finishes,...
virtual void configure(framework::config::Parameters &ps)
Callback for the EventProcessor to configure itself from the given set of parameters.
Class for particles reconstructed by the trigger system.