@@ -79,8 +79,9 @@ void TrendingRate::computeTOFRates(TH2F* h, std::vector<int>& bcInt, std::vector
7979
8080 // Counting background
8181 int nb = 0 ;
82+ float ybin_width = hDiffGlobal.GetYaxis ()->GetBinWidth (1 ) * 0.5 ;
8283 for (int i = 1 ; i <= hpdiff->GetNbinsX (); i++) {
83- if (hpdiff->GetBinContent (i) - 0.5 < mThresholdBkg ) {
84+ if (hpdiff->GetBinContent (i) - ybin_width < mThresholdBkg ) {
8485 if (!hback) {
8586 hback = hDiffGlobal.ProjectionY (" back" , i, i);
8687 } else {
@@ -97,14 +98,17 @@ void TrendingRate::computeTOFRates(TH2F* h, std::vector<int>& bcInt, std::vector
9798 if (nb == 0 ) { // threshold too low? return since hback was not created
9899 ILOG (Warning, Support) << " Counted 0 background events, BKG threshold might be too low!" << ENDM ;
99100 delete hpdiff;
101+ bcInt.push_back (0 .);
102+ bcRate.push_back (0 .);
103+ bcPileup.push_back (0 .);
100104 return ;
101105 }
102- if (hback->Integral () < 0 || hback->GetMean () < 0.5 ) {
106+ if (hback->Integral () < 0 || hback->GetMean () < ybin_width ) {
103107 return ;
104108 }
105109
106110 if (mActiveChannels > 0 ) {
107- mNoiseRatePerChannel = (hback->GetMean () - 0.5 ) / orbit_lenght * h->GetNbinsX () / mActiveChannels ;
111+ mNoiseRatePerChannel = (hback->GetMean () - ybin_width ) / orbit_lenght * h->GetNbinsX () / mActiveChannels ;
108112 }
109113
110114 std::vector<int > signals;
@@ -115,7 +119,7 @@ void TrendingRate::computeTOFRates(TH2F* h, std::vector<int>& bcInt, std::vector
115119
116120 if (nb) {
117121 for (int i = 1 ; i <= hDiffGlobal.GetNbinsX (); i++) {
118- if (hpdiff->GetBinContent (i) - 0.5 > mThresholdSgn ) {
122+ if (hpdiff->GetBinContent (i) - ybin_width > mThresholdSgn ) {
119123 signals.push_back (i);
120124 mNIBC ++;
121125 }
@@ -168,7 +172,7 @@ void TrendingRate::computeTOFRates(TH2F* h, std::vector<int>& bcInt, std::vector
168172
169173 if (sumw > 0 ) {
170174 mCollisionRate = ratetot;
171- mPileupRate = pilup / sumw;
175+ mPileupRate = pilup / sumw - 1 ;
172176 }
173177 delete hback;
174178 }
@@ -239,9 +243,12 @@ void TrendingRate::trendValues(const Trigger& t, repository::DatabaseInterface&
239243 if (dataSource.name == " HitMap" ) {
240244 foundHitMap = true ;
241245 TH2F * hmap = dynamic_cast <TH2F *>(mo->getObject ());
242- hmap->Divide (hmap);
243- mActiveChannels = hmap->Integral () * 24 ;
244- ILOG (Info, Support) << " N channels = " << mActiveChannels << ENDM ;
246+ if (hmap) {
247+ TH2F hcopy (*hmap);
248+ hcopy.Divide (hmap);
249+ mActiveChannels = hcopy.Integral () * 24 ;
250+ // ILOG(Info, Support) << "N channels = " << mActiveChannels << ENDM;
251+ }
245252 } else if (dataSource.name == " Multiplicity/VsBC" ) {
246253 moHistogramMultVsBC = mo;
247254 foundVsBC = true ;
@@ -265,11 +272,10 @@ void TrendingRate::trendValues(const Trigger& t, repository::DatabaseInterface&
265272
266273 computeTOFRates (dynamic_cast <TH2F *>(moHistogramMultVsBC->getObject ()), bcInt, bcRate, bcPileup);
267274
268- ILOG (Info, Support) << " In " << mActiveChannels << " channels, noise rate per channel= " << mNoiseRatePerChannel << " Hz - collision rate = " << mCollisionRate << " Hz - mu-pilup = " << mPileupRate << ENDM ;
269-
275+ /* ILOG(Info, Support) << "In " << mActiveChannels << " channels, noise rate per channel= " << mNoiseRatePerChannel << " Hz - collision rate = " << mCollisionRate << " Hz - mu-pilup = " << mPileupRate << ENDM;
270276 for (int i = 0; i < bcInt.size(); i++) {
271- ILOG (Info, Support) << " bc = " << bcInt[i] * 18 - 9 << " ) rate = " << bcRate[i] << " , pilup = " << bcPileup[i] << ENDM ;
272- }
277+ ILOG(Info, Support) << "bc = " << bcInt[i] * 18 - 9 << ") rate = " << bcRate[i] << ", pilup = " << bcPileup[i] - 1 << ENDM;
278+ }*/
273279
274280 mTrend ->Fill ();
275281}
0 commit comments