ATLAS Offline Software
TrigMuonMonitorAlgorithm.icc
Go to the documentation of this file.
1 /* -*- mode:c++ -*-
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 template <class T, class FUNCT>
7 StatusCode TrigMuonMonitorAlgorithm::fillVariablesRatioPlots(const EventContext &ctx, const xAOD::Muon* mu,
8  std::string &&trigstep,
9  xAOD::Muon::TrackParticleType type,
10  FUNCT matchFunc) const
11 {
12 
13  const xAOD::TrackParticle* OfflineTrack = mu->trackParticle(type);
14  if ( OfflineTrack ){
15  auto AboveCut = Monitored::Scalar<bool>(trigstep+"AboveCut",false);
16  float OffPt = OfflineTrack->pt()/1e3;
17  if ( OffPt > m_ratio_measurement_threshold ){
18  const T *trigMu = matchFunc(ctx, mu);
19  if ( trigMu ){
20  if ( std::abs( trigMu->pt() ) > m_ratio_measurement_threshold ) AboveCut = true;
21  }
22  }
23 
24  auto lb = Monitored::Scalar<int>("LB",-1.0);
25  lb = GetEventInfo(ctx)->lumiBlock();
26  fill(m_group, lb, AboveCut);
27  }
28 
29  return StatusCode::SUCCESS;
30 
31 }
32 
33 template<class T>
34 StatusCode TrigMuonMonitorAlgorithm::fillVariableEtaPhi(const EventContext &ctx,
35  SG::ReadHandleKey<DataVector<T> > ReadHandleKey,
36  std::string &&trigstep,
37  std::tuple<bool,double,double> (*PosFunc)(const T*)) const
38 {
39 
40  using CONTAINER = DataVector<T>;
41  SG::ReadHandle<CONTAINER> trigmuons(ReadHandleKey, ctx);
42  if (! trigmuons.isValid() ) {
43  ATH_MSG_ERROR("evtStore() does not contain collection with name "<< ReadHandleKey);
44  return StatusCode::FAILURE;
45  }
46 
47  for (const auto& trigmu : *trigmuons) {
48 
49  auto Eta = Monitored::Scalar<float>(trigstep+"Eta",-999.);
50  auto Phi = Monitored::Scalar<float>(trigstep+"Phi",-999.);
51 
52  const auto [status, trigEta, trigPhi] = PosFunc(trigmu);
53  if(!status) continue;
54  Eta = trigEta;
55  Phi = trigPhi;
56  fill(m_group, Eta, Phi);
57 
58  }
59 
60  return StatusCode::SUCCESS;
61 
62 }
63 
64 template<class T>
65 std::tuple<bool, double, double> TrigMuonMonitorAlgorithm::defaultPosFunc(const T* trig){
66  return std::abs(trig->pt()) > 0.00001 ? std::forward_as_tuple(true, trig->eta(), trig->phi()) : std::forward_as_tuple(false,0.,0.) ;
67 }