hlit-ana  0.0.0
 All Classes Functions Variables Pages
HlitTaskRsn.cxx
1 #include <HlitConfig.h>
2 #ifdef USE_OPENMP
3 #include <omp.h>
4 #endif
5 
6 #include <THnSparse.h>
7 #include "HlitEvent.h"
8 #include "HlitTrack.h"
9 #include "HlitTaskRsn.h"
10 
12 ClassImp(HlitTaskRsn);
14 
15 HlitTaskRsn::HlitTaskRsn(const char *name, const char *title)
16  : HlitTask(name, title), fEvent(0), fFillTmp(0), fSigBg(0), fBgLikePP(0),
17  fBgLikeMM(0), fBgEventMixPM(0), fNSkip(0) {
21 }
22 
27  delete[] fFillTmp;
28 }
29 
30 void HlitTaskRsn::Init(Option_t *option) {
34 
35  const Int_t nBins = 3;
36  Int_t bins[nBins] = {100, 20, 200};
37  Double_t min[nBins] = {0., 0., 0.};
38  Double_t max[nBins] = {10., 10., 200.};
39 
40  if (!fFillTmp)
41  fFillTmp = new Double_t[nBins];
42 
43  fSigBg = new THnSparseD("hSigBg", "SigBg", nBins, bins, min, max);
44  fOutput->Add(fSigBg);
45  fBgLikePP = new THnSparseD("hSigBg", "SigBg", nBins, bins, min, max);
46  fOutput->Add(fBgLikePP);
47  fBgLikeMM = new THnSparseD("hSigBg", "SigBg", nBins, bins, min, max);
48  fOutput->Add(fBgLikeMM);
49  // fBgEventMixPM = new THnSparseD("hSigBg", "SigBg", nBins, bins, min, max);
50  // fOutput->Add(fBgEventMixPM);
51 
52  // Do init for sub tasks
53  HlitTask::Init(option);
54 }
55 
56 void HlitTaskRsn::Exec(Option_t * /*option*/) {
60 
61  if (!fEvent) {
62  HlitTask *input = fParent;
63  fEvent = (HlitEvent *)input->GetOutput()->At(0);
64  }
65 
66  // Printf("\t%s %p", GetName(), fEvent);
67 
68  Long64_t nTracks = fEvent->GetNTrack();
69  Long64_t i, j;
70  HlitTrack *t1, *t2;
71  //#ifdef USE_OPENMP
72  //#pragma omp parallel for private(i, j, t1, t2) firstprivate(nTracks)
73  // num_threads(2)
74  //#endif
75  for (i = 0; i < nTracks; i++) {
76  //#ifdef USE_OPENMP
77  // if (!i)
78  // Printf("HlitTaskRsn num of threads : %d", omp_get_num_threads());
79  //#endif
80  if (i % fNSkip > 0)
81  continue;
82  t1 = (HlitTrack *)fEvent->GetTrack(i);
83  //#pragma omp parallel for
84  for (j = 0; j < nTracks; j++) {
85  if (i == j)
86  continue;
87  if (j % fNSkip > 0)
88  continue;
89 
90  t2 = (HlitTrack *)fEvent->GetTrack(j);
91  // Printf("\tpx1=%f px2=%f", t1->GetPx(), t2->GetPx());
92  fFillTmp[0] = t1->GetPx() + t2->GetPx();
93  fFillTmp[1] = t1->GetPy() + t2->GetPy();
94  fFillTmp[2] = nTracks;
95  //#pragma omp critical
96  // {
97  if (t1->GetCharge() == 1 && t2->GetCharge() == -1)
98  fSigBg->Fill(fFillTmp);
99  if (t1->GetCharge() == 1 && t2->GetCharge() == 1)
100  fBgLikePP->Fill(fFillTmp);
101  if (t1->GetCharge() == -1 && t2->GetCharge() == -1)
102  fBgLikeMM->Fill(fFillTmp);
103  // }
104  }
105  }
106 }
107 
108 void HlitTaskRsn::Finish(Option_t * /*option*/) {
109  Printf("name=%s", GetName());
110  if (fSigBg)
111  fSigBg->Print();
112 }
Track object.
Definition: HlitTrack.h:13
Double_t * fFillTmp
Tmp value for filling histogram.
Definition: HlitTaskRsn.h:39
virtual void Exec(Option_t *option)
User&#39;s function.
Definition: HlitTaskRsn.cxx:56
virtual void Init(Option_t *option)
Init function.
Definition: HlitTaskRsn.cxx:30
virtual void Finish(Option_t *option)
User&#39;s function executed after all sub tasks.
THnSparse * fBgLikePP
Background like sign ++.
Definition: HlitTaskRsn.h:42
TList * GetOutput() const
Returns output list.
Definition: HlitTask.h:79
HlitEvent * fEvent
Current event.
Definition: HlitTaskRsn.h:37
Double_t GetPy() const
Momentum y component.
Definition: HlitTrack.h:45
HlitTaskRsn(const char *name="HlitTaskRsn", const char *title="HlitTaskRsn title")
Definition: HlitTaskRsn.cxx:15
HlitTrack * GetTrack(Long64_t id)
Definition: HlitEvent.h:76
Base task.
Definition: HlitTask.h:13
Long64_t fNSkip
Skip N tracks (just for testing)
Definition: HlitTaskRsn.h:45
Resonance task.
Definition: HlitTaskRsn.h:16
Event object.
Definition: HlitEvent.h:15
Short_t GetCharge() const
Charge of track.
Definition: HlitTrack.h:47
virtual void Init(Option_t *option)
Init function.
Definition: HlitTask.cxx:159
THnSparse * fSigBg
Signal Background.
Definition: HlitTaskRsn.h:41
virtual ~HlitTaskRsn()
Definition: HlitTaskRsn.cxx:23
Double_t GetPx() const
Momentum x component.
Definition: HlitTrack.h:44
TList * fOutput
Output.
Definition: HlitTask.h:88
HlitTask * fParent
Partent task.
Definition: HlitTask.h:87
THnSparse * fBgLikeMM
Background like sign –.
Definition: HlitTaskRsn.h:43
Long64_t GetNTrack() const
Definition: HlitEvent.h:75