Neutral Particle Spectrometer analysis code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
THcNPSCoinTime.cxx
Go to the documentation of this file.
1#include "THcNPSCoinTime.h"
2#include "THcGlobals.h"
3#include "THcParmList.h"
4#include "THaEvData.h"
5#include "THcNPSCluster.h"
6#include <iostream>
7
8using namespace std;
9
10//________________________________________________________________________
11THcNPSCoinTime::THcNPSCoinTime( const char* name, const char* description,
12 const char* elecArmName, const char* hadArmName,
13 const char* coinname) :
14 THaPhysicsModule(name, description),
15 fCoinDetName(coinname),
16 fCoinDet(nullptr),
17 felecArmName(elecArmName),
18 fhadArmName(hadArmName),
19 fHMSSpect(nullptr),
20 fNPSSpect(nullptr)
21{
22 // Constructor
23}
24
25//________________________________________________________________________
27{
28 // Destructor
30}
31
32//________________________________________________________________________
41
42//________________________________________________________________________
44{
45 Clear(opt);
46}
47
48//________________________________________________________________________
50{
51
52 // Locate the spectrometer appratus and save pointer to it
53 cout << "*************************************************" << endl;
54 cout << "Initializing THcNPSCointTime Physics Modue" << endl;
55 cout << "Hadron Arm -------> " << fhadArmName << endl;
56 cout << "Electron Arm -------> " << felecArmName << endl;
57 cout << "TrigDet -------> " << fCoinDetName << endl;
58 cout << "**************************************************" << endl;
59
60 fStatus = kOK;
61
62 // Get spectrometers
63 if (felecArmName == "H") {
64 // HMS
65 fHMSSpect = dynamic_cast<THcHallCSpectrometer*>
66 ( FindModule( felecArmName.Data(), "THcHallCSpectrometer"));
67 // NPS
68 fNPSSpect = dynamic_cast<THcNPSApparatus*>
69 ( FindModule( fhadArmName.Data(), "THcNPSApparatus"));
70 }
71 else {
72 fHMSSpect = dynamic_cast<THcHallCSpectrometer*>
73 ( FindModule( fhadArmName.Data(), "THcHallCSpectrometer"));
74
75 fNPSSpect = dynamic_cast<THcNPSApparatus*>
76 ( FindModule( felecArmName.Data(), "THcNPSApparatus"));
77 }
78
79 if( !fHMSSpect || !fNPSSpect ) {
81 return fStatus;
82 }
83
84 fCoinDet = dynamic_cast<THcTrigDet*>
85 ( FindModule( fCoinDetName.Data(), "THcTrigDet"));
86 if( !fCoinDet ) {
87 cout << "THcCoinTime module Cannnot find TrigDet = " << fCoinDetName.Data() << endl;
89 return fStatus;
90 }
91
92 // Get NPS calorimeter
93 fNPSCalo = dynamic_cast<THcNPSCalorimeter*>(fNPSSpect->GetDetector("cal"));
94 if( !fNPSCalo ) {
96 return fStatus;
97 }
98
99 // NPS angle
101
102 if ((fStatus=THaPhysicsModule::Init( run_time )) != kOK )
103 return fStatus;
104
105 return fStatus;
106}
107
108//________________________________________________________________________
110{
111
112 DBRequest list[] = {
113 {"eHadCoinTime_Offset", &feHad_CT_Offset, kDouble, 0, 1}, // coin time offset for ep coincidence
114 {"HMS_CentralPathLen", &fHMScentralPathLen, kDouble, 0, 1},
115 {"NPS_CentralPathLen", &fNPScentralPathLen, kDouble, 0, 1},
116 {0}
117 };
118
119 // Default values if not read from param file
120 feHad_CT_Offset = 0.0;
121 fHMScentralPathLen = 22.*100;
122 fNPScentralPathLen = 9.5*100;
123
124 gHcParms->LoadParmValues((DBRequest*)&list, "");
125
126 return kOK;
127}
128
129//________________________________________________________________________
131{
132
133 if( mode == kDefine && fIsSetup ) return kOK;
134 fIsSetup = ( mode == kDefine );
135
136 RVarDef vars[] = {
137 {"epCoinTime1_ROC1", "ROC1 Corrected ep Coincidence Time, NPS & HMS 3/4", "fROC1_epCoinTime1"},
138 {"epCoinTime2_ROC1", "ROC1 Corrected ep Coincidence Time, NPS & El-Real", "fROC1_epCoinTime2"},
139 {"epCoinTime_NPS", "NPS Corrected ep Coincidence Time", "fNPS_epCoinTime"},
140 {"epCoinTime_HMS", "HMS Corrected ep Coincidence Time", "fHMS_epCoinTime"},
141
142 {"CoinTime1_RAW_ROC1", "ROC1 RAW Coincidence Time, NPS & HMS 3/4", "fROC1_RAW_CoinTime1"},
143 {"CoinTime2_RAW_ROC1", "ROC1 RAW Coincidence Time, NPS & El-Real", "fROC1_RAW_CoinTime2"},
144 {"CoinTime1_RAW_ROC1_NoTrack", "ROC1 RAW Coincidence Time w/o Track Param, NPS & HMS 3/4", "fROC1_RAW_CoinTime1_NoTrack"},
145 {"CoinTime2_RAW_ROC1_NoTrack", "ROC1 RAW Coincidence Time w/o Track Paarm, NPS & El-Real", "fROC1_RAW_CoinTime2_NoTrack"},
146 {"CoinTime_RAW_NPS", "NPS RAW Coincidence Time", "fNPS_RAW_CoinTime"},
147 {"CoinTime_RAW_HMS", "HMS RAW Coincidence Time", "fHMS_RAW_CoinTime"},
148
149 {"DeltaHMSPathLength", "DeltaHMSpathLength (cm)", "fDeltaHMSpathLength"},
150
151 {"elec_coinCorr", "", "elec_coinCorr"},
152 {"had_coinCorr_proton","", "had_coinCorr_proton"},
153 {0}
154 };
155
156 return DefineVarsFromList( vars, mode );
157}
158
159//________________________________________________________________________
161{
162
163 if( !IsOK() ) return -1;
164
165 // Raw Tdctime
166 // We only use ROC1
167 pNPS_TdcTime_ROC1 = fCoinDet->Get_CT_Trigtime(0); // pTRIG1_ROC1: NPS VTP
168 pHMS_TdcTime_ROC1 = fCoinDet->Get_CT_Trigtime(1); // pTRIG3_ROC1: HMS 3/4
169 pELRE_TdcTime_ROC1 = fCoinDet->Get_CT_Trigtime(3); // pTRIG4_ROC1: HMS ELREAL
170
171 // Raw, Uncorrected Coincidence Time with out Track
174
175 // HMS Track, NPS cluster
176 // Get HMS tracks
177 THaTrackInfo* hms_trkifo = fHMSSpect->GetTrackInfo();
178 if( !hms_trkifo ) return 1;
179
180 // Get NPS clusters
181 if( fNPSCalo->GetNClusters() == 0 ) return 1;
182
184 if( !theHMSTrack )
185 return 1;
186
187 // Loop over all clusters
188 // We don't have a "Golden cluster", use highest energy cluster for now
189 Double_t ClusterMaxE = 0.;
190 Double_t NPS_FPtime = kBig;
191 TVector3 pvect;
192 TVector3 vertex = theHMSTrack->GetVertex(); // Use vertex from HMS
193 for(auto& cluster : fNPSCalo->GetClusters()) {
194 if( cluster.E() > ClusterMaxE ) {
195 ClusterMaxE = cluster.E();
196
197 // Get P vector in lab frame
198 cluster.RotateToLab(fNPSAngle, vertex, pvect);
199
200 // Cluster time
201 NPS_FPtime = cluster.GetTime();
202 }// if found higher energy cluster
203 }
204
205 // HMS
206 Double_t hms_xptar = theHMSTrack->GetTTheta();
207 Double_t hms_dP = theHMSTrack->GetDp();
208 Double_t hms_xfp = theHMSTrack->GetX();
209 Double_t hms_xpfp = theHMSTrack->GetTheta();
210 Double_t hms_ypfp = theHMSTrack->GetPhi();
211 Double_t HMS_FPtime = theHMSTrack->GetFPTime();
212
213 // Assume these are the values when the variable is initialized
214 if (NPS_FPtime == -2000 || HMS_FPtime == -2000) return 1;
215 if (NPS_FPtime == -1000 || HMS_FPtime == -1000) return 1;
216
217 fDeltaHMSpathLength = -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*hms_xfp - 116.52*hms_ypfp*hms_ypfp);
218 fDeltaHMSpathLength = (.12*hms_xptar*1000 +0.17*hms_dP/100.);
219
220 // First assume NPS is the electron arm
221 Double_t ElecPathLength = fNPScentralPathLen;
223 Double_t elec_P = pvect.Mag();
224 Double_t had_P = theHMSTrack->GetP();
225 Int_t sign= -1;
226 if(felecArmName == "H") {
227 ElecPathLength = fHMScentralPathLen + fDeltaHMSpathLength;
228 HadPathLength = fNPScentralPathLen; // NPS dP = 0
229 elec_P = theHMSTrack->GetP(); // HMS golden track momentum
230 had_P = pvect.Mag(); // NPS golden cluster momentum
231 sign = 1;
232 }
233
234 // beta calculations beta = v/c = p/E
235 Double_t elecArm_BetaCalc = elec_P / sqrt(elec_P*elec_P + MASS_ELECTRON*MASS_ELECTRON);
236 Double_t hadArm_BetaCalc_proton = had_P / sqrt(had_P*had_P + MASS_PROTON*MASS_PROTON);
237
238 //Coincidence Corrections
239 elec_coinCorr = (ElecPathLength) / (LIGHTSPEED * elecArm_BetaCalc );
240 had_coinCorr_proton = (HadPathLength) / (LIGHTSPEED * hadArm_BetaCalc_proton );
241
242 // Raw, Uncorrected Coincidence Time
243 // Since we have two coincidence trig, check both
244
245 fROC1_RAW_CoinTime1 = (pNPS_TdcTime_ROC1 + NPS_FPtime) - (pHMS_TdcTime_ROC1 + HMS_FPtime);
246 fROC1_RAW_CoinTime2 = (pNPS_TdcTime_ROC1 + NPS_FPtime) - (pELRE_TdcTime_ROC1 + HMS_FPtime);
247
248 // Not sure if we want to keep those
249 fNPS_RAW_CoinTime = NPS_FPtime - HMS_FPtime; // essentially same as fHMS_RAW_CoinTime
250 fHMS_RAW_CoinTime = NPS_FPtime - HMS_FPtime;
251
252 // Corrected Coincidence Time for ROC1
255 fNPS_epCoinTime = fNPS_RAW_CoinTime + sign*( elec_coinCorr-had_coinCorr_proton) - feHad_CT_Offset; // essentially same as fHMS_epCoinTime
257
258 return 0;
259}
260
int Int_t
const Data_t kBig
double Double_t
const char Option_t
Option_t Option_t TPoint TPoint const char mode
ClassImp(VDC::AnalyticTTDConv) using namespace std
R__EXTERN class THcParmList * gHcParms
#define MASS_PROTON
#define MASS_ELECTRON
#define LIGHTSPEED
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()
virtual THaDetector * GetDetector(const char *name)
THaTrack * GetGoldenTrack() const
TVector3 & GetVertex()
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()
A dummy spectrometer apparatus for testing detectors.
Double_t GetNPSAngle()
Generic segmented shower detector.
vector< THcNPSCluster > GetClusters()
Double_t fHMScentralPathLen
Double_t fDeltaHMSpathLength
THaTrack * theHMSTrack
void Clear(Option_t *opt="")
Double_t fROC1_RAW_CoinTime1
Double_t fNPScentralPathLen
THcHallCSpectrometer * fHMSSpect
Double_t pNPS_TdcTime_ROC1
Double_t fROC1_RAW_CoinTime2_NoTrack
THcNPSCalorimeter * fNPSCalo
THcTrigDet * fCoinDet
Double_t fHMS_epCoinTime
THcNPSApparatus * fNPSSpect
Double_t pELRE_TdcTime_ROC1
Double_t feHad_CT_Offset
Double_t fROC1_epCoinTime2
void Reset(Option_t *opt="")
virtual Int_t ReadDatabase(const TDatime &date)
Double_t had_coinCorr_proton
Double_t elec_coinCorr
Double_t fNPS_RAW_CoinTime
THcNPSCoinTime(const char *name, const char *description, const char *elecArmName="", const char *hadArmName="", const char *coinname="")
Double_t fHMS_RAW_CoinTime
Double_t fROC1_epCoinTime1
Double_t fROC1_RAW_CoinTime2
Double_t pHMS_TdcTime_ROC1
Double_t fNPS_epCoinTime
virtual Int_t Process(const THaEvData &)
virtual Int_t DefineVariables(EMode mode=kDefine)
virtual ~THcNPSCoinTime()
Double_t fROC1_RAW_CoinTime1_NoTrack
Int_t LoadParmValues(const DBRequest *list, const char *prefix="")
Double_t Get_CT_Trigtime(Int_t ii)
const char * Data() const
Double_t Mag() 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)
constexpr Double_t DegToRad()
STL namespace.
double * vertex