Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Public Member Functions | Private Attributes | List of all members
LCE_CellList Class Reference
Collaboration diagram for LCE_CellList:

Classes

struct  thrCounter_t
 

Public Member Functions

void setFlaggingThresholds (const float hitsPerLB, const unsigned upperCountThr, const double lowerEThr, const unsigned lowerCountThr, const double upperEThr)
 
void setListingThresholds (const unsigned minNSeen, const unsigned minAboveSigNoise)
 
void readDefectLBList (const char *LBfile)
 
bool checkBadLBList (const unsigned lumiBlock) const
 
std::vector< LCE_CellList::thrCounter_tbuildList (const char *inputfile, const float nSigma, const float Ethr, const float QThr, unsigned &nLBsSeen) const
 
void writeList (const char *filename, const std::vector< LCE_CellList::thrCounter_t > &celllist) const
 
void addFlags (std::vector< LCE_CellList::thrCounter_t > &celllist, const unsigned nLBsSeen) const
 
bool applySelection (const LCE_CellList::thrCounter_t &counter) const
 
std::string partitionName (const short caloId, const short slot) const
 
void printThresholds () const
 

Private Attributes

std::set< unsigned > m_badLBs
 
float m_hitCountPerLBThreshold =0.01
 
unsigned m_UpperCountThreshold =50
 
unsigned m_LowerCountThreshold =20
 
double m_LowerCellEnergyThreshold =1000.0
 
double m_UpperCellEnergyThreshold =50000.0
 
unsigned m_minNSeen =10
 
unsigned m_minAboveSigNoise =1
 

Detailed Description

Definition at line 37 of file LCE_CellList.cxx.

Member Function Documentation

◆ addFlags()

void LCE_CellList::addFlags ( std::vector< LCE_CellList::thrCounter_t > &  celllist,
const unsigned  nLBsSeen 
) const

Definition at line 222 of file LCE_CellList.cxx.

222  {
223  for (thrCounter_t& counter : celllist) {
224  counter.MeanCellHitCut=(counter.nAboveAbsE> m_hitCountPerLBThreshold*nLBsSeen);
225  counter.EventEnergyCut= ((counter.nAboveSigNoise > m_UpperCountThreshold && (counter.Esum/counter.nAboveSigNoise) > m_LowerCellEnergyThreshold) ||
226  (counter.nAboveSigNoise > m_LowerCountThreshold && (counter.Esum/counter.nAboveSigNoise > m_UpperCellEnergyThreshold)));
227 
228  }
229 
230 }

◆ applySelection()

bool LCE_CellList::applySelection ( const LCE_CellList::thrCounter_t counter) const

Definition at line 234 of file LCE_CellList.cxx.

234  {
235  return counter.nSeen > m_minNSeen && counter.nAboveSigNoise > m_minAboveSigNoise;
236 }

◆ buildList()

std::vector< LCE_CellList::thrCounter_t > LCE_CellList::buildList ( const char *  inputfile,
const float  nSigma,
const float  Ethr,
const float  QThr,
unsigned &  nLBsSeen 
) const

Definition at line 165 of file LCE_CellList.cxx.

165  {
166 
167  std::vector<thrCounter_t> retvec;
168 
169  std::set<unsigned> nLBsSeenSet;
170 
172  const unsigned nchannels = tuple->nChannels();
173 
174  retvec.reserve(nchannels);
175 
176  for (unsigned ichan=0;ichan<nchannels;++ichan) {
177  const LArSamples::History* hist = tuple->cellHistory(ichan);
178  if (!hist) continue;
179  const LArSamples::CellInfo* cellInfo = hist->cellInfo();
180  const int nEvents=hist->nData();
181 
182  thrCounter_t cnt(cellInfo->onlid());
183  cnt.FT=cellInfo->feedThrough();
184  cnt.slot=cellInfo->slot();
185  cnt.channel=cellInfo->channel();
186  cnt.caloid=cellInfo->calo();
187  cnt.layer=cellInfo->layer();
188 
189  for (int iEvent=0;iEvent<nEvents;++iEvent) {
190  const LArSamples::Data* data = hist->data(iEvent);
191  const LArSamples::EventData* Evdata = data->eventData();
192  if(!Evdata) continue;
193  unsigned lumiBlock = Evdata->lumiBlock();
194  if (checkBadLBList(lumiBlock)) continue; //skip bad LBs
195 
196 
197  const double energy= data->energy();
198  const double noise = data->noise();
199  const double quality = data->quality();
200 
201  cnt.nSeen++;
202  if (energy > nSigma * noise) cnt.nAboveSigNoise++;
203  if (energy > Ethr) cnt.nAboveAbsE++;
204  if (quality > Qthr) cnt.nAboveQ++;
205  if (!cnt.bc_status) cnt.bc_status=data->status();
206  cnt.Esum+=energy;
207  cnt.LBs.insert(lumiBlock);
208  nLBsSeenSet.insert(lumiBlock);
209  }//End loop over events
210 
211  if (cnt.nSeen>0) retvec.emplace_back(cnt);
212  }//end loop over channels
213 
214  nLBsSeen=nLBsSeenSet.size();
215  std::cout << "Evaluated a total of " << nLBsSeen << "LBs" << std::endl;
216 
217  delete tuple;
218  return retvec;
219 
220 }

