GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
AngularCorrelationHelper.cxx
Go to the documentation of this file.
2
4{
5 // set up the queue for event mixing by filling it with empty events
6 // we chose 10 here as a reasonable compromise between statistics and computing power/memory needed
7 for(int i = 0; i < fNofMixedEvents; ++i) {
8 fGriffinDeque[slot].emplace_back(new TGriffin);
9 fBgoDeque[slot].emplace_back(new TGriffinBgo);
10 }
11
12 std::string conditions = fAddback ? "using addback" : "without addback";
13 conditions += fFolding ? ", folded around 90^{o}" : "";
14 conditions += fGrouping ? ", grouped" : "";
15
16 for(auto angle = fAngles->begin(); angle != fAngles->end(); ++angle) {
17 int i = std::distance(fAngles->begin(), angle);
18 fH2[slot][Form("AngularCorrelation%d", i)] = new TH2D(Form("AngularCorrelation%d", i), Form("%.1f^{o}: Suppressed #gamma-#gamma %s, |#Deltat_{#gamma-#gamma}| < %.1f", *angle, conditions.c_str(), fPrompt), fBins, fMinEnergy, fMaxEnergy, fBins, fMinEnergy, fMaxEnergy);
19 fH2[slot][Form("AngularCorrelationBG%d", i)] = new TH2D(Form("AngularCorrelationBG%d", i), Form("%.1f^{o}: Suppressed #gamma-#gamma %s, |#Deltat_{#gamma-#gamma}| = %.1f - %.1f", *angle, conditions.c_str(), fTimeRandomLow, fTimeRandomHigh), fBins, fMinEnergy, fMaxEnergy, fBins, fMinEnergy, fMaxEnergy);
20 fH2[slot][Form("AngularCorrelationMixed%d", i)] = new TH2D(Form("AngularCorrelationMixed%d", i), Form("%.1f^{o}: Event mixed suppressed #gamma-#gamma %s", *angle, conditions.c_str()), fBins, fMinEnergy, fMaxEnergy, fBins, fMinEnergy, fMaxEnergy);
21 }
22
23 fH2[slot]["AngularCorrelation"] = new TH2D("AngularCorrelation", Form("Suppressed #gamma-#gamma %s, |#Deltat_{#gamma-#gamma}| < %.1f", conditions.c_str(), fPrompt), fBins, fMinEnergy, fMaxEnergy, fBins, fMinEnergy, fMaxEnergy);
24 fH2[slot]["AngularCorrelationBG"] = new TH2D("AngularCorrelationBG", Form("Suppressed #gamma-#gamma %s, #Deltat_{#gamma-#gamma} = %.1f - %.1f", conditions.c_str(), fTimeRandomLow, fTimeRandomHigh), fBins, fMinEnergy, fMaxEnergy, fBins, fMinEnergy, fMaxEnergy);
25 fH2[slot]["AngularCorrelationMixed"] = new TH2D("AngularCorrelationMixed", Form("Event mixed suppressed #gamma-#gamma %s", conditions.c_str()), fBins, fMinEnergy, fMaxEnergy, fBins, fMinEnergy, fMaxEnergy);
26
27 // for the first slot we also write the griffin angles
28 if(slot == 0) {
29 fObject[slot]["GriffinAngles"] = fAngles;
30 }
31}
32
33void AngularCorrelationHelper::Exec(unsigned int slot, TGriffin& fGriffin, TGriffinBgo& fGriffinBgo)
34{
35 for(auto g1 = 0; g1 < (fAddback ? fGriffin.GetSuppressedAddbackMultiplicity(&fGriffinBgo) : fGriffin.GetSuppressedMultiplicity(&fGriffinBgo)); ++g1) {
36 auto grif1 = (fAddback ? fGriffin.GetSuppressedAddbackHit(g1) : fGriffin.GetSuppressedHit(g1));
37 if(ExcludeDetector(grif1->GetDetector()) || ExcludeCrystal(grif1->GetArrayNumber())) continue;
38
39 for(auto g2 = 0; g2 < (fAddback ? fGriffin.GetSuppressedAddbackMultiplicity(&fGriffinBgo) : fGriffin.GetSuppressedMultiplicity(&fGriffinBgo)); ++g2) {
40 if(g1 == g2) continue;
41 auto grif2 = (fAddback ? fGriffin.GetSuppressedAddbackHit(g2) : fGriffin.GetSuppressedHit(g2));
42 if(ExcludeDetector(grif2->GetDetector()) || ExcludeCrystal(grif2->GetArrayNumber())) continue;
43
44 // skip hits in the same detector when using addback, or in the same crystal when not using addback
45 if(grif1->GetDetector() == grif2->GetDetector() && (fAddback || grif1->GetCrystal() == grif2->GetCrystal())) {
46 continue;
47 }
48
49 // calculate the angle
50 double angle = grif1->GetPosition(fGriffinDistance).Angle(grif2->GetPosition(fGriffinDistance)) * 180. / TMath::Pi();
51 if(angle < fAngles->Rounding()) continue;
52 if(fFolding && angle > 90.) angle = 180. - angle;
53
54 // find the index of the angle
55 auto angleIndex = fAngles->Index(angle);
56 if(angleIndex < 0) continue;
57 // check the timing to see if these are coincident or time-random hits
58 double ggTime = TMath::Abs(grif2->GetTime() - grif1->GetTime());
59 if(ggTime <= fPrompt) {
60 fH2[slot].at("AngularCorrelation")->Fill(grif1->GetEnergy(), grif2->GetEnergy());
61 fH2[slot].at(Form("AngularCorrelation%d", angleIndex))->Fill(grif1->GetEnergy(), grif2->GetEnergy());
62 } else if(fTimeRandomLow <= ggTime && ggTime <= fTimeRandomHigh) {
63 fH2[slot].at("AngularCorrelationBG")->Fill(grif1->GetEnergy(), grif2->GetEnergy());
64 fH2[slot].at(Form("AngularCorrelationBG%d", angleIndex))->Fill(grif1->GetEnergy(), grif2->GetEnergy());
65 }
66 }
67
68 // Event mixing: loop over all stored events for this thread/slot and use them as the "second" gamma ray
69 for(auto l = 0; l < fGriffinDeque[slot].size(); ++l) {
70 auto fLastGriffin = fGriffinDeque[slot][l];
71 auto fLastBgo = fBgoDeque[slot][l];
72 for(auto g2 = 0; g2 < (fAddback ? fLastGriffin->GetSuppressedAddbackMultiplicity(fLastBgo) : fLastGriffin->GetSuppressedMultiplicity(fLastBgo)); ++g2) {
73 auto grif2 = (fAddback ? fLastGriffin->GetSuppressedAddbackHit(g2) : fLastGriffin->GetSuppressedHit(g2));
74 if(ExcludeDetector(grif2->GetDetector()) || ExcludeCrystal(grif2->GetArrayNumber())) continue;
75
76 // skip hits in the same detector when using addback, or in the same crystal when not using addback
77 if(grif1->GetDetector() == grif2->GetDetector() && (fAddback || grif1->GetCrystal() == grif2->GetCrystal())) continue;
78
79 double angle = grif1->GetPosition(fGriffinDistance).Angle(grif2->GetPosition(fGriffinDistance)) * 180. / TMath::Pi();
80 if(angle < fAngles->Rounding()) continue;
81 if(fFolding && angle > 90.) angle = 180. - angle;
82
83 // find the index of the angle
84 auto angleIndex = fAngles->Index(angle);
85 if(angleIndex < 0) continue;
86 // no point in checking the time here, the two hits are from different events
87 fH2[slot].at("AngularCorrelationMixed")->Fill(grif1->GetEnergy(), grif2->GetEnergy());
88 fH2[slot].at(Form("AngularCorrelationMixed%d", angleIndex))->Fill(grif1->GetEnergy(), grif2->GetEnergy());
89 }
90 }
91 }
92
93 // Add the current event to the queue, delete the oldest event in the queue, and pop the pointer from the queue.
94 fGriffinDeque[slot].emplace_back(new TGriffin(fGriffin));
95 fBgoDeque[slot].emplace_back(new TGriffinBgo(fGriffinBgo));
96
97 delete fGriffinDeque[slot].front();
98 delete fBgoDeque[slot].front();
99
100 fGriffinDeque[slot].pop_front();
101 fBgoDeque[slot].pop_front();
102}
void Exec(unsigned int slot, TGriffin &fGriffin, TGriffinBgo &fGriffinBgo)
void CreateHistograms(unsigned int slot) override
Virtual helper function that the user uses to create their histograms.
bool ExcludeCrystal(int arraynumber)
std::map< unsigned int, std::deque< TGriffin * > > fGriffinDeque
std::map< unsigned int, std::deque< TGriffinBgo * > > fBgoDeque
std::vector< TGRSIMap< std::string, TH2 * > > fH2
Definition TGRSIHelper.h:49
std::vector< TGRSIMap< std::string, TObject * > > fObject
Definition TGRSIHelper.h:54
std::set< double >::iterator end() const
int Index(double angle)
std::set< double >::iterator begin() const
TGriffinHit * GetSuppressedAddbackHit(const int &i)
Definition TGriffin.h:122
Short_t GetSuppressedMultiplicity(const TBgo *bgo)
Definition TGriffin.h:111
Short_t GetSuppressedAddbackMultiplicity(const TBgo *bgo)
Definition TGriffin.h:119
TGriffinHit * GetSuppressedHit(const int &i)
!
Definition TGriffin.h:108