LDMX Software
trigscint::TrigScintFirmwareTracker Class Reference

Public Member Functions

 TrigScintFirmwareTracker (const std::string &name, framework::Process &process)
 
void configure (framework::config::Parameters &ps) override
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
void produce (framework::Event &event) override
 Process the event and put new data products into it.
 
ldmx::TrigScintTrack makeTrack (Track outTrk)
 
- 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 minThr_ {0.}
 add a hit at index idx to a cluster
 
int verbose_ {0}
 
double padTime_ {0.}
 
double timeTolerance_ {0.}
 
std::string output_collection_
 
std::string digis1_collection_
 
std::string digis2_collection_
 
std::string digis3_collection_
 
std::vector< ldmx::TrigScintTracktracks_
 
std::string passName_ {""}
 
std::vector< unsigned int > v_addedIndices_
 
std::vector< unsigned int > v_usedIndices_
 
std::map< int, int > hitChannelMap_
 

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 TrigScintFirmwareTracker.h.

Constructor & Destructor Documentation

◆ TrigScintFirmwareTracker()

trigscint::TrigScintFirmwareTracker::TrigScintFirmwareTracker ( const std::string & name,
framework::Process & process )
inline

Definition at line 29 of file TrigScintFirmwareTracker.h.

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

Member Function Documentation

◆ configure()

void trigscint::TrigScintFirmwareTracker::configure ( framework::config::Parameters & parameters)
overridevirtual

Callback for the EventProcessor to configure itself from the given set of parameters.

The parameters a processor has access to are the member variables of the python class in the sequence that has className equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 13 of file TrigScintFirmwareTracker.cxx.

13 {
14 minThr_ = ps.getParameter<double>("clustering_threshold");
15 digis1_collection_ = ps.getParameter<std::string>("digis1_collection");
16 digis2_collection_ = ps.getParameter<std::string>("digis2_collection");
17 digis3_collection_ = ps.getParameter<std::string>("digis3_collection");
18 passName_ = ps.getParameter<std::string>("input_pass_name");
19 output_collection_ = ps.getParameter<std::string>("output_collection");
20 verbose_ = ps.getParameter<int>("verbosity");
21 timeTolerance_ = ps.getParameter<double>("time_tolerance");
22 padTime_ = ps.getParameter<double>("pad_time");
23
24 if (verbose_) {
25 ldmx_log(info) << "In TrigScintFirmwareTracker: configure done!";
26 ldmx_log(info) << "\nClustering threshold: " << minThr_
27 << "\nExpected pad hit time: " << padTime_
28 << "\nMax hit time delay: " << timeTolerance_
29 << "\ndigis1 collection: " << digis1_collection_
30 << "\ndigis2 collection: " << digis2_collection_
31 << "\ndigis3 collection: " << digis3_collection_
32 << "\nInput pass name: " << passName_
33 << "\nOutput collection: " << output_collection_
34 << "\nVerbosity: " << verbose_;
35 }
36
37 return;
38}
double minThr_
add a hit at index idx to a cluster

References minThr_.

◆ makeTrack()

ldmx::TrigScintTrack trigscint::TrigScintFirmwareTracker::makeTrack ( Track outTrk)

Definition at line 295 of file TrigScintFirmwareTracker.cxx.

295 {
296 // This takes a firmware track object and reverts it into an ldmx track
297 // object, unfortunately only retaining that information of the track that is
298 // retained in the firmware track.
300 float pe{0.};
301 pe += static_cast<float>(outTrk.Pad1.Seed.Amp) +
302 static_cast<float>(outTrk.Pad1.Sec.Amp);
303 pe += static_cast<float>(outTrk.Pad2.Seed.Amp) +
304 static_cast<float>(outTrk.Pad2.Sec.Amp);
305 pe += static_cast<float>(outTrk.Pad3.Seed.Amp) +
306 static_cast<float>(outTrk.Pad3.Sec.Amp);
307 tr.setCentroid(calcTCent(outTrk));
308 calcResid(outTrk);
309 tr.setPE(pe);
310 return tr;
311}
Represents a track of trigger scintillator clusters.
void setPE(float pe)
Set the average cluster pe of the track.
void setCentroid(float centroid)
Set the detector ID centroid of the track.

