9 #include <TLorentzVector.h>
91 InitJANAPlugin(locApplication);
104 printf (
"TEST>> DEventProcessor_fcal_charged::init - Other threads continue\n");
114 TDirectory *
main = gDirectory;
115 gDirectory->mkdir(
"fcal_charged")->cd();
121 h1_stats =
new TH1I(
"h1_stats",
"Run Statistics", 20,0,20);
123 h1_deltaX =
new TH1I(
"h1_deltaX",
"Fcal X - Track X", nbins,-25,25);
124 h1_deltaX->SetXTitle(
"Fcal - Track X (cm)");
126 h1_deltaY =
new TH1I(
"h1_deltaY",
"Fcal Y - Track X", nbins,-25,25);
127 h1_deltaY->SetXTitle(
"Fcal - Track Y (cm)");
130 h1_deltaX_tof =
new TH1I(
"h1_deltaX_tof",
"TOF X - Track X E1", nbins,-25,25);
133 h1_deltaY_tof =
new TH1I(
"h1_deltaY_tof",
"TOF Y - Track Y E1", nbins,-25,25);
137 h1_Ebcal =
new TH1I(
"h1_Ebcal",
"Sum of point energy", nbins,0,1);
138 h1_Ebcal->SetXTitle(
"Bcal point energy (GeV)");
141 h1_Efcal =
new TH1I(
"h1_Efcal",
"Hit energy", nbins,0,4);
142 h1_Efcal->SetXTitle(
"Fcal hit energy (GeV)");
144 h1_tfcal =
new TH1I(
"h1_tfcal",
"Hit time", 250,-25,225);
145 h1_tfcal->SetXTitle(
"Fcal hit time (ns)");
147 h1_intOverPeak =
new TH1I(
"h1_intOverPeak",
"Hit intOverPeak",nbins,0,25);
151 h2_dEdx_vsp =
new TH2I(
"h2_dEdx_vsp",
"Track dEdx vs p",nbins,0,4,nbins,0,10);
154 h2_dEdx9_vsp =
new TH2I(
"h2_dEdx9_vsp",
"Track dEdx9 vs p",nbins,0,4,nbins,0,10);
158 h1_N9 =
new TH1I(
"h1_N9",
"Hit N9",25,0,25);
159 h1_N9->SetXTitle(
"Number of Hits N9");
160 h1_N9->SetYTitle(
"counts");
161 h1_E9 =
new TH1I(
"h1_E9",
"Energy E9",nbins,0,2);
162 h1_E9->SetXTitle(
"Energy E9 (GeV)");
163 h1_E9->SetYTitle(
"counts");
164 h1_t9 =
new TH1I(
"h1_t9",
"Time t9",250,-25,225);
165 h1_t9->SetXTitle(
"Time t9 (ns)");
166 h1_t9->SetYTitle(
"counts");
167 h1_t9sigma =
new TH1I(
"h1_t9sigma",
"Time t9sigma",nbins,0,10);
168 h1_t9sigma->SetXTitle(
"Time spread t9sigma (ns)");
171 h2_YvsX9 =
new TH2I(
"h2_YvsX9",
"Hit position Y vs X, E9",240,-120,120,240,-120,120);
174 h2_YvsXcheck =
new TH2I(
"h2_YvsXcheck",
"Delta Hit Y vs X Checkered",nbins,-5,5,nbins,-5,5);
177 h2_E1vsRlocal =
new TH2I(
"h2_E1vsRlocal",
"E1 vs Rtrk rel to Block center (cm)",nbins,0,5,nbins,0,4);
180 h2_E9vsp =
new TH2I(
"h2_E9vsp",
"E9 vs p",nbins,0,4,nbins,0,4);
183 h2_dEdxvsE9 =
new TH2I(
"h2_dEdxvsE9",
"dEdx vs E9 energy",nbins,0,4,nbins,0,4);
187 h1_N1 =
new TH1I(
"h1_N1",
"Hit N1",25,0,25);
188 h1_N1->SetXTitle(
"Number of Hits N1");
189 h1_N1->SetYTitle(
"counts");
190 h1_E1 =
new TH1I(
"h1_E1",
"Energy E1",nbins,0,2);
191 h1_E1->SetXTitle(
"Energy E1 (GeV)");
192 h1_E1->SetYTitle(
"counts");
193 h1_t1 =
new TH1I(
"h1_t1",
"Time t1",250,-25,225);
194 h1_t1->SetXTitle(
"Time t1 (ns)");
195 h1_t1->SetYTitle(
"counts");
196 h1_t1sigma =
new TH1I(
"h1_t1sigma",
"Time t1sigma",nbins,0,10);
197 h1_t1sigma->SetXTitle(
"Time spread t1sigma (ns)");
200 h2_YvsX1 =
new TH2I(
"h2_YvsX1",
"Hit position Y vs X, E1",240,-120,120,240,-120,120);
203 h2_E1vsp =
new TH2I(
"h2_E1vsp",
"E1 vs p",nbins,0,4,nbins,0,4);
206 h2_E2vsp =
new TH2I(
"h2_E2vsp",
"E2 vs p",nbins,0,4,nbins,0,4);
209 h2_E1vspPos =
new TH2I(
"h2_E1vspPos",
"E1 vs p Q>0",nbins,0,4,nbins,0,4);
212 h2_E1peak_vsp =
new TH2I(
"h2_E1peak_vsp",
"E1peak*6 vs p",nbins,0,4,nbins,0,4);
218 h2_E1_vsintOverPeak =
new TH2I(
"h2_E1_vsintOverPeak",
"E1 vs intOverPeak",nbins,0,25,nbins,0,4);
222 h2_E9_vsTheta =
new TH2I(
"h2_E9_vsTheta",
"E9 vs Theta",90,0,30,nbins,0,4);
225 h2_E1_vsTheta =
new TH2I(
"h2_E1_vsTheta",
"E1 vs Theta",90,0,30,nbins,0,4);
228 h2_E9_vsPhi =
new TH2I(
"h2_E9_vsPhi",
"E9 vs Phi",90,-180,180,nbins,0,4);
231 h2_E1_vsPhi =
new TH2I(
"h2_E1_vsPhi",
"E1 vs Phi",90,-180,180,nbins,0,4);
235 h2_E9_vsThetaPhiw =
new TH2D(
"h2_E9_vsThetaPhiw",
"E9 vs ThetaPhiw",90,-180,180,90,0,30);
238 h2_E1_vsThetaPhi =
new TH2D(
"h2_E1_vsThetaPhi",
"Unity vs ThetaPhi",90,-180,180,90,0,30);
241 h2_E1_vsThetaPhiw =
new TH2D(
"h2_E1_vsThetaPhiw",
"E1 vs ThetaPhiw",90,-180,180,90,0,30);
246 printf (
"TEST>> DEventProcessor_fcal_charged::init - First thread created histograms\n");
305 vector<const DFCALShower*> locFCALShowers;
306 vector<const DBCALPoint*> bcalpoints;
307 vector<const DTOFPoint*> tofpoints;
308 vector<const DFCALHit*> fcalhits;
309 vector<const DFCALCluster*> locFCALClusters;
310 vector<const DVertex*> kinfitVertex;
313 locEventLoop->Get(locFCALShowers);
314 locEventLoop->Get(bcalpoints);;
315 locEventLoop->Get(tofpoints);
316 locEventLoop->Get(fcalhits);
317 locEventLoop->Get(locFCALClusters);
318 locEventLoop->Get(kinfitVertex);
320 vector<const DChargedTrack*> locChargedTrack;
321 locEventLoop->Get(locChargedTrack);
329 DVector3 fcal_origin(0.0,0.0,zfcal);
341 if (locEventNumber%100 == 0)
printf (
"EventNumber=%d\n",locEventNumber);
345 japp->RootFillLock(
this);
352 for (
unsigned int i=0; i < locChargedTrack.size() ; ++i){
355 vector<const DTrackTimeBased*> locTrackTimeBased;
356 bestctrack->Get(locTrackTimeBased);
358 double FOM = TMath::Prob(locTrackTimeBased[0]->chisq, locTrackTimeBased[0]->Ndof);
361 vector<DTrackFitter::Extrapolation_t>extrapolations=locTrackTimeBased[0]->extrapolations.at(
SYS_FCAL);
362 if (extrapolations.size()>0){
363 trkpos=extrapolations[0].position;
366 vector<DTrackFitter::Extrapolation_t>tof_extrapolations=locTrackTimeBased[0]->extrapolations.at(
SYS_TOF);
367 if (tof_extrapolations.size()==0)
continue;
369 trkpos_tof=tof_extrapolations[0].position;
373 float bcal_energy = 0;
374 for (
unsigned int j=0; j < bcalpoints.size(); ++j) {
375 bcal_energy += bcalpoints[j]->E();
377 if (bcal_energy < 0.15) {
384 double q = locTrackTimeBased[0]->charge();
385 p = locTrackTimeBased[0]->momentum().Mag();
386 double trkmass = locTrackTimeBased[0]->mass();
388 double radius =
sqrt(trkpos.X()*trkpos.X() + trkpos.Y()*trkpos.Y());
389 dEdx = (locTrackTimeBased[0]->dNumHitsUsedFordEdx_CDC >= locTrackTimeBased[0]->dNumHitsUsedFordEdx_FDC) ? locTrackTimeBased[0]->ddEdx_CDC_amp : locTrackTimeBased[0]->ddEdx_FDC;
391 if(!(trkmass < 0.15 && FOM>0.01 && radius>20)) {
405 double trkposX = trkpos.X();
406 double trkposY = trkpos.Y();
407 int trkrow = fcalgeom.
row((
float)trkposY);
408 int trkcol = fcalgeom.
column((
float)trkposX);
409 double dX_tof = 10000;
410 double dY_tof = 10000;
411 double dR_tof = 10000;
415 for (
unsigned int j=0; j < tofpoints.size(); ++j) {
418 if (tofpoints[j]->Is_XPositionWellDefined() && tofpoints[j]->Is_YPositionWellDefined()) {
419 DVector3 pos_tof = tofpoints[j]->pos;
422 printf (
"Event=%d tofx=%f, tofy=%f, trkx=%f, trky=%f \n",locEventNumber,tofx,tofy,trkposX,trkposY);
423 double dX_tof1 = tofx - trkpos_tof.X();
424 double dY_tof1 = tofy - trkpos_tof.Y();
425 if (
sqrt(dX_tof1*dX_tof1 + dY_tof1*dY_tof1) < dR_tof) {
428 dR_tof =
sqrt(dX_tof*dX_tof + dY_tof*dY_tof);
433 printf (
"\n1 Event=%d dX_tof=%f, DY_tof=%f, trkx=%f, trky=%f \n",locEventNumber,dX_tof,dY_tof,trkposX,trkposY);
434 if ( !(abs(dX_tof)<10 && abs(dY_tof)<10) )
continue;
437 printf (
"2 Event=%d dX_tof=%f, DY_tof=%f, trkx=%f, trky=%f \n",locEventNumber,dX_tof,dY_tof,trkposX,trkposY);
438 printf (
"Event=%d trkmass=%f radius=%f p=%f dEdx=%g,trkrow=%d trkcol=%d x=%f y=%f z=%f\n",locEventNumber,trkmass,radius,p,dEdx,trkrow,trkcol,trkposX,trkposY,trkpos.Z());
442 double theta = proj_mom.Theta()*180./M_PI;
443 double phi = proj_mom.Phi()*180./M_PI;
444 printf (
"Event=%d p=%f,theta=%f, phi=%f\n",locEventNumber,p,theta,phi);
467 trkrow += row_offset;
468 trkcol += col_offset;
470 for (
unsigned int j=0; j < fcalhits.size(); ++j) {
471 int row = fcalhits[j]->row;
472 int col = fcalhits[j]->column;
473 double x = fcalhits[j]->x;
474 double y = fcalhits[j]->y;
475 double Efcal = fcalhits[j]->E;
476 double tfcal= fcalhits[j]->t;
477 double intOverPeak = fcalhits[j]->intOverPeak;
481 int drow = abs(row - trkrow);
482 int dcol = abs(col - trkcol);
492 if (drow<=Delta_block && dcol<=Delta_block && (tfcal>-15 && tfcal<50) && (intOverPeak>2.5 && intOverPeak<9)) {
495 E9peak += Efcal*6/intOverPeak;
509 printf (
"Event=%d, trkposX=%f, trkposY=%f, dX_E1=%f, dY_E1=%f\n",locEventNumber,trkposX,trkposY,dX_E1,dY_E1);
514 x9 = N9>0? x9/N9 : 0;
515 y9 = N9>0? y9/N9 : 0;
516 t9 = N9>0? t9/N9 : 0;
517 t9sigma = N9>0?
sqrt(t9sq/N9 - t9*t9): 0;
522 if (E9 > 0.8 && theta<4)
continue;
555 double Rlocal =
sqrt(dX_E1*dX_E1 + dY_E1*dY_E1);
560 if (N9==1 || N9==2) {
570 japp->RootFillUnLock(
this);
static TH2I * h2_E1peak_vsp
jerror_t erun(void)
Called every time run number changes, provided brun has been called.
static TH2D * h2_E1_vsThetaPhi
static TH2I * h2_E1_vsPhi
static TH2I * h2_YvsXcheck
static TH1I * h1_deltaY_tof
static TH2I * h2_intOverPeak_vsEfcal
static TH2I * h2_E9_vsPhi
static TH2D * h2_E9_vsThetaPhiw
static TH2I * h2_dEdx9_vsp
static TH2I * h2_E1vspPos
static TH2I * h2_E1vsRlocal
jerror_t init(void)
Called once at program start.
int column(int channel) const
static TH1I * h1_intOverPeak
jerror_t fini(void)
Called after last event of last event source has been processed.
static TH2I * h2_E9_vsTheta
static TH2I * h2_dEdxvsE9
static TH2D * h2_E1_vsThetaPhiw
jerror_t brun(jana::JEventLoop *locEventLoop, int locRunNumber)
Called every time a new run number is detected.
const DChargedTrackHypothesis * Get_BestFOM(void) const
int row(int channel) const
static TH2I * h2_E1_vsTheta
static TH2I * h2_E1_vsintOverPeak
printf("string=%s", string)
static TH1I * h1_deltaX_tof
static TH2I * h2_dEdx_vsp
jerror_t evnt(jana::JEventLoop *locEventLoop, int locEventNumber)
Called every event.
int main(int argc, char *argv[])