Algorithm execute method.
28 {
29
30 SG::WriteCondHandle<BunchCrossingCondData> writeHdl(
m_outputKey, ctx);
31 if (writeHdl.isValid()) {
33 return StatusCode::SUCCESS;
34 }
35
36
37
39
40
41 auto bccd=std::make_unique<BunchCrossingCondData>();
42
44 const TrigConf::L1BunchGroupSet* bgs{nullptr};
47 if (! bgsh.isValid()) {
49 return StatusCode::FAILURE;
50 }
51 bgs = *bgsh;
52 } else {
54 }
55
56 if (bgs->
size() >= 2) {
59 bccd->m_beam1.set(pos);
60 bccd->m_beam2.set(pos);
61 bccd->m_luminous.set(pos);
62 }
63 }
64 else {
66 }
67
68
69 if (bgs->
size() >= 15) {
71 bccd->m_beam1.set(pos);
72 }
74 bccd->m_beam2.set(pos);
75 }
76 }
77
79
80 const auto& thisevt = ctx.eventID();
81 EventIDRange
range = EventIDRange(EventIDBase(thisevt.run_number(), EventIDBase::UNDEFEVT,
82 EventIDBase::UNDEFNUM, 0, thisevt.lumi_block()),
83 EventIDBase(thisevt.run_number(), EventIDBase::UNDEFEVT,
84 EventIDBase::UNDEFNUM, 0, thisevt.lumi_block()+1));
85 writeHdl.addDependency(range);
86 }
87
90 writeHdl.addDependency(prefLumiHdl);
91
92
93 float avMu = prefLumiHdl->lbAverageInteractionsPerCrossing();
94 const auto& lumiVec = prefLumiHdl->lbLuminosityPerBCIDVector();
95 float cutLumi = avMu/1000.f*prefLumiHdl->muToLumi();
96
98 if (lumiVec[bcid] > cutLumi) {
99 bccd->m_beam1.set(bcid);
100 bccd->m_beam2.set(bcid);
101 bccd->m_luminous.set(bcid);
102 }
103 }
104
106 }
107
109
111 writeHdl.addDependency(fillParamsHdl);
112
113 const AthenaAttributeList* attrList=*fillParamsHdl;
114
115
118 ATH_MSG_INFO(
"Got AttributeList with size " << attrList->size());
119 std::string sbunches;
120 try {
121 const coral::Attribute& attr=(*attrList)[std::string("BeamIntensityPattern")];
122 if (attr.isNull()) {
123 ATH_MSG_ERROR(
"Got NULL attribute for BeamIntensityPattern");
124 return StatusCode::FAILURE;
125 }
126 sbunches = attr.data< std::string >();
127 } catch (coral::AttributeListException& e) {
130 return StatusCode::FAILURE;
131 }
132
133 const float minBunchIntensity=0.001;
134 std::vector<float> bunches=
tokenize(sbunches);
135 if (!bunches.empty()) {
136
138
140
141
142
144 const int pos1 =
i % bunches.size();
145 const int pos2 = bunches.size() - 1 - (
i % bunches.size() );
146 if( bunches[ pos1 ] > minBunchIntensity) {
147 bccd->m_beam1.set(i);
148 bccd->m_beam2.set(i);
149 bccd->m_luminous.set(i);
150 }
151 if( bunches[ pos2 ] > minBunchIntensity) {
155 }
156 }
157
158 } else {
159
160
163 const int pos =
i % bunches.size();
164 if( bunches[ pos ] > minBunchIntensity) {
165 bccd->m_beam1.set(i);
166 bccd->m_beam2.set(i);
167 bccd->m_luminous.set(i);
168 }
169 }
170 }
171
173 }
174 else {
175 ATH_MSG_INFO(
"Bunch structure information not found in metadata");
176 ATH_MSG_INFO(
"Will consider all BCIDs as single filled bunches (no trains)");
177 bccd->m_beam1.set();
178 bccd->m_beam2.set();
179 bccd->m_luminous.set();
180 }
181 }
182 else {
183 if ((*attrList)["BCIDmasks"].isNull()) {
185 return StatusCode::FAILURE;
186 }
187
188
189
190 cool::UInt32 nb1 = (*attrList)["Beam1Bunches"].data<cool::UInt32>();
191 cool::UInt32 nb2 = (*attrList)["Beam2Bunches"].data<cool::UInt32>();
192 cool::UInt32 ncol = (*attrList)["LuminousBunches"].data<cool::UInt32>();
193
197
198 const coral::Blob&
blob = (*attrList)[
"BCIDmasks"].data<coral::Blob>();
199
202
203 if (
static_cast<cool::UInt32
>(
blob.size() ) != 2 * (nb1 + nb2 + ncol)) {
205 return StatusCode::SUCCESS;
206 }
208
209 for (
size_t idx=0;
idx<nb1;++
idx) {
211 bccd->m_beam1.set(bcid);
212 }
213
214
215 for (
size_t idx=nb1;
idx<nb2;++
idx) {
217 bccd->m_beam2.set(bcid);
218 }
219
220
221 for (
size_t idx=nb2;
idx<ncol;++
idx) {
223 bccd->m_luminous.set(bcid);
224 }
225 }
226 else {
228
229
232 return StatusCode::FAILURE;
233 }
236 if (blobAddr[bcid] & 0x1) {
237 bccd->m_beam1.set(bcid);
238 }
239 if (blobAddr[bcid] & 0x2) {
240 bccd->m_beam2.set(bcid);
241 }
242 if ((blobAddr[bcid] & 0x3) == 0x3) {
243 bccd->m_luminous.set(bcid);
244 }
245 }
246
247
248 if (bccd->m_beam1.count()!= nb1) {
249 ATH_MSG_WARNING(
"Found " << bccd->m_beam1.count() <<
" bunches in beam1, expected " << nb1);
250 }
251
252 if (bccd->m_beam2.count()!= nb2) {
253 ATH_MSG_WARNING(
"Found " << bccd->m_beam2.count() <<
" bunches in beam2, expected " << nb2);
254 }
255
256 if (bccd->m_luminous.count()!= ncol) {
257 ATH_MSG_WARNING(
"Found " << bccd->m_luminous.count() <<
" colliding bunches, expected " << ncol);
258 }
259 }
260
262 }
263 }
264
265 ATH_CHECK( writeHdl.record (std::move (bccd)) );
266 return StatusCode::SUCCESS;
267}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
std::vector< float > tokenize(const std::string &pattern) const
This helper function is used to convert a string of type "[0.0, 0.0, 1.0, 1.0, 1.0]" into a vector of...
Gaudi::Property< bool > m_isRun1
Gaudi::Property< int > m_mode
SG::WriteCondHandleKey< BunchCrossingCondData > m_outputKey
Output conditions object.
Gaudi::Property< unsigned > m_maxBunchSpacing
Gaudi::Property< unsigned > m_minBunchesPerTrain
std::vector< bunchTrain_t > findTrains(const std::bitset< BunchCrossingCondData::m_MAX_BCID > &pairsToConsume, const int maxSpacingInTrain, const unsigned minBunchesPerTrain) const
internal methods:
SG::ReadCondHandleKey< TrigConf::L1BunchGroupSet > m_bunchGroupCondDataKey
SG::ReadCondHandleKey< LuminosityCondData > m_lumiCondDataKey
const ServiceHandle< TrigConf::ILVL1ConfigSvc > m_trigConfigSvc
SG::ReadCondHandleKey< AthenaAttributeList > m_fillParamsFolderKey
Input conditions object.
static constexpr int m_MAX_BCID
static EventIDRange infiniteMixed()
Produces an mixed EventIDRange that is infinite in Time and RunLumi.
static constexpr unsigned int TOTAL_LHC_BCIDS
std::size_t size() const
Accessor to the number of defined bunchgroups.
const std::shared_ptr< L1BunchGroup > & getBunchGroup(const std::string &name) const
Accessor to the bunchgroup by name.
setEventNumber setTimeStamp bcid