30 std::unique_ptr<TFile>
f( TFile::Open(
fileName.c_str()) );
32 TTree*
t =
f->Get<TTree>(
"mapping");
34 unsigned long long scid = 0;
35 std::pair<int,int>
coord = {0,0};
36 std::pair<int,int> slot;
37 t->SetBranchAddress(
"scid",&scid);
38 t->SetBranchAddress(
"etaIndex",&
coord.first);
39 t->SetBranchAddress(
"phiIndex",&
coord.second);
40 t->SetBranchAddress(
"slot1",&slot.first);
41 t->SetBranchAddress(
"slot2",&slot.second);
42 for(Long64_t
i=0;
i<
t->GetEntries();
i++) {
44 m_scMap[std::make_pair(
coord,slot.first)].first.insert(scid);
45 m_scMap[std::make_pair(
coord,slot.second)].first.insert(scid);
50 for(
auto id : scs.first) {
74 return StatusCode::FAILURE;
87 if(larBadChan.isValid()) {
88 timeSince = ctx.eventID().time_stamp() - larBadChan.getRange().start().time_stamp();
89 timeUntil = larBadChan.getRange().stop().time_stamp() - ctx.eventID().time_stamp();
90 timeUntilCapped =
std::min(
int(timeUntil),199);
106 bool isPrescaled = (((
GetEventInfo(ctx)->extendedLevel1ID()&0xffffff) % 200) != 0);
107 size_t badTowers = 0;
110 fill(
"errors",
Decision,timeSince,timeUntil,evtNumber,lbn,lbnString,TowerId,Towereta,Towerphi,Toweremstatus,Towerhadstatus,TowerSlot,TowerCount,TowerRefCount,SlotSCID);
118 fill(
"errors",
Decision, timeSince, timeUntil, evtNumber, lbn, lbnString, TowerId, Towereta, Towerphi,
119 Toweremstatus, Towerhadstatus, TowerSlot, TowerCount, TowerRefCount, SlotSCID);
128 auto etaIndex = [](
float eta) {
return int(
eta*10 ) + ((
eta<0) ? -1 : 1); };
131 size_t missingSlots = 0;
132 if (eFexTowerContainerRef.isValid()) {
133 if(eFexTowerContainerRef->empty()) missingSlots=34048;
134 for (
auto eTower: *eFexTowerContainerRef) {
135 refTowers[std::pair(etaIndex(eTower->eta() + 0.025),
phiIndex(eTower->phi() + 0.025))] = eTower;
137 Towereta = eTower->eta(); Towerphi = eTower->phi();
138 std::vector<uint16_t> Toweret_count=eTower->et_count();
139 for(
size_t i=0;
i<Toweret_count.size();
i++) {
140 TowerRefCount = Toweret_count[
i];
141 if (TowerRefCount==1025) missingSlots+=1;
142 if(TowerRefCount==1025 || TowerRefCount==1022) TowerRefCount=0;
143 fill((
i<10) ?
"ecal" :
"hcal",lbn,Towereta,Towerphi,TowerRefCount);
147 if(missingSlots > 1280) {
149 fill(
"errors",
Decision,timeSince,timeUntil,evtNumber,lbn,lbnString,TowerId,Towereta,Towerphi,Toweremstatus,Towerhadstatus,TowerSlot,TowerCount,TowerRefCount,SlotSCID);
155 std::set<std::pair<std::pair<int,int>,
int>> doneCounts;
163 std::set<std::string> reportedErrors;
166 TowerId = eTower->id();
167 Towereta=eTower->eta();
168 Towerphi=eTower->phi();
169 Toweremstatus=eTower->em_status();
170 Towerhadstatus=eTower->had_status();
171 if(eTower->em_status()) {
173 ErrorAndLocation =
"#splitline{" +
static_cast<std::string
>(
Decision) +
"}{" +
std::to_string(TowerId) +
"}";
174 fill(
"errors",
Decision,ErrorAndLocation,timeSince,timeUntil,evtNumber,lbn,lbnString,TowerId,Towereta,Towerphi,Toweremstatus,Towerhadstatus,TowerSlot,TowerCount,TowerRefCount,SlotSCID,IsMonReady);
175 if(!reportedErrors.count(
Decision)) {
180 if(eTower->had_status()) {
182 ErrorAndLocation =
"#splitline{" +
static_cast<std::string
>(
Decision) +
"}{" +
std::to_string(TowerId) +
"}";
183 fill(
"errors",
Decision,ErrorAndLocation,timeSince,timeUntil,evtNumber,lbn,lbnString,TowerId,Towereta,Towerphi,Toweremstatus,Towerhadstatus,TowerSlot,TowerCount,TowerRefCount,SlotSCID,IsMonReady);
184 if(!reportedErrors.count(
Decision)) {
189 std::vector<uint16_t>
counts=eTower->et_count();
190 std::vector<uint16_t> refcounts;
191 auto coord = std::pair(etaIndex(eTower->eta() + 0.025),
phiIndex(eTower->phi() + 0.025));
192 if(!refTowers.empty()) {
193 if(
auto itr = refTowers.find(
coord); itr != refTowers.end()) {
194 refcounts = itr->second->et_count();
198 if (eTower->disconnectedCount(
i))
continue;
200 if (doneCounts.find(std::pair(
coord,
i))==doneCounts.end()) {
201 doneCounts.insert(std::pair(
coord,
i));
205 bool isLAr = !(
i==10 && std::abs(Towereta)<=1.5);
210 SlotSCID = itr->second.second;
213 fill(
"errors",
Decision,timeSince,timeUntil,evtNumber,lbn,lbnString,TowerId,Towereta,Towerphi,Toweremstatus,Towerhadstatus,TowerSlot,TowerCount,TowerRefCount,SlotSCID,IsMonReady);
214 if(!reportedErrors.count(
Decision)) {
221 fill(
"errors",
Decision,timeSince,timeUntil,evtNumber,lbn,lbnString,TowerId,Towereta,Towerphi,Toweremstatus,Towerhadstatus,TowerSlot,TowerCount,TowerRefCount,SlotSCID,IsMonReady);
222 if(!reportedErrors.count(
Decision)) {
233 if(!refTowers.empty()) {
234 if(refcounts.size() !=
counts.size()) {
237 TowerRefCount = refcounts.at(
i);
239 if(TowerCount==1022) {
241 if(TowerRefCount!=1022) {
242 Decision =
"LArInvalidCodeMismatched";
244 }
else if(!TowerCount && TowerRefCount) {
246 }
else if(TowerCount && !TowerRefCount) {
248 }
else if(TowerCount != TowerRefCount) {
249 if(TowerRefCount==1025) {
256 }
else if(TowerCount != TowerRefCount) {
257 if(TowerRefCount==1025) {
264 if(!std::string(
Decision).empty()) {
267 SlotSCID = itr->second.second;
270 if(!(isLAr && timeUntil>=0 && timeUntil<=5)) {
271 ErrorAndLocation =
"#splitline{" +
static_cast<std::string
>(
Decision) +
"}{" +
std::to_string(TowerId) +
"}";
272 fill(
"errors",
Decision, ErrorAndLocation, timeSince, timeUntil, evtNumber, lbn, lbnString,
273 TowerId, Towereta, Towerphi, Toweremstatus, Towerhadstatus, TowerSlot, TowerCount,
274 TowerRefCount, SlotSCID,IsMonReady);
275 if (!reportedErrors.count(
Decision)) {
277 << std::string(lbnString));
284 if ((!isLAr) || (TowerCount != 1022)) {
285 AboveCut = (TowerCount >= (isLAr ? 52:1));
286 BelowCut = (TowerCount < (isLAr ? 23:0) && TowerCount>0);
287 if(AboveCut || BelowCut) {
288 int etaIdx = TowerId/100000;
289 if(etaIdx>0) etaIdx--;
290 int phiIdx = std::abs(TowerId % 100000)/1000;
291 if(phiIdx>31) phiIdx -= 64;
292 binNumber = (25 + etaIdx)*64 + phiIdx+33;
293 fill((
i<10) ?
"ecal" :
"hcal",lbn,Towereta,Towerphi,TowerCount,AboveCut,BelowCut,binNumber);
300 return StatusCode::SUCCESS;