ATLAS Offline Software
Public Member Functions | Private Types | Static Private Member Functions | Private Attributes | List of all members
CaloCellGroup Class Reference

#include <CaloCellGroup.h>

Collaboration diagram for CaloCellGroup:

Public Member Functions

 CaloCellGroup ()
 
bool setDefinition (const CaloCell_Base_ID *caloCellId, const std::string &definition, MsgStream &logStr)
 
bool inGroup (const Identifier id) const
 
const std::vector< float > & getValue () const
 
void printDef () const
 

Private Types

enum  Fields {
  LAYER, REGION, ETA, PHI,
  NFIELDS
}
 

Static Private Member Functions

static void complain (MsgStream &, const std::string &)
 

Private Attributes

bool m_pos
 
bool m_neg
 
bool m_emb
 
bool m_emecow
 
bool m_emeciw
 
bool m_hec
 
bool m_fcal
 
std::vector< std::pair< int, int > > m_fieldBoundaries
 
std::vector< float > m_values
 
const CaloCell_Base_IDm_caloCellId
 

Detailed Description

Definition at line 11 of file CaloCellGroup.h.

Member Enumeration Documentation

◆ Fields

enum CaloCellGroup::Fields
private
Enumerator
LAYER 
REGION 
ETA 
PHI 
NFIELDS 

Definition at line 28 of file CaloCellGroup.h.

28  {
29  LAYER,
30  REGION,
31  ETA,
32  PHI,
33  NFIELDS
34  };

Constructor & Destructor Documentation

◆ CaloCellGroup()

CaloCellGroup::CaloCellGroup ( )

Definition at line 10 of file CaloCellGroup.cxx.

10  :
11  m_pos(false),
12  m_neg(false),
13  m_emb(false),
14  m_emecow(false),
15  m_emeciw(false),
16  m_hec(false),
17  m_fcal(false),
18  m_caloCellId(nullptr)
19 {
20 }

Member Function Documentation

◆ complain()

void CaloCellGroup::complain ( MsgStream &  logStr,
const std::string &  problem 
)
staticprivate

Definition at line 218 of file CaloCellGroup.cxx.

218  {
219  logStr << MSG::ERROR << "Malformed definition string '"<<problem << "'" << endmsg;
220 }

◆ getValue()

const std::vector<float>& CaloCellGroup::getValue ( ) const
inline

Definition at line 20 of file CaloCellGroup.h.

20 {return m_values;}

◆ inGroup()

bool CaloCellGroup::inGroup ( const Identifier  id) const

Definition at line 165 of file CaloCellGroup.cxx.

165  {
166  //std::cout << "Check if in Group..";
167  if (!m_caloCellId) {
168  //throw exception;
169  //std::cout << "No Calo Cell Id" << std::endl;
170  return false;
171  };
172 
173  if (!m_caloCellId->is_lar(id))
174  return false; //Not a lar cell
175 
176  //std::cout << "have calo..";
177 
178  if (m_caloCellId->is_em_barrel(id) && !m_emb) return false;
179  if (m_caloCellId->is_em_endcap_inner(id) && !m_emeciw) return false;
180  if (m_caloCellId->is_em_endcap_outer(id) && !m_emecow) return false;
181  if (m_caloCellId->is_hec(id) && !m_hec) return false;
182  if (m_caloCellId->is_fcal(id) && !m_fcal) return false;
183 
184  //std::cout << "have subcalo..";
185 
186  //Check side
187  const int pn=m_caloCellId->pos_neg(id);
188  if (pn<0 && !m_neg) return false;
189  if (pn>0 && !m_pos) return false;
190 
191  //std::cout << "have side..";
192 
193  const int layer=m_caloCellId->sampling(id);
194  if (layer<m_fieldBoundaries[0].first || layer>m_fieldBoundaries[0].second) return false;
195 
196  //std::cout << "have layer..";
197 
198  const int region=m_caloCellId->region(id);
199  if (region<m_fieldBoundaries[1].first || region>m_fieldBoundaries[1].second) return false;
200 
201  //std::cout << "have region..";
202 
203  const int eta=m_caloCellId->eta(id);
204  if (eta<m_fieldBoundaries[2].first || eta>m_fieldBoundaries[2].second) return false;
205 
206 
207  //std::cout << "have eta..";
208 
209  const int phi=m_caloCellId->phi(id);
210  if (phi<m_fieldBoundaries[3].first || phi>m_fieldBoundaries[3].second) return false;
211 
212  //std::cout << "have phi..match! ";
213  return true;
214 }

◆ printDef()

void CaloCellGroup::printDef ( ) const

Definition at line 312 of file CaloCellGroup.cxx.

312  {
313 
314  std::cout << "Values";
315  for (std::size_t i=0;i<m_values.size();i++)
316  std::cout << " " << m_values[i];
317  std::cout << " will be used for the following region:" << std::endl;
318  std::cout << "SubCalos: " <<m_emb<<m_emecow<<m_emeciw<<m_hec <<m_fcal <<std::endl;
319  std::cout << "pos=" << m_pos << " neg=" << m_neg << std::endl;
320  std::cout << "Layer [" << m_fieldBoundaries[0].first << " - " << m_fieldBoundaries[0].second << "]" << std::endl;
321  std::cout << "Region [" << m_fieldBoundaries[1].first << " - " << m_fieldBoundaries[1].second << "]" << std::endl;
322  std::cout << "Eta [" << m_fieldBoundaries[2].first << " - " << m_fieldBoundaries[2].second << "]" << std::endl;
323  std::cout << "Phi [" << m_fieldBoundaries[3].first << " - " << m_fieldBoundaries[3].second << "]" << std::endl << std::endl;
324 }

◆ setDefinition()

bool CaloCellGroup::setDefinition ( const CaloCell_Base_ID caloCellId,
const std::string &  definition,
MsgStream &  logStr 
)

Definition at line 23 of file CaloCellGroup.cxx.

