Hall C ROOT/C++ Analyzer (hcana)
Loading...
Searching...
No Matches
THcCoinTime.cxx
Go to the documentation of this file.
1
10#include "THaEvData.h"
11#include "THaCutList.h"
12#include "VarDef.h"
13#include "VarType.h"
14#include "TClonesArray.h"
15
16#include <cstring>
17#include <cstdio>
18#include <cstdlib>
19#include <iostream>
20
21#include "THcCoinTime.h"
22#include "THcTrigDet.h"
23#include "THaApparatus.h"
24#include "THcHodoHit.h"
25#include "THcGlobals.h"
26#include "THcParmList.h"
27
28using namespace std;
29
30//_____________________________________________________________________________
31THcCoinTime::THcCoinTime (const char *name, const char* description, const char* hadArmName,
32 const char* elecArmName, const char* coinname) :
33
34 THaPhysicsModule(name, description),
35 fCoinDetName(coinname),
36 fhadArmName(hadArmName), //initialize spectro names
37 felecArmName(elecArmName),
38 fhadSpectro(NULL), //initialize spectro objects
39 felecSpectro(NULL),
40 fCoinDet(NULL)
41{
42
43}
44
45//_____________________________________________________________________________
47{
48 //Destructor
49
51
52}
53//_____________________________________________________________________________
78
79//_____________________________________________________________________________
81// Clear event-by-event data
82{
83 Clear(opt);
84}
85
86
87//_____________________________________________________________________________
89{
90 // Initialize THcCoinTime physics module
91
92 cout << "*************************************************" << endl;
93 cout << "Initializing THcCointTime Physics Modue" << endl;
94 cout << "Hadron Arm -------> " << fhadArmName << endl;
95 cout << "Electron Arm -------> " << felecArmName << endl;
96 cout << "TrigDet -------> " << fCoinDetName << endl;
97 cout << "**************************************************" << endl;
98
99 fStatus = kOK;
100
101 fhadSpectro = dynamic_cast<THcHallCSpectrometer*>
102 ( FindModule( fhadArmName.Data(), "THcHallCSpectrometer"));
103 if( !fhadSpectro ) {
104 cout << "THcCoinTime module Cannnot find Hadron Arm = " << fhadArmName.Data() << endl;
106 return fStatus;
107 }
108
109 felecSpectro = dynamic_cast<THcHallCSpectrometer*>
110 ( FindModule( felecArmName.Data(), "THcHallCSpectrometer"));
111 if( !felecSpectro ) {
112 cout << "THcCoinTime module Cannnot find Electron Arm = " << felecArmName.Data() << endl;
114 return fStatus;
115 }
116
117 fCoinDet = dynamic_cast<THcTrigDet*>
118 ( FindModule( fCoinDetName.Data(), "THcTrigDet"));
119 if( !fCoinDet ) {
120 cout << "THcCoinTime module Cannnot find TrigDet = " << fCoinDetName.Data() << endl;
122 return fStatus;
123 }
124
125 if( (fStatus=THaPhysicsModule::Init( run_time )) != kOK ) {
126 return fStatus;
127 }
128
129 return fStatus;
130}
131
132//_____________________________________________________________________________
134{
135 // Read database. Gets variable needed for CoinTime calculation
136 DBRequest list[]={
137 {"eHadCoinTime_Offset", &eHad_CT_Offset, kDouble, 0, 1}, //coin time offset for ep coincidences
138
139 {"HMS_CentralPathLen", &HMScentralPathLen, kDouble, 0, 1},
140 {"SHMS_CentralPathLen", &SHMScentralPathLen, kDouble, 0, 1},
141 {0}
142 };
143
144 //Default values if not read from param file
145 eHad_CT_Offset = 0.0;
146
147 HMScentralPathLen = 22.0*100.;
148 SHMScentralPathLen = 18.1*100.;
149
150 gHcParms->LoadParmValues((DBRequest*)&list, "");
151
152 return kOK;
153}
154
155//_____________________________________________________________________________
157{
158
159 if( mode == kDefine && fIsSetup ) return kOK;
160 fIsSetup = ( mode == kDefine );
161
162 const RVarDef vars[] = {
163 {"epCoinTime_ROC1", "ROC1 Corrected ep Coincidence Time", "fROC1_epCoinTime"},
164 {"epCoinTime_ROC2", "ROC2 Corrected ep Coincidence Time", "fROC2_epCoinTime"},
165 {"epCoinTime_SHMS", "SHMS Corrected ep Coincidence Time", "fSHMS_epCoinTime"},
166 {"epCoinTime_HMS", "HMS Corrected ep Coincidence Time", "fHMS_epCoinTime"},
167
168 {"eKCoinTime_ROC1", "ROC1 Corrected eK Coincidence Time", "fROC1_eKCoinTime"},
169 {"eKCoinTime_ROC2", "ROC2 Corrected eK Coincidence Time", "fROC2_eKCoinTime"},
170 {"eKCoinTime_SHMS", "SHMS Corrected eK Coincidence Time", "fSHMS_eKCoinTime"},
171 {"eKCoinTime_HMS", "HMS Corrected eK Coincidence Time", "fHMS_eKCoinTime"},
172
173 {"ePiCoinTime_ROC1", "ROC1 Corrected ePi Coincidence Time", "fROC1_ePiCoinTime"},
174 {"ePiCoinTime_ROC2", "ROC2 Corrected ePi Coincidence Time", "fROC2_ePiCoinTime"},
175 {"ePiCoinTime_SHMS", "SHMS Corrected ePi Coincidence Time", "fSHMS_ePiCoinTime"},
176 {"ePiCoinTime_HMS", "HMS Corrected ePi Coincidence Time", "fHMS_ePiCoinTime"},
177
178 {"ePositronCoinTime_ROC1", "ROC1 Corrected e-Positorn Coincidence Time", "fROC1_ePosCoinTime"},
179 {"ePositronCoinTime_ROC2", "ROC2 Corrected e-Positron Coincidence Time", "fROC2_ePosCoinTime"},
180 {"ePositronCoinTime_SHMS", "SHMS Corrected e-Positorn Coincidence Time", "fSHMS_ePosCoinTime"},
181 {"ePositronCoinTime_HMS", "HMS Corrected e-Positron Coincidence Time", "fHMS_ePosCoinTime"},
182
183 {"CoinTime_RAW_ROC1", "ROC1 RAW Coincidence Time", "fROC1_RAW_CoinTime"},
184 {"CoinTime_RAW_ROC2", "ROC2 RAW Coincidence Time", "fROC2_RAW_CoinTime"},
185 {"CoinTime_RAW_SHMS", "SHMS RAW Coincidence Time", "fSHMS_RAW_CoinTime"},
186 {"CoinTime_RAW_HMS", "HMS RAW Coincidence Time", "fHMS_RAW_CoinTime"},
187 {"CoinTime_RAW_ROC1_NoTrack", "ROC1 RAW Coincidence Time w/o Tracked Param", "fROC1_RAW_CoinTime_NoTrack"},
188 {"CoinTime_RAW_ROC2_NoTrack", "ROC2 RAW Coincidence Time w/o Tracked Param", "fROC2_RAW_CoinTime_NoTrack"},
189 {"CoinTime_RAW_SHMS_NoTrack", "SHMS RAW Coincidence Time w/o Tracked Param", "fSHMS_RAW_CoinTime_NoTrack"},
190 {"CoinTime_RAW_HMS_NoTrack", "HMS RAW Coincidence Time w/o Tracked Param", "fHMS_RAW_CoinTime_NoTrack"},
191 {"DeltaSHMSPathLength","DeltaSHMSpathLength (cm)","DeltaSHMSpathLength"},
192 {"DeltaHMSPathLength", "DeltaHMSpathLength (cm)","DeltaHMSpathLength"},
193 {"had_coinCorr_Positron", "", "had_coinCorr_Positron"},
194 {"elec_coinCorr", "", "elec_coinCorr"},
195
196 { 0 }
197 };
198
199 return DefineVarsFromList( vars, mode );
200
201}
202
203//_____________________________________________________________________________
205{
206
207 if( !IsOK() || !gHaRun ) return -1;
208
209 //Declare track information objects for hadron/electron arm
210 THaTrackInfo* had_trkifo = fhadSpectro->GetTrackInfo();
211 THaTrackInfo* elec_trkifo = felecSpectro->GetTrackInfo();
212
213 if( !had_trkifo) cout << " no hadron track " << endl;
214 if( !elec_trkifo) cout << " no electron track " << endl;
215 //Check if the hadron/electron arm had a track
216 if( !had_trkifo || !had_trkifo->IsOK() ) return 1;
217 if( !elec_trkifo || !elec_trkifo->IsOK() ) return 1;
218
219 //Create THaTrack object for hadron/elec arms to get relevant golden track quantities
220 if (felecArmName=="H") {
223 } else{
226 }
227 //Gather relevant variables for Coincidence time calculation
228 lightSpeed = 29.9792; // in cm/ns
229
232 //Particle Masses (HardCoded)
233 elecMass = 0.510998/1000.0; // electron mass in GeV/c^2
234 positronMass = 0.510998/1000.0;
235 protonMass = 938.27208/1000.0; // proton mass in GeV/c^2
236 kaonMass = 493.677/1000.0; //charged kaon mass in GeV/c^2
237 pionMass = 139.570/1000.0; //charged pion mass in GeV/c^2
238
239 //Check if there was a golden track in both arms
240 if (!theSHMSTrack || !theHMSTrack)
241 {
242 return 1;
243 }
244
245 //Check if Database is reading the correct elec-arm particle mass
246 if (felecSpectro->GetParticleMass() > 0.00052) {
247 cout << "ERROR CHECK PARTICLE MASS IN STANDARD.KINEMATICS ! ! !" << endl;
248 return 1;
249 }
250
251 //SHMS arm
252 Double_t shms_xptar = theSHMSTrack->GetTTheta();
253 Double_t shms_dP = theSHMSTrack->GetDp();
254 Double_t SHMS_FPtime = theSHMSTrack->GetFPTime();
255
256 //HMS arm
257 Double_t hms_xptar = theHMSTrack->GetTTheta();
258 Double_t hms_dP = theHMSTrack->GetDp();
259 Double_t hms_xfp = theHMSTrack->GetX();
260 Double_t hms_xpfp = theHMSTrack->GetTheta();
261 Double_t hms_ypfp = theHMSTrack->GetPhi();
262 Double_t HMS_FPtime = theHMSTrack->GetFPTime();
263
264 if (SHMS_FPtime==-2000 || HMS_FPtime==-2000) return 1;
265 if (SHMS_FPtime==-1000 || HMS_FPtime==-1000) return 1;
266
267 //Get raw TDC Times for HMS/SHMS (3/4 trigger)
272
273 DeltaSHMSpathLength = .11*shms_xptar*1000 +0.057*shms_dP/100.;
274 DeltaHMSpathLength = -1.0*(12.462*hms_xpfp + 0.1138*hms_xpfp*hms_xfp - 0.0154*hms_xfp - 72.292*hms_xpfp*hms_xpfp - 0.0000544*hms_xfp*had_xfp - 116.52*hms_ypfp*hms_ypfp);
275 DeltaHMSpathLength = (.12*hms_xptar*1000 +0.17*hms_dP/100.);
276
277 // default assume SHMS is electron arm
280 elec_P = theSHMSTrack->GetP(); //electron golden track arm momentum
281 had_P = theHMSTrack->GetP(); //hadron golden track arm momentum
282 Int_t sign=-1;
283 if (felecArmName=="H") {
284 ElecPathLength=HMScentralPathLen + DeltaHMSpathLength;
286 elec_P = theHMSTrack->GetP(); //electron golden track arm momentum
287 had_P = theSHMSTrack->GetP(); //hadron golden track arm momentum
288 sign=1;
289 }
290
291 //beta calculations beta = v/c = p/E
297
298 //Coincidence Corrections
299 elec_coinCorr = (ElecPathLength) / (lightSpeed * elecArm_BetaCalc );
301 had_coinCorr_Kaon = (HadPathLength)/ (lightSpeed * hadArm_BetaCalc_Kaon );
302 had_coinCorr_Pion = (HadPathLength)/ (lightSpeed * hadArm_BetaCalc_Pion );
304
305 //Raw, Uncorrected Coincidence Time
306 fROC1_RAW_CoinTime = (pSHMS_TdcTime_ROC1 + SHMS_FPtime) - (pHMS_TdcTime_ROC1 + HMS_FPtime);
307 fROC2_RAW_CoinTime = (pSHMS_TdcTime_ROC2 + SHMS_FPtime) - (pHMS_TdcTime_ROC2 + HMS_FPtime);
308 fSHMS_RAW_CoinTime = (pSHMS_TdcTime_ROC1 + SHMS_FPtime) - (pSHMS_TdcTime_ROC2 + HMS_FPtime);
309 fHMS_RAW_CoinTime = (pHMS_TdcTime_ROC1 + SHMS_FPtime) - (pHMS_TdcTime_ROC2 + HMS_FPtime);
310 // 04/05/21 - SJDK - Added for use in Report files for tracking efficiency calculations
311 //Raw, Uncorrected Coincidence Time WITHOUT any tracked quantities
316 //Corrected Coincidence Time for ROC1/ROC2 (ROC1 Should be identical to ROC2)
317 //
318 //PROTON
323
324 //KAON
329
330 //PION
335
336 //POSITRON
341
342 return 0;
343}
344
345//_____________________________________________________________________________
346
int Int_t
const Data_t kBig
double Double_t
const char Option_t
Option_t Option_t TPoint TPoint const char mode
R__EXTERN class THaRunBase * gHaRun
ClassImp(VDC::AnalyticTTDConv) using namespace std
R__EXTERN class THcParmList * gHcParms
Definition THcGlobals.h:11
static Int_t DefineVarsFromList(const void *list, EType type, EMode mode, const char *def_prefix, const TObject *obj, const char *prefix, const char *here, const char *comment_subst="")
THaAnalysisObject * FindModule(const char *name, const char *classname, bool do_error=true)
Bool_t IsOK() const
Int_t RemoveVariables()
THaTrack * GetGoldenTrack() const
Bool_t IsOK() const
Double_t GetX() const
Double_t GetPhi() const
Double_t GetDp() const
Double_t GetTheta() const
Double_t GetP() const
Double_t GetTTheta() const
Double_t GetFPTime() const
THaTrackInfo * GetTrackInfo()
Class for calculating and adding the Coincidence Time in the Tree. SJDK - 08/09/21 - Switched Trig4 t...
Definition THcCoinTime.h:29
Double_t fROC1_RAW_CoinTime
Definition THcCoinTime.h:81
TString felecArmName
Definition THcCoinTime.h:52
Double_t fROC2_ePosCoinTime
Double_t hadArm_BetaCalc_Positron
Double_t elec_coinCorr
Double_t had_coinCorr_Kaon
Double_t fSHMS_ePiCoinTime
Double_t had_xfp
Double_t protonMass
Definition THcCoinTime.h:69
Double_t lightSpeed
Definition THcCoinTime.h:64
Double_t had_coinCorr_Pion
Double_t fHMS_ePiCoinTime
virtual ~THcCoinTime()
virtual Int_t DefineVariables(EMode mode=kDefine)
Double_t fSHMS_RAW_CoinTime_NoTrack
Definition THcCoinTime.h:88
Double_t fROC2_epCoinTime
Definition THcCoinTime.h:92
Double_t DeltaSHMSpathLength
Definition THcCoinTime.h:78
Double_t pHMS_TdcTime_ROC2
Double_t fROC1_epCoinTime
Definition THcCoinTime.h:91
Double_t elec_P
THaTrack * theHMSTrack
Definition THcCoinTime.h:59
Double_t fROC1_ePiCoinTime
Double_t fSHMS_eKCoinTime
Definition THcCoinTime.h:98
Double_t kaonMass
Definition THcCoinTime.h:70
Double_t fROC2_eKCoinTime
Definition THcCoinTime.h:97
Double_t hadArm_BetaCalc_proton
THcCoinTime(const char *name, const char *description, const char *hadArmName="", const char *elecArmName="", const char *coinname="")
Double_t fROC1_eKCoinTime
Definition THcCoinTime.h:96
Double_t hadArm_BetaCalc_Pion
Double_t fSHMS_RAW_CoinTime
Definition THcCoinTime.h:83
Double_t fHMS_eKCoinTime
Definition THcCoinTime.h:99
Double_t fHMS_RAW_CoinTime_NoTrack
Definition THcCoinTime.h:89
Double_t HMScentralPathLen
Definition THcCoinTime.h:76
void Reset(Option_t *opt="")
Double_t fROC2_ePiCoinTime
THcHallCSpectrometer * felecSpectro
Definition THcCoinTime.h:55
Double_t fSHMS_ePosCoinTime
Double_t pionMass
Definition THcCoinTime.h:71
void Clear(Option_t *opt="")
Double_t positronMass
Definition THcCoinTime.h:66
Double_t elecMass
Definition THcCoinTime.h:65
Double_t fSHMS_epCoinTime
Definition THcCoinTime.h:93
THaTrack * theSHMSTrack
Definition THcCoinTime.h:58
Double_t had_coinCorr_proton
Double_t pSHMS_TdcTime_ROC2
TString fhadArmName
Definition THcCoinTime.h:51
virtual Int_t Process(const THaEvData &)
Double_t fHMS_RAW_CoinTime
Definition THcCoinTime.h:84
Double_t fROC2_RAW_CoinTime
Definition THcCoinTime.h:82
Double_t hadArm_BetaCalc_Kaon
THcHallCSpectrometer * fhadSpectro
Definition THcCoinTime.h:54
Double_t eHad_CT_Offset
Definition THcCoinTime.h:73
Double_t fHMS_ePosCoinTime
Double_t pSHMS_TdcTime_ROC1
Double_t elecArm_BetaCalc
Double_t had_coinCorr_Positron
Double_t fROC2_RAW_CoinTime_NoTrack
Definition THcCoinTime.h:87
THcTrigDet * fCoinDet
Definition THcCoinTime.h:56
virtual Int_t ReadDatabase(const TDatime &date)
Double_t fHMS_epCoinTime
Definition THcCoinTime.h:94
Double_t fROC1_ePosCoinTime
Double_t pHMS_TdcTime_ROC1
Double_t had_P
Double_t SHMScentralPathLen
Definition THcCoinTime.h:75
Double_t DeltaHMSpathLength
Definition THcCoinTime.h:79
TString fCoinDetName
Definition THcCoinTime.h:50
Double_t fROC1_RAW_CoinTime_NoTrack
Definition THcCoinTime.h:86
A standard Hall C spectrometer apparatus.
Double_t GetParticleMass() const
Int_t LoadParmValues(const DBRequest *list, const char *prefix="")
Retrieve parameter values from the parameter cache.
A mock detector to hold trigger related data.
Definition THcTrigDet.h:16
Double_t Get_CT_Trigtime(Int_t ii)
Definition THcTrigDet.h:36
const char * Data() const
Expr< UnaryOp< Sqrt< T >, Expr< A, T, D, D2, R >, T >, T, D, D2, R > sqrt(const Expr< A, T, D, D2, R > &rhs)
STL namespace.