// $Id$ // // File: DTOFPoint_factory.cc // Created: Tue Oct 18 09:50:52 EST 2005 // Creator: remitche (on Linux mantrid00 2.4.20-18.8smp i686) // #include #include using namespace std; #include "DTOFPoint_factory.h" #define MAXTOFHITS 50 //------------------ // brun //------------------ jerror_t DTOFPoint_factory::brun(JEventLoop *loop, int runnumber) { map tofparms; if ( !loop->GetCalib("TOF/tof_parms", tofparms)){ cout<<"DTOFPoint_factory: loading values from TOF data base"< hits; loop->Get(hits); // Local vectors for separating hits by plane vectoruhits; vectorvhits; for (unsigned int j = 0; j < hits.size(); j++){ const DTOFHit *hit=hits[j]; // zero is vertical plane, one is horizontal plane if (hit->E_north>0 || hit->E_south>0) { if (hit->orientation) { uhits.push_back(hit); } else { vhits.push_back(hit); } } } // Match hits in the two planes by bar number and position as determined from // the time difference between two ends, where available. for (unsigned int i=0;itimediff * VELOCITY ; double utof = uhits[i]->meantime; double dy = uhits[i]->bar > 20 ? BARWIDTH : -BARWIDTH; double uy = BARWIDTH*(uhits[i]->bar-20.5)+dy; double x_cut = BARWIDTH*0.55; // changed to "*0.55" from "/2." 4/28/2010 DL double t_cut = 1.; // Handle the single-ended bars if (uhits[i]->bar>40){ x_cut=120.; t_cut=10.; switch(uhits[i]->bar){ case 41: uy=-3.; ux=-72.; utof=uhits[i]->t_south-HALFPADDLE/VELOCITY; break; case 43: uy=3.; ux=-72.; utof=uhits[i]->t_south-HALFPADDLE/VELOCITY; break; case 42: uy=-3.; ux=+72.; utof=uhits[i]->t_north-HALFPADDLE/VELOCITY; break; case 44: uy=+3.; ux=+72.; utof=uhits[i]->t_north-HALFPADDLE/VELOCITY; break; default: break; } } for (unsigned int j=0;jtimediff * VELOCITY; double vtof = vhits[j]->meantime; double dx = vhits[j]->bar > 20 ? BARWIDTH:-BARWIDTH; double vx = BARWIDTH*(vhits[j]->bar-20.5)+dx; double y_cut = BARWIDTH*0.55; // changed to "*0.55" from "/2." 4/28/2010 DL // Handle the single-ended bars if (vhits[j]->bar>40){ y_cut=120.; t_cut=10.; switch(vhits[j]->bar){ case 41: vx=-3.; vy=72.; vtof=vhits[j]->t_south-HALFPADDLE/VELOCITY; break; case 43: vx=3.; vy=72.; vtof=vhits[j]->t_south-HALFPADDLE/VELOCITY; break; case 42: vx=-3.; vy=-72.; vtof=vhits[j]->t_north-HALFPADDLE/VELOCITY; break; case 44: vx=3.; vy=-72; vtof=vhits[j]->t_north-HALFPADDLE/VELOCITY; break; default: break; } } // If we have a match in both position and time, output the point with // the combined 2-layer data //cout<chisq=0.; //?? if (vhits[j]->bar<41 && uhits[i]->bar<41){ point->pos.SetXYZ(ux,vy,618.81); point->t=(utof+vtof)/2.; point->dedx=(sqrt(uhits[i]->E_north*uhits[i]->E_south) +sqrt(vhits[j]->E_north*vhits[j]->E_south))/2.; point->AddAssociatedObject(uhits[i]); point->AddAssociatedObject(vhits[j]); } else if (vhits[j]->bar<41 && uhits[i]->bar>40){ point->pos.SetXYZ(vx,vy,617.52); point->t=vtof; point->dedx=sqrt(vhits[j]->E_north*vhits[j]->E_south); point->AddAssociatedObject(vhits[j]); } else{ point->pos.SetXYZ(ux,uy,620.10); point->t=utof; point->dedx=sqrt(uhits[i]->E_north*uhits[i]->E_south); point->AddAssociatedObject(uhits[i]); } _data.push_back(point); } } } return NOERROR; }