LDMX Software
Public Member Functions | Private Attributes | List of all members
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 maxWidth_ {2}
 
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_ {""}
 
int vertBarStartIdx_ {52}
 
float centroid_ {0.}
 
float centroidX_ {-1}
 
float centroidY_ {-1}
 
float val_ {0.}
 
float valE_ {0.}
 
std::vector< unsigned int > v_addedIndices_
 
std::vector< unsigned int > v_usedIndices_
 
float beamE_ {0.}
 
float time_ {0.}
 
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 if (verbose_) {
24 ldmx_log(info) << "In TrigScintFirmwareTracker: configure done!";
25 ldmx_log(info) << "\nClustering threshold: " << minThr_
26 << "\nExpected pad hit time: " << padTime_
27 << "\nMax hit time delay: " << timeTolerance_
28 << "\ndigis1 collection: " << digis1_collection_
29 << "\ndigis2 collection: " << digis2_collection_
30 << "\ndigis3 collection: " << digis3_collection_
31 << "\nInput pass name: " << passName_
32 << "\nOutput collection: " << output_collection_
33 << "\nVerbosity: " << verbose_;
34 }
35
36 return;
37}
double minThr_
add a hit at index idx to a cluster

References framework::config::Parameters::getParameter(), and minThr_.

◆ makeTrack()

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

Definition at line 294 of file TrigScintFirmwareTracker.cxx.

294 {
295 // This takes a firmware track object and reverts it into an ldmx track
296 // object, unfortunately only retaining that information of the track that is
297 // retained in the firmware track.
299 float pe{0.};
300 pe += static_cast<float>(outTrk.Pad1.Seed.Amp) +
301 static_cast<float>(outTrk.Pad1.Sec.Amp);
302 pe += static_cast<float>(outTrk.Pad2.Seed.Amp) +
303 static_cast<float>(outTrk.Pad2.Sec.Amp);
304 pe += static_cast<float>(outTrk.Pad3.Seed.Amp) +
305 static_cast<float>(outTrk.Pad3.Sec.Amp);
306 tr.setCentroid(calcTCent(outTrk));
307 calcResid(outTrk);
308 tr.setPE(pe);
309 return tr;
310}
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 39 of file TrigScintFirmwareTracker.cxx.

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

References minThr_.

Member Data Documentation

◆ beamE_

float trigscint::TrigScintFirmwareTracker::beamE_ {0.}
private

Definition at line 97 of file TrigScintFirmwareTracker.h.

97{0.};

◆ centroid_

float trigscint::TrigScintFirmwareTracker::centroid_ {0.}
private

Definition at line 75 of file TrigScintFirmwareTracker.h.

75{0.};

◆ centroidX_

float trigscint::TrigScintFirmwareTracker::centroidX_ {-1}
private

Definition at line 78 of file TrigScintFirmwareTracker.h.

78{-1};

◆ centroidY_

float trigscint::TrigScintFirmwareTracker::centroidY_ {-1}
private

Definition at line 81 of file TrigScintFirmwareTracker.h.

81{-1};

◆ digis1_collection_

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

Definition at line 62 of file TrigScintFirmwareTracker.h.

◆ digis2_collection_

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

Definition at line 63 of file TrigScintFirmwareTracker.h.

◆ digis3_collection_

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

Definition at line 64 of file TrigScintFirmwareTracker.h.

◆ hitChannelMap_

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

Definition at line 103 of file TrigScintFirmwareTracker.h.

◆ maxWidth_

int trigscint::TrigScintFirmwareTracker::maxWidth_ {2}
private

Definition at line 47 of file TrigScintFirmwareTracker.h.

47{2};

◆ 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 59 of file TrigScintFirmwareTracker.h.

◆ padTime_

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

Definition at line 53 of file TrigScintFirmwareTracker.h.

53{0.};

◆ passName_

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

Definition at line 69 of file TrigScintFirmwareTracker.h.

69{""};

◆ time_

float trigscint::TrigScintFirmwareTracker::time_ {0.}
private

Definition at line 100 of file TrigScintFirmwareTracker.h.

100{0.};

◆ timeTolerance_

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

Definition at line 56 of file TrigScintFirmwareTracker.h.

56{0.};

◆ tracks_

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

Definition at line 66 of file TrigScintFirmwareTracker.h.

◆ v_addedIndices_

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

Definition at line 90 of file TrigScintFirmwareTracker.h.

◆ v_usedIndices_

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

Definition at line 93 of file TrigScintFirmwareTracker.h.

◆ val_

float trigscint::TrigScintFirmwareTracker::val_ {0.}
private

Definition at line 84 of file TrigScintFirmwareTracker.h.

84{0.};

◆ valE_

float trigscint::TrigScintFirmwareTracker::valE_ {0.}
private

Definition at line 87 of file TrigScintFirmwareTracker.h.

87{0.};

◆ verbose_

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

Definition at line 50 of file TrigScintFirmwareTracker.h.

50{0};

◆ vertBarStartIdx_

int trigscint::TrigScintFirmwareTracker::vertBarStartIdx_ {52}
private

Definition at line 72 of file TrigScintFirmwareTracker.h.

72{52};

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