12 #include "dqm_core/exceptions.h"
13 #include "dqm_core/AlgorithmManager.h"
14 #include "dqm_core/AlgorithmConfig.h"
15 #include "dqm_core/Result.h"
35 message +=
"Description: For use with SCT Track Time Bins ONLY!\n";
36 message +=
" Prints the ratio of 010 : 01X hits.\n";
37 message +=
" Prints the mean hit time, with 100 as -1 BunchCrossing (early) and 001 as +1 BunchCrossing (late)\n";
38 message +=
" where 011 would contribute half a hit to 0 BC (timed in) and half a hit to +1 BC (late)\n";
39 message +=
" and the hit patterns 000, 111, and 101 will be ignored.\n";
64 execute(
const std::string&
name,
const TObject&
data,
const dqm_core::AlgorithmConfig& )
71 if(
data.IsA()->InheritsFrom(
"TH1" )) {
72 h =
static_cast<const TH1*
>(&
data);
73 if (
h->GetDimension() > 1 ) {
74 throw dqm_core::BadConfig( ERS_HERE,
name,
"Not SCT Time Bins: Hist. Dimension > 1 " );
76 if (
h->GetNbinsX() != 8) {
77 throw dqm_core::BadConfig( ERS_HERE,
name,
"Not SCT Time Bins: Hist. NBins != 8 " );
80 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1");
89 double EarlyHits = 0.;
90 double InTimeHits = 0.;
92 double AllEntries = 0.;
96 TBin =
h->GetBinContent(0+1);
99 TBin =
h->GetBinContent(1+1);
103 TBin =
h->GetBinContent(2+1);
108 TBin =
h->GetBinContent(3+1);
110 InTimeHits += TBin/2;
114 TBin =
h->GetBinContent(4+1);
118 TBin =
h->GetBinContent(5+1);
121 TBin =
h->GetBinContent(6+1);
123 InTimeHits += TBin/2;
126 TBin =
h->GetBinContent(7+1);
132 if (Hits010 + Hits011 > 0.) {
133 double HitBin_ratio = Hits010 / (Hits010 + Hits011);
134 std::string HitBin_ratio_name = Form(
"%s_Ratio_010_over_01X",
name.c_str());
135 result->tags_[HitBin_ratio_name.c_str()] = HitBin_ratio;
138 if (AllEntries > 0.) {
139 double Edge0_ratio = Hits010 / AllEntries;
140 std::string Edge0_name = Form(
"%s_Ratio_010_over_XXX",
name.c_str());
141 result->tags_[Edge0_name.c_str()] = Edge0_ratio;
144 if (AllEntries > 0.) {
145 double Edge1_ratio = Hits011 / AllEntries;
146 std::string Edge1_name = Form(
"%s_Ratio_011_over_XXX",
name.c_str());
147 result->tags_[Edge1_name.c_str()] = Edge1_ratio;
150 if (AllEntries > 0.) {
151 double EdgeX_ratio = (Hits010 + Hits011) / AllEntries;
152 std::string EdgeX_name = Form(
"%s_Ratio_01X_over_XXX",
name.c_str());
153 result->tags_[EdgeX_name.c_str()] = EdgeX_ratio;
156 if (LateHits + InTimeHits + EarlyHits > 0.) {
157 double HitMean_time = (LateHits - EarlyHits) / (LateHits + InTimeHits + EarlyHits);
158 std::string HitMean_name = Form(
"%s_MeanHitTimeBC",
name.c_str());
159 result->tags_[HitMean_name.c_str()] = HitMean_time;
161 double HitWidth_time = (LateHits + EarlyHits) / (LateHits + InTimeHits + EarlyHits);
162 HitWidth_time = std::sqrt(HitWidth_time - HitMean_time*HitMean_time);
163 std::string HitWidth_name = Form(
"%s_VarianceHitTimeBC",
name.c_str());
164 result->tags_[HitWidth_name.c_str()] = HitWidth_time;