Class Reference for E1039 Core & Analysis Software
test_minimum.cxx
Go to the documentation of this file.
1 #include <iostream>
2 #include <cmath>
3 #include <list>
4 
5 #include <TGeoManager.h>
6 #include <TRandom.h>
7 
8 #include <jobopts_svc/JobOptsSvc.h>
9 #include <geom_svc/GeomSvc.h>
10 #include <phfield/PHField.h>
11 #include <phfield/PHFieldConfig_v3.h>
12 #include <phfield/PHFieldUtility.h>
13 #include <phool/recoConsts.h>
14 
15 #include "GFField.h"
16 #include "GFFitter.h"
17 #include "GFTrack.h"
18 #include "FastTracklet.h"
19 #include "KalmanFastTracking.h"
20 
21 using namespace std;
22 
23 int main(int argc, char* argv[])
24 {
25  double fudgefactor = 0.;
26  if(argc > 1) fudgefactor = atof(argv[1]);
27  cout << "fudgefactor = " << fudgefactor << endl;
28 
30  rc->set_DoubleFlag("FMAGSTR", 1.);
31  rc->set_DoubleFlag("KMAGSTR", 1.);
32  rc->Print();
33 
34  JobOptsSvc* p_jobOptsSvc = JobOptsSvc::instance();
35  p_jobOptsSvc->init("run7_sim.opts");
36 
37  GeomSvc::UseDbSvc(true);
38  GeomSvc* p_geomSvc = GeomSvc::instance();
39  p_geomSvc->printTable();
40 
41  TGeoManager::Import("geom.root");
42 
43  //Let's hack a zero field
44  unique_ptr<PHFieldConfig> default_field_cfg(nullptr);
45  default_field_cfg.reset(new PHFieldConfig_v3(p_jobOptsSvc->m_fMagFile, p_jobOptsSvc->m_kMagFile));
46  PHField* phfield = PHFieldUtility::BuildFieldMap(default_field_cfg.get(), 10);
47  SQGenFit::GFField* gfield = new SQGenFit::GFField(phfield);
48  //gfield->disable();
49 
50  KalmanFastTracking* fasttracker = new KalmanFastTracking(phfield, gGeoManager, false);
51 
52  SQGenFit::GFFitter* fitter = new SQGenFit::GFFitter();
53  fitter->init(gfield, "KalmanFitterRefTrack");
54  fitter->setVerbosity(99);
55 
56  Tracklet candidate;
57  candidate.stationID = 7;
58  candidate.tx = 0.01;
59  candidate.ty = 0.01;
60  candidate.x0 = 5.;
61  candidate.y0 = 5.;
62  candidate.invP = 0.03;
63 
64  TRandom rndm(1);
65  for(int i = 0; i < 18; ++i)
66  {
67  SignedHit newHit;
68 
69  newHit.hit.detectorID = i < 6 ? i+1 : i+13;
70  double w_exp = candidate.getExpPositionW(newHit.hit.detectorID);
71  newHit.hit.elementID = p_geomSvc->getExpElementID(newHit.hit.detectorID, w_exp);
72  newHit.hit.pos = p_geomSvc->getMeasurement(newHit.hit.detectorID, newHit.hit.elementID);
73  newHit.hit.driftDistance = fabs(w_exp - newHit.hit.pos + rndm.Gaus(0., fudgefactor*p_geomSvc->getPlaneResolution(newHit.hit.detectorID)));
74  newHit.sign = w_exp > newHit.hit.pos ? 1 : -1;
75  newHit.hit.index = i;
76 
77  candidate.hits.push_back(newHit);
78  }
79  candidate.print();
80  fasttracker->fitTracklet(candidate);
81 
82  //cout << p_geomSvc->getInterception(19, 0.5, 0.5, 1.0, 1.0) << endl;
83  candidate.print();
84 
85  SQGenFit::GFTrack gtrack;
86  gtrack.setTracklet(candidate);
87  gtrack.setVerbosity(99);
88 
89  cout << "----------------- Fit status: " << fitter->processTrack(gtrack) << endl;
90  gtrack.postFitUpdate();
91  //gtrack.print();
92 
93  /*
94  genfit::MeasuredStateOnPlane msop1;
95  TVector3 pc(0., 0., 0.);
96  TVector3 pd(0., 0., 1.);
97  double l = gtrack.extrapolateToPlane(msop1, pc, pd);
98  cout << l << endl;
99  msop1.Print();
100  */
101 
102  cout << "----------------- Fit Results ------------------" << endl;
103  //gtrack.getGenFitTrack()->Print();
104  gtrack.print(99);
105 
106  //fitter->displayEvent();
107  cout << "Exit" << endl;
108  return 0;
109 }
User interface class about the geometry of detector planes.
Definition: GeomSvc.h:164
void printTable()
Definition: GeomSvc.cxx:1134
static GeomSvc * instance()
singlton instance
Definition: GeomSvc.cxx:212
void getMeasurement(int detectorID, int elementID, double &measurement, double &dmeasurement)
Convert the detectorID and elementID to the actual hit position.
Definition: GeomSvc.cxx:651
static bool UseDbSvc()
Definition: GeomSvc.h:352
double getPlaneResolution(int detectorID) const
Definition: GeomSvc.h:245
int getExpElementID(int detectorID, double pos_exp)
Definition: GeomSvc.cxx:677
Int_t index
Definition: SRawEvent.h:77
Float_t pos
Definition: SRawEvent.h:82
Short_t elementID
Definition: SRawEvent.h:79
Short_t detectorID
Definition: SRawEvent.h:78
Float_t driftDistance
Definition: SRawEvent.h:81
int fitTracklet(Tracklet &tracklet)
PHFieldConfig_v3 implements field configuration information for input a field map file.
static PHField * BuildFieldMap(const PHFieldConfig *field_config, const int verbosity=0)
Build or build field map with a configuration object.
transient DST object for field storage and access
Definition: PHField.h:14
virtual void set_DoubleFlag(const std::string &name, const double flag)
Definition: PHFlag.cc:77
void init(GFField *field, const TString &fitter_choice="KalmanFitterRefTrack")
Definition: GFFitter.cxx:29
void setVerbosity(unsigned int v)
Definition: GFFitter.cxx:23
int processTrack(GFTrack &track, bool display=false)
Definition: GFFitter.cxx:50
void print(unsigned int debugLvl=0)
Definition: GFTrack.cxx:467
void setVerbosity(unsigned int v)
Definition: GFTrack.cxx:114
void postFitUpdate(bool updateMeasurements=true)
Definition: GFTrack.cxx:385
void setTracklet(Tracklet &tracklet, double z_reference=590., bool wildseedcov=false)
Definition: GFTrack.cxx:338
double invP
Definition: FastTracklet.h:239
std::list< SignedHit > hits
Definition: FastTracklet.h:228
double y0
Definition: FastTracklet.h:238
int stationID
Definition: FastTracklet.h:214
double ty
Definition: FastTracklet.h:236
double tx
Definition: FastTracklet.h:235
double x0
Definition: FastTracklet.h:237
double getExpPositionW(int detectorID) const
void print(std::ostream &os=std::cout)
void Print() const
print all the parameters
Definition: recoConsts.cc:214
static recoConsts * instance()
Definition: recoConsts.cc:7
int main(int argc, char *argv[])