◆ produce()

void trigscint::TrigScintFirmwareTracker::produce ( framework::Event & event)
overridevirtual

Process the event and put new data products into it.

Parameters
eventThe Event to process.

Implements framework::Producer.

Definition at line 40 of file TrigScintFirmwareTracker.cxx.

40 {
41 // This processor takes in TS digis and outputs a track collection. It does so
42 // using clusterproducer_sw and trackproducer_hw, which are validated pieces
43 // of HLS code (though clusterproducer_sw has had its instances of pragmas
44 // excluded. I will comment on how clusterproducer and trackproducer work more
45 // thouroughly in them respectively, but generally the clusterproducer makes
46 // only two hit clusters (as ready that was all that was made from the
47 // original sw) and does so by making a digi map and running along channels
48 // numerically and pairing if possible. The trackproducer takes a LOOKUP array
49 // as a LUT and does track pattern mathcing. This depends on alignment through
50 // the A vector below.
51
52 if (verbose_) {
53 ldmx_log(debug)
54 << "TrigScintFirmwareTracker: produce() starts! Event number: "
55 << event.getEventHeader().getEventNumber();
56 }
57
58 // A is the mis-alignment vector
59 ap_int<12> A[3] = {0, 0, 0};
60 ap_int<12> LOOKUP[NCENT][COMBO][2];
61
62 // Initialize the LOOKUP table to zero
63 for (int i = 0; i < NCENT; ++i) {
64 for (int j = 0; j < COMBO; ++j) {
65 for (int k = 0; k < 2; ++k) {
66 LOOKUP[i][j][k] = ap_int<12>(-1);
67 }
68 }
69 }
70
71 // This line fills in the LOOKUP table used for patter matching latter. The
72 // array takes in as its first argument the centroid of a first pad cluster,
73 // then the next two take on which track pattern (of ~9) we are matching to
74 // and the last if we are matching to a cluster with two hits
75 for (int i = 0; i < NCENT; i++) {
76 for (int j = 0; j < COMBO; j++) {
77 LOOKUP[i][j][0] = (i - A[1] + A[0]);
78 LOOKUP[i][j][1] = (i - A[2] + A[0]);
79 if (j / 3 == 0) {
80 LOOKUP[i][j][0] -= 1;
81 } else if (j / 3 == 2) {
82 LOOKUP[i][j][0] += 1;
83 }
84 if (j % 3 == 0) {
85 LOOKUP[i][j][1] -= 1;
86 } else if (j % 3 == 2) {
87 LOOKUP[i][j][1] += 1;
88 }
89 if (not((LOOKUP[i][j][0] >= 0) and (LOOKUP[i][j][1] >= 0) and
90 (LOOKUP[i][j][0] < NCENT) and (LOOKUP[i][j][1] < NCENT))) {
91 LOOKUP[i][j][0] = -1;
92 LOOKUP[i][j][1] = -1;
93 }
94 }
95 }
96 // Here we instantiate arrays necessary to do the rest of it.
97 Hit HPad1[NHITS];
98 Hit HPad2[NHITS];
99 Hit HPad3[NHITS];
100
101 // Pad1 goes with NTRK bc of firmware bandwidth constraints
102 // It is also expected on Pad1 to have 1 cluster per track
103 Cluster Pad1[NTRK];
104 Cluster Pad2[NCLUS];
105 Cluster Pad3[NCLUS];
106 Track outTrk[NTRK];
107
108 for (int j = 0; j < NHITS; j++) {
109 clearHit(HPad1[j]);
110 clearHit(HPad2[j]);
111 clearHit(HPad3[j]);
112 }
113 for (int j = 0; j < NCLUS; j++) {
114 if (j < NTRK) {
115 clearClus(Pad1[j]);
116 }
117 clearClus(Pad2[j]);
118 clearClus(Pad3[j]);
119 }
120 for (int j = 0; j < NTRK; j++) {
121 clearTrack(outTrk[j]);
122 }
123 // I am reading in the three digi collections
124 const auto &digis1{
125 event.getCollection<ldmx::TrigScintHit>(digis1_collection_, passName_)};
126 const auto &digis2{
127 event.getCollection<ldmx::TrigScintHit>(digis2_collection_, passName_)};
128 const auto &digis3{
129 event.getCollection<ldmx::TrigScintHit>(digis3_collection_, passName_)};
130
131 if (verbose_) {
132 ldmx_log(debug) << "Got digi collection " << digis1_collection_ << "_"
133 << passName_ << " with " << digis1.size() << " entries ";
134 }
135
136 // The next collection of things fill in the firmware hit objects from reading
137 // in the digi collections the necessary information. The firmware hit objects
138 // only keep bID,mID,Time, and PE count.
139 int occupied[NCHAN];
140 for (int i = 0; i < NCHAN; i++) {
141 occupied[i] = -1;
142 }
143 int count = 0;
144 for (const auto &digi : digis1) {
145 if ((digi.getPE() > minThr_) and (digi.getBarID() <= NCHAN) and
146 (digi.getBarID() >= 0)) {
147 ap_int<12> bID = (ap_int<12>)(digi.getBarID());
148 ap_int<12> Amp = (ap_int<12>)(digi.getPE());
149 if (occupied[digi.getBarID()] >= 0) {
150 if (HPad1[occupied[digi.getBarID()]].Amp < digi.getPE()) {
151 HPad1[occupied[digi.getBarID()]].bID = (ap_int<12>)(digi.getBarID());
152 HPad1[occupied[digi.getBarID()]].mID =
153 (ap_int<12>)(digi.getModuleID());
154 HPad1[occupied[digi.getBarID()]].Amp = (ap_int<12>)(digi.getPE());
155 HPad1[occupied[digi.getBarID()]].Time = (ap_int<12>)(digi.getTime());
156 }
157 } else {
158 HPad1[count].bID = (ap_int<12>)(digi.getBarID());
159 HPad1[count].mID = (ap_int<12>)(digi.getModuleID());
160 HPad1[count].Amp = (ap_int<12>)(digi.getPE());
161 HPad1[count].Time = (ap_int<12>)(digi.getTime());
162 occupied[digi.getBarID()] = count;
163 count++;
164 }
165 }
166 }
167
168 for (int i = 0; i < NCHAN; i++) {
169 occupied[i] = -1;
170 }
171 count = 0;
172 for (const auto &digi : digis2) {
173 if ((digi.getPE() > minThr_) and (digi.getBarID() <= NCHAN) and
174 (digi.getBarID() >= 0)) {
175 ap_int<12> bID = (ap_int<12>)(digi.getBarID());
176 ap_int<12> Amp = (ap_int<12>)(digi.getPE());
177 if (occupied[digi.getBarID()] >= 0) {
178 if (HPad2[occupied[digi.getBarID()]].Amp < digi.getPE()) {
179 HPad2[occupied[digi.getBarID()]].bID = (ap_int<12>)(digi.getBarID());
180 HPad2[occupied[digi.getBarID()]].mID =
181 (ap_int<12>)(digi.getModuleID());
182 HPad2[occupied[digi.getBarID()]].Amp = (ap_int<12>)(digi.getPE());
183 HPad2[occupied[digi.getBarID()]].Time = (ap_int<12>)(digi.getTime());
184 }
185 } else {
186 HPad2[count].bID = (ap_int<12>)(digi.getBarID());
187 HPad2[count].mID = (ap_int<12>)(digi.getModuleID());
188 HPad2[count].Amp = (ap_int<12>)(digi.getPE());
189 HPad2[count].Time = (ap_int<12>)(digi.getTime());
190 occupied[digi.getBarID()] = count;
191 count++;
192 }
193 }
194 }
195 for (int i = 0; i < NCHAN; i++) {
196 occupied[i] = -1;
197 }
198 count = 0;
199 for (const auto &digi : digis3) {
200 if ((digi.getPE() > minThr_) and (digi.getBarID() <= NCHAN) and
201 (digi.getBarID() >= 0)) {
202 ap_int<12> bID = (ap_int<12>)(digi.getBarID());
203 ap_int<12> Amp = (ap_int<12>)(digi.getPE());
204 if (occupied[digi.getBarID()] >= 0) {
205 if (HPad3[occupied[digi.getBarID()]].Amp < digi.getPE()) {
206 HPad3[occupied[digi.getBarID()]].bID = (ap_int<12>)(digi.getBarID());
207 HPad3[occupied[digi.getBarID()]].mID =
208 (ap_int<12>)(digi.getModuleID());
209 HPad3[occupied[digi.getBarID()]].Amp = (ap_int<12>)(digi.getPE());
210 HPad3[occupied[digi.getBarID()]].Time = (ap_int<12>)(digi.getTime());
211 }
212 } else {
213 HPad3[count].bID = (ap_int<12>)(digi.getBarID());
214 HPad3[count].mID = (ap_int<12>)(digi.getModuleID());
215 HPad3[count].Amp = (ap_int<12>)(digi.getPE());
216 HPad3[count].Time = (ap_int<12>)(digi.getTime());
217 occupied[digi.getBarID()] = count;
218 count++;
219 }
220 }
221 }
222 // These next lines here calls clusterproducer_sw(HPad1), which is just the
223 // validated firmware module. Since ap_* class is messy, I had to do some
224 // post-call cleanup before looping over the clusters and putting them into
225 // Point i which is feed into track producer
226 int counterN = 0;
227 std::array<Cluster, NCLUS> Point1 = clusterproducer_sw(HPad1);
228 int topSeed = 0;
229 for (int i = 0; i < NCLUS; i++) {
230 if ((Point1[i].Seed.Amp < 450) and (Point1[i].Seed.Amp > 30) and
231 (Point1[i].Seed.bID < (NCHAN + 1)) and (Point1[i].Seed.bID >= 0) and
232 (Point1[i].Sec.Amp < 450) and (counterN < NTRK)) {
233 if (Point1[i].Seed.bID >= topSeed) {
234 cpyHit(Pad1[counterN].Seed, Point1[i].Seed);
235 cpyHit(Pad1[counterN].Sec, Point1[i].Sec);
236 calcCent(Pad1[counterN]);
237 counterN++;
238 topSeed = Point1[i].Seed.bID;
239 }
240 }
241 }
242 std::array<Cluster, NCLUS> Point2 = clusterproducer_sw(HPad2);
243 topSeed = 0;
244 for (int i = 0; i < NCLUS; i++) {
245 if ((Point2[i].Seed.Amp < 450) and (Point2[i].Seed.Amp > 30) and
246 (Point2[i].Seed.bID < (NCHAN + 1)) and (Point2[i].Seed.bID >= 0) and
247 (Point2[i].Sec.Amp < 450)) {
248 if (Point2[i].Seed.bID >= topSeed) {
249 cpyHit(Pad2[i].Seed, Point2[i].Seed);
250 cpyHit(Pad2[i].Sec, Point2[i].Sec);
251 calcCent(Pad2[i]);
252 topSeed = Point2[i].Seed.bID;
253 }
254 }
255 }
256 std::array<Cluster, NCLUS> Point3 = clusterproducer_sw(HPad3);
257 topSeed = 0;
258 for (int i = 0; i < NCLUS; i++) {
259 if ((Point3[i].Seed.Amp < 450) and (Point3[i].Seed.Amp > 30) and
260 (Point3[i].Seed.bID < (NCHAN + 1)) and (Point3[i].Seed.bID >= 0) and
261 (Point3[i].Sec.Amp < 450)) {
262 if (Point3[i].Seed.bID >= topSeed) {
263 cpyHit(Pad3[i].Seed, Point3[i].Seed);
264 cpyHit(Pad3[i].Sec, Point3[i].Sec);
265 calcCent(Pad3[i]);
266 topSeed = Point3[i].Seed.bID;
267 }
268 }
269 }
270 // I have stagged the digis into firmware digi objects and paired them into
271 // firmware cluster objects, so at this point I can insert them and the LUT
272 // into the trackproducer_hw to create the track collection I use makeTrack to
273 // revert the firmware track object back into a regular track object for
274 // analysis purposes
275 //
276 // NOTE: Pad1 has NTRK instead of NCLUS clusters for a reason: the firmware
277 // cannot facilitate NCLUS many tracks within its alloted bandwidth , we have
278 // to put a cut on them which is facilitated by a cut on the number of
279 // clusters in Pad1. Do not change this.
280 trackproducer_hw(Pad1, Pad2, Pad3, outTrk, LOOKUP);
281 for (int I = 0; I < NTRK; I++) {
282 if (outTrk[I].Pad1.Seed.Amp > 0. && outTrk[I].Pad1.Sec.Amp >= 0. &&
283 outTrk[I].Pad2.Seed.Amp > 0. && outTrk[I].Pad2.Sec.Amp >= 0. &&
284 outTrk[I].Pad3.Seed.Amp > 0. && outTrk[I].Pad3.Sec.Amp >= 0.) {
285 ldmx::TrigScintTrack trk = makeTrack(outTrk[I]);
286 tracks_.push_back(trk);
287 }
288 }
289 event.add(output_collection_, tracks_);
290 tracks_.resize(0);
291
292 return;
293}
Definition objdef.h:49
Sign Arbitrary Precision Type.
Definition ap_int.h:28

