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