54{
55
56 std::map<std::pair<int, int>, int> noiseCutsMap;
57 bool useHardcodedCuts = false;
59
61 useHardcodedCuts = true;
62 } else {
63 SG::ReadCondHandle <CondAttrListCollection> noiseCuts{
m_noiseCutsKey, ctx};
68 noiseCuts->dump();
69 }
70 if(noiseCuts->size()==0) {
71 ATH_MSG_ERROR(
"No noise cuts loaded from conditions db for event with timestamp" << ctx.eventID().time_stamp());
72 return StatusCode::FAILURE;
73 }
74 for (auto itr = noiseCuts->begin(); itr != noiseCuts->end(); ++itr) {
75 if (itr->first >= 50) continue;
76 noiseCutsMap[std::pair(itr->first, 0)] = itr->second["EmPS"].data<int>();
77 noiseCutsMap[std::pair(itr->first, 1)] = itr->second["EmFR"].data<int>();
78 noiseCutsMap[std::pair(itr->first, 2)] = itr->second["EmMD"].data<int>();
79 noiseCutsMap[std::pair(itr->first, 3)] = itr->second["EmBK"].data<int>();
80 noiseCutsMap[std::pair(itr->first, 4)] = (itr->first >= 10 && itr->first < 40)
81 ? itr->second["Tile"].data<int>()
82 : itr->second["HEC"].data<int>();
83 }
84 }
85 }
86 }
87
88
89 std::unique_ptr<eTowerContainer> local_eTowerContainerRaw = std::make_unique<eTowerContainer>();
90
91
93 local_eTowerContainerRaw->clearContainerMap();
94 local_eTowerContainerRaw->fillContainerMap();
95
97
98
99 size_t badTowers = 0;
100 if(eFexTowers.isValid()) {
101 for(auto eFexTower : *eFexTowers) {
103 }
104 }
107
108
109
110
111
112 }
113
114
115 for(auto eFexTower : *eFexTowers) {
116
117
120 for(
size_t i=0;
i<
counts.size();
i++) {
121 if(i<10 && eFexTower->em_status()) continue;
125
126
129 else if(i<5)
layer = 1;
130 else if(i<9)
layer = 2;
131 else if(i<10)
layer = 3;
133
134
135
136
137 if(!useHardcodedCuts &&
counts.at(i) <= noiseCutsMap[std::pair(
int( (
eFexTower->
eta() + 2.525)/0.1 ), layer)])
continue;
138
139
140
141 if(!tower->getET_float(layer,cell-(layer==1)*1-(layer==2)*5-(layer==3)*9-(layer==4)*10)) {
142
145 }
146 }
147 }
148
151
152
153
154 TFile *debugFile = dynamic_cast<TFile *>(gROOT->GetListOfFiles()->FindObject("debug_eFexTowerMakerFromEfexTowers.root"));
155 if (!debugFile) debugFile = TFile::Open("debug_eFexTowerMakerFromEfexTowers.root", "RECREATE");
156 if (debugFile->GetListOfKeys()->GetEntries() < 20) {
158 debugFile->cd();
159 TH2D
ps(
"ps",
"ps [code];#eta;#phi", 50, -2.5, 2.5, 64, -
M_PI,
M_PI);
160 TH2D
l1(
"l1",
"l1 [code];#eta;#phi", 200, -2.5, 2.5, 64, -
M_PI,
M_PI);
161 TH2D
l2(
"l2",
"l2 [code];#eta;#phi", 200, -2.5, 2.5, 64, -
M_PI,
M_PI);
162 TH2D l3(
"l3",
"l3 [code];#eta;#phi", 50, -2.5, 2.5, 64, -
M_PI,
M_PI);
163 TH2D had(
"had",
"had [code~25MeV or 500MeV for tile];#eta;#phi", 50, -2.5, 2.5, 64, -
M_PI,
M_PI);
164 std::vector < TH1 * >
hists{&
ps, &
l1, &
l2, &l3, &had};
165 for(auto eFexTower : *eFexTowers) {
167 if (
counts.empty())
continue;
170 double tEta = ((etaIndex < 0 ? 0.5 : -0.5) + etaIndex - 0.5) * 0.1;
172 for(
size_t i=0;
i<
counts.size();
i++) {
173 if(i<10 && eFexTower->em_status()) continue;
182 if(!useHardcodedCuts &&
counts.at(i) <= noiseCutsMap[std::pair(
int( (
eFexTower->
eta() + 2.525)/0.1 ), layer)])
continue;
183 hists.at(layer)->SetBinContent(
hists.at(layer)->FindFixBin(tEta + 0.025 * cell + 0.0125, tPhi),
counts.at(i));
184
185 }
186 }
187
189 c.SetName(TString::Format(
"evt%lu", ctx.eventID().event_number()));
190 c.SetTitle(TString::Format(
"Run %u LB %u Event %lu", ctx.eventID().run_number(), ctx.eventID().lumi_block(),
191 ctx.eventID().event_number()));
193 TH2D tobs(
"tobs",
"Sum [MeV];#eta;#phi", 50, -2.5, 2.5, 64, -
M_PI,
M_PI);
194 for (
size_t i = 0;
i <
hists.size();
i++) {
195 c.GetPad(i + 1)->cd();gPad->SetGrid(1,1);
196 hists[
i]->SetStats(
false);
197 hists[
i]->SetMarkerSize(2);
198 hists[
i]->GetXaxis()->SetRangeUser(-0.3, 0.3);
199 hists[
i]->GetYaxis()->SetRangeUser(-0.3, 0.3);
200 hists[
i]->Draw((hists[i]->GetNbinsX() > 50) ?
"coltext89" :
"coltext");
201 for (
int ii = 1; ii <=
hists[
i]->GetNbinsX(); ii++) {
202 bool isTile = (
i==4 && std::abs(hists[i]->GetXaxis()->GetBinCenter(ii))<1.5);
203 for (
int jj = 1; jj <=
hists[
i]->GetNbinsY(); jj++)
204 tobs.Fill(hists[i]->GetXaxis()->GetBinCenter(ii), hists[i]->GetYaxis()->GetBinCenter(jj),
206 }
207 }
208 c.GetPad(
hists.size() + 1)->cd();
209 tobs.SetStats(false);
210 tobs.Draw("col");
211 TBox
b(-0.3, -0.3, 0.3, 0.3);
212 b.SetLineColor(kRed);
215 b.SetBit(TBox::kCannotMove);
216 tobs.GetListOfFunctions()->Add(
b.Clone());
217 gPad->AddExec("onClick", TString::Format(
218 "{ auto pad = gPad->GetCanvas()->GetPad(%lu); if( pad->GetEvent()==kButton1Down ) { double x = pad->PadtoX(pad->AbsPixeltoX(pad->GetEventX())); double y = pad->PadtoY(pad->AbsPixeltoY(pad->GetEventY())); for(int i=1;i<%lu;i++) {auto h = dynamic_cast<TH1*>(gPad->GetCanvas()->GetPad(i)->GetListOfPrimitives()->At(1)); if(h) {h->GetXaxis()->SetRangeUser(x-0.3,x+0.3);h->GetYaxis()->SetRangeUser(y-0.3,y+0.3); } } if(auto b = dynamic_cast<TBox*>(pad->FindObject(\"tobs\")->FindObject(\"TBox\"))) {b->SetX1(x-0.3);b->SetX2(x+0.3);b->SetY1(y-0.3);b->SetY2(y+0.3);} gPad->GetCanvas()->Paint(); gPad->GetCanvas()->Update(); } }",
222 }
223 }
224
225
226
227
229 ATH_CHECK(eTowerContainerSG.record(std::move(local_eTowerContainerRaw)));
230
231
233
234 return StatusCode::SUCCESS;
235}
#define ATH_CHECK
Evaluate an expression and check for errors.
bool msgLvl(const MSG::Level lvl) const
static int expand(unsigned int code)
Uncompress data.
SG::ReadHandleKey< xAOD::eFexTowerContainer > m_eFexTowerContainer2SGKey
SG::ReadHandleKey< xAOD::eFexTowerContainer > m_eFexTowerContainerSGKey
UnsignedIntegerProperty m_noiseCutBeginTimestamp
UnsignedIntegerProperty m_minTowersRequired
SG::ReadCondHandleKey< CondAttrListCollection > m_noiseCutsKey
ToolHandle< IeTowerBuilder > m_eTowerBuilderTool
std::atomic< bool > m_printedNoiseCuts
SG::WriteHandleKey< LVL1::eTowerContainer > m_eTowerContainerSGKey
uint32_t em_status() const
get em status bit
uint32_t had_status() const
setter for the above
uint32_t eFEXtowerID() const
setter for the above
const std::vector< uint16_t > & et_count() const
get Energy Counts
float phi() const
setter for the above
bool disconnectedCount(size_t idx) const
setter for the above
float eta() const
The pseudorapidity ( )
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
eFexTower_v1 eFexTower
Define the latest version of the TriggerTower class.