Bug Summary

File:plugins/monitoring/PSPair_online/JEventProcessor_PSPair_online.cc
Location:line 284, column 10
Description:Value stored to 'desired_range' during its initialization is never read

Annotated Source Code

1// $Id$
2//
3// File: JEventProcessor_PSPair_online.cc
4// Created: Fri Mar 20 16:32:04 EDT 2015
5// Creator: nsparks (on Linux cua2.jlab.org 2.6.32-431.5.1.el6.x86_64 x86_64)
6//
7#include <iostream>
8#include <sstream>
9#include "JEventProcessor_PSPair_online.h"
10
11using namespace std;
12using namespace jana;
13
14#include <PAIR_SPECTROMETER/DPSCPair.h>
15#include <PAIR_SPECTROMETER/DPSPair.h>
16#include <PAIR_SPECTROMETER/DPSGeometry.h>
17#include <TAGGER/DTAGHHit.h>
18#include <TAGGER/DTAGHGeometry.h>
19#include <TAGGER/DTAGMHit.h>
20#include <TAGGER/DTAGMGeometry.h>
21
22#include <JANA/JApplication.h>
23#include <JANA/JFactory.h>
24#include <TDirectory.h>
25#include <TH1.h>
26#include <TH2.h>
27
28
29const int Narms = DPSGeometry::NUM_ARMS; // 2
30const int NC_PSC = DPSGeometry::NUM_COARSE_COLUMNS; // 8: number of PSC modules (counters) per arm
31const int NC_PS = DPSGeometry::NUM_FINE_COLUMNS; // 145: number of PS columns (tiles) per arm
32const int NC_TAGH = DTAGHGeometry::kCounterCount; // 274: number of TAGH counters
33const int NC_TAGM = DTAGMGeometry::kColumnCount; // 102: number of TAGM columns
34// root hist pointers
35static TH1I *hPSC_NHitPairs;
36static TH1I *hPS_NHitPairs;
37// PSC pairs
38static TH2F *hPSC_PSCIDLeftVsIDRight;
39static TH2I *hPSC_tdiffVsPSCIDLeft[NC_PSC];
40static TH2I *hPSC_tdiffVsPSCIDRight[NC_PSC];
41// PSC,PS pairs
42static TH1I *pspair_num_events;
43static TH2F *hPS_PSCIDLeftVsIDRight;
44static TH2F *hPS_PSIDLeftVsIDRight;
45static TH2F *hPS_ElVsEr;
46static TH1F *hPS_E;
47static TH2F *hPS_timeVsE;
48static TH2I *hPS_PSIDLeftVsPSCIDLeft;
49static TH2I *hPS_PSIDRightVsPSCIDRight;
50static TH2I *hPS_ElVsPSCIDLeft;
51static TH2I *hPS_ErVsPSCIDRight;
52// TAGX occupancies, all hits for events with PSC,PS pairs
53static TH1F *hPS_TAGHCounterID;
54static TH1F *hPS_Etagh;
55static TH2F *hPS_timeVsEtagh;
56static TH1F *hPS_TAGMColumn;
57static TH1F *hPS_Etagm;
58static TH2F *hPS_timeVsEtagm;
59// PSC,PS,TAGH coincidences
60static TH2F *hPSTAGH_tdiffVsEdiff;
61static TH2I *hPSTAGH_EVsEtagh;
62static TH2F *hPSTAGH_PSCIDLeftVsIDRight;
63static TH2F *hPSTAGH_PSIDLeftVsIDRight;
64static TH2F *hPSTAGH_ElVsEr;
65static TH1F *hPSTAGH_E;
66static TH2F *hPSTAGH_timeVsE;
67static TH1F *hPSTAGH_TAGHCounterID;
68static TH1F *hPSTAGH_Etagh;
69static TH2F *hPSTAGH_timeVsEtagh;
70static TH2I *hPSTAGH_EdiffVsTAGHCounterID;
71static TH2I *hPSTAGH_EdiffVsEtagh;
72static TH2I *hPSTAGH_tdiffVsTAGHCounterID_L[NC_PSC];
73static TH2I *hPSTAGH_tdiffVsTAGHCounterID_R[NC_PSC];
74// PSC,PS,TAGM coincidences
75static TH2F *hPSTAGM_tdiffVsEdiff;
76static TH2I *hPSTAGM_EVsEtagm;
77static TH2F *hPSTAGM_PSCIDLeftVsIDRight;
78static TH2F *hPSTAGM_PSIDLeftVsIDRight;
79static TH2F *hPSTAGM_ElVsEr;
80static TH1F *hPSTAGM_E;
81static TH2F *hPSTAGM_timeVsE;
82static TH1F *hPSTAGM_TAGMColumn;
83static TH1F *hPSTAGM_Etagm;
84static TH2F *hPSTAGM_timeVsEtagm;
85static TH2I *hPSTAGM_EdiffVsTAGMColumn;
86static TH2I *hPSTAGM_EdiffVsEtagm;
87static TH2I *hPSTAGM_tdiffVsTAGMColumn_L[NC_PSC];
88static TH2I *hPSTAGM_tdiffVsTAGMColumn_R[NC_PSC];
89//-------------------------
90// Routine used to create our JEventProcessor
91extern "C"{
92 void InitPlugin(JApplication *app){
93 InitJANAPlugin(app);
94 app->AddProcessor(new JEventProcessor_PSPair_online());
95
96 }
97} // "C"
98
99
100//------------------
101// JEventProcessor_PSPair_online (Constructor)
102//------------------
103JEventProcessor_PSPair_online::JEventProcessor_PSPair_online()
104{
105
106}
107
108//------------------
109// ~JEventProcessor_PSPair_online (Destructor)
110//------------------
111JEventProcessor_PSPair_online::~JEventProcessor_PSPair_online()
112{
113
114}
115
116//------------------
117// init
118//------------------
119jerror_t JEventProcessor_PSPair_online::init(void)
120{
121 // energy binning
122 const double Ebw_PS = 0.1;
123 const double Ebl_PS = 5.0; const double Ebl_PSarm = 2.0;
124 const double Ebh_PS = 13.0; const double Ebh_PSarm = 7.0;
125 const int NEb_PS = int((Ebh_PS-Ebl_PS)/Ebw_PS); const int NEb_PSarm = int((Ebh_PSarm-Ebl_PSarm)/Ebw_PS);
126 const double Ebw_TAG = 0.1;
127 const double Ebl_TAG = 2.5;
128 const double Ebh_TAG = 10.5;
129 const int NEb_TAG = int((Ebh_TAG-Ebl_TAG)/Ebw_TAG);
130 // time binning
131 const double Tbw = 0.06;
132 const double Tbl_PS = -4.5;
133 const double Tbh_PS = 4.5;
134 const int NTb_PS = int((Tbh_PS-Tbl_PS)/Tbw);
135 const double Tbl_TAG = -30.0;
136 const double Tbh_TAG = 30.0;
137 const int NTb_TAG = int((Tbh_TAG-Tbl_TAG)/Tbw);
138 //
139 japp->RootWriteLock();
140 // create root folder for pspair and cd to it, store main dir
141 TDirectory *mainDir = gDirectory(TDirectory::CurrentDirectory());
142 TDirectory *psPairDir = gDirectory(TDirectory::CurrentDirectory())->mkdir("PSPair");
143 psPairDir->cd();
144 // book hists
145 pspair_num_events = new TH1I("pspair_num_events","PS pair number of events",1,0.5,1.5);
146 hPSC_NHitPairs = new TH1I("PSC_NHitPairs","PSC pair multiplicity",8,0.5,8.5);
147 hPS_NHitPairs = new TH1I("PS_NHitPairs","PS pair multiplicity",8,0.5,8.5);
148 //
149 gDirectory(TDirectory::CurrentDirectory())->mkdir("PSC")->cd();
150 hPSC_PSCIDLeftVsIDRight = new TH2F("PSC_PSCIDLeftVsIDRight","PSC pair: Coarse PS ID left arm vs. ID right arm;module(right arm);module(left arm)",NC_PSC,0.5,0.5+NC_PSC,NC_PSC,0.5,0.5+NC_PSC);
151 gDirectory(TDirectory::CurrentDirectory())->mkdir("PSCRightArmTimeOffsets")->cd();
152 for (int i=0;i<NC_PSC;i++) {
153 stringstream ss; ss << i+1;
154 TString id = ss.str();
155 TString strN = "_L" + id;
156 hPSC_tdiffVsPSCIDRight[i] = new TH2I("PSC_tdiffVsPSCIDRight"+strN,"PSC pair: TDC time difference vs. right arm module, fixed left arm module "+id+";module(right arm);time(module "+id+", left arm) - time(right arm) [ns]",NC_PSC,0.5,0.5+NC_PSC,NTb_PS,Tbl_PS,Tbh_PS);
157 }
158 gDirectory(TDirectory::CurrentDirectory())->cd("../");
159 gDirectory(TDirectory::CurrentDirectory())->mkdir("PSCLeftArmTimeOffsets")->cd();
160 for (int i=0;i<NC_PSC;i++) {
161 stringstream ss; ss << i+1;
162 TString id = ss.str();
163 TString strN = "_R" + id;
164 hPSC_tdiffVsPSCIDLeft[i] = new TH2I("PSC_tdiffVsPSCIDLeft"+strN,"PSC pair: TDC time difference vs. left arm module, fixed right arm module "+id+";module(left arm);time(left arm) - time(module "+id+", right arm) [ns]",NC_PSC,0.5,0.5+NC_PSC,NTb_PS,Tbl_PS,Tbh_PS);
165 }
166 psPairDir->cd();
167 //
168 gDirectory(TDirectory::CurrentDirectory())->mkdir("PSC_PS")->cd();
169 hPS_PSCIDLeftVsIDRight = new TH2F("PS_PSCIDLeftVsIDRight","PS pair: Coarse PS ID left arm vs. ID right arm;module(right arm);module(left arm)",NC_PSC,0.5,0.5+NC_PSC,NC_PSC,0.5,0.5+NC_PSC);
170 hPS_PSIDLeftVsIDRight = new TH2F("PS_PSIDLeftVsIDRight","PS pair: Fine PS ID left arm vs. ID right arm;column(right arm);column(left arm)",NC_PS,0.5,0.5+NC_PS,NC_PS,0.5,0.5+NC_PS);
171 hPS_ElVsEr = new TH2F("PS_ElVsEr","PS pair: left-arm energy vs. right-arm energy;energy(right arm) [GeV];energy(left arm) [GeV]",NEb_PSarm,Ebl_PSarm,Ebh_PSarm,NEb_PSarm,Ebl_PSarm,Ebh_PSarm);
172 hPS_E = new TH1F("PS_E","PS pair energy;PS pair energy [GeV];events",NEb_PS,Ebl_PS,Ebh_PS);
173 hPS_timeVsE = new TH2F("PS_timeVsE","PSC TDC time, Left arm vs. PS pair energy;PS pair energy [GeV];PSC TDC time, Left arm [ns]",NEb_PS,Ebl_PS,Ebh_PS,NTb_PS,Tbl_PS,Tbh_PS);
174 //
175 hPS_PSIDLeftVsPSCIDLeft = new TH2I("PS_PSIDLeftVsPSCIDLeft","PS pair: Fine PS ID left arm vs. Coarse PS ID left arm;coarse PS module(left arm);fine PS column(left arm)",NC_PSC,0.5,0.5+NC_PSC,NC_PS,0.5,0.5+NC_PS);
176 hPS_PSIDRightVsPSCIDRight = new TH2I("PS_PSIDRightVsPSCIDRight","PS pair: Fine PS ID right arm vs. Coarse PS ID right arm;coarse PS module(right arm);fine PS column(right arm)",NC_PSC,0.5,0.5+NC_PSC,NC_PS,0.5,0.5+NC_PS);
177 hPS_ElVsPSCIDLeft = new TH2I("PS_ElVsPSCIDLeft","PS pair: PS left-arm energy vs. Coarse PS ID left arm;coarse PS module(left arm);PS energy(left arm)",NC_PSC,0.5,0.5+NC_PSC,NEb_PSarm,Ebl_PSarm,Ebh_PSarm);
178 hPS_ErVsPSCIDRight = new TH2I("PS_ErVsPSCIDRight","PS pair: PS right-arm energy vs. Coarse PS ID right arm;coarse PS module(right arm);PS energy(right arm)",NC_PSC,0.5,0.5+NC_PSC,NEb_PSarm,Ebl_PSarm,Ebh_PSarm);
179 //
180 gDirectory(TDirectory::CurrentDirectory())->mkdir("TAGX_AllHits")->cd();
181 hPS_TAGHCounterID = new TH1F("PS_TAGHCounterID","PS pair: TAGH counter ID, all hits;TAGH counter ID;hits",NC_TAGH,0.5,0.5+NC_TAGH);
182 hPS_Etagh = new TH1F("PS_Etagh","PS pair: TAGH photon energy, all hits;TAGH photon energy [GeV];hits",NEb_TAG,Ebl_TAG,Ebh_TAG);
183 hPS_timeVsEtagh = new TH2F("PS_timeVsEtagh","PS pair: TAGH time vs. photon energy, all hits;TAGH photon energy [GeV];time [ns]",NEb_TAG,Ebl_TAG,Ebh_TAG,NTb_TAG,Tbl_TAG,Tbh_TAG);
184 hPS_TAGMColumn = new TH1F("PS_TAGMColumn","PS pair: TAGM column, all hits;TAGM column;hits",NC_TAGM,0.5,0.5+NC_TAGM);
185 hPS_Etagm = new TH1F("PS_Etagm","PS pair: TAGM photon energy, all hits;TAGM photon energy [GeV];hits",NEb_PS,Ebl_PS,Ebh_PS);
186 hPS_timeVsEtagm = new TH2F("PS_timeVsEtagm","PS pair: TAGM time vs. photon energy, all hits;TAGM photon energy [GeV];time [ns]",NEb_PS,Ebl_PS,Ebh_PS,NTb_TAG,Tbl_TAG,Tbh_TAG);
187 psPairDir->cd();
188 //
189 gDirectory(TDirectory::CurrentDirectory())->mkdir("PSC_PS_TAGH")->cd();
190 hPSTAGH_tdiffVsEdiff = new TH2F("PSTAGH_tdiffVsEdiff","PS pair - TAGH: PS-TAGH time difference vs. PS-TAGH energy difference;[E(PS) - E(TAGH)] / E(PS);PSC/TAGH time difference [ns]",80,-0.15,0.15,NTb_TAG,Tbl_TAG,Tbh_TAG);
191 hPSTAGH_TAGHCounterID = new TH1F("PSTAGH_TAGHCounterID","PS pair - TAGH: TAGH counter ID;TAGH counter ID;events",NC_TAGH,0.5,0.5+NC_TAGH);
192 hPSTAGH_Etagh = new TH1F("PSTAGH_Etagh","PS pair - TAGH: TAGH photon energy;TAGH photon energy [GeV];events",NEb_TAG,Ebl_TAG,Ebh_TAG);
193 hPSTAGH_timeVsEtagh = new TH2F("PSTAGH_timeVsEtagh","PS pair - TAGH: TAGH time vs. photon energy;TAGH photon energy [GeV];time [ns]",NEb_TAG,Ebl_TAG,Ebh_TAG,NTb_TAG,Tbl_TAG,Tbh_TAG);
194 hPSTAGH_EVsEtagh = new TH2I("PSTAGH_EVsEtagh","PS pair - TAGH: PS energy vs. TAGH energy;TAGH energy [GeV];PS energy [GeV]",NEb_PS,Ebl_PS,Ebh_PS,NEb_PS,Ebl_PS,Ebh_PS);
195 hPSTAGH_EdiffVsEtagh = new TH2I("PSTAGH_EdiffVsEtagh","PS pair - TAGH: PS-TAGH energy difference vs. TAGH energy;TAGH energy [GeV];[E(PS) - E(TAGH)] / E(PS)",NEb_TAG,Ebl_TAG,Ebh_TAG,80,-0.15,0.15);
196 hPSTAGH_EdiffVsTAGHCounterID = new TH2I("PSTAGH_EdiffVsTAGHCounterID","PS pair - TAGH: PS-TAGH energy difference vs. TAGH counter ID;TAGH counter ID;[E(PS) - E(TAGH)] / E(PS)",NC_TAGH,0.5,0.5+NC_TAGH,80,-0.15,0.15);
197 hPSTAGH_PSCIDLeftVsIDRight = new TH2F("PSTAGH_PSCIDLeftVsIDRight","PS pair - TAGH: Coarse PS ID left arm vs. ID right arm;module(right arm);module(left arm)",NC_PSC,0.5,0.5+NC_PSC,NC_PSC,0.5,0.5+NC_PSC);
198 hPSTAGH_PSIDLeftVsIDRight = new TH2F("PSTAGH_PSIDLeftVsIDRight","PS pair - TAGH: Fine PS ID left arm vs. ID right arm;column(right arm);column(left arm)",NC_PS,0.5,0.5+NC_PS,NC_PS,0.5,0.5+NC_PS);
199 hPSTAGH_ElVsEr = new TH2F("PSTAGH_ElVsEr","PS pair - TAGH: left-arm energy vs. right-arm energy;energy(right arm) [GeV];energy(left arm) [GeV]",NEb_PSarm,Ebl_PSarm,Ebh_PSarm,NEb_PSarm,Ebl_PSarm,Ebh_PSarm);
200 hPSTAGH_E = new TH1F("PSTAGH_E","PS pair - TAGH: PS pair energy;PS pair energy [GeV];events",NEb_PS,Ebl_PS,Ebh_PS);
201 hPSTAGH_timeVsE = new TH2F("PSTAGH_timeVsE","PSC/TAGH time difference vs. PS pair energy;PS pair energy [GeV];PSC/TAGH time difference [ns]",NEb_PS,Ebl_PS,Ebh_PS,NTb_TAG,Tbl_TAG,Tbh_TAG);
202 gDirectory(TDirectory::CurrentDirectory())->mkdir("PSTAGHTimeOffsets_L")->cd();
203 for (int i=0; i<NC_PSC; i++) {
204 stringstream ss; ss << i+1;
205 TString id = ss.str();
206 hPSTAGH_tdiffVsTAGHCounterID_L[i] = new TH2I("PSTAGH_tdiffVsTAGHCounterID_L"+id,"PS-TAGH TDC time difference vs. TAGH counter ID, fixed left arm PSC module "+id+";TAGH counter ID;time(PSC module "+id+", left arm) - time(TAGH) [ns]",NC_TAGH,0.5,0.5+NC_TAGH,NTb_TAG,Tbl_TAG,Tbh_TAG);
207 }
208 gDirectory(TDirectory::CurrentDirectory())->cd("../");
209 gDirectory(TDirectory::CurrentDirectory())->mkdir("PSTAGHTimeOffsets_R")->cd();
210 for (int i=0; i<NC_PSC; i++) {
211 stringstream ss; ss << i+1;
212 TString id = ss.str();
213 hPSTAGH_tdiffVsTAGHCounterID_R[i] = new TH2I("PSTAGH_tdiffVsTAGHCounterID_R"+id,"PS-TAGH TDC time difference vs. TAGH counter ID, fixed right arm PSC module "+id+";TAGH counter ID;time(PSC module "+id+", right arm) - time(TAGH) [ns]",NC_TAGH,0.5,0.5+NC_TAGH,NTb_TAG,Tbl_TAG,Tbh_TAG);
214 }
215 psPairDir->cd();
216 //
217 gDirectory(TDirectory::CurrentDirectory())->mkdir("PSC_PS_TAGM")->cd();
218 hPSTAGM_tdiffVsEdiff = new TH2F("PSTAGM_tdiffVsEdiff","PS pair - TAGM: PS-TAGM time difference vs. PS-TAGM energy difference;[E(PS) - E(TAGM)] / E(PS);PSC/TAGM time difference [ns]",80,-0.15,0.15,NTb_TAG,Tbl_TAG,Tbh_TAG);
219 hPSTAGM_TAGMColumn = new TH1F("PSTAGM_TAGMColumn","PS pair - TAGM: TAGM column;TAGM column;events",NC_TAGM,0.5,0.5+NC_TAGM);
220 hPSTAGM_Etagm = new TH1F("PSTAGM_Etagm","PS pair - TAGM: TAGM photon energy;TAGM photon energy [GeV];events",NEb_PS,Ebl_PS,Ebh_PS);
221 hPSTAGM_timeVsEtagm = new TH2F("PSTAGM_timeVsEtagm","PS pair - TAGM: TAGM time vs. photon energy;TAGM photon energy [GeV];time [ns]",NEb_PS,Ebl_PS,Ebh_PS,NTb_TAG,Tbl_TAG,Tbh_TAG);
222 hPSTAGM_EVsEtagm = new TH2I("PSTAGM_EVsEtagm","PS pair - TAGM: PS energy vs. TAGM energy;TAGM energy [GeV];PS energy [GeV]",NEb_PS,Ebl_PS,Ebh_PS,NEb_PS,Ebl_PS,Ebh_PS);
223 hPSTAGM_EdiffVsEtagm = new TH2I("PSTAGM_EdiffVsEtagm","PS pair - TAGM: PS-TAGM energy difference vs. TAGM energy;TAGM energy [GeV];[E(PS) - E(TAGM)] / E(PS)",NEb_PS,Ebl_PS,Ebh_PS,80,-0.15,0.15);
224 hPSTAGM_EdiffVsTAGMColumn = new TH2I("PSTAGM_EdiffVsTAGMColumn","PS pair - TAGM: PS-TAGM energy difference vs. TAGM column;TAGM column;[E(PS) - E(TAGM)] / E(PS)",NC_TAGM,0.5,0.5+NC_TAGM,80,-0.15,0.15);
225 hPSTAGM_PSCIDLeftVsIDRight = new TH2F("PSTAGM_PSCIDLeftVsIDRight","PS pair - TAGM: Coarse PS ID left arm vs. ID right arm;module(right arm);module(left arm)",NC_PSC,0.5,0.5+NC_PSC,NC_PSC,0.5,0.5+NC_PSC);
226 hPSTAGM_PSIDLeftVsIDRight = new TH2F("PSTAGM_PSIDLeftVsIDRight","PS pair - TAGM: Fine PS ID left arm vs. ID right arm;column(right arm);column(left arm)",NC_PS,0.5,0.5+NC_PS,NC_PS,0.5,0.5+NC_PS);
227 hPSTAGM_ElVsEr = new TH2F("PSTAGM_ElVsEr","PS pair - TAGM: left-arm energy vs. right-arm energy;energy(right arm) [GeV];energy(left arm) [GeV]",NEb_PSarm,Ebl_PSarm,Ebh_PSarm,NEb_PSarm,Ebl_PSarm,Ebh_PSarm);
228 hPSTAGM_E = new TH1F("PSTAGM_E","PS pair - TAGM: PS pair energy;PS pair energy [GeV];events",NEb_PS,Ebl_PS,Ebh_PS);
229 hPSTAGM_timeVsE = new TH2F("PSTAGM_timeVsE","PSC/TAGM time difference vs. PS pair energy;PS pair energy [GeV];PSC/TAGM time difference [ns]",NEb_PS,Ebl_PS,Ebh_PS,NTb_TAG,Tbl_TAG,Tbh_TAG);
230 gDirectory(TDirectory::CurrentDirectory())->mkdir("PSTAGMTimeOffsets_L")->cd();
231 for (int i=0; i<NC_PSC; i++) {
232 stringstream ss; ss << i+1;
233 TString id = ss.str();
234 hPSTAGM_tdiffVsTAGMColumn_L[i] = new TH2I("PSTAGM_tdiffVsTAGMColumn_L"+id,"PS-TAGM TDC time difference vs. TAGM column, fixed left arm PSC module "+id+";TAGM column;time(PSC module "+id+", left arm) - time(TAGM) [ns]",NC_TAGM,0.5,0.5+NC_TAGM,NTb_TAG,Tbl_TAG,Tbh_TAG);
235 }
236 gDirectory(TDirectory::CurrentDirectory())->cd("../");
237 gDirectory(TDirectory::CurrentDirectory())->mkdir("PSTAGMTimeOffsets_R")->cd();
238 for (int i=0; i<NC_PSC; i++) {
239 stringstream ss; ss << i+1;
240 TString id = ss.str();
241 hPSTAGM_tdiffVsTAGMColumn_R[i] = new TH2I("PSTAGM_tdiffVsTAGMColumn_R"+id,"PS-TAGM TDC time difference vs. TAGM column, fixed right arm PSC module "+id+";TAGM column;time(PSC module "+id+", right arm) - time(TAGM) [ns]",NC_TAGM,0.5,0.5+NC_TAGM,NTb_TAG,Tbl_TAG,Tbh_TAG);
242 }
243 // back to main dir
244 mainDir->cd();
245
246 japp->RootUnLock();
247
248 return NOERROR;
249}
250
251//------------------
252// brun
253//------------------
254jerror_t JEventProcessor_PSPair_online::brun(JEventLoop *eventLoop, int32_t runnumber)
255{
256 // This is called whenever the run number changes
257 // extract the PS geometry
258 vector<const DPSGeometry*> psGeomVect;
259 eventLoop->Get(psGeomVect);
260 if (psGeomVect.size() < 1)
261 return OBJECT_NOT_AVAILABLE;
262 const DPSGeometry& psGeom = *(psGeomVect[0]);
263 // get photon energy bin lows for variable-width energy binning
264 double Elows_PSarm[Narms][NC_PS+1];
265 double wl_min=0.05,wr_min = 0.05;
266 for (int i=0;i<NC_PS;i++) {
267 Elows_PSarm[0][i] = psGeom.getElow(0,i+1);
268 Elows_PSarm[1][i] = psGeom.getElow(1,i+1);
269 // find smallest bin widths to use for PS pair energy binning
270 double wl = psGeom.getEhigh(0,i+1) - psGeom.getElow(0,i+1);
271 double wr = psGeom.getEhigh(1,i+1) - psGeom.getElow(1,i+1);
272 if (wl<wl_min) wl_min = wl;
273 if (wr<wr_min) wr_min = wr;
274 }
275 // add the upper limits
276 Elows_PSarm[0][NC_PS] = psGeom.getEhigh(0,NC_PS);
277 Elows_PSarm[1][NC_PS] = psGeom.getEhigh(1,NC_PS);
278 // PS pair energy binning
279 double Ebw_PS = wl_min + wr_min;
280 const double Ebl_PS = psGeom.getElow(0,1) + psGeom.getElow(1,1);
281 double Ebh_PS = psGeom.getEhigh(0,NC_PS) + psGeom.getEhigh(1,NC_PS);
282 double range = Ebh_PS-Ebl_PS;
283 int NEb_PS = range/Ebw_PS-int(range/Ebw_PS) < 0.5 ? int(range/Ebw_PS) : int(range/Ebw_PS) + 1;
284 double desired_range = NEb_PS*Ebw_PS;
Value stored to 'desired_range' during its initialization is never read
285// Ebh_PS = Ebl_PS + desired_range; // tweak the upper limit to obtain the desired constant bin width
286 double Elows_PS[NEb_PS+1];
287 for (int i=0;i<NEb_PS+1;i++) {
288 Elows_PS[i] = Ebl_PS + i*Ebw_PS;
289 }
290 // extract the TAGH geometry
291 vector<const DTAGHGeometry*> taghGeomVect;
292 eventLoop->Get(taghGeomVect);
293 if (taghGeomVect.size() < 1)
294 return OBJECT_NOT_AVAILABLE;
295 const DTAGHGeometry& taghGeom = *(taghGeomVect[0]);
296 // get photon energy bin low of each counter for energy histogram binning
297 double Elows_TAGH[NC_TAGH+1];
298 for (int i=0;i<NC_TAGH;i++) {
299 Elows_TAGH[i] = taghGeom.getElow(NC_TAGH-i);
300 }
301 // add the upper limit
302 Elows_TAGH[NC_TAGH] = taghGeom.getEhigh(1);
303 // extract the TAGM geometry
304 vector<const DTAGMGeometry*> tagmGeomVect;
305 eventLoop->Get(tagmGeomVect);
306 if (tagmGeomVect.size() < 1)
307 return OBJECT_NOT_AVAILABLE;
308 const DTAGMGeometry& tagmGeom = *(tagmGeomVect[0]);
309 // get photon energy bin low of each counter for energy histogram binning
310 double Elows_TAGM[NC_TAGM+1];
311 for (int i=0;i<NC_TAGM;i++) {
312 Elows_TAGM[i] = tagmGeom.getElow(NC_TAGM-i);
313 }
314 // add the upper limit
315 Elows_TAGM[NC_TAGM] = tagmGeom.getEhigh(1);
316 //
317 const int NEdiff = 80;
318 double EdiffLows[NEdiff+1];
319 for (int i=0;i<NEdiff+1;i++) {
320 EdiffLows[i] = -0.15 + i*0.00375;
321 }
322 double modules[NC_PSC+1];
323 for (int i=0;i<=NC_PSC;i++) {
324 modules[i] = 0.5+i;
325 }
326 const int NTb = 2000;
327 double Tlows[NTb+1];
328 for (int i=0;i<=NTb;i++) {
329 Tlows[i] = -400.0+i*0.4;
330 }
331 japp->RootWriteLock(); //ACQUIRE ROOT LOCK!!
332 // set variable-width energy bins if histogram is empty
333 // PS
334 if (hPS_ElVsEr->GetEntries()==0) hPS_ElVsEr->SetBins(NC_PS,Elows_PSarm[1],NC_PS,Elows_PSarm[0]);
335 if (hPS_ElVsPSCIDLeft->GetEntries()==0) hPS_ElVsPSCIDLeft->SetBins(NC_PSC,modules,NC_PS,Elows_PSarm[0]);
336 if (hPS_ErVsPSCIDRight->GetEntries()==0) hPS_ErVsPSCIDRight->SetBins(NC_PSC,modules,NC_PS,Elows_PSarm[1]);
337 if (hPSTAGH_ElVsEr->GetEntries()==0) hPSTAGH_ElVsEr->SetBins(NC_PS,Elows_PSarm[1],NC_PS,Elows_PSarm[0]);
338 if (hPSTAGM_ElVsEr->GetEntries()==0) hPSTAGM_ElVsEr->SetBins(NC_PS,Elows_PSarm[1],NC_PS,Elows_PSarm[0]);
339 if (hPS_E->GetEntries()==0) hPS_E->SetBins(NEb_PS,Elows_PS);
340 if (hPSTAGH_E->GetEntries()==0) hPSTAGH_E->SetBins(NEb_PS,Elows_PS);
341 if (hPSTAGM_E->GetEntries()==0) hPSTAGM_E->SetBins(NEb_PS,Elows_PS);
342 if (hPS_timeVsE->GetEntries()==0) hPS_timeVsE->SetBins(NEb_PS,Elows_PS,NTb,Tlows);
343 if (hPSTAGH_timeVsE->GetEntries()==0) hPSTAGH_timeVsE->SetBins(NEb_PS,Elows_PS,NTb,Tlows);
344 if (hPSTAGM_timeVsE->GetEntries()==0) hPSTAGM_timeVsE->SetBins(NEb_PS,Elows_PS,NTb,Tlows);
345 // TAGH
346 if (hPS_Etagh->GetEntries()==0) hPS_Etagh->SetBins(NC_TAGH,Elows_TAGH);
347 if (hPS_timeVsEtagh->GetEntries()==0) hPS_timeVsEtagh->SetBins(NC_TAGH,Elows_TAGH,NTb,Tlows);
348 if (hPSTAGH_Etagh->GetEntries()==0) hPSTAGH_Etagh->SetBins(NC_TAGH,Elows_TAGH);
349 if (hPSTAGH_EVsEtagh->GetEntries()==0) hPSTAGH_EVsEtagh->SetBins(NC_TAGH,Elows_TAGH,NEb_PS,Elows_PS);
350 if (hPSTAGH_timeVsEtagh->GetEntries()==0) hPSTAGH_timeVsEtagh->SetBins(NC_TAGH,Elows_TAGH,NTb,Tlows);
351 if (hPSTAGH_EdiffVsEtagh->GetEntries()==0) hPSTAGH_EdiffVsEtagh->SetBins(NC_TAGH,Elows_TAGH,NEdiff,EdiffLows);
352 // TAGM
353 if (hPS_Etagm->GetEntries()==0) hPS_Etagm->SetBins(NC_TAGM,Elows_TAGM);
354 if (hPS_timeVsEtagm->GetEntries()==0) hPS_timeVsEtagm->SetBins(NC_TAGM,Elows_TAGM,NTb,Tlows);
355 if (hPSTAGM_Etagm->GetEntries()==0) hPSTAGM_Etagm->SetBins(NC_TAGM,Elows_TAGM);
356 if (hPSTAGM_EVsEtagm->GetEntries()==0) hPSTAGM_EVsEtagm->SetBins(NC_TAGM,Elows_TAGM,NEb_PS,Elows_PS);
357 if (hPSTAGM_timeVsEtagm->GetEntries()==0) hPSTAGM_timeVsEtagm->SetBins(NC_TAGM,Elows_TAGM,NTb,Tlows);
358 if (hPSTAGM_EdiffVsEtagm->GetEntries()==0) hPSTAGM_EdiffVsEtagm->SetBins(NC_TAGM,Elows_TAGM,NEdiff,EdiffLows);
359 japp->RootUnLock(); //RELEASE ROOT LOCK!!
360 //
361 return NOERROR;
362}
363
364//------------------
365// evnt
366//------------------
367jerror_t JEventProcessor_PSPair_online::evnt(JEventLoop *loop, uint64_t eventnumber)
368{
369 // This is called for every event. Use of common resources like writing
370 // to a file or filling a histogram should be mutex protected. Using
371 // loop->Get(...) to get reconstructed objects (and thereby activating the
372 // reconstruction algorithm) should be done outside of any mutex lock
373 // since multiple threads may call this method at the same time.
374 // coarse PS pairs
375 vector<const DPSCPair*> cpairs;
376 loop->Get(cpairs);
377 // fine PS pairs
378 vector<const DPSPair*> fpairs;
379 loop->Get(fpairs);
380 // tagger hits
381 vector<const DTAGHHit*> taghhits;
382 loop->Get(taghhits);
383 vector<const DTAGMHit*> tagmhits;
384 loop->Get(tagmhits);
385 //
386 japp->RootWriteLock();
387 hPSC_NHitPairs->Fill(cpairs.size());
388 hPS_NHitPairs->Fill(fpairs.size());
389 // PSC coincidences
390 if (cpairs.size()>=1) {
391 // take pair with smallest time difference from sorted vector
392 const DPSCHit* clhit = cpairs[0]->ee.first; // left hit in coarse PS
393 const DPSCHit* crhit = cpairs[0]->ee.second;// right hit in coarse PS
394 hPSC_PSCIDLeftVsIDRight->Fill(crhit->module,clhit->module);
395 hPSC_tdiffVsPSCIDRight[clhit->module-1]->Fill(crhit->module,clhit->t-crhit->t);
396 hPSC_tdiffVsPSCIDLeft[crhit->module-1]->Fill(clhit->module,clhit->t-crhit->t);
397 // PSC,PS coincidences
398 if (fpairs.size()>=1) {
399 pspair_num_events->Fill(1);
400 // take pair with smallest time difference from sorted vector
401 const DPSHit* flhit = fpairs[0]->ee.first; // left hit in fine PS
402 const DPSHit* frhit = fpairs[0]->ee.second; // right hit in fine PS
403 double E_pair = flhit->E+frhit->E;
404 hPS_PSCIDLeftVsIDRight->Fill(crhit->module,clhit->module);
405 hPS_PSIDLeftVsIDRight->Fill(frhit->column,flhit->column);
406 hPS_ElVsEr->Fill(frhit->E,flhit->E);
407 hPS_E->Fill(E_pair);
408 hPS_timeVsE->Fill(E_pair,clhit->t);
409 // correlation between PSC and PS ids for each arm
410 hPS_PSIDLeftVsPSCIDLeft->Fill(clhit->module,flhit->column);
411 hPS_PSIDRightVsPSCIDRight->Fill(crhit->module,frhit->column);
412 hPS_ElVsPSCIDLeft->Fill(clhit->module,flhit->E);
413 hPS_ErVsPSCIDRight->Fill(crhit->module,frhit->E);
414 // PSC,PS,TAGH coincidences
415 double EdiffMax = 0.15; // max percent difference of tagger hit and pair energies
416 for (unsigned int i=0; i < taghhits.size(); i++) {
417 const DTAGHHit* tag = taghhits[i];
418 if (!tag->has_TDC||!tag->has_fADC) continue;
419 hPS_TAGHCounterID->Fill(tag->counter_id);
420 hPS_Etagh->Fill(tag->E);
421 hPS_timeVsEtagh->Fill(tag->E,tag->t);
422 hPSTAGH_tdiffVsEdiff->Fill((E_pair-tag->E)/E_pair,clhit->t-tag->t);
423 if (fabs(E_pair-tag->E)/E_pair > EdiffMax) continue; // loose cut on energy difference
424 hPSTAGH_TAGHCounterID->Fill(tag->counter_id);
425 hPSTAGH_Etagh->Fill(tag->E);
426 hPSTAGH_timeVsEtagh->Fill(tag->E,tag->t);
427 hPSTAGH_EVsEtagh->Fill(tag->E,E_pair);
428 hPSTAGH_EdiffVsEtagh->Fill(tag->E,(E_pair-tag->E)/E_pair);
429 hPSTAGH_EdiffVsTAGHCounterID->Fill(tag->counter_id,(E_pair-tag->E)/E_pair);
430 hPSTAGH_tdiffVsTAGHCounterID_L[clhit->module-1]->Fill(tag->counter_id,clhit->t-tag->t);
431 hPSTAGH_tdiffVsTAGHCounterID_R[crhit->module-1]->Fill(tag->counter_id,crhit->t-tag->t);
432 hPSTAGH_PSCIDLeftVsIDRight->Fill(crhit->module,clhit->module);
433 hPSTAGH_PSIDLeftVsIDRight->Fill(frhit->column,flhit->column);
434 hPSTAGH_ElVsEr->Fill(frhit->E,flhit->E);
435 hPSTAGH_E->Fill(E_pair);
436 hPSTAGH_timeVsE->Fill(E_pair,clhit->t-tag->t);
437 }
438 // PSC,PS,TAGM coincidences
439 for (unsigned int i=0; i < tagmhits.size(); i++) {
440 const DTAGMHit* tag = tagmhits[i];
441 if (!tag->has_TDC||!tag->has_fADC) continue;
442 if (tag->row!=0) continue;
443 hPS_TAGMColumn->Fill(tag->column);
444 hPS_Etagm->Fill(tag->E);
445 hPS_timeVsEtagm->Fill(tag->E,tag->t);
446 hPSTAGM_tdiffVsEdiff->Fill((E_pair-tag->E)/E_pair,clhit->t-tag->t);
447 if (fabs(E_pair-tag->E)/E_pair > EdiffMax) continue; // loose cut on energy difference
448 hPSTAGM_TAGMColumn->Fill(tag->column);
449 hPSTAGM_Etagm->Fill(tag->E);
450 hPSTAGM_timeVsEtagm->Fill(tag->E,tag->t);
451 hPSTAGM_EVsEtagm->Fill(tag->E,E_pair);
452 hPSTAGM_EdiffVsEtagm->Fill(tag->E,(E_pair-tag->E)/E_pair);
453 hPSTAGM_EdiffVsTAGMColumn->Fill(tag->column,(E_pair-tag->E)/E_pair);
454 hPSTAGM_tdiffVsTAGMColumn_L[clhit->module-1]->Fill(tag->column,clhit->t-tag->t);
455 hPSTAGM_tdiffVsTAGMColumn_R[crhit->module-1]->Fill(tag->column,crhit->t-tag->t);
456 hPSTAGM_PSCIDLeftVsIDRight->Fill(crhit->module,clhit->module);
457 hPSTAGM_PSIDLeftVsIDRight->Fill(frhit->column,flhit->column);
458 hPSTAGM_ElVsEr->Fill(frhit->E,flhit->E);
459 hPSTAGM_E->Fill(E_pair);
460 hPSTAGM_timeVsE->Fill(E_pair,clhit->t-tag->t);
461 }
462 }
463 }
464 //
465 japp->RootUnLock();
466
467 return NOERROR;
468}
469
470//------------------
471// erun
472//------------------
473jerror_t JEventProcessor_PSPair_online::erun(void)
474{
475 // This is called whenever the run number changes, before it is
476 // changed to give you a chance to clean up before processing
477 // events from the next run number.
478 return NOERROR;
479}
480
481//------------------
482// fini
483//------------------
484jerror_t JEventProcessor_PSPair_online::fini(void)
485{
486 // Called before program exit after event processing is finished.
487 return NOERROR;
488}
489