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);
109 fill(
"errors",
Decision,timeSince,timeUntil,evtNumber,lbn,lbnString,TowerId,Towereta,Towerphi,Toweremstatus,Towerhadstatus,TowerSlot,TowerCount,TowerRefCount,SlotSCID);
112 fill(
"errors",
Decision,timeSince,timeUntil,evtNumber,lbn,lbnString,TowerId,Towereta,Towerphi,Toweremstatus,Towerhadstatus,TowerSlot,TowerCount,TowerRefCount,SlotSCID);
120 auto etaIndex = [](
float eta) {
return int( eta*10 ) + ((eta<0) ? -1 : 1); };
121 auto phiIndex = [](
float phi) {
return int( phi*32./
M_PI ) + (phi<0 ? -1 : 1); };
123 bool missingLAr =
false;
124 if (eFexTowerContainerRef.isValid()) {
125 if(eFexTowerContainerRef->empty()) missingLAr=
true;
126 for (
auto eTower: *eFexTowerContainerRef) {
127 refTowers[std::pair(etaIndex(eTower->eta() + 0.025),
phiIndex(eTower->phi() + 0.025))] = eTower;
129 Towereta = eTower->eta(); Towerphi = eTower->phi();
130 std::vector<uint16_t> Toweret_count=eTower->et_count();
131 for(
size_t i=0;
i<Toweret_count.size();
i++) {
132 TowerRefCount = Toweret_count[
i];
133 if (TowerRefCount==1025) missingLAr=
true;
134 if(TowerRefCount==1025 || TowerRefCount==1022) TowerRefCount=0;
135 fill((
i<10) ?
"ecal" :
"hcal",lbn,Towereta,Towerphi,TowerRefCount);
141 fill(
"errors",
Decision,timeSince,timeUntil,evtNumber,lbn,lbnString,TowerId,Towereta,Towerphi,Toweremstatus,Towerhadstatus,TowerSlot,TowerCount,TowerRefCount,SlotSCID);
146 std::set<std::pair<std::pair<int,int>,
int>> doneCounts;
155 TowerId = eTower->id();
156 Towereta=eTower->eta();
157 Towerphi=eTower->phi();
158 Toweremstatus=eTower->em_status();
159 Towerhadstatus=eTower->had_status();
160 if(eTower->em_status()) {
163 fill(
"errors",
Decision,ErrorAndLocation,timeSince,timeUntil,evtNumber,lbn,lbnString,TowerId,Towereta,Towerphi,Toweremstatus,Towerhadstatus,TowerSlot,TowerCount,TowerRefCount,SlotSCID,IsMonReady);
165 if(eTower->had_status()) {
168 fill(
"errors",
Decision,ErrorAndLocation,timeSince,timeUntil,evtNumber,lbn,lbnString,TowerId,Towereta,Towerphi,Toweremstatus,Towerhadstatus,TowerSlot,TowerCount,TowerRefCount,SlotSCID,IsMonReady);
170 std::vector<uint16_t> counts=eTower->et_count();
171 std::vector<uint16_t> refcounts;
172 auto coord = std::pair(etaIndex(eTower->eta() + 0.025),
phiIndex(eTower->phi() + 0.025));
173 if(!refTowers.empty()) {
174 if(
auto itr = refTowers.find(
coord); itr != refTowers.end()) {
175 refcounts = itr->second->et_count();
178 for(
size_t i=0;
i<counts.size();
i++) {
179 if (eTower->disconnectedCount(
i))
continue;
181 if (doneCounts.find(std::pair(
coord,
i))==doneCounts.end()) {
182 doneCounts.insert(std::pair(
coord,
i));
186 bool isLAr = !(
i==10 && std::abs(Towereta)<=1.5);
188 TowerCount = counts[
i];
191 if(!refTowers.empty()) {
192 if(refcounts.size() != counts.size()) {
195 TowerRefCount = refcounts.at(
i);
197 if(TowerCount==1022) {
199 if(TowerRefCount!=1022) {
200 Decision =
"LArInvalidCodeMismatched";
202 }
else if(!TowerCount && TowerRefCount) {
204 }
else if(TowerCount && !TowerRefCount) {
206 }
else if(TowerCount != TowerRefCount) {
210 }
else if(TowerCount != TowerRefCount) {
214 if(!std::string(
Decision).empty()) {
217 SlotSCID = itr->second.second;
221 fill(
"errors",
Decision,ErrorAndLocation,timeSince,timeUntil,evtNumber,lbn,lbnString,TowerId,Towereta,Towerphi,Toweremstatus,Towerhadstatus,TowerSlot,TowerCount,TowerRefCount,SlotSCID);
225 if ((!isLAr) || (TowerCount != 1022)) {
226 AboveCut = (TowerCount >= (isLAr ? 52:1));
227 BelowCut = (TowerCount < (isLAr ? 23:0) && TowerCount>0);
228 if(AboveCut || BelowCut) {
229 int etaIdx = TowerId/100000;
230 if(etaIdx>0) etaIdx--;
231 int phiIdx = std::abs(TowerId % 100000)/1000;
232 if(phiIdx>31) phiIdx -= 64;
233 binNumber = (phiIdx+32)*50 + 26 + etaIdx;
234 fill((
i<10) ?
"ecal" :
"hcal",lbn,Towereta,Towerphi,TowerCount,AboveCut,BelowCut,binNumber);
241 return StatusCode::SUCCESS;