References minThr_.

Member Data Documentation

◆ digis1_collection_

std::string trigscint::TrigScintFirmwareTracker::digis1_collection_
private

Definition at line 59 of file TrigScintFirmwareTracker.h.

◆ digis2_collection_

std::string trigscint::TrigScintFirmwareTracker::digis2_collection_
private

Definition at line 60 of file TrigScintFirmwareTracker.h.

◆ digis3_collection_

std::string trigscint::TrigScintFirmwareTracker::digis3_collection_
private

Definition at line 61 of file TrigScintFirmwareTracker.h.

◆ hitChannelMap_

std::map<int, int> trigscint::TrigScintFirmwareTracker::hitChannelMap_
private

Definition at line 75 of file TrigScintFirmwareTracker.h.

◆ minThr_

double trigscint::TrigScintFirmwareTracker::minThr_ {0.}
private

add a hit at index idx to a cluster

Definition at line 44 of file TrigScintFirmwareTracker.h.

44{0.};

Referenced by configure(), and produce().

◆ output_collection_

std::string trigscint::TrigScintFirmwareTracker::output_collection_
private

Definition at line 56 of file TrigScintFirmwareTracker.h.

◆ padTime_

double trigscint::TrigScintFirmwareTracker::padTime_ {0.}
private

Definition at line 50 of file TrigScintFirmwareTracker.h.

50{0.};

◆ passName_

std::string trigscint::TrigScintFirmwareTracker::passName_ {""}
private

Definition at line 66 of file TrigScintFirmwareTracker.h.

66{""};

◆ timeTolerance_

double trigscint::TrigScintFirmwareTracker::timeTolerance_ {0.}
private

Definition at line 53 of file TrigScintFirmwareTracker.h.

53{0.};

◆ tracks_

std::vector<ldmx::TrigScintTrack> trigscint::TrigScintFirmwareTracker::tracks_
private

Definition at line 63 of file TrigScintFirmwareTracker.h.

◆ v_addedIndices_

std::vector<unsigned int> trigscint::TrigScintFirmwareTracker::v_addedIndices_
private

Definition at line 69 of file TrigScintFirmwareTracker.h.

◆ v_usedIndices_

std::vector<unsigned int> trigscint::TrigScintFirmwareTracker::v_usedIndices_
private

Definition at line 72 of file TrigScintFirmwareTracker.h.

◆ verbose_

int trigscint::TrigScintFirmwareTracker::verbose_ {0}
private

Definition at line 47 of file TrigScintFirmwareTracker.h.

47{0};

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