95 const double cw = 3.97;
96 const double pw = 6.654;
132 fMaxE (p.
get<double>(
"EnergyCutOff") ),
142 produces<std::vector<TriggerDecision>>();
146 return h.
TDC() < tdc;
155 float xcell_convert = m*xcell +
b;
156 float ycell_convert = m*ycell +
b;
157 if(xcell_convert > 94) xcell_convert = 94;
158 if(ycell_convert > 94) ycell_convert = 94;
167 double r = (double)
rand() / (double)RAND_MAX;
176 std::unique_ptr<std::vector<TriggerDecision>>
177 trigger_decisions(
new std::vector<TriggerDecision>);
178 bool isTriggering =
false;
186 assert(fohl.size() == Tracks->size());
192 std::vector<std::vector<novaddt::DAQHit>>
result;
195 for(
uint iii = 0; iii < Tracks->size(); ++iii){
201 if(!track.
Is3D())
continue;
204 trk_end[0] = track.
Start();
205 trk_end[1] = track.
End();
207 for(
int which_end = 0; which_end < 2; which_end++){
218 std::vector<novaddt::DAQHit> meCluster;
229 for(
uint trackHits = 0; trackHits < this_hit_list->size(); trackHits++){
231 min_TDC = this_hit_list->at(trackHits).TDC().val;
232 if( this_hit_list->at(trackHits).ADC().val < 50)
continue;
233 if( this_hit_list->at(trackHits).TDC().val < min_TDC)
234 min_TDC = this_hit_list->at(trackHits).TDC().val;
235 double w = this_hit_list->at(trackHits).ADC().val;
236 avg_t += this_hit_list->at(trackHits).TDC().val *
w;
247 std::vector<novaddt::DAQHit> daqHits = *(cellHits);
250 const auto cellHitsBegin = std::lower_bound(daqHits.begin(),
251 daqHits.end(), firstT,
253 const auto cellHitsEnd = std::lower_bound(cellHitsBegin, daqHits.end(),
259 std::vector<novaddt::DAQHit> meList;
260 double michel_pos[3] = {0,0,0};
261 int seed_plane_pos = -5;
262 double seed_time = 0;
264 double distance_min = 1000;
265 for(
auto cellHitsIter = cellHitsBegin; cellHitsIter != cellHitsEnd; ++cellHitsIter)
268 if(c.
ADC() < 50)
continue;
272 double cellpos[3] = {0,0,0};
278 cellpos[1] = trk_end[which_end].
Y();
280 cellpos[0] = trk_end[which_end].X();
283 distance.SetXYZ((cellpos[0] - trk_end[which_end].
X())*
cw,
284 (cellpos[1] - trk_end[which_end].
Y())*
cw,
285 (cellpos[2] - trk_end[which_end].
Z())*
pw);
287 double dist = distance.Mag();
291 meList.push_back(hit);
294 if(hit.
ADC() > maxE && dist < distance_min){
295 seed_time = hit.
TDC().
val;
296 seed_plane_pos = cellpos[2];
298 michel_pos[0] = cellpos[0];
299 michel_pos[1] = cellpos[1];
300 michel_pos[2] = cellpos[2];
306 if(seed_plane_pos < 0)
continue;
311 auto iter = meList.begin();
312 while( iter != meList.end()){
317 dist2 =
abs( plane - seed_plane_pos)*
pw;
326 meCluster.push_back(*iter);
327 if ((*iter).TDC().val > max_TDC)
328 max_TDC = (*iter).TDC().val;
338 if(meCluster.size() > 0){
339 for(
uint ihit = 0; ihit < meCluster.size(); ihit++){
344 TotalADC += meCluster[ihit].ADC().val;
348 if( x_hits > 0 && y_hits > 0){
349 result.push_back(meCluster);
360 trigger_decisions->emplace_back(min_TDC, max_TDC - min_TDC,
374 if(result.size() > 0 && trigger_decisions->size() > 0) isTriggering =
true;
375 e.
put(std::move(trigger_decisions));
void reconfigure(fhicl::ParameterSet const &p)
novaddt::Plane const & Plane() const
novaddt::TDC const & TDC() const
std::vector< DAQHit > HitList
bool GetSmartPrescaleDecision(double prescale)
DEFINE_ART_MODULE(TestTMapFile)
unsigned distance(const T &t1, const T &t2)
TVector3 const & End() const
ProductID put(std::unique_ptr< PROD > &&product)
bool filter(art::Event &e) override
bool cmp_tdc(const novaddt::DAQHit &h, const novaddt::TDC &tdc)
novaddt::ADC const & ADC() const
novaddt::View const & View() const
double fadditionalPrescale
Identifier for the X measuring view of the detector (top)
float GetSmartPrescale(int xcell, int ycell)
TVector3 const & Start() const
MichelETrigger & operator=(MichelETrigger const &)=delete
bool const & Is3D() const
const std::vector< std::vector< float > > prescale_table
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
fvar< T > floor(const fvar< T > &x)
novaddt::Cell const & Cell() const
assert(nhit_max >=nhit_nbins)
MichelETrigger(fhicl::ParameterSet const &p)
ValidHandle< PROD > getValidHandle(InputTag const &tag) const