22 #include "TDirectory.h"
27 #include "uiuc_utils.h"
72 sprintf(key_name,
"Runinfo/Run number");
74 db_get_value(
hDB,0,key_name, &runnumber, &size, TID_INT,1);
78 sprintf(stem,
"/Experiment/Run%d",PSI_runnumber);
79 printf(
"==================\n\n\n in MMuSCAnalysisC_init\n PSI runnumber is %d\n\n=============\n",PSI_runnumber);
80 sprintf(key_name,
"%s/muSC/muSCCopy2TimeOffset",stem);
84 sprintf(key_name,
"%s/muSC/muSCATimeOffset",stem);
88 sprintf(key_name,
"%s/muSC/muSCRoutedTimeOffset",stem);
97 sprintf(hist_name,
"muSC_copy1_successive_hit_tdiffs");
98 sprintf(hist_title,
"#muSC tdiffs between successive hits");
102 sprintf(hist_name,
"muSC_time");
103 sprintf(hist_title,
"muSC time");
104 muSC_time =
new TH1D(hist_name, hist_title, 44201, -5000.625, 50250.625);
107 sprintf(hist_name,
"muSC_copy1_AD_successive_hit_tdiffs");
108 sprintf(hist_title,
"#muSC tdiffs between successive AD hits");
112 sprintf(hist_name,
"muSC_router_seq_errors");
113 sprintf(hist_title,
"#muSC router sequence errors");
117 sprintf(hist_name,
"blocks_skipped_muSC_matching_errors");
118 sprintf(hist_title,
"blocks skipped due to #muSC matching errors");
131 int hit_bank_size = bk_locate(pevent,
"HITS", (
DWORD *) &hit_bank);
133 if (hit_bank == NULL) {
134 fprintf(stderr,
"MMuSCAnalysisC: Could not find bank HITS.\n");
139 int prevMuSChitindex = -1;
140 int prevMuSCADhitindex = -1;
141 for (
int i=0;
i<hit_bank_size;
i++) {
145 if (prevMuSChitindex >= 0) {
146 double tdiff = hit_bank[
i].
time -
147 hit_bank[prevMuSChitindex].
time;
150 prevMuSChitindex =
i;
153 if (prevMuSCADhitindex >= 0) {
154 double tdiff = hit_bank[
i].
time -
155 hit_bank[prevMuSCADhitindex].
time;
158 prevMuSCADhitindex =
i;
161 if (prevMuSCADhitindex == -1) {
162 prevMuSCADhitindex =
i;
171 int last_route_port = -1;
172 double last_route_time = -1;
173 for (
int i=0;
i<hit_bank_size;
i++) {
176 if(last_route_port != -1 && port != (last_route_port+1)%4) {
179 last_route_port =
port;
180 last_route_time = hit_bank[
i].
time;
188 for(
int i = 1;
i <= 2;
i++) {
190 sprintf(name,
"muSC_copy%d_only_block",
i);
193 fprintf(stderr,
"Warning: Unable to find histogram %s\n", name);
196 int bin = only->GetXaxis()->FindBin(pheader->serial_number);
198 fprintf(stderr,
"Skipping block %d: too many hits in muSC copy %d only (%f)\n",
199 pheader->serial_number,
i, only->GetBinContent(bin));