◆ checkBadLBList()

bool LCE_CellList::checkBadLBList ( const unsigned  lumiBlock) const
inline

Definition at line 74 of file LCE_CellList.cxx.

74  {
75  return (m_badLBs.find(lumiBlock)!=m_badLBs.end());
76 }

◆ partitionName()

std::string LCE_CellList::partitionName ( const short  caloId,
const short  slot 
) const

Definition at line 271 of file LCE_CellList.cxx.

271  {
272 
273  std::string name;
274  std::string slayer=std::to_string(layer);
275  std::string side;
276 
277  switch (caloId) {
278  case EMB_C:
279  name="EMB";
280  side="C";
281  if (layer==0) slayer="P";
282  break;
283  case EMB_A:
284  name="EMB";
285  side="A";
286  if (layer==0) slayer="P";
287  break;
288 
289  case EMEC_INNER_C:
290  case EMEC_OUTER_C:
291  name="EMEC";
292  side="C";
293  if (layer==0) slayer="P";
294  break;
295 
296  case EMEC_INNER_A:
297  case EMEC_OUTER_A:
298  name="EMEC";
299  side="A";
300  if (layer==0) slayer="P";
301  break;
302 
303  case HEC_A:
304  name="HEC";
305  side="A";
306  break;
307 
308  case HEC_C:
309  name="HEC";
310  side="C";
311  break;
312 
313  case FCAL_A:
314  name="FCAL";
315  side="A";
316  break;
317 
318  case FCAL_C:
319  name="FCAL";
320  side="C";
321  break;
322 
323  default:
324  name="UNKNOWN";
325  slayer="";
326  }
327 
328  return name+slayer+side;
329 }

◆ printThresholds()

void LCE_CellList::printThresholds ( ) const

Definition at line 122 of file LCE_CellList.cxx.

122  {
123  printf ("Listing Thresholds:\n");
124  printf ("\tMin number of appearences in LCE ntuple: %u\n",m_minNSeen);
125  printf ("\tMin mumber of events with E> n Sigma Noise: %u\n", m_minAboveSigNoise);
126  printf ("Flagging Thresholds:\n");
127  printf ("\tMin number of events > sigNoise: %.3f * nLumiBlocks\n",m_hitCountPerLBThreshold);
128  printf ("\tUpper count threshold for event energy cut %u\n", m_UpperCountThreshold);
129  printf ("\tLower count threshold for event energy cut %u\n", m_LowerCountThreshold);
130  printf ("\tUpper mean energy threshold for event energy cut %.2f MeV\n", m_UpperCellEnergyThreshold);
131  printf ("\tLower mean energy threshold for event energy cut %.2f MeV\n",m_LowerCellEnergyThreshold);
132 }

◆ readDefectLBList()

void LCE_CellList::readDefectLBList ( const char *  LBfile)

Definition at line 136 of file LCE_CellList.cxx.

136  {
137 
138  if (!m_badLBs.empty())
139  printf("Appending to already-existing list of bad lumi-blocks of size %zu\n",m_badLBs.size());
140 
141 
142  std::ifstream infile(LBfile);
143  std::string line;
144 
145  // assume single-line format with coma-separated LBs (from python)
146  std::getline(infile,line,'\n');
147  if (line.empty()) {
148  printf("No bad LBs found in file %s\n" ,(const char*)LBfile);
149  return;
150  }
151 
152  for (size_t pos=0;pos!=std::string::npos;pos=line.find(',',pos)) {
153  if (pos) pos++; //Jump over comma if not the first iteration
154  //std::cout << "Parsing " << line.c_str()+pos << std::endl;
155  unsigned LB=std::atoi(line.c_str()+pos);
156  m_badLBs.insert(LB);
157  }
158 
159  printf("Number of bad lumi-blocks: %d\n",(int)m_badLBs.size());
160 
161  return;
162 }

◆ setFlaggingThresholds()

