ATLAS Offline Software
FCS_Cell.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef FCS_Cell
6 #define FCS_Cell
7 #include <vector>
8 //#include <stdint.h>
9 #include <Rtypes.h>
10 #include <TLorentzVector.h>
11 //#include <iostream>
12 /******************************************
13 This contains structure definition
14 All structures are relatively simple
15 each matched cell remembers - cell properties + vector of g4hits in this cell + vector of FCS hits in this cell
16 
17 Technicalities - needs a Linkdef.h file + makefile to create the dictionary for ROOT
18 then the last class could be saved in to the TTree
19 
20  ******************************************/
21 
22 struct FCS_cell
23 {
24  Long64_t cell_identifier;
25  int sampling;
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 
33 struct 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)
36  Long64_t cell_identifier;
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  //float hit_sampfrac;
45 };
46 
47 struct FCS_g4hit //this is the standard G4Hit
48 {
49  Long64_t identifier;
50  Long64_t cell_identifier;
51  int sampling;
52  float hit_energy;
53  float hit_time;
54  //float hit_sampfrac;
55  bool operator<(const FCS_g4hit &rhs) const { return hit_energy > rhs.hit_energy;};
56 };
57 
58 struct FCS_matchedcell //this is the matched structure for a single cell
59 {
61  std::vector<FCS_g4hit> g4hit;
62  std::vector<FCS_hit> hit;
63  inline void clear() {g4hit.clear(); hit.clear();};
64  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!
65  bool operator<(const FCS_matchedcell &rhs) const { return cell.energy > rhs.cell.energy;};
66  inline void sorthit() { std::sort(hit.begin(), hit.end());};
67  inline void sortg4hit() { std::sort(g4hit.begin(), g4hit.end());};
68  inline void sort() { sorthit(); sortg4hit();};
69  inline void time_trim(float timing_cut) { /*std::cout <<"Cutting: "<<timing_cut<<" from: "<<hit.size()<<" "<<g4hit.size()<<std::endl;*/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());/*std::cout <<"remaining: "<<hit.size()<<" "<<g4hit.size()<<std::endl;*/};
70 };
71 
72 struct FCS_matchedcellvector //this is the matched structure for the whole event (or single layer) - vector of FCS_matchedcell
73 {
74  //Note that struct can have methods
75  //Note the overloaded operator(s) to access the underlying vector
76  std::vector<FCS_matchedcell> m_vector;
77  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;};
78  inline FCS_matchedcell operator[](unsigned int place) { return m_vector[place];};
79  inline unsigned int size() {return m_vector.size();};
80  inline void push_back(FCS_matchedcell cell) { m_vector.push_back(cell);};
81  inline void sort_cells() { std::sort(m_vector.begin(), m_vector.end());};
82  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();};};
83  inline void time_trim(float timing_cut)
84  { 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 && fabs(rhs.cell.energy)<1e-3);}), m_vector.end());};
85  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!
86 };
87 
88 
89 #endif
90 
FCS_cell::operator<
bool operator<(const FCS_cell &rhs) const
Definition: FCS_Cell.h:38
FCS_hit::hit_time
float hit_time
Definition: FCS_Cell.h:39
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
FCS_g4hit::identifier
Long64_t identifier
Definition: FCS_Cell.h:49
FCS_matchedcellvector::sort_cells
void sort_cells()
Definition: FCS_Cell.h:81
FCS_matchedcell::clear
void clear()
Definition: FCS_Cell.h:63
FCS_matchedcell::cell
FCS_cell cell
Definition: FCS_Cell.h:60
FCS_g4hit
Definition: FCS_Cell.h:48
FCS_hit
Definition: FCS_Cell.h:34
FCS_hit::identifier
Long64_t identifier
Definition: FCS_Cell.h:35
FCS_hit::operator<
bool operator<(const FCS_hit &rhs) const
Definition: FCS_Cell.h:43
FCS_hit::hit_energy
float hit_energy
Definition: FCS_Cell.h:38
FCS_matchedcell::sortg4hit
void sortg4hit()
Definition: FCS_Cell.h:67
FCS_matchedcell::g4hit
std::vector< FCS_g4hit > g4hit
Definition: FCS_Cell.h:61
FCS_matchedcell::operator<
bool operator<(const FCS_matchedcell &rhs) const
Definition: FCS_Cell.h:65
FCS_matchedcell::sorthit
void sorthit()
Definition: FCS_Cell.h:66
FCS_g4hit::sampling
int sampling
Definition: FCS_Cell.h:51
FCS_matchedcell::time_trim
void time_trim(float timing_cut)
Definition: FCS_Cell.h:69
FCS_cell::center_x
float center_x
Definition: FCS_Cell.h:35
FCS_g4hit::hit_energy
float hit_energy
Definition: FCS_Cell.h:52
FCS_matchedcell
Definition: FCS_Cell.h:59
FCS_cell::sampling
int sampling
Definition: FCS_Cell.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
ret
T ret(T t)
Definition: rootspy.cxx:260
FCS_matchedcellvector::push_back
void push_back(FCS_matchedcell cell)
Definition: FCS_Cell.h:80
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
FCS_g4hit::operator<
bool operator<(const FCS_g4hit &rhs) const
Definition: FCS_Cell.h:55
FCS_cell::center_z
float center_z
Definition: FCS_Cell.h:37
FCS_cell::cell_identifier
Long64_t cell_identifier
Definition: FCS_Cell.h:32
FCS_g4hit::cell_identifier
Long64_t cell_identifier
Definition: FCS_Cell.h:50
FCS_matchedcellvector::scalingfactor
float scalingfactor()
Definition: FCS_Cell.h:85
FCS_matchedcellvector::size
unsigned int size()
Definition: FCS_Cell.h:79
FCS_matchedcellvector
Definition: FCS_Cell.h:73
FCS_cell::energy
float energy
Definition: FCS_Cell.h:34
FCS_matchedcellvector::operator[]
FCS_matchedcell operator[](unsigned int place)
Definition: FCS_Cell.h:78
FCS_hit::hit_x
float hit_x
Definition: FCS_Cell.h:40
FCS_matchedcellvector::time_trim
void time_trim(float timing_cut)
Definition: FCS_Cell.h:83
FCS_matchedcell::sort
void sort()
Definition: FCS_Cell.h:68
FCS_matchedcellvector::GetLayer
std::vector< FCS_matchedcell > GetLayer(int layer)
Definition: FCS_Cell.h:77
FCS_cell
Definition: FCS_Cell.h:23
FCS_g4hit::hit_time
float hit_time
Definition: FCS_Cell.h:53
FCS_matchedcellvector::sort
void sort()
Definition: FCS_Cell.h:82
FCS_cell::center_y
float center_y
Definition: FCS_Cell.h:36
FCS_matchedcellvector::m_vector
std::vector< FCS_matchedcell > m_vector
Definition: FCS_Cell.h:76
FCS_hit::hit_z
float hit_z
Definition: FCS_Cell.h:42
FCS_matchedcell::scalingfactor
float scalingfactor()
Definition: FCS_Cell.h:64
FCS_hit::hit_y
float hit_y
Definition: FCS_Cell.h:41
FCS_matchedcell::hit
std::vector< FCS_hit > hit
Definition: FCS_Cell.h:62
FCS_hit::sampling
int sampling
Definition: FCS_Cell.h:37
FCS_hit::cell_identifier
Long64_t cell_identifier
Definition: FCS_Cell.h:36