ATLAS Offline Software
Loading...
Searching...
No Matches
FCS_Cell.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef FCS_Cell
6#define FCS_Cell
7#include <vector>
8#include <cmath> //std::abs
9#include <algorithm> //std::sort, std::remove_if
10#include <Rtypes.h>
11#include <TLorentzVector.h>
12/******************************************
13This contains structure definition
14All structures are relatively simple
15each matched cell remembers - cell properties + vector of g4hits in this cell + vector of FCS hits in this cell
16
17Technicalities - needs a Linkdef.h file + makefile to create the dictionary for ROOT
18then the last class could be saved in to the TTree
19
20 ******************************************/
21
23{
26 float energy;
27 float center_x;
28 float center_y;
29 float center_z; //to be updated later
30 bool operator<(const FCS_cell &rhs) const { return energy > rhs.energy;};
31};
32
33struct FCS_hit //this is the FCS detailed hit
34{
35 Long64_t identifier; //hit in the same tile cell can have two identifiers (for two PMTs)
37 int sampling; //calorimeter layer
38 float hit_energy; //energy is already scaled for the sampling fraction
39 float hit_time;
40 float hit_x;
41 float hit_y;
42 float hit_z;
43 bool operator<(const FCS_hit &rhs) const { return hit_energy > rhs.hit_energy;};
44};
45
46struct FCS_g4hit //this is the standard G4Hit
47{
48 Long64_t identifier;
52 float hit_time;
53 bool operator<(const FCS_g4hit &rhs) const { return hit_energy > rhs.hit_energy;};
54};
55
56struct FCS_matchedcell //this is the matched structure for a single cell
57{
59 std::vector<FCS_g4hit> g4hit;
60 std::vector<FCS_hit> hit;
61 inline void clear() {g4hit.clear(); hit.clear();};
62 inline float scalingfactor(){float hitsum =0.; for (unsigned int i=0; i<hit.size(); i++){hitsum+=hit[i].hit_energy;}; return cell.energy/hitsum;}; //doesn't check for 0!
63 bool operator<(const FCS_matchedcell &rhs) const { return cell.energy > rhs.cell.energy;};
64 inline void sorthit() { std::sort(hit.begin(), hit.end());};
65 inline void sortg4hit() { std::sort(g4hit.begin(), g4hit.end());};
66 inline void sort() { sorthit(); sortg4hit();};
67 inline void time_trim(float timing_cut) { hit.erase(std::remove_if(hit.begin(), hit.end(), [&timing_cut](const FCS_hit &rhs) { return rhs.hit_time>timing_cut;}), hit.end()); g4hit.erase(std::remove_if(g4hit.begin(), g4hit.end(), [&timing_cut](const FCS_g4hit &rhs) { return rhs.hit_time>timing_cut;}),g4hit.end());};
68};
69
70struct FCS_matchedcellvector //this is the matched structure for the whole event (or single layer) - vector of FCS_matchedcell
71{
72 //Note that struct can have methods
73 //Note the overloaded operator(s) to access the underlying vector
74 std::vector<FCS_matchedcell> m_vector;
75 inline std::vector<FCS_matchedcell> GetLayer(int layer){std::vector<FCS_matchedcell> ret; for (unsigned i=0; i<m_vector.size(); i++) {if (m_vector[i].cell.sampling == layer) ret.push_back(m_vector[i]);}; return ret;};
76 inline FCS_matchedcell operator[](unsigned int place) { return m_vector[place];};
77 inline unsigned int size() {return m_vector.size();};
78 inline void push_back(const FCS_matchedcell & cell) { m_vector.push_back(cell);};
79 inline void sort_cells() { std::sort(m_vector.begin(), m_vector.end());};
80 inline void sort() { std::sort(m_vector.begin(), m_vector.end()); for (unsigned int i=0; i<m_vector.size(); i++) { m_vector[i].sort();};};
81 inline void time_trim(float timing_cut)
82 { for (unsigned int i=0; i< m_vector.size(); i++) { m_vector[i].time_trim(timing_cut); }; m_vector.erase(std::remove_if(m_vector.begin(), m_vector.end(), [] (const FCS_matchedcell &rhs) { return (rhs.hit.size()==0 && rhs.g4hit.size() ==0 && std::fabs(rhs.cell.energy)<1e-3);}), m_vector.end());};
83 inline float scalingfactor(){float cellsum=0.; float hitsum=0.; for (unsigned int i=0; i<m_vector.size(); i++){cellsum+=m_vector[i].cell.energy;for (unsigned int j=0; j<m_vector[i].hit.size(); j++){hitsum+=m_vector[i].hit[j].hit_energy;};}; return cellsum/hitsum;}; //doesn't check for 0!
84};
85
86
87#endif
88
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
DataModel_detail::iterator< DVL > remove_if(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, Predicate pred)
Specialization of remove_if for DataVector/List.
float energy
Definition FCS_Cell.h:26
float center_x
Definition FCS_Cell.h:27
int sampling
Definition FCS_Cell.h:25
float center_y
Definition FCS_Cell.h:28
Long64_t cell_identifier
Definition FCS_Cell.h:24
bool operator<(const FCS_cell &rhs) const
Definition FCS_Cell.h:30
float center_z
Definition FCS_Cell.h:29
int sampling
Definition FCS_Cell.h:50
bool operator<(const FCS_g4hit &rhs) const
Definition FCS_Cell.h:53
float hit_time
Definition FCS_Cell.h:52
Long64_t cell_identifier
Definition FCS_Cell.h:49
Long64_t identifier
Definition FCS_Cell.h:48
float hit_energy
Definition FCS_Cell.h:51
float hit_time
Definition FCS_Cell.h:39
float hit_z
Definition FCS_Cell.h:42
float hit_x
Definition FCS_Cell.h:40
Long64_t identifier
Definition FCS_Cell.h:35
float hit_y
Definition FCS_Cell.h:41
float hit_energy
Definition FCS_Cell.h:38
int sampling
Definition FCS_Cell.h:37
bool operator<(const FCS_hit &rhs) const
Definition FCS_Cell.h:43
Long64_t cell_identifier
Definition FCS_Cell.h:36
void sorthit()
Definition FCS_Cell.h:64
std::vector< FCS_g4hit > g4hit
Definition FCS_Cell.h:59
std::vector< FCS_hit > hit
Definition FCS_Cell.h:60
float scalingfactor()
Definition FCS_Cell.h:62
bool operator<(const FCS_matchedcell &rhs) const
Definition FCS_Cell.h:63
void time_trim(float timing_cut)
Definition FCS_Cell.h:67
void sortg4hit()
Definition FCS_Cell.h:65
FCS_cell cell
Definition FCS_Cell.h:58
void time_trim(float timing_cut)
Definition FCS_Cell.h:81
unsigned int size()
Definition FCS_Cell.h:77
std::vector< FCS_matchedcell > m_vector
Definition FCS_Cell.h:74
void push_back(const FCS_matchedcell &cell)
Definition FCS_Cell.h:78
FCS_matchedcell operator[](unsigned int place)
Definition FCS_Cell.h:76
std::vector< FCS_matchedcell > GetLayer(int layer)
Definition FCS_Cell.h:75