void LCE_CellList::setFlaggingThresholds ( const float  hitsPerLB,
const unsigned  upperCountThr,
const double  lowerEThr,
const unsigned  lowerCountThr,
const double  upperEThr 
)

Definition at line 107 of file LCE_CellList.cxx.

107  {
108  m_hitCountPerLBThreshold=hitsPerLB;
109  m_UpperCountThreshold = upperCountThr;
110  m_LowerCountThreshold = lowerCountThr;
111  m_LowerCellEnergyThreshold = lowerEThr;
112  m_UpperCellEnergyThreshold = upperEThr;
113  }

◆ setListingThresholds()

void LCE_CellList::setListingThresholds ( const unsigned  minNSeen,
const unsigned  minAboveSigNoise 
)

Definition at line 116 of file LCE_CellList.cxx.

116  {
117  m_minNSeen=minNSeen;
118  m_minAboveSigNoise=minAboveSigNoise;
119 }

◆ writeList()

void LCE_CellList::writeList ( const char *  filename,
const std::vector< LCE_CellList::thrCounter_t > &  celllist 
) const

Definition at line 239 of file LCE_CellList.cxx.

239  {
240  FILE* pFile = fopen (textfilename , "w");
241  // 0 1 2 3 4 5 6 7 8 9 10
242  fprintf(pFile,"onlid // partition // FT // Slot // channel // nAboveSigNoise // nAboveAbsE // MeanE [GeV] // fracQ4k // nLBs // Algoflag\n");
243 
244  for (const auto& cnt : cellList) {
245  if (applySelection(cnt)) {
246  unsigned flag=0;
247  if (cnt.EventEnergyCut) {
248  flag=1;
249  if (cnt.MeanCellHitCut) flag=2;
250  }
251  //Expected format (by WDE):
252  //online id Partition FT Slot Chan nEvt>10Sig nEvt>1GeV, MeanE, fracQ4k, nLBs,
253  // 0 1 2 3 4 5 6 7 8 9 10
254  fprintf(pFile,"0x%8.8x \t %7s \t %i \t %i \t %i \t %i \t %i \t %.3f \t %.3f \t %u \t %u",
255  cnt.onlId, partitionName(cnt.caloid,cnt.layer).c_str(),
256  cnt.FT, cnt.slot, cnt.channel, cnt.nAboveSigNoise, cnt.nAboveAbsE,
257  cnt.Esum/(1000.0*cnt.nSeen), (float)cnt.nAboveQ/cnt.nSeen,
258  (unsigned)cnt.LBs.size(), flag );
259  //for (const unsigned lb : cnt.LBs) {
260  // fprintf(pFile, "%i ", lb);
261  //}
262 
263  fprintf(pFile,"\n");
264  }
265  }
266  fclose(pFile);
267  return;
268 }

Member Data Documentation

◆ m_badLBs

std::set<unsigned> LCE_CellList::m_badLBs
private

Definition at line 91 of file LCE_CellList.cxx.

◆ m_hitCountPerLBThreshold

float LCE_CellList::m_hitCountPerLBThreshold =0.01
private

Definition at line 94 of file LCE_CellList.cxx.

◆ m_LowerCellEnergyThreshold

double LCE_CellList::m_LowerCellEnergyThreshold =1000.0
private

Definition at line 97 of file LCE_CellList.cxx.

◆ m_LowerCountThreshold

unsigned LCE_CellList::m_LowerCountThreshold =20
private

Definition at line 96 of file LCE_CellList.cxx.

◆ m_minAboveSigNoise

unsigned LCE_CellList::m_minAboveSigNoise =1
private

Definition at line 102 of file LCE_CellList.cxx.

◆ m_minNSeen

unsigned LCE_CellList::m_minNSeen =10
private

Definition at line 101 of file LCE_CellList.cxx.

◆ m_UpperCellEnergyThreshold

double LCE_CellList::m_UpperCellEnergyThreshold =50000.0
private

Definition at line 98 of file LCE_CellList.cxx.

◆ m_UpperCountThreshold

unsigned LCE_CellList::m_UpperCountThreshold =50
private

Definition at line 95 of file LCE_CellList.cxx.


