LArInteractionTypeHelper.cc
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArHelpers/LArInteractionTypeHelper.cc
3  *
4  * @brief Implementation of the interaction type helper class.
5  *
6  * $Log: $
7  */
8 
12 
13 using namespace pandora;
14 
15 namespace lar_content
16 {
17 
18 LArInteractionTypeHelper::InteractionType LArInteractionTypeHelper::GetInteractionType(const MCParticleList &mcPrimaryList)
19 {
20  if (mcPrimaryList.empty())
21  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
22 
23  InteractionParameters parameters;
24  LArInteractionTypeHelper::SetInteractionParameters(mcPrimaryList, parameters);
25 
26  const InteractionType cosmicRayHypothesis(LArInteractionTypeHelper::CosmicRayHypothesis(mcPrimaryList, parameters));
27 
28  if (OTHER_INTERACTION != cosmicRayHypothesis)
29  return cosmicRayHypothesis;
30 
31  if ((1 == mcPrimaryList.size()) && LArMCParticleHelper::IsBeamParticle(mcPrimaryList.front()))
32  {
33  if (1 == parameters.m_nMuons)
34  return BEAM_PARTICLE_MU;
35  if (1 == parameters.m_nProtons)
36  return BEAM_PARTICLE_P;
37  if (1 == parameters.m_nElectrons)
38  return BEAM_PARTICLE_E;
39  if (1 == parameters.m_nPhotons)
40  return BEAM_PARTICLE_PHOTON;
41  if (1 == parameters.m_nPiPlus)
42  return BEAM_PARTICLE_PI_PLUS;
43  if (1 == parameters.m_nPiMinus)
44  return BEAM_PARTICLE_PI_MINUS;
45  if (1 == parameters.m_nKaonPlus)
46  return BEAM_PARTICLE_KAON_PLUS;
47  if (1 == parameters.m_nKaonMinus)
48  return BEAM_PARTICLE_KAON_MINUS;
49  else
50  return BEAM_PARTICLE_OTHER;
51  }
52 
53  const MCParticle *pMCNeutrino(nullptr);
54 
55  for (const MCParticle *const pMCPrimary : mcPrimaryList)
56  {
57  if (!LArMCParticleHelper::IsBeamNeutrinoFinalState(pMCPrimary) ||
58  (pMCNeutrino && (pMCNeutrino != LArMCParticleHelper::GetParentMCParticle(pMCPrimary))))
59  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
60 
61  pMCNeutrino = LArMCParticleHelper::GetParentMCParticle(pMCPrimary);
62  }
63 
64  if (!pMCNeutrino)
65  throw StatusCodeException(STATUS_CODE_FAILURE);
66 
67  const int nuNuanceCode(LArMCParticleHelper::GetNuanceCode(pMCNeutrino));
68 
69  if (1001 == nuNuanceCode)
70  {
71  if ((1 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (0 == parameters.m_nProtons))
72  return CCQEL_MU;
73  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (1 == parameters.m_nProtons))
74  return CCQEL_MU_P;
75  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (2 == parameters.m_nProtons))
76  return CCQEL_MU_P_P;
77  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (3 == parameters.m_nProtons))
78  return CCQEL_MU_P_P_P;
79  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (4 == parameters.m_nProtons))
80  return CCQEL_MU_P_P_P_P;
81  if ((6 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (5 == parameters.m_nProtons))
82  return CCQEL_MU_P_P_P_P_P;
83 
84  if ((1 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (0 == parameters.m_nProtons))
85  return CCQEL_E;
86  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (1 == parameters.m_nProtons))
87  return CCQEL_E_P;
88  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (2 == parameters.m_nProtons))
89  return CCQEL_E_P_P;
90  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (3 == parameters.m_nProtons))
91  return CCQEL_E_P_P_P;
92  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (4 == parameters.m_nProtons))
93  return CCQEL_E_P_P_P_P;
94  if ((6 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (5 == parameters.m_nProtons))
95  return CCQEL_E_P_P_P_P_P;
96  }
97 
98  if (1002 == nuNuanceCode)
99  {
100  if ((1 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons))
101  return NCQEL_P;
102  if ((2 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons))
103  return NCQEL_P_P;
104  if ((3 == parameters.m_nNonNeutrons) && (3 == parameters.m_nProtons))
105  return NCQEL_P_P_P;
106  if ((4 == parameters.m_nNonNeutrons) && (4 == parameters.m_nProtons))
107  return NCQEL_P_P_P_P;
108  if ((5 == parameters.m_nNonNeutrons) && (5 == parameters.m_nProtons))
109  return NCQEL_P_P_P_P_P;
110  }
111 
112  if ((nuNuanceCode >= 1003) && (nuNuanceCode <= 1005))
113  {
114  if ((1 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (0 == parameters.m_nProtons))
115  return CCRES_MU;
116  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (1 == parameters.m_nProtons))
117  return CCRES_MU_P;
118  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (2 == parameters.m_nProtons))
119  return CCRES_MU_P_P;
120  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (3 == parameters.m_nProtons))
121  return CCRES_MU_P_P_P;
122  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (4 == parameters.m_nProtons))
123  return CCRES_MU_P_P_P_P;
124  if ((6 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (5 == parameters.m_nProtons))
125  return CCRES_MU_P_P_P_P_P;
126 
127  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (0 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
128  return CCRES_MU_PIPLUS;
129  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (1 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
130  return CCRES_MU_P_PIPLUS;
131  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (2 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
132  return CCRES_MU_P_P_PIPLUS;
133  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (3 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
134  return CCRES_MU_P_P_P_PIPLUS;
135  if ((6 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (4 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
136  return CCRES_MU_P_P_P_P_PIPLUS;
137  if ((7 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (5 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
138  return CCRES_MU_P_P_P_P_P_PIPLUS;
139 
140  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (0 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
141  return CCRES_MU_PHOTON;
142  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (1 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
143  return CCRES_MU_P_PHOTON;
144  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (2 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
145  return CCRES_MU_P_P_PHOTON;
146  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (3 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
147  return CCRES_MU_P_P_P_PHOTON;
148  if ((6 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (4 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
149  return CCRES_MU_P_P_P_P_PHOTON;
150  if ((7 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (5 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
151  return CCRES_MU_P_P_P_P_P_PHOTON;
152 
153  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (0 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
154  return CCRES_MU_PIZERO;
155  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (1 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
156  return CCRES_MU_P_PIZERO;
157  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (2 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
158  return CCRES_MU_P_P_PIZERO;
159  if ((6 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (3 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
160  return CCRES_MU_P_P_P_PIZERO;
161  if ((7 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (4 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
162  return CCRES_MU_P_P_P_P_PIZERO;
163  if ((8 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (5 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
164  return CCRES_MU_P_P_P_P_P_PIZERO;
165 
166  if ((1 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (0 == parameters.m_nProtons))
167  return CCRES_E;
168  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (1 == parameters.m_nProtons))
169  return CCRES_E_P;
170  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (2 == parameters.m_nProtons))
171  return CCRES_E_P_P;
172  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (3 == parameters.m_nProtons))
173  return CCRES_E_P_P_P;
174  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (4 == parameters.m_nProtons))
175  return CCRES_E_P_P_P_P;
176  if ((6 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (5 == parameters.m_nProtons))
177  return CCRES_E_P_P_P_P_P;
178 
179  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (0 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
180  return CCRES_E_PIPLUS;
181  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (1 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
182  return CCRES_E_P_PIPLUS;
183  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (2 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
184  return CCRES_E_P_P_PIPLUS;
185  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (3 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
186  return CCRES_E_P_P_P_PIPLUS;
187  if ((6 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (4 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
188  return CCRES_E_P_P_P_P_PIPLUS;
189  if ((7 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (5 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
190  return CCRES_E_P_P_P_P_P_PIPLUS;
191 
192  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (0 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
193  return CCRES_E_PHOTON;
194  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (1 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
195  return CCRES_E_P_PHOTON;
196  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (2 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
197  return CCRES_E_P_P_PHOTON;
198  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (3 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
199  return CCRES_E_P_P_P_PHOTON;
200  if ((6 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (4 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
201  return CCRES_E_P_P_P_P_PHOTON;
202  if ((7 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (5 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
203  return CCRES_E_P_P_P_P_P_PHOTON;
204 
205  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (0 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
206  return CCRES_E_PIZERO;
207  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (1 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
208  return CCRES_E_P_PIZERO;
209  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (2 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
210  return CCRES_E_P_P_PIZERO;
211  if ((6 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (3 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
212  return CCRES_E_P_P_P_PIZERO;
213  if ((7 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (4 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
214  return CCRES_E_P_P_P_P_PIZERO;
215  if ((8 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons) && (5 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
216  return CCRES_E_P_P_P_P_P_PIZERO;
217  }
218 
219  if ((nuNuanceCode >= 1006) && (nuNuanceCode <= 1009))
220  {
221  if ((1 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons))
222  return NCRES_P;
223  if ((2 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons))
224  return NCRES_P_P;
225  if ((3 == parameters.m_nNonNeutrons) && (3 == parameters.m_nProtons))
226  return NCRES_P_P_P;
227  if ((4 == parameters.m_nNonNeutrons) && (4 == parameters.m_nProtons))
228  return NCRES_P_P_P_P;
229  if ((5 == parameters.m_nNonNeutrons) && (5 == parameters.m_nProtons))
230  return NCRES_P_P_P_P_P;
231 
232  if ((1 == parameters.m_nNonNeutrons) && (0 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
233  return NCRES_PIPLUS;
234  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
235  return NCRES_P_PIPLUS;
236  if ((3 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
237  return NCRES_P_P_PIPLUS;
238  if ((4 == parameters.m_nNonNeutrons) && (3 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
239  return NCRES_P_P_P_PIPLUS;
240  if ((5 == parameters.m_nNonNeutrons) && (4 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
241  return NCRES_P_P_P_P_PIPLUS;
242  if ((6 == parameters.m_nNonNeutrons) && (5 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
243  return NCRES_P_P_P_P_P_PIPLUS;
244 
245  if ((1 == parameters.m_nNonNeutrons) && (0 == parameters.m_nProtons) && (1 == parameters.m_nPiMinus))
246  return NCRES_PIMINUS;
247  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons) && (1 == parameters.m_nPiMinus))
248  return NCRES_P_PIMINUS;
249  if ((3 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons) && (1 == parameters.m_nPiMinus))
250  return NCRES_P_P_PIMINUS;
251  if ((4 == parameters.m_nNonNeutrons) && (3 == parameters.m_nProtons) && (1 == parameters.m_nPiMinus))
252  return NCRES_P_P_P_PIMINUS;
253  if ((5 == parameters.m_nNonNeutrons) && (4 == parameters.m_nProtons) && (1 == parameters.m_nPiMinus))
254  return NCRES_P_P_P_P_PIMINUS;
255  if ((6 == parameters.m_nNonNeutrons) && (5 == parameters.m_nProtons) && (1 == parameters.m_nPiMinus))
256  return NCRES_P_P_P_P_P_PIMINUS;
257 
258  if ((1 == parameters.m_nNonNeutrons) && (0 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
259  return NCRES_PHOTON;
260  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
261  return NCRES_P_PHOTON;
262  if ((3 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
263  return NCRES_P_P_PHOTON;
264  if ((4 == parameters.m_nNonNeutrons) && (3 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
265  return NCRES_P_P_P_PHOTON;
266  if ((5 == parameters.m_nNonNeutrons) && (4 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
267  return NCRES_P_P_P_P_PHOTON;
268  if ((6 == parameters.m_nNonNeutrons) && (5 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
269  return NCRES_P_P_P_P_P_PHOTON;
270 
271  if ((2 == parameters.m_nNonNeutrons) && (0 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
272  return NCRES_PIZERO;
273  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
274  return NCRES_P_PIZERO;
275  if ((4 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
276  return NCRES_P_P_PIZERO;
277  if ((5 == parameters.m_nNonNeutrons) && (3 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
278  return NCRES_P_P_P_PIZERO;
279  if ((6 == parameters.m_nNonNeutrons) && (4 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
280  return NCRES_P_P_P_P_PIZERO;
281  if ((7 == parameters.m_nNonNeutrons) && (5 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
282  return NCRES_P_P_P_P_P_PIZERO;
283  }
284 
285  if (1091 == nuNuanceCode)
286  {
287  if ((1 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (0 == parameters.m_nProtons))
288  return CCDIS_MU;
289  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (1 == parameters.m_nProtons))
290  return CCDIS_MU_P;
291  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (2 == parameters.m_nProtons))
292  return CCDIS_MU_P_P;
293  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (3 == parameters.m_nProtons))
294  return CCDIS_MU_P_P_P;
295  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (4 == parameters.m_nProtons))
296  return CCDIS_MU_P_P_P_P;
297  if ((6 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (5 == parameters.m_nProtons))
298  return CCDIS_MU_P_P_P_P_P;
299 
300  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (0 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
301  return CCDIS_MU_PIPLUS;
302  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (1 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
303  return CCDIS_MU_P_PIPLUS;
304  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (2 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
305  return CCDIS_MU_P_P_PIPLUS;
306  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (3 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
307  return CCDIS_MU_P_P_P_PIPLUS;
308  if ((6 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (4 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
309  return CCDIS_MU_P_P_P_P_PIPLUS;
310  if ((7 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (5 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
311  return CCDIS_MU_P_P_P_P_P_PIPLUS;
312 
313  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (0 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
314  return CCDIS_MU_PHOTON;
315  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (1 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
316  return CCDIS_MU_P_PHOTON;
317  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (2 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
318  return CCDIS_MU_P_P_PHOTON;
319  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (3 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
320  return CCDIS_MU_P_P_P_PHOTON;
321  if ((6 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (4 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
322  return CCDIS_MU_P_P_P_P_PHOTON;
323  if ((7 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (5 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
324  return CCDIS_MU_P_P_P_P_P_PHOTON;
325 
326  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (0 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
327  return CCDIS_MU_PIZERO;
328  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (1 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
329  return CCDIS_MU_P_PIZERO;
330  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (2 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
331  return CCDIS_MU_P_P_PIZERO;
332  if ((6 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (3 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
333  return CCDIS_MU_P_P_P_PIZERO;
334  if ((7 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (4 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
335  return CCDIS_MU_P_P_P_P_PIZERO;
336  if ((8 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons) && (5 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
337  return CCDIS_MU_P_P_P_P_P_PIZERO;
338  }
339 
340  if (1092 == nuNuanceCode)
341  {
342  if ((1 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons))
343  return NCDIS_P;
344  if ((2 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons))
345  return NCDIS_P_P;
346  if ((3 == parameters.m_nNonNeutrons) && (3 == parameters.m_nProtons))
347  return NCDIS_P_P_P;
348  if ((4 == parameters.m_nNonNeutrons) && (4 == parameters.m_nProtons))
349  return NCDIS_P_P_P_P;
350  if ((5 == parameters.m_nNonNeutrons) && (5 == parameters.m_nProtons))
351  return NCDIS_P_P_P_P_P;
352 
353  if ((1 == parameters.m_nNonNeutrons) && (0 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
354  return NCDIS_PIPLUS;
355  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
356  return NCDIS_P_PIPLUS;
357  if ((3 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
358  return NCDIS_P_P_PIPLUS;
359  if ((4 == parameters.m_nNonNeutrons) && (3 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
360  return NCDIS_P_P_P_PIPLUS;
361  if ((5 == parameters.m_nNonNeutrons) && (4 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
362  return NCDIS_P_P_P_P_PIPLUS;
363  if ((6 == parameters.m_nNonNeutrons) && (5 == parameters.m_nProtons) && (1 == parameters.m_nPiPlus))
364  return NCDIS_P_P_P_P_P_PIPLUS;
365 
366  if ((1 == parameters.m_nNonNeutrons) && (0 == parameters.m_nProtons) && (1 == parameters.m_nPiMinus))
367  return NCDIS_PIMINUS;
368  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons) && (1 == parameters.m_nPiMinus))
369  return NCDIS_P_PIMINUS;
370  if ((3 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons) && (1 == parameters.m_nPiMinus))
371  return NCDIS_P_P_PIMINUS;
372  if ((4 == parameters.m_nNonNeutrons) && (3 == parameters.m_nProtons) && (1 == parameters.m_nPiMinus))
373  return NCDIS_P_P_P_PIMINUS;
374  if ((5 == parameters.m_nNonNeutrons) && (4 == parameters.m_nProtons) && (1 == parameters.m_nPiMinus))
375  return NCDIS_P_P_P_P_PIMINUS;
376  if ((6 == parameters.m_nNonNeutrons) && (5 == parameters.m_nProtons) && (1 == parameters.m_nPiMinus))
377  return NCDIS_P_P_P_P_P_PIMINUS;
378 
379  if ((1 == parameters.m_nNonNeutrons) && (0 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
380  return NCDIS_PHOTON;
381  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
382  return NCDIS_P_PHOTON;
383  if ((3 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
384  return NCDIS_P_P_PHOTON;
385  if ((4 == parameters.m_nNonNeutrons) && (3 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
386  return NCDIS_P_P_P_PHOTON;
387  if ((5 == parameters.m_nNonNeutrons) && (4 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
388  return NCDIS_P_P_P_P_PHOTON;
389  if ((6 == parameters.m_nNonNeutrons) && (5 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
390  return NCDIS_P_P_P_P_P_PHOTON;
391 
392  if ((2 == parameters.m_nNonNeutrons) && (0 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
393  return NCDIS_PIZERO;
394  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
395  return NCDIS_P_PIZERO;
396  if ((4 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
397  return NCDIS_P_P_PIZERO;
398  if ((5 == parameters.m_nNonNeutrons) && (3 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
399  return NCDIS_P_P_P_PIZERO;
400  if ((6 == parameters.m_nNonNeutrons) && (4 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
401  return NCDIS_P_P_P_P_PIZERO;
402  if ((7 == parameters.m_nNonNeutrons) && (5 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
403  return NCDIS_P_P_P_P_P_PIZERO;
404  }
405 
406  if (1096 == nuNuanceCode)
407  return NCCOH;
408  if (1097 == nuNuanceCode)
409  return CCCOH;
410 
411  return OTHER_INTERACTION;
412 }
413 
414 //------------------------------------------------------------------------------------------------------------------------------------------
415 
416 LArInteractionTypeHelper::InteractionType LArInteractionTypeHelper::GetTestBeamHierarchyInteractionType(const MCParticleList &mcPrimaryList)
417 {
418  if (mcPrimaryList.empty())
419  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
420 
421  InteractionParameters parameters;
422  LArInteractionTypeHelper::SetInteractionParameters(mcPrimaryList, parameters);
423 
424  const InteractionType cosmicRayHypothesis(LArInteractionTypeHelper::CosmicRayHypothesis(mcPrimaryList, parameters));
425 
426  if (OTHER_INTERACTION != cosmicRayHypothesis)
427  return cosmicRayHypothesis;
428 
429  int targetParentId(0);
430 
431  for (const MCParticle *const pMCPrimary : mcPrimaryList)
432  {
433  if (LArMCParticleHelper::GetParentMCParticle(pMCPrimary) != pMCPrimary)
434  continue;
435 
436  if (13 == std::fabs(pMCPrimary->GetParticleId()))
437  --parameters.m_nMuons;
438  else if (11 == std::fabs(pMCPrimary->GetParticleId()))
439  --parameters.m_nElectrons;
440  else if (2212 == std::fabs(pMCPrimary->GetParticleId()))
441  --parameters.m_nProtons;
442  else if (22 == pMCPrimary->GetParticleId())
443  --parameters.m_nPhotons;
444  else if (211 == pMCPrimary->GetParticleId())
445  --parameters.m_nPiPlus;
446  else if (-211 == pMCPrimary->GetParticleId())
447  --parameters.m_nPiMinus;
448  else if (321 == pMCPrimary->GetParticleId())
449  --parameters.m_nKaonPlus;
450  else if (-321 == pMCPrimary->GetParticleId())
451  --parameters.m_nKaonMinus;
452 
453  --parameters.m_nNonNeutrons;
454  targetParentId = pMCPrimary->GetParticleId();
455  }
456 
457  MCParticleSet piZero, kaon0L;
458  for (const MCParticle *const pMCPrimary : mcPrimaryList)
459  {
460  if (22 == pMCPrimary->GetParticleId() && pMCPrimary->GetParentList().size() == 1)
461  {
462  const MCParticle *const pParentMCParticle(pMCPrimary->GetParentList().front());
463  if (pParentMCParticle->GetParticleId() == 111 && !piZero.count(pParentMCParticle))
464  piZero.insert(pParentMCParticle);
465  }
466  else if ((111 == pMCPrimary->GetParticleId() || 211 == std::fabs(pMCPrimary->GetParticleId())) && pMCPrimary->GetParentList().size() == 1)
467  {
468  const MCParticle *const pParentMCParticle(pMCPrimary->GetParentList().front());
469  if (pParentMCParticle->GetParticleId() == 130 && !kaon0L.count(pParentMCParticle))
470  kaon0L.insert(pParentMCParticle);
471  }
472  }
473 
474  parameters.m_nPiZero = piZero.size();
475  parameters.m_nKaon0L = kaon0L.size();
476 
477  if (211 == targetParentId)
478  {
479  if ((1 == parameters.m_nNonNeutrons) && (1 == parameters.m_nPiPlus))
480  return BEAM_PARTICLE_PI_PLUS_PI_PLUS;
481  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nPiPlus) && (1 == parameters.m_nPhotons))
482  return BEAM_PARTICLE_PI_PLUS_PI_PLUS_PHOTON;
483  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nPiPlus) && (1 == parameters.m_nPiZero))
484  return BEAM_PARTICLE_PI_PLUS_PI_PLUS_PIZERO;
485  return BEAM_PARTICLE_PI_PLUS_COMPLEX;
486  }
487  else if (-211 == targetParentId)
488  {
489  if ((1 == parameters.m_nNonNeutrons) && (1 == parameters.m_nPiMinus))
490  return BEAM_PARTICLE_PI_MINUS_PI_MINUS;
491  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nPiMinus) && (1 == parameters.m_nPhotons))
492  return BEAM_PARTICLE_PI_MINUS_PI_MINUS_PHOTON;
493  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nPiMinus) && (1 == parameters.m_nPiZero))
494  return BEAM_PARTICLE_PI_MINUS_PI_MINUS_PIZERO;
495  return BEAM_PARTICLE_PI_MINUS_COMPLEX;
496  }
497  else if (2212 == targetParentId)
498  {
499  if ((1 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons))
500  return BEAM_PARTICLE_P_P;
501  if ((2 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
502  return BEAM_PARTICLE_P_P_PHOTON;
503  if ((3 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
504  return BEAM_PARTICLE_P_P_PHOTON_PHOTON;
505  if ((4 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons) && (3 == parameters.m_nPhotons))
506  return BEAM_PARTICLE_P_P_PHOTON_PHOTON_PHOTON;
507  if ((5 == parameters.m_nNonNeutrons) && (1 == parameters.m_nProtons) && (4 == parameters.m_nPhotons))
508  return BEAM_PARTICLE_P_P_PHOTON_PHOTON_PHOTON_PHOTON;
509 
510  if ((2 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons))
511  return BEAM_PARTICLE_P_P_P;
512  if ((3 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
513  return BEAM_PARTICLE_P_P_P_PHOTON;
514  if ((4 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
515  return BEAM_PARTICLE_P_P_P_PHOTON_PHOTON;
516  if ((5 == parameters.m_nNonNeutrons) && (2 == parameters.m_nProtons) && (3 == parameters.m_nPhotons))
517  return BEAM_PARTICLE_P_P_P_PHOTON_PHOTON_PHOTON;
518 
519  if ((3 == parameters.m_nNonNeutrons) && (3 == parameters.m_nProtons))
520  return BEAM_PARTICLE_P_P_P_P;
521  if ((4 == parameters.m_nNonNeutrons) && (3 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
522  return BEAM_PARTICLE_P_P_P_P_PHOTON;
523  if ((5 == parameters.m_nNonNeutrons) && (3 == parameters.m_nProtons) && (2 == parameters.m_nPhotons))
524  return BEAM_PARTICLE_P_P_P_P_PHOTON_PHOTON;
525 
526  if ((4 == parameters.m_nNonNeutrons) && (4 == parameters.m_nProtons))
527  return BEAM_PARTICLE_P_P_P_P_P;
528  if ((5 == parameters.m_nNonNeutrons) && (4 == parameters.m_nProtons) && (1 == parameters.m_nPhotons))
529  return BEAM_PARTICLE_P_P_P_P_P_PHOTON;
530 
531  if ((5 == parameters.m_nNonNeutrons) && (5 == parameters.m_nProtons))
532  return BEAM_PARTICLE_P_P_P_P_P_P;
533 
534  return BEAM_PARTICLE_P_COMPLEX;
535  }
536  else if (13 == std::fabs(targetParentId))
537  {
538  if (0 == parameters.m_nNonNeutrons)
539  return BEAM_PARTICLE_MU;
540  if ((1 == parameters.m_nNonNeutrons) && (1 == parameters.m_nElectrons))
541  return BEAM_PARTICLE_MU_E;
542  return BEAM_PARTICLE_MU_COMPLEX;
543  }
544  else if (321 == targetParentId)
545  {
546  if ((1 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons))
547  return BEAM_PARTICLE_KAON_PLUS_MU;
548  if ((parameters.m_nNonNeutrons >= 2) && (1 == parameters.m_nKaonPlus) && (1 == parameters.m_nKaon0L))
549  return BEAM_PARTICLE_KAON_PLUS_KAON_PLUS_KAON0L_COMPLEX;
550  if ((parameters.m_nNonNeutrons > 1) && (1 == parameters.m_nKaonPlus))
551  return BEAM_PARTICLE_KAON_PLUS_KAON_PLUS_COMPLEX;
552  return BEAM_PARTICLE_KAON_PLUS_COMPLEX;
553  }
554  else if (-321 == targetParentId)
555  {
556  if ((1 == parameters.m_nNonNeutrons) && (1 == parameters.m_nMuons))
557  return BEAM_PARTICLE_KAON_MINUS_MU;
558  if ((parameters.m_nNonNeutrons >= 2) && (1 == parameters.m_nKaonMinus) && (1 == parameters.m_nKaon0L))
559  return BEAM_PARTICLE_KAON_MINUS_KAON_MINUS_KAON0L_COMPLEX;
560  if ((parameters.m_nNonNeutrons > 1) && (1 == parameters.m_nKaonMinus))
561  return BEAM_PARTICLE_KAON_MINUS_KAON_MINUS_COMPLEX;
562  return BEAM_PARTICLE_KAON_MINUS_COMPLEX;
563  }
564  else if (11 == std::fabs(targetParentId))
565  {
566  if (0 == parameters.m_nNonNeutrons)
567  return BEAM_PARTICLE_E;
568  return BEAM_PARTICLE_E_COMPLEX;
569  }
570 
571  if (parameters.m_nNonNeutrons > 5)
572  return BEAM_PARTICLE_COMPLEX_HIERARCHY;
573 
574  return BEAM_PARTICLE_UNKNOWN_HIERARCHY;
575 }
576 
577 //------------------------------------------------------------------------------------------------------------------------------------------
578 
579 void LArInteractionTypeHelper::SetInteractionParameters(const MCParticleList &mcPrimaryList, InteractionParameters &parameters)
580 {
581  for (const MCParticle *const pMCPrimary : mcPrimaryList)
582  {
583  if (2112 != pMCPrimary->GetParticleId())
584  ++parameters.m_nNonNeutrons;
585  if (13 == std::fabs(pMCPrimary->GetParticleId()))
586  ++parameters.m_nMuons;
587  if (11 == std::fabs(pMCPrimary->GetParticleId()))
588  ++parameters.m_nElectrons;
589  else if (2212 == std::fabs(pMCPrimary->GetParticleId()))
590  ++parameters.m_nProtons;
591  else if (22 == pMCPrimary->GetParticleId())
592  ++parameters.m_nPhotons;
593  else if (211 == pMCPrimary->GetParticleId())
594  ++parameters.m_nPiPlus;
595  else if (-211 == pMCPrimary->GetParticleId())
596  ++parameters.m_nPiMinus;
597  else if (321 == pMCPrimary->GetParticleId())
598  ++parameters.m_nKaonPlus;
599  else if (-321 == pMCPrimary->GetParticleId())
600  ++parameters.m_nKaonMinus;
601  }
602 }
603 
604 //------------------------------------------------------------------------------------------------------------------------------------------
605 
606 LArInteractionTypeHelper::InteractionType LArInteractionTypeHelper::CosmicRayHypothesis(
607  const MCParticleList &mcPrimaryList, const InteractionParameters &parameters)
608 {
609  if ((1 == mcPrimaryList.size()) && LArMCParticleHelper::IsCosmicRay(mcPrimaryList.front()))
610  {
611  if (1 == parameters.m_nMuons)
612  return COSMIC_RAY_MU;
613  if (1 == parameters.m_nProtons)
614  return COSMIC_RAY_P;
615  if (1 == parameters.m_nElectrons)
616  return COSMIC_RAY_E;
617  if (1 == parameters.m_nPhotons)
618  return COSMIC_RAY_PHOTON;
619  else
620  return COSMIC_RAY_OTHER;
621  }
622 
623  return OTHER_INTERACTION;
624 }
625 
626 //------------------------------------------------------------------------------------------------------------------------------------------
627 
628 std::string LArInteractionTypeHelper::ToString(const InteractionType interactionType)
629 {
630  switch (interactionType)
631  {
633  default:
634  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
635  }
636 }
637 
638 //------------------------------------------------------------------------------------------------------------------------------------------
639 //------------------------------------------------------------------------------------------------------------------------------------------
640 
641 LArInteractionTypeHelper::InteractionParameters::InteractionParameters() :
642  m_nNonNeutrons(0),
643  m_nMuons(0),
644  m_nElectrons(0),
645  m_nPhotons(0),
646  m_nProtons(0),
647  m_nPiPlus(0),
648  m_nPiMinus(0),
649  m_nPiZero(0),
650  m_nKaonPlus(0),
651  m_nKaonMinus(0),
652  m_nKaon0L(0)
653 {
654 }
655 
656 } // namespace lar_content
Header file for the interaction type helper class.
std::string string
Definition: nybbler.cc:12
#define GET_INTERACTION_TYPE_NAME_SWITCH(a)
The name switch statement macro.
Header file for the lar monitoring helper helper class.
Header file for the lar monte carlo particle helper helper class.
#define INTERACTION_TYPE_TABLE(d)
if(!yymsg) yymsg