NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
NcInvmass.cxx
Go to the documentation of this file.
1
31
33
122
123#include "NcInvmass.h"
124#include "Riostream.h"
125
126ClassImp(NcInvmass); // Class implementation to enable ROOT I/O
127
130{
136
137 fPi=acos(-1.);
138 fMode=2;
139 fBkg=0;
140 fNewtheta=1;
141 fNewphi=1;
142 fMinv=0;
143 fMbkg=0;
144}
145
147{
153
154 if (fMinv)
155 {
156 delete fMinv;
157 fMinv=0;
158 }
159
160 if (fMbkg)
161 {
162 delete fMbkg;
163 fMbkg=0;
164 }
165}
166
168{
174
175 fMode=2;
176 if (m==1) fMode=1;
177}
178
180{
187
188 fNewtheta=1;
189 if (i==0) fNewtheta=0;
190}
191
193{
200
201 fNewphi=1;
202 if (i==0) fNewphi=0;
203}
204
206{
212
213 return fMode;
214}
215
217{
223
224 return fNewtheta;
225}
226
228{
234
235 return fNewphi;
236}
237
238TObjArray* NcInvmass::Invmass(TObjArray* a1,TObjArray* a2)
239{
245
246 fBkg=0;
247 Combine(a1,a2);
248 return fMinv;
249}
250
251TObjArray* NcInvmass::CombBkg(TObjArray* a1,TObjArray* a2)
252{
258
259 fBkg=1;
260 Combine(a1,a2);
261 if (fMode != 1)
262 {
263 return fMbkg;
264 }
265 else
266 {
267 return fMinv;
268 }
269}
270
271void NcInvmass::Combine(TObjArray* a1,TObjArray* a2)
272{
278
279 if ((!fBkg || fMode==1) && fMinv)
280 {
281 delete fMinv;
282 fMinv=0;
283 }
284
285 if (fBkg && (fMode !=1) && fMbkg)
286 {
287 delete fMbkg;
288 fMbkg=0;
289 }
290
291 Int_t isame; // Indicates whether both lists are identical
292 isame=0;
293 if (a1==a2) isame=1;
294
295 // Index i must loop over the shortest of a1 and a2
296 TObjArray* listi=a1;
297 TObjArray* listj=a2;
298 Int_t ni=a1->GetEntries();
299 Int_t nj=a2->GetEntries();
300 if (nj < ni)
301 {
302 ni=a2->GetEntries();
303 nj=a1->GetEntries();
304 listi=a2;
305 listj=a1;
306 }
307
308 NcTrack* p1=0;
309 NcTrack* p2=0;
310 NcTrack* px=0;
311 Nc4Vector ptot;
312 NcTrack* t=0;
313 Double_t v2[4],vx[4];
314 Float_t q1,q2;
315
316 Int_t jmin; // Start index for list j
317 Int_t jx; // Index for randomly picked particle for comb. bkg. reconstruction
318
319 for (Int_t i=0; i<ni; i++) // Select first a particle from list i
320 {
321 p1=(NcTrack*)listi->At(i);
322 p2=0;
323
324 if (!p1) continue;
325
326 jmin=0;
327 if (isame) jmin=i+1;
328 for (Int_t j=jmin; j<nj; j++) // Select also a particle from list j
329 {
330 p2=(NcTrack*)listj->At(j);
331 if (p1==p2) p2=0; // Don't combine particle with itself
332
333 if (!p2) continue;
334
335 p2->GetVector(v2,"sph");
336
337 // Take theta and phi from randomly chosen other list j particle for bkg. reconstr.
338 if (fBkg)
339 {
340 px=0;
341 if ((!isame && nj>1) || (isame && nj>2))
342 {
343 jx=int(fRndm.Uniform(0,float(nj)));
344 px=(NcTrack*)listj->At(jx);
345
346 while (!px || px==p2 || px==p1)
347 {
348 jx++;
349 if (jx >= nj) jx=0;
350 px=(NcTrack*)listj->At(jx);
351 }
352
353 px->GetVector(vx,"sph");
354 if (fNewtheta) v2[2]=vx[2]; // Replace the theta angle in the v2 vector
355 if (fNewphi) v2[3]=vx[3]; // Replace the phi angle in the v2 vector
356 }
357 }
358
359 if ((!fBkg && p2) || (fBkg && px))
360 {
361 // Store the data of this two-particle combination
362 ptot.SetVector(v2,"sph");
363 ptot=(Nc4Vector)(ptot+(*p1));
364 q1=p1->GetCharge();
365 q2=p2->GetCharge();
366 t=new NcTrack;
367 t->Set4Momentum(ptot);
368 t->SetCharge(q1+q2);
369 if (!fBkg || fMode==1)
370 {
371 if (!fMinv)
372 {
373 fMinv=new TObjArray();
374 fMinv->SetOwner();
375 }
376 fMinv->Add(t);
377 }
378 else
379 {
380 if (!fMbkg)
381 {
382 fMbkg=new TObjArray();
383 fMbkg->SetOwner();
384 }
385 fMbkg->Add(t);
386 }
387 }
388
389 } // End of second particle loop
390
391 } // End of first particle loop
392}
393
ClassImp(NcInvmass)
Handling of Lorentz 4-vectors in various reference frames.
Definition Nc4Vector.h:14
void SetVector(Double_t v0, Nc3Vector &v)
void GetVector(Double_t *v, TString f, TString u="rad")
Construction of invariant mass and combinatorial background.
Definition NcInvmass.h:17
TObjArray * CombBkg(TObjArray *a1, TObjArray *a2)
Int_t GetPhiSwitch() const
NcRandom fRndm
Definition NcInvmass.h:34
Int_t fMode
Definition NcInvmass.h:32
Int_t GetStorageMode() const
Int_t fNewtheta
Definition NcInvmass.h:35
Int_t fBkg
Definition NcInvmass.h:33
void SetThetaSwitch(Int_t i=1)
Int_t fNewphi
Definition NcInvmass.h:36
void SetPhiSwitch(Int_t i=1)
TObjArray * Invmass(TObjArray *a1, TObjArray *a2)
TObjArray * fMbkg
Definition NcInvmass.h:38
Double_t fPi
Definition NcInvmass.h:31
TObjArray * fMinv
Definition NcInvmass.h:37
Int_t GetThetaSwitch() const
void Combine(TObjArray *a1, TObjArray *a2)
void SetStorageMode(Int_t m)
Handling of the attributes of a reconstructed particle track.
Definition NcTrack.h:19
void Set4Momentum(Nc4Vector &p)
Definition NcTrack.cxx:415
void SetCharge(Float_t q)
Definition NcTrack.cxx:444
Float_t GetCharge() const
Definition NcTrack.cxx:710