ATLAS Offline Software
HllgamRepeatTimeShower.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 
9  HllgamRepeatTimeShower::HllgamRepeatTimeShower(const std::string& type, const std::string& name, const IInterface* parent) :
11  m_nPass(0),
12  m_nVetos(0){
13  declareInterface<IPythia8Custom>(this);
14  }
15 
16 
18  ATH_MSG_INFO( "Initialisation of " << name() << " was successful" );
19 
20  ATH_MSG_INFO( "********************************************************************************" );
21  ATH_MSG_INFO( "********************************************************************************" );
22  ATH_MSG_INFO( "*** Will run with repeated time showers of H decay ***" );
23  ATH_MSG_INFO( "*** N.B. only make sense for gamma gamma decays ***" );
24  ATH_MSG_INFO( "********************************************************************************" );
25  ATH_MSG_INFO( "********************************************************************************" );
26 
27  return StatusCode::SUCCESS;
28  }
29 
30 
32 
33  ATH_MSG_INFO( "*************************************************************" );
34  ATH_MSG_INFO( "N retries " << m_nVetos );
35  ATH_MSG_INFO( "N pass " << m_nPass );
36  ATH_MSG_INFO( "*************************************************************" );
37 
38  ATH_MSG_INFO( "Finalisation of " << name() << " was successful" );
39  return StatusCode::SUCCESS;
40  }
41 
43  unsigned long sum = m_nVetos + m_nPass;
44  if(sum == 0 || m_nPass==0 ){
45  ATH_MSG_WARNING( "Are you sure that this code has been called correctly?? " );
46  return 1.;
47  }
48 
49  return double (m_nPass)/double ( sum );
50  }
51 
53 
54  //Index of the photons for the Higgs decay
55  std::vector<int> photons;
56 
57  int trials = 0;
58 
59  bool checkEvent = true;
60 
61  Pythia8::Event& event = pythia.event;
62 
63  while(checkEvent){
64 
65  int higgsIndex = -1;
66  for(int ii=0; ii != event.size(); ++ii){
67  // status 22 is intermediate hard process.
68  // I think that is correct here because although the output
69  // from Powheg is the Higgs, Pythia should still consider the
70  // decay products of the Higgs to be part of the hard process
71  if(event[ii].id() == 25 && abs(event[ii].status()) == 22){
72  higgsIndex = ii;
73  break;
74  }
75  }
76 
77  if(higgsIndex <0){
78  // didn't find a Higgs - barf
79  ATH_MSG_ERROR("No Higgs in event record");
80  return StatusCode::FAILURE;
81  }
82 
83  std::vector<int> daughters = event[higgsIndex].daughterList();
84  while(daughters.size()==1){
85  daughters=event[daughters[0]].daughterList();
86  }
87 
88  std::vector<int> photons;
89 
90  for(const auto d: daughters){
91  if(event[d].id() == 22){
92  photons.push_back(d);
93  }
94  }
95 
96  if(photons.size() < 2){
97  ATH_MSG_ERROR("Wrong number of photons from H decay. Expected >= 2, got " + std::to_string(photons.size()));
98  return StatusCode::FAILURE;
99  }
100 
101  for(const auto p: photons){
102  daughters = event[p].daughterList();
103  while(daughters.size() == 1){
104  daughters = event[daughters[0]].daughterList();
105  }
106 
107  if(daughters.size() < 2) continue;
108  size_t nLeptons=0;
109 
110  for(const auto d: daughters){
111  if(event[d].isLepton()) ++nLeptons;
112  }
113 
114  if(nLeptons >= 2){
115  checkEvent = false;
116  break;
117  }
118  }
119 
120  if(checkEvent){
121  pythia.forceTimeShower( photons[0], photons[1], 1000000);
122  ++trials;
123  ++m_nVetos;
124  if(trials % 1000 == 0 ){
125  ATH_MSG_WARNING("Has the decay been setup in Pythia correctly? Possibly stuck in loop so far " << trials << " attempts have been made");
126  }
127  }else{
128  pythia.forceHadronLevel();
129  ++m_nPass;
130  }
131  }
132 
133  return StatusCode::SUCCESS;
134  }
135 
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
HllgamRepeatTimeShower::HllgamRepeatTimeShower
HllgamRepeatTimeShower(const std::string &, const std::string &, const IInterface *)
AlgTool style constructor.
Definition: HllgamRepeatTimeShower.cxx:9
hist_file_dump.d
d
Definition: hist_file_dump.py:137
JiveXML::Event
struct Event_t Event
Definition: ONCRPCServer.h:65
bTosllAli.Pythia
Pythia
Definition: bTosllAli.py:46
HllgamRepeatTimeShower::finalize
StatusCode finalize() override
AlgTool finalize method.
Definition: HllgamRepeatTimeShower.cxx:31
HllgamRepeatTimeShower::m_nVetos
unsigned long m_nVetos
Definition: HllgamRepeatTimeShower.h:41
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
HllgamRepeatTimeShower.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
HllgamRepeatTimeShower::ModifyPythiaEvent
StatusCode ModifyPythiaEvent(Pythia8::Pythia &pythia) const override
Update the pythia event.
Definition: HllgamRepeatTimeShower.cxx:52
test_pyathena.parent
parent
Definition: test_pyathena.py:15
HllgamRepeatTimeShower::initialize
StatusCode initialize() override
AlgTool initialize method.
Definition: HllgamRepeatTimeShower.cxx:17
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
HllgamRepeatTimeShower::m_nPass
unsigned long m_nPass
Definition: HllgamRepeatTimeShower.h:40
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
HllgamRepeatTimeShower::CrossSectionScaleFactor
virtual double CrossSectionScaleFactor() const override
Return how much the cross section is modified.
Definition: HllgamRepeatTimeShower.cxx:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
isLepton
bool isLepton(const T &p)
APID: the fourth generation leptons are leptons.
Definition: AtlasPID.h:130
merge.status
status
Definition: merge.py:17
AthAlgTool
Definition: AthAlgTool.h:26