The documentation for this class was generated from the following file:
nEvents
const int nEvents
Definition: fbtTestBasics.cxx:77
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
LArSamples::CellInfo::slot
short slot() const
Definition: CellInfo.h:68
LArSamples::CellInfo::calo
CaloId calo() const
Definition: CellInfo.h:50
run.infile
string infile
Definition: run.py:13
CaloCellTimeCorrFiller.LB
LB
Definition: CaloCellTimeCorrFiller.py:37
collListGuids.line
string line
Definition: collListGuids.py:77
plotmaker.hist
hist
Definition: plotmaker.py:148
LArSamples::History
Definition: History.h:35
defineDB.ichan
ichan
Definition: JetTagCalibration/share/defineDB.py:28
LCE_CellList::m_UpperCountThreshold
unsigned m_UpperCountThreshold
Definition: LCE_CellList.cxx:95
LArSamples::CellInfo::feedThrough
short feedThrough() const
Definition: CellInfo.h:65
LArSamples::FCAL_C
@ FCAL_C
Definition: CaloId.h:22
LArSamples::Interface::cellHistory
const History * cellHistory(unsigned int i) const
Definition: Interface.cxx:116
LCE_CellList::checkBadLBList
bool checkBadLBList(const unsigned lumiBlock) const
Definition: LCE_CellList.cxx:74
LArSamples::HEC_A
@ HEC_A
Definition: CaloId.h:24
LArSamples::FCAL_A
@ FCAL_A
Definition: CaloId.h:24
LArSamples::EMEC_OUTER_C
@ EMEC_OUTER_C
Definition: CaloId.h:22
TRT::Hit::side
@ side
Definition: HitInfo.h:83
LCE_CellList::m_hitCountPerLBThreshold
float m_hitCountPerLBThreshold
Definition: LCE_CellList.cxx:94
PUfitVar::nSigma
constexpr float nSigma
Definition: GepMETPufitAlg.cxx:16
LArSamples::CellInfo::onlid
ULong64_t onlid() const
Definition: CellInfo.h:90
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
LArSamples::EMB_C
@ EMB_C
Definition: CaloId.h:22
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
master.flag
bool flag
Definition: master.py:29
LCE_CellList::m_LowerCellEnergyThreshold
double m_LowerCellEnergyThreshold
Definition: LCE_CellList.cxx:97
LCE_CellList::applySelection
bool applySelection(const LCE_CellList::thrCounter_t &counter) const
Definition: LCE_CellList.cxx:234
LCE_CellList::m_badLBs
std::set< unsigned > m_badLBs
Definition: LCE_CellList.cxx:91
LArSamples::EMEC_OUTER_A
@ EMEC_OUTER_A
Definition: CaloId.h:24
LArSamples::Data
Definition: Data.h:72
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
LCE_CellList::m_UpperCellEnergyThreshold
double m_UpperCellEnergyThreshold
Definition: LCE_CellList.cxx:98
LCE_CellList::m_minAboveSigNoise
unsigned m_minAboveSigNoise
Definition: LCE_CellList.cxx:102
LArSamples::CellInfo
Definition: CellInfo.h:31
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
LCE_CellList::m_minNSeen
unsigned m_minNSeen
Definition: LCE_CellList.cxx:101
Trk::open
@ open
Definition: BinningType.h:40
LArSamples::CellInfo::channel
short channel() const
Definition: CellInfo.h:76
LCE_CellList::m_LowerCountThreshold
unsigned m_LowerCountThreshold
Definition: LCE_CellList.cxx:96
trigbs_pickEvents.cnt
cnt
Definition: trigbs_pickEvents.py:71
LCE_CellList::partitionName
std::string partitionName(const short caloId, const short slot) const
Definition: LCE_CellList.cxx:271
FullCPAlgorithmsTest_CA.inputfile
dictionary inputfile
Definition: FullCPAlgorithmsTest_CA.py:62
python.TrackLeptonConfig.quality
quality
Definition: TrackLeptonConfig.py:16
LArSamples::EMEC_INNER_C
@ EMEC_INNER_C
Definition: CaloId.h:22
LArSamples::HEC_C
@ HEC_C
Definition: CaloId.h:22
LArSamples::Interface
Definition: Interface.h:36
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
LArSamples::EMB_A
@ EMB_A
Definition: CaloId.h:24
LArSamples::EventData::lumiBlock
unsigned int lumiBlock() const
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:47
LArSamples::EMEC_INNER_A
@ EMEC_INNER_A
Definition: CaloId.h:24
test_pyathena.counter
counter
Definition: test_pyathena.py:15
xAOD::lumiBlock
setTeId lumiBlock
Definition: L2StandAloneMuon_v1.cxx:327
LArSamples::EventData
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:29
LArSamples::CellInfo::layer
short layer() const
Definition: CellInfo.h:53
LArSamples::AbsLArCells::nChannels
virtual unsigned int nChannels() const
Definition: AbsLArCells.h:34
WriteCellNoiseToCool.noise
noise
Definition: WriteCellNoiseToCool.py:380