ATLAS Offline Software
Loading...
Searching...
No Matches
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}
double m_UpperCellEnergyThreshold
double m_LowerCellEnergyThreshold
unsigned m_LowerCountThreshold
unsigned m_UpperCountThreshold
float m_hitCountPerLBThreshold

◆ 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}
unsigned m_minAboveSigNoise
unsigned m_minNSeen

◆ 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
171 LArSamples::Interface* tuple = (LArSamples::Interface*)Interface::open(inputfile);
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}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
virtual unsigned int nChannels() const
Definition AbsLArCells.h:34
short slot() const
Definition CellInfo.h:68
short layer() const
Definition CellInfo.h:53
short feedThrough() const
Definition CellInfo.h:65
ULong64_t onlid() const
Definition CellInfo.h:90
CaloId calo() const
Definition CellInfo.h:50
short channel() const
Definition CellInfo.h:76
const History * cellHistory(unsigned int i) const
bool checkBadLBList(const unsigned lumiBlock) const
const int nEvents
setTeId lumiBlock

◆ 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}
std::set< unsigned > m_badLBs

◆ partitionName()

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

Definition at line 273 of file LCE_CellList.cxx.

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

◆ 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}
str infile
Definition run.py:13

◆ 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 if (!pFile) {
242 std::cerr << "Cannot open output file " << textfilename << "\n";
243 exit(1);
244 }
245 // 0 1 2 3 4 5 6 7 8 9 10
246 fprintf(pFile,"onlid // partition // FT // Slot // channel // nAboveSigNoise // nAboveAbsE // MeanE [GeV] // fracQ4k // nLBs // Algoflag\n");
247
248 for (const auto& cnt : cellList) {
249 if (applySelection(cnt)) {
250 unsigned flag=0;
251 if (cnt.EventEnergyCut) {
252 flag=1;
253 if (cnt.MeanCellHitCut) flag=2;
254 }
255 //Expected format (by WDE):
256 //online id Partition FT Slot Chan nEvt>10Sig nEvt>1GeV, MeanE, fracQ4k, nLBs,
257 // 0 1 2 3 4 5 6 7 8 9 10
258 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",
259 cnt.onlId, partitionName(cnt.caloid,cnt.layer).c_str(),
260 cnt.FT, cnt.slot, cnt.channel, cnt.nAboveSigNoise, cnt.nAboveAbsE,
261 cnt.Esum/(1000.0*cnt.nSeen), (float)cnt.nAboveQ/cnt.nSeen,
262 (unsigned)cnt.LBs.size(), flag );
263
264
265 fprintf(pFile,"\n");
266 }
267 }
268 fclose(pFile);
269 return;
270}
std::string partitionName(const short caloId, const short slot) const
bool applySelection(const LCE_CellList::thrCounter_t &counter) const
bool flag
Definition master.py:29

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: