14 #include <phgeom/PHGeomUtility.h>
21 #include <calobase/RawCluster.h>
22 #include <calobase/RawTowerDefs.h>
24 #include <phfield/PHFieldUtility.h>
26 #include <phgenfit/Fitter.h>
27 #include <phgenfit/PlanarMeasurement.h>
28 #include <phgenfit/Track.h>
29 #include <phgenfit/SpacepointMeasurement.h>
31 #include <GenFit/RKTrackRep.h>
32 #include <GenFit/FieldManager.h>
52 cerr <<
"No fitter found at: " << endl;
71 arr_pos[0] =
state->get_x();
72 arr_pos[1] =
state->get_y();
73 arr_pos[2] =
state->get_z();
94 arr_mom[0] =
state->get_px();
95 arr_mom[1] =
state->get_py();
96 arr_mom[2] =
state->get_pz();
111 std::vector< float > distance_from_track_to_cluster;
112 bool there_is_a_track=
false;
121 if(the_track == NULL)
123 distance_from_track_to_cluster.push_back(NAN);
128 there_is_a_track =
true;
130 float distance_from_state_to_cluster = 9990;
134 float distance_from_state_to_cluster_temp = 9999;
140 cout <<
"State is NULL, skipping..." << endl;
150 if(distance_from_state_to_cluster_temp < distance_from_state_to_cluster)
152 distance_from_state_to_cluster = distance_from_state_to_cluster_temp;
155 if(distance_from_state_to_cluster!=9990)
157 distance_from_track_to_cluster.push_back(distance_from_state_to_cluster);
179 if(distance_from_track_to_cluster.size()==0)
181 else if(there_is_a_track==
false)
185 float min_distance = 9999;
186 int min_distance_index = 0;
187 for(
unsigned i = 0;
i<distance_from_track_to_cluster.size();
i++)
189 if(distance_from_track_to_cluster.at(
i)<min_distance)
191 min_distance = distance_from_track_to_cluster.at(
i);
192 min_distance_index =
i;
198 else if(min_distance<deltaR)
209 float distance_from_state_to_cluster = 9990;
210 int best_state_index = -1;
215 float distance_from_state_to_cluster_temp = 9999;
221 cout <<
"State is NULL, skipping..." << endl;
226 if(distance_from_state_to_cluster_temp < distance_from_state_to_cluster)
228 best_state_index =
count;
229 distance_from_state_to_cluster = distance_from_state_to_cluster_temp;
233 if(distance_from_state_to_cluster==-1||best_state_index==-1)
235 cout <<
"State Map issue, returning NULL" << endl;
240 if(count!=best_state_index)
274 cout <<
"WARNING: get_detector was unable to find a defined detector" << endl;
286 cout <<
"No state found here!" << endl;
293 unique_ptr<genfit::MeasuredStateOnPlane> msop80 =
nullptr;
298 cout <<
pos(0) <<
" : " <<
pos(1) <<
" : " <<
pos(2) << endl;
304 for (
int i = 0;
i < 6; ++
i) {
305 for (
int j = 0;
j < 6; ++
j) {
318 rep->extrapolateToSphere(*msop80, surface_par, TVector3(0,0,0),
false,
false);
322 rep->extrapolateToCylinder(*msop80, surface_par, TVector3(0,0,0), TVector3(0,0,1));
327 TVector3 cluster_pos(cluster->
get_x(),cluster->
get_y(),cluster->
get_z());
329 double xvect=0;
double yvect = 0;
double zvect = 0;
332 xvect = cos(cluster->
get_phi());
333 yvect = sin(cluster->
get_phi());
345 cout <<
"WARNING: detector variable native to TrackProjectorPlaneECAL not defined" << endl;
349 TVector3 cluster_norm(xvect,yvect,zvect);
351 if(xvect==0&&yvect==0&&zvect==0)
353 cout <<
"WARNING: Cluster normal vector uninitialized. Aborting track" << endl;
359 rep->extrapolateToCylinder(*msop80, 95, TVector3(0,0,0), TVector3(0,0,1));
369 cout <<
"track extrapolateToXX failed" << endl;
385 for (
int i = 0;
i < 6;
i++) {
386 for (
int j =
i;
j < 6;
j++) {
411 cout <<
"WARNING: set_detector call received unrecognized char " << c << endl;
421 if(strcmp(caloid_to_name,
"EEMC")==0)
return 'E';
422 else if(strcmp(caloid_to_name,
"CEMC")==0)
return 'C';
423 else if(strcmp(caloid_to_name,
"FEMC")==0)
return 'F';
426 cout <<
"Unrecognized calorimeter. Default to CEMC" << endl;