18 #include <JANA/JApplication.h>
32 pthread_mutex_init(&mutex, NULL);
53 pullsWB =
new TTree(
"pullsWB",
"Wire-based hits");
54 pullsWB->Branch(
"W",
"pull_t",&pullWB_ptr);
56 pullsTB =
new TTree(
"pullsTB",
"Time-based hits");
57 pullsTB->Branch(
"W",
"pull_t",&pullTB_ptr);
67 RECALCULATE_CHISQ =
false;
69 gPARMS->SetDefaultParameter(
"RECALCULATE_CHISQ", RECALCULATE_CHISQ,
"Recalculate Chisq, Ndof, and pulls based on track parameters and hits rather than use what's recorded in track objects");
79 vector<const DChargedTrack*> tracks;
85 loop->GetSingle(thrown_single);
86 loop->GetSingle(
fitter,
"ALT1");
92 japp->RootWriteLock();
94 for(
unsigned int i=0; i<tracks.size(); i++){
97 pullWB.pthrown.SetXYZ(0,0,0);
98 pullTB.pthrown.SetXYZ(0,0,0);
100 if(tracks[i]->hypotheses.size()>0){
110 tbtrk->GetSingle(thrown);
111 if(!thrown)thrown = thrown_single;
114 pullTB.pthrown.SetXYZ(x.X(), x.Y(), x.Z());
119 double chisq = tbtrk->
chisq;
120 int Ndof = tbtrk->
Ndof;
121 vector<DTrackFitter::pull_t> pulls = tbtrk->
pulls;
124 if(RECALCULATE_CHISQ){
128 pullTB.eventnumber = eventnumber;
129 pullTB.trk_chisq = chisq;
130 pullTB.trk_Ndof = Ndof;
132 for(
unsigned int j=0; j<pulls.size(); j++){
133 pullTB.resi = pulls[j].resi;
134 pullTB.err = pulls[j].err;
135 pullTB.s = pulls[j].s;
136 pullTB.pull = pullTB.resi/pullTB.err;
141 tbtrk->GetSingle(wbtrk);
144 pullWB.eventnumber = eventnumber;
145 pullWB.trk_chisq = wbtrk->
chisq;
146 pullWB.trk_Ndof = wbtrk->
Ndof;
150 wbtrk->GetSingle(thrown);
151 if(!thrown)thrown = thrown_single;
154 pullWB.pthrown.SetXYZ(x.X(), x.Y(), x.Z());
157 for(
unsigned int j=0; j<wbtrk->
pulls.size(); j++){
158 pullWB.resi = wbtrk->
pulls[j].resi;
159 pullWB.err = wbtrk->
pulls[j].err;
160 pullWB.s = wbtrk->
pulls[j].s;
161 pullWB.pull = pullWB.resi/pullWB.err;
200 _DBG_<<
"DTrackFitter:ALT1 not available when RECALCULATE_CHISQ is set!"<<endl;
float chisq
Chi-squared for the track (not chisq/dof!)
float chisq
Chi-squared for the track (not chisq/dof!)
DEventProcessor_pulls_tree()
jerror_t fini(void)
Called after last event of last event source has been processed.
vector< DTrackFitter::pull_t > pulls
Holds pulls used in chisq calc. (not including off-diagonals)
int Ndof
Number of degrees of freedom in the fit.
int Ndof
Number of degrees of freedom in the fit.
~DEventProcessor_pulls_tree()
vector< DTrackFitter::pull_t > pulls
Holds pulls used in chisq calc. (not including off-diagonals)
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
const DVector3 & momentum(void) const
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
const DTrackFitter * fitter
jerror_t init(void)
Called once at program start.
void RecalculateChisq(DTrackFitter::fit_type_t fit_type, const DKinematicData *kd, double &chisq, int &Ndof, vector< DTrackFitter::pull_t > &pulls)