23  {
24  m_caloCellId=caloCellId;
25  m_fieldBoundaries.clear();
26  m_values.clear();
27  m_emb=false;
28  m_emecow=false;
29  m_emeciw=false;
30  m_hec=false;
31  m_fcal=false;
32  m_pos=false;
33  m_neg=false;
34 
35  std::vector<std::string> subdefs(2+NFIELDS);
36  std::string valuesStr;
37 
38  std::size_t pos1,pos2;
39  pos1=definition.find('[');
40  if( pos1==std::string::npos) {
41  complain(logStr,definition);
42  return false;
43  }
44 
45  std::size_t i,iField=0;
46  for (i=1+pos1;i<definition.size();i++) {
47  char c=definition[i];
48  if (isspace(c)) continue;
49  if (c==']') break;
50  if (c=='/') {
51  //std::cout << "Subfield " << iField << ": " << subdefs[iField] << std::endl;
52  iField++;
53  if (iField >= subdefs.size()) break;
54  }
55  else
56  subdefs[iField].push_back(c);
57  }
58 
59  if (iField!=subdefs.size()-1 || i==definition.size()) {
60  logStr << MSG::ERROR << "Definition String [" << definition << "] malformed. Expect "
61  << NFIELDS << " fileds separated by '/'" << endmsg;
62  return false;
63  }
64 
65  valuesStr=definition.substr(i+1);
66  //std::cout << "ValueStr " << valuesStr << std::endl;
67 
68  //Interpret subcalo-string (first field)
69  std::string& subCaloStr=subdefs[0];
70  size_t len;
71  pos1=0;
72  do {
73  pos2=subCaloStr.find(',',pos1);
74  if (pos2==std::string::npos)
75  len=subCaloStr.size();
76  else
77  len=pos2-pos1;
78  if (subCaloStr.compare(pos1,len,"EMB")==0)
79  m_emb=true;
80  else if(subCaloStr.compare(pos1,len,"EMECIW")==0)
81  m_emeciw=true;
82  else if(subCaloStr.compare(pos1,len,"EMECOW")==0)
83  m_emecow=true;
84  else if(subCaloStr.compare(pos1,len,"HEC")==0)
85  m_hec=true;
86  else if(subCaloStr.compare(pos1,len,"FCAL")==0)
87  m_fcal=true;
88  else {
89  logStr << MSG::ERROR << "Unknown sub-calo name '"<< subCaloStr.substr(pos1,len) <<"'found. "
90  << "Allowed values are EMB, EMECIW, EMECOW, HEC and FCAL" << endmsg;
91  return false;
92  }
93  pos1=pos2+1;
94  }
95  while(pos2!=std::string::npos);
96 
97  //Interpret side-field (second field)
98  if (subdefs[1].size()!=1) {
99  complain(logStr,subdefs[1]);
100  return false;
101  }
102 
103  if (subdefs[1][0]=='A')
104  m_pos=true;
105  else if (subdefs[1][0]=='C')
106  m_neg=true;
107  else if (subdefs[1][0]=='*')
108  m_pos=m_neg=true;
109  else {
110  logStr << MSG::ERROR << "Allowed values for side are: A,C or * (means both), found " << subdefs[1] << endmsg;
111  return false;
112  }
113  //Interpret remaining fields
114  for (std::size_t i=0;i<NFIELDS;i++) {
115  std::string& subdef=subdefs[i+2];
116  int lower=std::numeric_limits<int>::min();
118  if (subdef.compare("*")!=0) {
119  std::size_t pos1=subdef.find('-');
120  if (pos1==std::string::npos) {
121  if (isdigit(subdef[0]))
122  lower=upper=atol(subdef.c_str());
123  else
124  logStr << MSG::ERROR << "Malformed string [" << subdef << "], expected numerical value!" << endmsg;
125  }
126  else {//Found '-'
127  std::string lStr=subdef.substr(0,pos1);
128  std::string uStr=subdef.substr(pos1+1);
129  if (!lStr.empty()) {
130  if (isdigit(lStr[0]))
131  lower=atol(lStr.c_str());
132  else
133  logStr << MSG::ERROR << "Malformed string [" << subdef << "], expected numerical value!" << endmsg;
134  }
135  if (!uStr.empty()) {
136  if (isdigit(uStr[0]))
137  upper=atol(uStr.c_str());
138  else
139  logStr << MSG::ERROR << "Malformed string [" << subdef << "], expected numerical value!" << endmsg;
140  }
141  }
142  }//end not *
143  m_fieldBoundaries.emplace_back(lower,upper);
144  }//end loop over fields
145 
146 
147  const char* ptr1=valuesStr.c_str();
148  char* ptr2;
149  float val;
150  //errno=0;
151  do {
152  val=strtof(ptr1,&ptr2);
153  if (ptr1!=ptr2)
154  m_values.push_back(val);
155  ptr1=const_cast<const char*>(ptr2+1);
156  }
157  while(*ptr2!='\0');
158 
159  logStr << MSG::INFO << "Sussefully parsed defintion string" << endmsg;
160  return true;
161 }

Member Data Documentation

◆ m_caloCellId

const CaloCell_Base_ID* CaloCellGroup::m_caloCellId
private

Definition at line 55 of file CaloCellGroup.h.

◆ m_emb

bool CaloCellGroup::m_emb
private

Definition at line 51 of file CaloCellGroup.h.

◆ m_emeciw

bool CaloCellGroup::m_emeciw
private

Definition at line 51 of file CaloCellGroup.h.

◆ m_emecow

bool CaloCellGroup::m_emecow
private

Definition at line 51 of file CaloCellGroup.h.

◆ m_fcal

bool CaloCellGroup::m_fcal
private

Definition at line 51 of file CaloCellGroup.h.

