12 #include <JANA/JApplication.h>
13 #include <JANA/JFactory.h>
15 #include <TDirectory.h>
87 TDirectory *
main = gDirectory;
88 gDirectory->mkdir(
"st_tracking")->cd();
90 h2_r_vs_z =
new TH2I(
"r_vs_z",
"Charged Track & ST Intersection; Z (cm); R (cm)", 280, 30, 100, 500, 0, 10);
91 h2_y_vs_x =
new TH2I(
"y_vs_x",
"Charged Track & ST Intersection; X (cm); Y (cm)", 2000, -20, 20, 1000, -10, 10);
95 h2_dedx_P_mag =
new TH2I(
"h2_dedx_P_mag",
"#frac{dE}{dx} vs Momentum; Momentum (Gev/c); dEdx (au)", 1000, 0, 2, 150, 0, .015);
96 h2_dedx_P_mag_postv=
new TH2I(
"h2_dedx_P_mag_postv",
"#frac{dE}{dx} vs Momentum (q > 0); Momentum (Gev/c); #frac{dE}{dx} (au)", 1000, 0, 2, 150, 0, .015);
97 h2_dedx_P_mag_negtv=
new TH2I(
"h2_dedx_P_mag_negtv",
"#frac{dE}{dx} vs Momentum (q < 0); Momentum (Gev/c); #frac{dE}{dx} (au)", 1000, 0, 2, 150, 0, .015);
100 gDirectory->cd(
"../");
138 vector<const DSCDigiHit*> st_adc_digi_hits;
139 vector<const DParticleID*> pid_algorithm;
140 vector<const DSCHit*> st_hits;
143 eventLoop->GetSingle(locTrigger);
148 vector<const DParticleID *> locParticleID_algos;
149 eventLoop->Get(locParticleID_algos);
150 if(locParticleID_algos.size() < 1)
152 _DBG_<<
"Unable to get a DParticleID object! NO PID will be done!"<<endl;
153 return RESOURCE_UNAVAILABLE;
155 const DParticleID* locParticleID = locParticleID_algos[0];
157 eventLoop->Get(st_adc_digi_hits);
158 eventLoop->Get(pid_algorithm);
159 eventLoop->Get(st_hits);
160 vector<DVector3> sc_track_position;
161 vector<const DChargedTrack*> chargedTrackVector;
162 eventLoop->Get(chargedTrackVector);
165 eventLoop->GetSingle(locDetectorMatches);
169 japp->RootFillLock(
this);
171 sc_track_position.clear();
174 for (uint32_t i = 0; i < chargedTrackVector.size(); i++)
177 const DChargedTrack *thisChargedTrack = chargedTrackVector[i];
182 float trackingFOMCut = 0.0027;
183 if(timeBasedTrack->
FOM < trackingFOMCut)
continue;
185 int q = timeBasedTrack->
charge();
187 shared_ptr<const DSCHitMatchParams> locBestSCHitMatchParams;
188 bool foundSC = locParticleID->
Get_BestSCMatchParams(timeBasedTrack, locDetectorMatches, locBestSCHitMatchParams);
189 if (!foundSC)
continue;
193 vertex = timeBasedTrack->
position();
195 double z_v = vertex.z();
196 double r_v = vertex.Perp();
201 bool z_vertex_cut = 50.0 <= z_v && z_v <= 80.0;
202 bool r_vertex_cut = r_v < 0.5;
204 if (!z_vertex_cut)
continue;
205 if (!r_vertex_cut)
continue;
213 vector<shared_ptr<const DSCHitMatchParams>> st_params;
214 bool st_match = locDetectorMatches->
Get_SCMatchParams(timeBasedTrack, st_params);
216 if (!st_match)
continue;
218 shared_ptr<DSCHitMatchParams> locSCHitMatchParams;
220 bool st_match_pid = locParticleID->
Cut_MatchDistance(extrapolations, st_params[0]->dSCHit, st_params[0]->dSCHit->t, locSCHitMatchParams,
true, &IntersectionPoint, &IntersectionMomentum);
222 if(!st_match_pid)
continue;
225 momentum_vec = timeBasedTrack->
momentum();
228 double P_mag = Lor_Mom.P();
229 double phi_mom = momentum_vec.Phi()*
RAD2DEG;
230 if (phi_mom < 0.0) phi_mom += 360.0;
235 Int_t sector_m = st_params[0]->dSCHit->sector;
237 double dEdx = st_params[0]->dEdx;
238 double dphi = st_params[0]->dDeltaPhiToHit*
RAD2DEG;
252 double phi_ip = IntersectionPoint.Phi()*
RAD2DEG;
254 if (phi_ip < 0.0) phi_ip += 360.0;
256 sc_track_position.push_back(IntersectionPoint);
263 for (uint32_t i = 0; i < sc_track_position.size(); i++)
265 h2_r_vs_z->Fill(sc_track_position[i].z(),sc_track_position[i].Perp());
266 h2_y_vs_x->Fill(sc_track_position[i].
x(),sc_track_position[i].
y());
269 japp->RootFillUnLock(
this);
bool Get_SCMatchParams(const DTrackingData *locTrack, vector< shared_ptr< const DSCHitMatchParams > > &locMatchParams) const
static TH2I * h2_dphi_sector
const DChargedTrackHypothesis * Get_BestTrackingFOM(void) const
jerror_t fini(void)
Called after last event of last event source has been processed.
JEventProcessor_ST_online_tracking()
const DVector3 & position(void) const
const DTrackTimeBased * Get_TrackTimeBased(void) const
uint32_t Get_L1FrontPanelTriggerBits(void) const
static TH2I * h2_dedx_P_mag
TLorentzVector DLorentzVector
static TH2I * h2_phi_vs_sector
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
bool Get_BestSCMatchParams(const DTrackingData *locTrack, const DDetectorMatches *locDetectorMatches, shared_ptr< const DSCHitMatchParams > &locBestMatchParams) const
static TH2I * h2_dedx_P_mag_negtv
jerror_t init(void)
Called once at program start.
double charge(void) const
static TH2I * h2_dedx_P_mag_postv
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
bool Cut_MatchDistance(const DReferenceTrajectory *rt, const DBCALShower *locBCALShower, double locInputStartTime, shared_ptr< DBCALShowerMatchParams > &locShowerMatchParams, DVector3 *locOutputProjPos=nullptr, DVector3 *locOutputProjMom=nullptr) const
DLorentzVector lorentzMomentum(void) const
const DVector3 & momentum(void) const
~JEventProcessor_ST_online_tracking()
map< DetectorSystem_t, vector< DTrackFitter::Extrapolation_t > > extrapolations
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
int main(int argc, char *argv[])