47 void NumberOfCellsPerLength(
HitList const &hits,
double tracklength_of_xview,
double tracklength_of_yview,
double &number_of_cells_per_length_xview,
double &number_of_cells_per_length_yview)
const;
48 float Distance(
unsigned const &xcell1,
unsigned const &ycell1,
unsigned const &plane1,
unsigned const &xcell2,
unsigned const &ycell2 ,
unsigned const &plane2)
const;
50 double WeightedCenterCut(
HitList const &hits,
float PX_min,
float PX_max,
float PY_min,
float PY_max,
float CX_min,
float CX_max,
float CY_min,
float CY_max,
double &weighted_off_center_xx,
double &weighted_off_center_xz,
double &weighted_off_center_yy,
double &weighted_off_center_yz)
const;
102 produces<std::vector<TriggerDecision>>();
111 std::unique_ptr<std::vector<TriggerDecision>>
112 trigger_decisions(
new std::vector<TriggerDecision>);
116 for (
unsigned i = 0;
i!= slices->size(); ++
i) {
126 TX_max = hits.front().TDC().val;
128 TX_min = hits.back().TDC().val;
134 bool PassThrough =
false;
135 bool Intrusion =
false;
140 for (
auto const hit: hits) {
163 else if (!PassThrough) {
164 if (
hit.Cell().val <
_xMin+
_deltx && entry_id != 1) PassThrough =
true;
165 else if (
hit.Cell().val>
_xMax-
_deltx && entry_id != 2) PassThrough =
true;
189 else if (!PassThrough) {
190 if (
hit.Cell().val <
_yMin+
_delty && entry_id != 3) PassThrough =
true;
191 else if (
hit.Cell().val>
_yMax-
_delty && entry_id != 4) PassThrough =
true;
205 else if (!PassThrough) {
206 if (
hit.Plane().val <
_zMin+
_deltz && entry_id != 5) PassThrough=
true;
207 else if (
hit.Plane().val >
_zMax-
_deltz && entry_id != 6) PassThrough=
true;
213 if (nx<10 || ny<10)
continue;
216 if (!PassThrough)
continue;
240 double number_of_cells_per_length_xview=0;
241 double number_of_cells_per_length_yview=0;
244 NumberOfCellsPerLength(hits,tracklength_of_xview,tracklength_of_yview,number_of_cells_per_length_xview,number_of_cells_per_length_yview);
249 double stdev_cells_per_plane_xview=0, stdev_cells_per_plane_yview=0;
255 double weighted_off_center_xx=0, weighted_off_center_xz=0, weighted_off_center_yy=0, weighted_off_center_yz=0;
256 WeightedCenterCut(hits,
PX_min,
PX_max,
PY_min,
PY_max,
CX_min,
CX_max,
CY_min,
CY_max, weighted_off_center_xx, weighted_off_center_xz, weighted_off_center_yy, weighted_off_center_yz );
274 e.
put(std::move(trigger_decisions));
281 std::vector<std::vector<int>> x_hits_plane(
PX_max-
PX_min+1,std::vector<int>(0));
282 std::vector<std::vector<int>> y_hits_plane(
PY_max-
PY_min+1,std::vector<int>(0));
283 for (
auto const hit: hits) {
286 x_hits_plane[
hit.Plane().val-
PX_min].push_back(
hit.Cell().val);
290 y_hits_plane[
hit.Plane().val-
PY_min].push_back(
hit.Cell().val);
296 for (
unsigned i=0;
i!=x_hits_plane.size();
i++){
297 std::sort(x_hits_plane[
i].begin(),x_hits_plane[
i].
end());
298 std::vector<int>::iterator
it;
299 it = std::unique (x_hits_plane[
i].begin(),x_hits_plane[
i].
end());
301 x_cells_plane[
i]=x_hits_plane[
i].size();
303 for (
unsigned i=0;
i!=y_hits_plane.size();
i++){
304 std::sort(y_hits_plane[
i].begin(),y_hits_plane[
i].
end());
305 std::vector<int>::iterator
it;
306 it = std::unique (y_hits_plane[
i].begin(),y_hits_plane[
i].
end());
308 y_cells_plane[
i]=y_hits_plane[
i].size();
312 for (
unsigned i=0;
i!=x_cells_plane.size();
i++){
313 sum_of_cells+=x_cells_plane[
i];
315 number_of_cells_per_length_xview=sum_of_cells/tracklength_of_xview;
317 for (
unsigned i=0;
i!=y_cells_plane.size();
i++){
318 sum_of_cells+=y_cells_plane[
i];
320 number_of_cells_per_length_yview=sum_of_cells/tracklength_of_yview;
325 std::vector<std::vector<int>> x_hits_plane(
PX_max-
PX_min+1,std::vector<int>(0));
326 std::vector<std::vector<int>> y_hits_plane(
PY_max-
PY_min+1,std::vector<int>(0));
327 for (
auto const hit: hits) {
330 x_hits_plane[
hit.Plane().val-
PX_min].push_back(
hit.Cell().val);
334 y_hits_plane[
hit.Plane().val-
PY_min].push_back(
hit.Cell().val);
345 for (
unsigned i=0;
i!=x_hits_plane.size();
i++){
346 std::sort(x_hits_plane[
i].begin(),x_hits_plane[
i].
end());
347 std::vector<int>::iterator
it;
348 it = std::unique (x_hits_plane[
i].begin(),x_hits_plane[
i].
end());
350 x_cells_plane[
i]=x_hits_plane[
i].size();
352 for (
unsigned i=0;
i!=y_hits_plane.size();
i++){
353 std::sort(y_hits_plane[
i].begin(),y_hits_plane[
i].
end());
354 std::vector<int>::iterator
it;
355 it = std::unique (y_hits_plane[
i].begin(),y_hits_plane[
i].
end());
357 y_cells_plane[
i]=y_hits_plane[
i].size();
359 sum = std::accumulate(x_cells_plane.begin(),x_cells_plane.end(),0.0);
360 mean = sum / x_cells_plane.size();
361 sq_sum = std::inner_product(x_cells_plane.begin(),x_cells_plane.end(),x_cells_plane.begin(),0.0);
362 stdev =
std::sqrt(sq_sum / x_cells_plane.size()-mean *
mean);
363 stdev_cells_per_plane_xview=stdev/
mean;
364 sum = std::accumulate(y_cells_plane.begin(),y_cells_plane.end(),0.0);
365 mean = sum / y_cells_plane.size();
366 sq_sum = std::inner_product(y_cells_plane.begin(),y_cells_plane.end(),y_cells_plane.begin(),0.0);
367 stdev =
std::sqrt(sq_sum / y_cells_plane.size()-mean *
mean);
368 stdev_cells_per_plane_yview=stdev/
mean;
370 float novaddt::FastMMTrigger::Distance(
unsigned const &xcell1,
unsigned const &ycell1,
unsigned const &plane1,
unsigned const &xcell2,
unsigned const &ycell2 ,
unsigned const &plane2)
const {
371 return std::sqrt((plane1-plane2)*(plane1-plane2)*2.82072+(xcell1-xcell2)*(xcell1-xcell2)+(ycell1-ycell2)*(ycell1-ycell2));
384 int number_of_surface_hits=0;
385 for(
unsigned i=0;
i!=hits.size();++
i){
386 if(
SurfAssign(hits[
i])==
true) number_of_surface_hits++;
388 return number_of_surface_hits;
390 double novaddt::FastMMTrigger::WeightedCenterCut(
HitList const &
hits,
float PX_min,
float PX_max,
float PY_min,
float PY_max,
float CX_min,
float CX_max,
float CY_min,
float CY_max,
double &weighted_off_center_xx,
double &weighted_off_center_xz,
double &weighted_off_center_yy,
double &weighted_off_center_yz )
const{
391 float Weighted_PX_Center=0.5,Weighted_CX_Center=0.5,Weighted_PY_Center=0.5,Weighted_CY_Center=0.5,SumOfXHitsADC=0,SumOfYHitsADC=0;
392 for (
auto const hit: hits) {
394 SumOfXHitsADC+=
hit.ADC().val;
395 Weighted_PX_Center+=
hit.ADC().val*(
hit.Plane().val-
PX_min);
396 Weighted_CX_Center+=
hit.ADC().val*(
hit.Cell().val-
CX_min);
399 SumOfYHitsADC+=
hit.ADC().val;
400 Weighted_PY_Center+=
hit.ADC().val*(
hit.Plane().val-
PY_min);
401 Weighted_CY_Center+=
hit.ADC().val*(
hit.Cell().val-
CY_min);
404 if(PX_max!=PX_min) Weighted_PX_Center=Weighted_PX_Center/SumOfXHitsADC/(PX_max-
PX_min);
405 if(PY_max!=PY_min) Weighted_PY_Center=Weighted_PY_Center/SumOfYHitsADC/(PY_max-
PY_min);
406 if(CX_max!=CX_min) Weighted_CX_Center=Weighted_CX_Center/SumOfXHitsADC/(CX_max-
CX_min);
407 if(CY_max!=CY_min) Weighted_CY_Center=Weighted_CY_Center/SumOfYHitsADC/(CY_max-
CY_min);
408 weighted_off_center_xx=
std::abs(Weighted_CX_Center-0.5);
409 weighted_off_center_xz=
std::abs(Weighted_PX_Center-0.5);
410 weighted_off_center_yy=
std::abs(Weighted_CY_Center-0.5);
411 weighted_off_center_yz=
std::abs(Weighted_PY_Center-0.5);
418 double number_hits_in_overlap_planes=0;
419 for (
auto const hit: hits) {
420 if(
hit.Plane().val<=max &&
hit.Plane().val>=
min) number_hits_in_overlap_planes++;
423 return number_hits_in_overlap_planes/hits.size();
T max(const caf::Proxy< T > &a, T b)
void StdevCellsPerPlane(HitList const &hits, double &stdev_cells_per_plane_xview, double &stdev_cells_per_plane_yview) const
double _Min_number_of_surface_hits
double _Max_stdev_cells_per_plane_yview
virtual bool filter(art::Event &e) override
void NumberOfCellsPerLength(HitList const &hits, double tracklength_of_xview, double tracklength_of_yview, double &number_of_cells_per_length_xview, double &number_of_cells_per_length_yview) const
novaddt::Plane const & Plane() const
std::vector< DAQHit > HitList
double _Max_weighted_off_center_yz
double _Min_percent_of_hits_in_overlap_planes
double _Min_number_of_cells_per_length_xview
DEFINE_ART_MODULE(TestTMapFile)
unsigned distance(const T &t1, const T &t2)
double _Max_weighted_off_center_xz
Identifier for the Y measuring view of the detector (side)
double _Max_stdev_cells_per_plane_xview
ProductID put(std::unique_ptr< PROD > &&product)
double WeightedCenterCut(HitList const &hits, float PX_min, float PX_max, float PY_min, float PY_max, float CX_min, float CX_max, float CY_min, float CY_max, double &weighted_off_center_xx, double &weighted_off_center_xz, double &weighted_off_center_yy, double &weighted_off_center_yz) const
unsigned long long value_type
float Distance(unsigned const &xcell1, unsigned const &ycell1, unsigned const &plane1, unsigned const &xcell2, unsigned const &ycell2, unsigned const &plane2) const
double _Min_number_of_cells_per_length_yview
double _Min_number_of_hits_per_length
Identifier for the X measuring view of the detector (top)
double NumberOfHitsInOverlapPlanesCut(HitList const &hits, float PX_min, float PX_max, float PY_min, float PY_max) const
static float min(const float a, const float b, const float c)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
novaddt::Cell const & Cell() const
FastMMTrigger(fhicl::ParameterSet const &p)
bool SurfAssign(DAQHit const &hit) const
T min(const caf::Proxy< T > &a, T b)
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
std::string _sliceinstance
double _Min_slice_diagonal_length
int NumberOfSurfaceHits(HitList const &hits) const