◆ m_fieldBoundaries

std::vector<std::pair<int,int> > CaloCellGroup::m_fieldBoundaries
private

Definition at line 52 of file CaloCellGroup.h.

◆ m_hec

bool CaloCellGroup::m_hec
private

Definition at line 51 of file CaloCellGroup.h.

◆ m_neg

bool CaloCellGroup::m_neg
private

Definition at line 50 of file CaloCellGroup.h.

◆ m_pos

bool CaloCellGroup::m_pos
private

Definition at line 50 of file CaloCellGroup.h.

◆ m_values

std::vector<float> CaloCellGroup::m_values
private

Definition at line 53 of file CaloCellGroup.h.


The documentation for this class was generated from the following files:
CaloCell_Base_ID::is_em_endcap_outer
bool is_em_endcap_outer(const Identifier id) const
test if the id belongs to the EM Endcap outer wheel
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
CaloCellGroup::m_fieldBoundaries
std::vector< std::pair< int, int > > m_fieldBoundaries
Definition: CaloCellGroup.h:52
CaloCellGroup::m_emecow
bool m_emecow
Definition: CaloCellGroup.h:51
CaloCell_Base_ID::region
int region(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
CaloCellGroup::ETA
@ ETA
Definition: CaloCellGroup.h:31
AtlasDetectorID::is_lar
bool is_lar(Identifier id) const
Definition: AtlasDetectorID.h:689
CaloCellGroup::REGION
@ REGION
Definition: CaloCellGroup.h:30
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
CaloCell_Base_ID::pos_neg
int pos_neg(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
CaloCellGroup::NFIELDS
@ NFIELDS
Definition: CaloCellGroup.h:33
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
CaloCellGroup::LAYER
@ LAYER
Definition: CaloCellGroup.h:29
CaloCell_Base_ID::is_hec
bool is_hec(const Identifier id) const
test if the id belongs to the HEC
python.ZdcRecConfig.pn
pn
Definition: ZdcRecConfig.py:524
CaloCellGroup::PHI
@ PHI
Definition: CaloCellGroup.h:32
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
CaloCellGroup::m_caloCellId
const CaloCell_Base_ID * m_caloCellId
Definition: CaloCellGroup.h:55
CaloCellGroup::m_emb
bool m_emb
Definition: CaloCellGroup.h:51
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloCell_Base_ID::is_fcal
bool is_fcal(const Identifier id) const
test if the id belongs to the FCAL - true also for MiniFCAL
CaloCell_Base_ID::sampling
int sampling(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
CaloCell_Base_ID::is_em_endcap_inner
bool is_em_endcap_inner(const Identifier id) const
test if the id belongs to the EM Endcap inner wheel
CaloCell_Base_ID::eta
int eta(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
CaloCellGroup::m_emeciw
bool m_emeciw
Definition: CaloCellGroup.h:51
CaloCell_Base_ID::is_em_barrel
bool is_em_barrel(const Identifier id) const
test if the id belongs to the EM barrel
CaloCellGroup::m_hec
bool m_hec
Definition: CaloCellGroup.h:51
CaloCellGroup::m_neg
bool m_neg
Definition: CaloCellGroup.h:50
CaloCell_Base_ID::phi
int phi(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
CaloCellGroup::m_pos
bool m_pos
Definition: CaloCellGroup.h:50
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
AsgConfigHelper::strtof
bool strtof(const std::string &input, T &f)
Definition: AsgEGammaConfigHelper.cxx:47
DeMoScan.first
bool first
Definition: DeMoScan.py:536
CaloCellGroup::m_values
std::vector< float > m_values
Definition: CaloCellGroup.h:53
python.compressB64.c
def c
Definition: compressB64.py:93
CaloCellGroup::m_fcal
bool m_fcal
Definition: CaloCellGroup.h:51
CaloCellGroup::complain
static void complain(MsgStream &, const std::string &)
Definition: CaloCellGroup.cxx:218