ATLAS Offline Software
Loading...
Searching...
No Matches
EffiCollection.cxx File Reference
Include dependency graph for EffiCollection.cxx:

Go to the source code of this file.

Functions

namespace ADD_CMODE (CP)

Function Documentation

◆ ADD_CMODE()

namespace ADD_CMODE ( CP )

Use a lambda function to assign the maps easily

Only the Z reconstruction analysis has different files for bulk / calo-tag / low-pt and forward eta

At this stage we know that all efficiencies have been loaded successfully. We need to now to order the maps to make global bin numbers

Systematic constructor has been called. We can now assemble the systematic variations

Let the world implode... Yeaha register foreach bin a systematic variation

If the isLRT decor is not available, try to see if patternRecoInfo is available for the corresponding ID track.

All LRT muons should have ID tracks. The muons without ID tracks have to come from the standard muon container.

Check that there are no overlapping run numbers in the periods

Definition at line 1 of file EffiCollection.cxx.

10 {
11 namespace {
12 static const std::vector<std::string> ToRemove { "GeV", "MeV", "[", "]", "{", "}", "(", ")", "#", " " };
13 typedef std::pair<std::string,std::string> stringpair;
14 static const std::vector<stringpair> ToReplace { stringpair("-","minus"), stringpair(".","p")};
15
16 }
17 EffiCollection::EffiCollection(MuonEfficiencyScaleFactors& ref_tool) :
18 m_ref_tool(ref_tool),
19 m_central_eff(),
20 m_calo_eff(),
21 m_forward_eff(),
22 m_lowpt_central_eff(),
23 m_lowpt_calo_eff(),
24 m_lrt_central_eff(),
25 m_lrt_lowpt_central_eff(),
26 m_syst_set(std::make_unique<CP::SystematicSet>()){
27
28 ref_tool.addSubtool (*this);
29
30 m_central_eff = std::make_shared<CollectionContainer>(m_ref_tool, CollectionType::Central);
31 m_central_eff->addSubtoolsTo(*this);
32 if (m_ref_tool.filename_Calo() != m_ref_tool.filename_Central()){
33 m_calo_eff = std::make_shared<CollectionContainer>(m_ref_tool,CollectionType::Calo);
34 m_calo_eff->addSubtoolsTo(*this);
35 } else m_calo_eff = m_central_eff;
36
37 if (m_ref_tool.filename_HighEta() != m_ref_tool.filename_Central()){
38 m_forward_eff = std::make_shared<CollectionContainer>(m_ref_tool,CollectionType::Forward);
39 m_forward_eff->addSubtoolsTo(*this);
40 } else m_forward_eff = m_central_eff;
41
42 if (m_ref_tool.lowPtTransition() > 0 && m_ref_tool.filename_LowPt() != m_ref_tool.filename_Central()){
43 m_lowpt_central_eff = std::make_shared<CollectionContainer>(m_ref_tool,CollectionType::CentralLowPt);
44 m_lowpt_central_eff->addSubtoolsTo(*this);
45 } else m_lowpt_central_eff = m_central_eff;
46
47 if (m_ref_tool.lowPtTransition() > 0 && m_ref_tool.filename_LowPtCalo() != m_ref_tool.filename_Central()){
48 m_lowpt_calo_eff = std::make_shared<CollectionContainer>(m_ref_tool, CollectionType::CaloLowPt);
49 m_lowpt_calo_eff->addSubtoolsTo(*this);
50 } else m_lowpt_calo_eff = m_central_eff;
51
52 if(m_ref_tool.use_lrt()) {
53 if (m_ref_tool.filename_LRTCentral() != m_ref_tool.filename_Central()) {
54 m_lrt_central_eff = std::make_shared<CollectionContainer>(m_ref_tool,CollectionType::LRTCentral);
55 m_lrt_central_eff->addSubtoolsTo(*this);
56 }
57 else {
58 m_lrt_central_eff = m_central_eff;
59 }
60 if (m_ref_tool.lowPtTransition() > 0 ) {
61 if (m_ref_tool.filename_LRTLowPt() != m_ref_tool.filename_LRTCentral()) {
62 m_lrt_lowpt_central_eff = m_lrt_central_eff;
63 }
64 else if (m_ref_tool.filename_LRTLowPt() == m_ref_tool.filename_LowPt()) {
65 m_lrt_lowpt_central_eff = m_lowpt_central_eff;
66 }
67 else if (m_ref_tool.filename_LRTLowPt() == m_ref_tool.filename_Central()) {
68 m_lrt_lowpt_central_eff = m_central_eff;
69 }
70 else {
71 m_lrt_lowpt_central_eff = std::make_shared<CollectionContainer>(m_ref_tool,CollectionType::LRTCentralLowPt);
72 m_lrt_lowpt_central_eff->addSubtoolsTo(*this);
73 }
74 }
75 else {
76 m_lrt_lowpt_central_eff = m_lrt_central_eff;
77 }
78 }
79 }
80
81 EffiCollection::EffiCollection(const EffiCollection* Nominal, MuonEfficiencyScaleFactors& ref_tool, const std::string& syst, int syst_bit_map, bool is_up):
82 m_ref_tool(ref_tool),
83 m_central_eff(),
84 m_calo_eff(),
85 m_forward_eff(),
86 m_lowpt_central_eff(),
87 m_lowpt_calo_eff(),
88 m_lrt_central_eff(),
89 m_lrt_lowpt_central_eff(),
90 m_syst_set() {
91
92 ref_tool.addSubtool (*this);
93
94 if (is_up) syst_bit_map |= EffiCollection::UpVariation;
96 std::function< std::shared_ptr<CollectionContainer>(CollectionType)> make_variation = [this,&ref_tool, Nominal, syst_bit_map, syst](CollectionType type){
97 if (syst_bit_map & type) {
98 return std::make_shared<CollectionContainer>(ref_tool,
99 Nominal->retrieveContainer(type).get(),
100 syst, syst_bit_map); }
102 if (ref_tool.measurement() != MuonEfficiencyType::Reco) return m_central_eff;
103 return Nominal->retrieveContainer(type);
104 };
105 m_central_eff = make_variation(CollectionType::Central);
106 m_central_eff->addSubtoolsTo (*this);
107 m_forward_eff = make_variation(CollectionType::Forward);
108 m_forward_eff->addSubtoolsTo (*this);
109 m_calo_eff = make_variation(CollectionType::Calo);
110 m_calo_eff->addSubtoolsTo (*this);
111 m_lowpt_central_eff = make_variation(CollectionType::CentralLowPt);
112 m_lowpt_central_eff->addSubtoolsTo (*this);
113 m_lowpt_calo_eff = make_variation(CollectionType::CaloLowPt);
114 m_lowpt_calo_eff->addSubtoolsTo (*this);
115
116 if (m_ref_tool.use_lrt()) {
117 if(Nominal->m_lrt_central_eff == Nominal->m_central_eff) {
118 m_lrt_central_eff = m_central_eff;
119 }
120 else {
121 m_lrt_central_eff = make_variation(CollectionType::LRTCentral);
122 m_lrt_central_eff->addSubtoolsTo (*this);
123 }
124 if (Nominal->m_lrt_lowpt_central_eff == Nominal->m_lrt_central_eff) {
125 m_lrt_lowpt_central_eff = m_lrt_central_eff;
126 } else if (Nominal->m_lrt_lowpt_central_eff == Nominal->m_lowpt_central_eff) {
127 m_lrt_lowpt_central_eff = m_lowpt_central_eff;
128 } else if (Nominal->m_lrt_lowpt_central_eff == Nominal->m_central_eff) {
129 m_lrt_lowpt_central_eff = m_central_eff;
130 } else {
131 m_lrt_lowpt_central_eff = make_variation(CollectionType::LRTCentralLowPt);
132 m_lrt_lowpt_central_eff->addSubtoolsTo (*this);
133 }
134 }
135 }
136
137 std::shared_ptr<CollectionContainer> EffiCollection::retrieveContainer(CollectionType Type) const {
138 if (Type == CollectionType::Central) return m_central_eff;
139 if (Type == CollectionType::Forward) return m_forward_eff;
140 if (Type == CollectionType::Calo) return m_calo_eff;
141 if (Type == CollectionType::CentralLowPt) return m_lowpt_central_eff;
142 if (Type == CollectionType::CaloLowPt) return m_lowpt_calo_eff;
143 if (Type == CollectionType::LRTCentral) return m_lrt_central_eff;
144 if (Type == CollectionType::LRTCentralLowPt) return m_lrt_lowpt_central_eff;
145 return std::shared_ptr<CollectionContainer>();
146 }
147 bool EffiCollection::CheckConsistency() {
148 if (!m_central_eff || !m_central_eff->CheckConsistency()) {
149 Error("EffiCollection()", "Consistency check for central file failed");
150 return false;
151 }
152 if (!m_calo_eff || !m_calo_eff->CheckConsistency()) {
153 Error("EffiCollection()", "Consistency check for calo file failed");
154 return false;
155 }
156 if (!m_forward_eff || !m_forward_eff->CheckConsistency()) {
157 Error("EffiCollection()", "Consistency check for forward file failed");
158 return false;
159 }
160 if (!m_lowpt_central_eff || !m_lowpt_central_eff->CheckConsistency()) {
161 Error("EffiCollection()", "Consistency check for low-pt file failed");
162 return false;
163 }
164 if (!m_lowpt_calo_eff || !m_lowpt_calo_eff->CheckConsistency()) {
165 Error("EffiCollection()", "Consistency check for low-pt calo file failed");
166 return false;
167 }
168 if (m_ref_tool.use_lrt()) {
169 if (!m_lrt_central_eff || !m_lrt_central_eff->CheckConsistency()) {
170 Error("EffiCollection()", "Consistency check for LRT central file failed");
171 return false;
172 }
173 if (!m_lrt_lowpt_central_eff || !m_lrt_lowpt_central_eff->CheckConsistency()) {
174 Error("EffiCollection()", "Consistency check for LRT low-pt file failed");
175 return false;
176 }
177 }
181 unsigned int n = m_central_eff->nBins();
182 std::function<void (CollectionContainer*)> assign_mapping = [this, &n](CollectionContainer* container){
183 if (container != m_central_eff.get() && container->separateBinSyst()){
184 container->SetGlobalOffSet(n);
185 n += container->nBins();
186 };
187 };
188 assign_mapping(m_calo_eff.get());
189 assign_mapping(m_calo_eff.get());
190 assign_mapping(m_lowpt_central_eff.get());
191 assign_mapping(m_lowpt_calo_eff.get());
192
193 assign_mapping(m_forward_eff.get());
194
195 if (m_ref_tool.use_lrt()) {
196 assign_mapping(m_lrt_central_eff.get());
197 assign_mapping(m_lrt_lowpt_central_eff.get());
198 }
201 if (!m_syst_set){
202 m_syst_set = std::make_unique<CP::SystematicSet>();
203 size_t glob_sys = m_ref_tool.getPosition(this);
204 if (glob_sys > m_ref_tool.getNCollections()){
205 Error("EffiCollection()", "Invalid position in the list of systematics. It seems that I'm not part of the referring ScaleFactorTool.");
206 return false;
207 }
208
209 std::vector<EffiCollection::CollectionType> collection_types{EffiCollection::Central, EffiCollection::Calo, EffiCollection::Forward,
210 EffiCollection::CentralLowPt, EffiCollection::CaloLowPt};
211 if (m_ref_tool.use_lrt()) {
212 collection_types.push_back(EffiCollection::LRTCentral);
213 collection_types.push_back(EffiCollection::LRTCentralLowPt);
214 }
215 for (const EffiCollection::CollectionType& collection_type: collection_types){
216
217 std::shared_ptr<CollectionContainer> container = retrieveContainer(collection_type);
218 if (container->isNominal()) continue;
219 if (container->separateBinSyst()){
222 for (unsigned int b = container->nBins() - 1; b > 0 ; --b){
223 unsigned int bin = b + container->globalOffSet();
224 if (container->isOverFlowBin(bin)) continue;
225 m_syst_set->insert(CP::SystematicVariation::makeToyVariation("MUON_EFF_" + container->sysname() + GetBinName(bin) , bin, glob_sys));
226 }
227 } else {
228 m_syst_set->insert( CP::SystematicVariation("MUON_EFF_" + container->sysname(), container->isUpVariation() ? 1 : -1));
229 }
230 }
231 }
232 return true;
233 }
234
235 CollectionContainer* EffiCollection::FindContainer(columnar::MuonId mu) const {
236 if (m_ref_tool.use_lrt()) {
237 if (isLRTmuon.isAvailable(mu)) {
238 if (isLRTmuon(mu)) return FindLRTContainer(mu);
239 }
240 else {
241 static const SG::Accessor<uint64_t> patternAcc("patternRecoInfo");
242 const xAOD::TrackParticle* idtrack = mu.getXAODObject().trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
243 if(idtrack) {
244 if(!patternAcc.isAvailable(*idtrack)) {
245 Error("CollectionContainer", "No information available to tell if the muon is LRT or standard. Either run MuonLRTMergingAlg to decorate with `isLRT` flag, or supply the patternRecoInfo for the original ID track.");
246 }
247 std::bitset<xAOD::NumberOfTrackRecoInfo> patternBitSet(patternAcc(*idtrack));
248 if (patternBitSet.test(xAOD::SiSpacePointsSeedMaker_LargeD0)) return FindLRTContainer(mu);
249 }
250 }
251 }
252 if (ptAcc(mu) < m_ref_tool.lowPtTransition()) {
253 if (std::abs(etaAcc(mu)) >= 2.5) {
254 return m_forward_eff.get();
255 }
256 if (muonTypeAcc(mu) == xAOD::Muon::MuonType::CaloTagged) {
257 return m_lowpt_calo_eff.get();
258 }
259 return m_lowpt_central_eff.get();
260 }
261 if (muonTypeAcc(mu) == xAOD::Muon::MuonType::CaloTagged) {
262 return m_calo_eff.get();
263 } else if (std::abs(etaAcc(mu)) < 2.5) {
264 return m_central_eff.get();
265 } else {
266 return m_forward_eff.get();
267 }
268 }
269 CollectionContainer* EffiCollection::FindContainer(unsigned int bin) const{
270 if (m_central_eff->isBinInMap(bin)) return m_central_eff.get();
271 if (m_forward_eff->isBinInMap(bin)) return m_forward_eff.get();
272 if (m_calo_eff->isBinInMap(bin)) return m_calo_eff.get();
273 if (m_lowpt_central_eff->isBinInMap(bin)) return m_lowpt_central_eff.get();
274 if (m_lowpt_calo_eff->isBinInMap(bin)) return m_lowpt_calo_eff.get();
275 if (m_ref_tool.use_lrt()) {
276 if (m_lrt_central_eff->isBinInMap(bin)) return m_lrt_central_eff.get();
277 if (m_lrt_lowpt_central_eff->isBinInMap(bin)) return m_lrt_lowpt_central_eff.get();
278 }
279 return nullptr;
280 }
281 CollectionContainer* EffiCollection::FindLRTContainer(columnar::MuonId mu) const {
282 if (ptAcc(mu) < m_ref_tool.lowPtTransition()) return m_lrt_lowpt_central_eff.get();
283 else return m_lrt_central_eff.get();
284 }
285 EfficiencyScaleFactor* EffiCollection::retrieveSF(const xAOD::Muon& mu, unsigned int RunNumber) const {
286 return retrieveSF (columnar::MuonId (mu), RunNumber);
287 }
288 EfficiencyScaleFactor* EffiCollection::retrieveSF(columnar::MuonId mu, unsigned int RunNumber) const {
289 CollectionContainer* Cont = FindContainer(mu);
290 if (Cont != nullptr) return Cont->retrieve(RunNumber);
291 Warning("EffiCollection::retrieveSF()", "Invalid muon");
292 return nullptr;
293 }
294 unsigned int EffiCollection::nBins() const {
295 unsigned int Nbins = 0;
296 if (m_central_eff) {
297 Nbins += m_central_eff->nBins();
298 }
299 if (m_central_eff != m_calo_eff) {
300 Nbins += m_calo_eff->nBins();
301 }
302 if (m_forward_eff != m_central_eff) {
303 Nbins += m_forward_eff->nBins();
304 }
305 if (m_lowpt_central_eff != m_central_eff) {
306 Nbins += m_lowpt_central_eff->nBins();
307 }
308 if (m_lowpt_calo_eff != m_central_eff) {
309 Nbins += m_lowpt_calo_eff->nBins();
310 }
311 if (m_ref_tool.use_lrt()) {
312 if (m_lrt_central_eff) {
313 Nbins += m_lrt_central_eff->nBins();
314 }
315 if (m_lrt_lowpt_central_eff) {
316 Nbins += m_lrt_lowpt_central_eff->nBins();
317 }
318 }
319 return Nbins;
320 }
321 bool EffiCollection::SetSystematicBin(unsigned int Bin) {
322 CollectionContainer* Cont = FindContainer(Bin);
323 if (!Cont) return false;
324 return Cont->SetSystematicBin(Bin);
325 }
326 bool EffiCollection::IsLowPtBin(unsigned int Bin) const {
327 return (m_central_eff != m_lowpt_central_eff && m_lowpt_central_eff->isBinInMap(Bin)) ||
328 (m_central_eff != m_lowpt_calo_eff && m_lowpt_calo_eff->isBinInMap(Bin));
329 }
330 bool EffiCollection::IsForwardBin(unsigned int Bin) const {
331 return m_forward_eff != m_central_eff && m_forward_eff->isBinInMap(Bin);
332 }
333
334 std::string EffiCollection::FileTypeName(EffiCollection::CollectionType T) {
335 if (T == CollectionType::Central) return "Central";
336 if (T == CollectionType::Calo) return "Calo";
337 if (T == CollectionType::Forward) return "Forward";
338 if (T == CollectionType::CentralLowPt) return "CentralLowPt";
339 if (T == CollectionType::CaloLowPt) return "CaloLowPt";
340 if (T == CollectionType::LRTCentral) return "LRTCentral";
341 if (T == CollectionType::LRTCentralLowPt) return "LRTCentralLowPt";
342 return "EffiCollection::FileTypeName() - WARNING: Unknown EffiCollection::CollectionType!";
343 }
344
345 std::string EffiCollection::GetBinName(unsigned int bin) const {
346 CollectionContainer* Cont = FindContainer(bin);
347 if (Cont) {
348 std::string BinName = FileTypeName(Cont->type()) +"_"+ Cont->GetBinName(bin);
349 for (const std::string& R : ToRemove) {
350 BinName = ReplaceExpInString(BinName, R, "");
351 }
352 for (const stringpair& R : ToReplace) {
353 BinName = ReplaceExpInString(BinName, R.first, R.second);
354 }
355 return BinName;
356 }
357 Warning("EffiCollection::GetBinName()", "Unknown bin %u", bin);
358
359 return "UNKNOWN_BIN";
360 }
361 int EffiCollection::getUnCorrelatedSystBin(const xAOD::Muon& mu) const {
362 CollectionContainer* container = FindContainer(mu);
363 if (container) return container->FindBinSF(mu);
364 return -1;
365 }
366 CP::SystematicSet* EffiCollection::getSystSet() const{
367 return m_syst_set.get();
368 }
369 bool EffiCollection::isAffectedBySystematic(const CP::SystematicVariation& variation) const {
370 return m_syst_set->find(variation) != m_syst_set->end();
371 }
372 bool EffiCollection::isAffectedBySystematic(const CP::SystematicSet& set) const{
373 if (set.empty()) return m_syst_set->empty();
374 for (const CP::SystematicVariation& variation: set){
375 if (isAffectedBySystematic(variation)) return true;
376 }
377 return false;
378 }
379
380
381 //################################################################################
382 // CollectionContainer
383 //################################################################################
384 CollectionContainer::CollectionContainer(const MuonEfficiencyScaleFactors& ref_tool, EffiCollection::CollectionType FileType):
385 m_SF(),
386 m_currentSF(nullptr),
387 m_FileType(FileType),
388 m_binOffSet(0){
389
390 std::map<std::string, std::pair<unsigned int, unsigned int>> map = findPeriods(ref_tool);
391 for (auto& period : map) {
392 m_SF.push_back(std::make_shared<EfficiencyScaleFactor>(ref_tool, fileName(ref_tool), period.first));
393 m_SF.back()->setFirstLastRun(period.second.first, period.second.second);
394 }
395 }
396 CollectionContainer::CollectionContainer(const MuonEfficiencyScaleFactors& ref_tool, CollectionContainer* Nominal, const std::string& syst_name, unsigned int syst_bit_map):
397 m_SF(),
398 m_currentSF(nullptr),
399 m_FileType(Nominal->type()),
400 m_binOffSet(0) {
401 std::map<std::string, std::pair<unsigned int, unsigned int>> map = findPeriods(ref_tool);
402 for (auto& period : map) {
403 std::vector< std::shared_ptr<EfficiencyScaleFactor>>::const_iterator itr = std::find_if( Nominal->m_SF.begin(),
404 Nominal->m_SF.end(),
405 [&period](const std::shared_ptr<EfficiencyScaleFactor>& a){
406 return a->coversRunNumber(period.second.first);
407 });
408 m_SF.push_back(std::make_shared<EfficiencyScaleFactor>(*itr, ref_tool, fileName(ref_tool), period.first, syst_name, syst_bit_map));
409 m_SF.back()->setFirstLastRun(period.second.first, period.second.second);
410 }
411 }
412 std::map<std::string, std::pair<unsigned int, unsigned int>> CollectionContainer::findPeriods(const MuonEfficiencyScaleFactors& ref_tool) const{
413
414 std::string file_name = fileName(ref_tool);
415 std::map<std::string, std::pair<unsigned int, unsigned int>> map;
416
417 std::unique_ptr<TFile> fin (TFile::Open(file_name.c_str()));
418 if (!fin || !fin->IsOpen()) {
419 Error("CollectionContainer","Unable to open file %s", file_name.c_str());
420 return map;
421 }
422 TTree* intree = 0;
423 fin->GetObject("LumiData", intree);
424
425 // if no Lumi tree is found, we assume that the SF are not binned in time
426 if (!intree) {
427 map["All"] = std::pair<unsigned int,unsigned int>(1, 999999);
428 } else {
429 std::string *period = 0;
430 unsigned int firstRun = 0;
431 unsigned int lastRun = 0;
432 intree->SetBranchAddress("Period", &period);
433 intree->SetBranchAddress("FirstRun", &firstRun);
434 intree->SetBranchAddress("LastRun", &lastRun);
435 for (int t = 0; intree->GetEntry(t); t++) {
436 map[*period] = std::pair<unsigned int, unsigned int>(firstRun, lastRun);
437 }
438 }
439 return map;
440 }
441 std::string CollectionContainer::fileName(const MuonEfficiencyScaleFactors& ref_tool) const{
442 if (type() == EffiCollection::CollectionType::Central) return ref_tool.filename_Central();
443 if (type() == EffiCollection::CollectionType::Calo) return ref_tool.filename_Calo();
444 if (type() == EffiCollection::CollectionType::CentralLowPt) return ref_tool.filename_LowPt();
445 if (type() == EffiCollection::CollectionType::CaloLowPt) return ref_tool.filename_LowPtCalo();
446 if (type() == EffiCollection::CollectionType::LRTCentral) return ref_tool.filename_LRTCentral();
447 if (type() == EffiCollection::CollectionType::LRTCentralLowPt) return ref_tool.filename_LRTLowPt();
448 return ref_tool.filename_HighEta();
449 }
450
451 bool CollectionContainer::CheckConsistency() {
452 if (m_SF.empty()) {
453 Error("CollectionContainer", "Could not retrieve any SFs from the input file");
454 return false;
455 }
457 for (std::vector< std::shared_ptr<EfficiencyScaleFactor>>::const_iterator first_sf = m_SF.begin() ; first_sf != m_SF.end(); ++first_sf) {
458 if (!(*first_sf)->CheckConsistency()) return false;
459 for (std::vector< std::shared_ptr<EfficiencyScaleFactor>>::const_iterator second_sf = m_SF.begin(); second_sf != first_sf; ++second_sf) {
460 if ( (*first_sf)->coversRunNumber( (*second_sf)->firstRun()) || (*first_sf)->coversRunNumber((*second_sf)->lastRun()) ||
461 (*second_sf)->coversRunNumber( (*first_sf)->firstRun()) || (*second_sf)->coversRunNumber((*first_sf)->lastRun())){
462 Error("CollectionContainer", "Overlapping periods observed in file type %s. As run %i is in period %i - %i. Please check your SF file!",
463 EffiCollection::FileTypeName(m_FileType).c_str(), (*first_sf)->firstRun(), (*second_sf)->firstRun(), (*second_sf)->lastRun());
464 return false;
465 }
466 }
467 }
468
469 std::sort(m_SF.begin(), m_SF.end(), [](const std::shared_ptr<EfficiencyScaleFactor>& a, const std::shared_ptr<EfficiencyScaleFactor>& b){
470 return a->firstRun() < b->firstRun();});
471 return true;
472 }
473 bool CollectionContainer::LoadPeriod(unsigned int RunNumber) {
474 if (!m_currentSF || !m_currentSF->coversRunNumber(RunNumber)) {
475 for (auto& period : m_SF) {
476 if (period->coversRunNumber(RunNumber)) {
477 m_currentSF = period.get();
478 return true;
479 }
480 }
481 } else return true;
482 if (!m_warnedForRunNumber.contains(RunNumber)) {
483 Warning("CollectionContainer", "Could not find any SF period in %s matching the run number %u", EffiCollection::FileTypeName(type()).c_str(), RunNumber);
484 m_warnedForRunNumber.insert(RunNumber);
485 }
486 return false;
487 }
488 EfficiencyScaleFactor* CollectionContainer::retrieve(unsigned int RunNumber) {
489 if (!LoadPeriod(RunNumber)) {
490 return (*m_SF.rbegin()).get();
491 }
492 return m_currentSF;
493 }
494 bool CollectionContainer::SetSystematicBin(unsigned int Bin) {
495 for ( std::shared_ptr<EfficiencyScaleFactor>& Period : m_SF) {
496 if (!Period->SetSystematicBin(Bin- m_binOffSet)) {
497 return false;
498 }
499 }
500 return true;
501 }
502 unsigned int CollectionContainer::nBins() const {
503 return m_SF.empty() ? 0 : (*m_SF.begin())->nBins();
504 }
505 unsigned int CollectionContainer::nOverFlowBins() const {
506 return m_SF.empty() ? 0 : (*m_SF.begin())->nOverFlowBins();
507 }
508 bool CollectionContainer::isOverFlowBin(int b) const {
509 return m_SF.empty() ? true : (*m_SF.begin())->isOverFlowBin(b-m_binOffSet);
510 }
511 bool CollectionContainer::isBinInMap(unsigned int bin) const{
512 return m_binOffSet <= bin && bin < m_binOffSet + nBins();
513 }
514 EffiCollection::CollectionType CollectionContainer::type() const {
515 return m_FileType;
516 }
517 std::string CollectionContainer::GetBinName(unsigned int Bin) const {
518 return (*m_SF.begin())->GetBinName(Bin- m_binOffSet);
519 }
520 int CollectionContainer::FindBinSF(const xAOD::Muon &mu) const {
521 if (m_SF.empty() ) return -1;
522 int bin = (*m_SF.begin())->FindBinSF(mu);
523 return bin > 0 ? m_binOffSet + bin : bin;
524 }
525 void CollectionContainer::SetGlobalOffSet(unsigned int OffSet){
526 m_binOffSet = OffSet;
527 }
528 unsigned int CollectionContainer::globalOffSet() const{
529 return m_binOffSet;
530 }
531 bool CollectionContainer::isNominal() const {
532 if (m_SF.empty()) return false;
533 return (*m_SF.begin())->sysname(false).empty();
534 }
535 bool CollectionContainer::isUpVariation() const {
536 if (m_SF.empty()) return false;
537 return (*m_SF.begin())->IsUpVariation();
538 }
539 bool CollectionContainer::separateBinSyst() const {
540 if (m_SF.empty()) return false;
541 return (*m_SF.begin())->separateBinSyst();
542 }
543 std::string CollectionContainer::sysname() const{
544 if (m_SF.empty()) return "UNKNOWN SYST";
545 return (*m_SF.begin())->sysname(false);
546 }
547 void CollectionContainer::addSubtoolsTo (columnar::ColumnarTool<>& parentTool){
548 for (auto& SF : m_SF)
549 parentTool.addSubtool(*SF);
550 }
551}
static Double_t a
const_iterator begin() const
Class to wrap a set of SystematicVariations.
iterator find(const SystematicVariation &sys) const
description: find an element in the set
static SystematicVariation makeToyVariation(const std::string &basename, unsigned toyIndex, float toyScale)
constructor for toy systematics
Helper class to provide type-safe access to aux data.
Class to wrap a set of SystematicVariations.
STL class.
STL class.
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)
Select isolated Photons, Electrons and Muons.
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition Error.h:16
const SG::AuxVectorData * container() const
Return the container holding this element.
int Period
--> Execution phase:
ObjectId< MuonDef > MuonId
Definition MuonDef.h:22
STL namespace.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Muon_v1 Muon
Reference the current persistent version:
Definition Muon.h:13
@ SiSpacePointsSeedMaker_LargeD0