1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | #include "JEventProcessor_ST_online_efficiency.h" |
9 | using namespace jana; |
10 | using namespace std; |
11 | |
12 | |
13 | #include <JANA/JApplication.h> |
14 | #include <JANA/JFactory.h> |
15 | extern "C"{ |
16 | void InitPlugin(JApplication *app){ |
17 | InitJANAPlugin(app); |
18 | app->AddProcessor(new JEventProcessor_ST_online_efficiency()); |
19 | } |
20 | } |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | JEventProcessor_ST_online_efficiency::JEventProcessor_ST_online_efficiency() |
27 | { |
28 | |
29 | } |
30 | |
31 | |
32 | |
33 | |
34 | JEventProcessor_ST_online_efficiency::~JEventProcessor_ST_online_efficiency() |
35 | { |
36 | |
37 | } |
38 | |
39 | |
40 | |
41 | |
42 | jerror_t JEventProcessor_ST_online_efficiency::init(void) |
43 | { |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | gPARMS->SetParameter("TRKFIT:USE_SC_TIME",false); |
54 | |
55 | |
56 | TDirectory *main = gDirectory(TDirectory::CurrentDirectory()); |
57 | gDirectory(TDirectory::CurrentDirectory())->mkdir("st_efficiency")->cd(); |
58 | |
59 | h_N_trck_prd_All = new TH1D("h_N_trck_prd_All", "h_N_trck_prd_All; Sector; Predicted Hit Counts", 31, -0.5, 30.5); |
60 | h_N_recd_hit_All = new TH1D("h_N_recd_hit_All", "h_N_recd_hit_All; Sector; Recorded Hit Counts", 31, -0.5, 30.5); |
61 | |
62 | h_N_trck_prd_ss = new TH1D("h_N_trck_prd_ss", "h_N_trck_prd_ss; Sector; Predicted Hit Counts", 31, -0.5, 30.5); |
63 | h_N_recd_hit_ss = new TH1D("h_N_recd_hit_ss", "h_N_recd_hit_ss; Sector; Recorded Hit Counts", 31, -0.5, 30.5); |
64 | |
65 | h_N_trck_prd_bs = new TH1D("h_N_trck_prd_bs", "h_N_trck_prd_bs; Sector; Predicted Hit Counts", 31, -0.5, 30.5); |
66 | h_N_recd_hit_bs = new TH1D("h_N_recd_hit_bs", "h_N_recd_hit_bs; Sector; Recorded Hit Counts", 31, -0.5, 30.5); |
67 | |
68 | h_N_trck_prd_ns = new TH1D("h_N_trck_prd_ns", "h_N_trck_prd_ns; Sector; Predicted Hit Counts", 31, -0.5, 30.5); |
69 | h_N_recd_hit_ns = new TH1D("h_N_recd_hit_ns", "h_N_recd_hit_ns; Sector; Recorded Hit Counts", 31, -0.5, 30.5); |
70 | |
71 | h_ST_Eff_All= new TH1D("h_ST_Eff_All", " Efficiency; Sector; N_{RECD}/N_{TRCK}", 31, -0.5, 30.5); |
72 | h_ST_Eff_ss = new TH1D("h_ST_Eff_ss", " SS Efficiency; Sector; N_{RECD}/N_{TRCK}", 31, -0.5, 30.5); |
73 | h_ST_Eff_bs = new TH1D("h_ST_Eff_bs", " BS Efficiency; Sector; N_{RECD}/N_{TRCK}", 31, -0.5, 30.5); |
74 | h_ST_Eff_ns = new TH1D("h_ST_Eff_ns", " NS Efficiency; Sector; N_{RECD}/N_{TRCK}", 31, -0.5, 30.5); |
75 | |
76 | gDirectory(TDirectory::CurrentDirectory())->cd("../"); |
77 | main->cd(); |
78 | |
79 | |
80 | memset(N_trck_prd_All, 0, sizeof(N_trck_prd_All)); |
81 | memset(N_recd_hit_All, 0, sizeof(N_recd_hit_All)); |
82 | memset(N_trck_prd_ss, 0, sizeof(N_trck_prd_ss)); |
83 | memset(N_recd_hit_ss, 0, sizeof(N_recd_hit_ss)); |
84 | memset(N_trck_prd_bs, 0, sizeof(N_trck_prd_bs)); |
85 | memset(N_recd_hit_bs, 0, sizeof(N_recd_hit_bs)); |
86 | memset(N_trck_prd_ns, 0, sizeof(N_trck_prd_ns)); |
87 | memset(N_recd_hit_ns, 0, sizeof(N_recd_hit_ns)); |
88 | |
89 | return NOERROR; |
90 | } |
91 | |
92 | |
93 | |
94 | |
95 | jerror_t JEventProcessor_ST_online_efficiency::brun(JEventLoop *eventLoop, int32_t runnumber) |
96 | { |
97 | |
98 | |
99 | map<string,double> target_params; |
100 | if (eventLoop->GetCalib("/TARGET/target_parms", target_params)) |
| |
101 | jout << "Error loading /TARGET/target_parms/ !" << endl; |
102 | if (target_params.find("TARGET_Z_POSITION") != target_params.end()) |
| |
103 | z_target_center = target_params["TARGET_Z_POSITION"]; |
104 | else |
105 | jerr << "Unable to get TARGET_Z_POSITION from /TARGET/target_parms !" << endl; |
106 | |
107 | DApplication* dapp = dynamic_cast<DApplication*>(eventLoop->GetJApplication()); |
| 3 | | Calling 'JEventLoop::GetJApplication' | |
|
| 4 | | Returning from 'JEventLoop::GetJApplication' | |
|
| |
108 | if(!dapp) |
| |
| |
109 | _DBG_std::cerr<<"plugins/monitoring/ST_online_efficiency/JEventProcessor_ST_online_efficiency.cc" <<":"<<109<<" "<<"Cannot get DApplication from JEventLoop! (are you using a JApplication based program?)"<<endl; |
110 | DGeometry* locGeometry = dapp->GetDGeometry(eventLoop->GetJEvent().GetRunNumber()); |
| 8 | | Called C++ object pointer is null |
|
111 | locGeometry->GetStartCounterGeom(sc_pos, sc_norm); |
112 | return NOERROR; |
113 | } |
114 | |
115 | |
116 | |
117 | |
118 | jerror_t JEventProcessor_ST_online_efficiency::evnt(JEventLoop *eventLoop, uint64_t eventnumber) |
119 | { |
120 | |
121 | |
122 | |
123 | |
124 | |
125 | |
126 | |
127 | |
128 | |
129 | |
130 | |
131 | |
132 | |
133 | vector<const DSCDigiHit*> st_adc_digi_hits; |
134 | vector<const DParticleID*> pid_algorithm; |
135 | vector<const DSCHit*> st_hits; |
136 | vector<const DChargedTrack*> chargedTrackVector; |
137 | eventLoop->Get(st_adc_digi_hits); |
138 | eventLoop->Get(pid_algorithm); |
139 | eventLoop->Get(st_hits); |
140 | eventLoop->Get(chargedTrackVector); |
141 | |
142 | const DDetectorMatches* locDetectorMatches = NULL__null; |
143 | eventLoop->GetSingle(locDetectorMatches); |
144 | |
145 | |
146 | |
147 | japp->RootFillLock(this); |
148 | |
149 | |
150 | for (uint32_t i = 0; i < chargedTrackVector.size(); i++) |
151 | { |
152 | |
153 | const DChargedTrack *thisChargedTrack = chargedTrackVector[i]; |
154 | |
155 | const DTrackTimeBased *timeBasedTrack; |
156 | |
157 | thisChargedTrack->Get_BestTrackingFOM()->GetSingle(timeBasedTrack); |
158 | float trackingFOMCut = 0.0027; |
159 | if(timeBasedTrack->FOM < trackingFOMCut) continue; |
160 | |
161 | DVector3 vertex; |
162 | |
163 | vertex = timeBasedTrack->position(); |
164 | |
165 | double z_v = vertex.z(); |
166 | double r_v = vertex.Perp(); |
167 | bool z_vertex_cut = fabs(z_target_center - z_v) <= 15.0; |
168 | bool r_vertex_cut = r_v < 0.3; |
169 | |
170 | if (!z_vertex_cut) continue; |
171 | if (!r_vertex_cut) continue; |
172 | int st_pred_id = pid_algorithm[0]->PredictSCSector(timeBasedTrack->rt,0.05235,&locProjPos,&Barrel); |
173 | int st_pred_id_index = st_pred_id - 1; |
174 | |
175 | locSCzIntersection = locProjPos.z(); |
176 | locSCrIntersection = locProjPos.Perp(); |
177 | |
178 | |
179 | DVector3 Momentum; |
180 | Momentum = timeBasedTrack->momentum(); |
181 | if (st_pred_id != 0) |
182 | { |
183 | |
184 | sc_index = st_pred_id_index; |
185 | |
186 | sc_pos_soss = sc_pos[sc_index][0].z(); |
187 | sc_pos_eoss = sc_pos[sc_index][1].z(); |
188 | sc_pos_eobs = sc_pos[sc_index][11].z(); |
189 | sc_pos_eons = sc_pos[sc_index][12].z(); |
190 | ss_interval = (sc_pos_eoss - sc_pos_soss)/Nof_ss_intervals; |
191 | bs_interval = (sc_pos_eobs - sc_pos_eoss)/Nof_bs_intervals; |
192 | ns_interval = (sc_pos_eons - sc_pos_eobs)/Nof_ns_intervals; |
193 | |
194 | |
195 | |
196 | |
197 | N_trck_prd_All[st_pred_id_index] += 1; |
198 | |
199 | for (uint32_t j = 0; j < st_hits.size(); j++) |
200 | { |
201 | int phi_sec_hit_sector = st_hits[j]->sector; |
202 | |
203 | |
204 | |
205 | if (st_pred_id == phi_sec_hit_sector){ |
206 | N_recd_hit_All[st_pred_id_index] += 1; |
207 | break; |
208 | } |
209 | } |
210 | |
211 | |
212 | |
213 | if ( sc_pos_soss <= locSCzIntersection && locSCzIntersection <= sc_pos_eoss) |
214 | { |
215 | N_trck_prd_ss[st_pred_id_index] += 1; |
216 | |
217 | for (uint32_t j = 0; j < st_hits.size(); j++) |
218 | { |
219 | int phi_sec_hit_sector = st_hits[j]->sector; |
220 | if (st_pred_id == phi_sec_hit_sector) |
221 | { |
222 | N_recd_hit_ss[st_pred_id_index] += 1; |
223 | break; |
224 | } |
225 | } |
226 | } |
227 | |
228 | |
229 | |
230 | if ( sc_pos_eoss < locSCzIntersection && locSCzIntersection <= sc_pos_eobs) |
231 | { |
232 | N_trck_prd_bs[st_pred_id_index] += 1; |
233 | |
234 | for (uint32_t j = 0; j < st_hits.size(); j++) |
235 | { |
236 | int phi_sec_hit_sector = st_hits[j]->sector; |
237 | if (st_pred_id == phi_sec_hit_sector) |
238 | { |
239 | N_recd_hit_bs[st_pred_id_index] += 1; |
240 | break; |
241 | } |
242 | } |
243 | } |
244 | |
245 | |
246 | |
247 | if ( sc_pos_eobs < locSCzIntersection && locSCzIntersection <= sc_pos_eons) |
248 | { |
249 | N_trck_prd_ns[st_pred_id_index] += 1; |
250 | |
251 | |
252 | for (uint32_t j = 0; j < st_hits.size(); j++) |
253 | { |
254 | int phi_sec_hit_sector = st_hits[j]->sector; |
255 | if (st_pred_id == phi_sec_hit_sector) |
256 | { |
257 | N_recd_hit_ns[st_pred_id_index] += 1; |
258 | break; |
259 | } |
260 | } |
261 | } |
262 | } |
263 | } |
264 | |
265 | japp->RootFillUnLock(this); |
266 | |
267 | return NOERROR; |
268 | } |
269 | |
270 | |
271 | |
272 | |
273 | jerror_t JEventProcessor_ST_online_efficiency::erun(void) |
274 | { |
275 | |
276 | |
277 | |
278 | return NOERROR; |
279 | } |
280 | |
281 | |
282 | |
283 | |
284 | jerror_t JEventProcessor_ST_online_efficiency::fini(void) |
285 | { |
286 | |
287 | for (uint32_t i = 0; i < NCHANNELS; i++) |
288 | { |
289 | |
290 | h_N_trck_prd_All->Fill(i+1,double(N_trck_prd_All[i])); |
291 | h_N_recd_hit_All->Fill(i+1,double(N_recd_hit_All[i])); |
292 | h_N_trck_prd_ss->Fill(i+1,double(N_trck_prd_ss[i])); |
293 | h_N_recd_hit_ss->Fill(i+1,double(N_recd_hit_ss[i])); |
294 | h_N_trck_prd_bs->Fill(i+1,double(N_trck_prd_bs[i])); |
295 | h_N_recd_hit_bs->Fill(i+1,double(N_recd_hit_bs[i])); |
296 | h_N_trck_prd_ns->Fill(i+1,double(N_trck_prd_ns[i])); |
297 | h_N_recd_hit_ns->Fill(i+1,double(N_recd_hit_ns[i])); |
298 | } |
299 | return NOERROR; |
300 | } |
301 | |