ATLAS Offline Software
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 35 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 220 of file LCE_CellList.cxx.

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

◆ applySelection()

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

Definition at line 232 of file LCE_CellList.cxx.

232  {
233  return counter.nSeen > m_minNSeen && counter.nAboveSigNoise > m_minAboveSigNoise;
234 }

◆ 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 163 of file LCE_CellList.cxx.

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

◆ checkBadLBList()

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

Definition at line 72 of file LCE_CellList.cxx.

72  {
73  return (m_badLBs.find(lumiBlock)!=m_badLBs.end());
74 }

◆ partitionName()

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

Definition at line 269 of file LCE_CellList.cxx.

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

◆ printThresholds()

void LCE_CellList::printThresholds ( ) const

Definition at line 120 of file LCE_CellList.cxx.

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

◆ readDefectLBList()

void LCE_CellList::readDefectLBList ( const char *  LBfile)

Definition at line 134 of file LCE_CellList.cxx.

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

◆ setFlaggingThresholds()

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

Definition at line 105 of file LCE_CellList.cxx.

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

◆ setListingThresholds()

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

Definition at line 114 of file LCE_CellList.cxx.

114  {
115  m_minNSeen=minNSeen;
116  m_minAboveSigNoise=minAboveSigNoise;
117 }

◆ writeList()

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

Definition at line 237 of file LCE_CellList.cxx.

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

Member Data Documentation

◆ m_badLBs

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

Definition at line 89 of file LCE_CellList.cxx.

◆ m_hitCountPerLBThreshold

float LCE_CellList::m_hitCountPerLBThreshold =0.01
private

Definition at line 92 of file LCE_CellList.cxx.

◆ m_LowerCellEnergyThreshold

double LCE_CellList::m_LowerCellEnergyThreshold =1000.0
private

Definition at line 95 of file LCE_CellList.cxx.

◆ m_LowerCountThreshold

unsigned LCE_CellList::m_LowerCountThreshold =20
private

Definition at line 94 of file LCE_CellList.cxx.

◆ m_minAboveSigNoise

unsigned LCE_CellList::m_minAboveSigNoise =1
private

Definition at line 100 of file LCE_CellList.cxx.

◆ m_minNSeen

unsigned LCE_CellList::m_minNSeen =10
private

Definition at line 99 of file LCE_CellList.cxx.

◆ m_UpperCellEnergyThreshold

double LCE_CellList::m_UpperCellEnergyThreshold =50000.0
private

Definition at line 96 of file LCE_CellList.cxx.

◆ m_UpperCountThreshold

unsigned LCE_CellList::m_UpperCountThreshold =50
private

Definition at line 93 of file LCE_CellList.cxx.


The documentation for this class was generated from the following file:
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
checkFileSG.line
line
Definition: checkFileSG.py:75
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
plotmaker.hist
hist
Definition: plotmaker.py:148
LArSamples::History
Definition: History.h:40
LCE_CellList::m_UpperCountThreshold
unsigned m_UpperCountThreshold
Definition: LCE_CellList.cxx:93
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:114
LCE_CellList::checkBadLBList
bool checkBadLBList(const unsigned lumiBlock) const
Definition: LCE_CellList.cxx:72
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:92
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:95
LCE_CellList::applySelection
bool applySelection(const LCE_CellList::thrCounter_t &counter) const
Definition: LCE_CellList.cxx:232
nEvents
int nEvents
Definition: fbtTestBasics.cxx:77
LCE_CellList::m_badLBs
std::set< unsigned > m_badLBs
Definition: LCE_CellList.cxx:89
LArSamples::EMEC_OUTER_A
@ EMEC_OUTER_A
Definition: CaloId.h:24
defineDB.ichan
int ichan
Definition: JetTagCalibration/share/defineDB.py:28
LArSamples::Data
Definition: Data.h:77
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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:96
LCE_CellList::m_minAboveSigNoise
unsigned m_minAboveSigNoise
Definition: LCE_CellList.cxx:100
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:99
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:94
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:269
FullCPAlgorithmsTest_CA.inputfile
dictionary inputfile
Definition: FullCPAlgorithmsTest_CA.py:59
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