Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CalibXT.cc
Go to the documentation of this file.
1 #include <iomanip>
2 #include <TGraphErrors.h>
4 #include <interface_main/SQRun.h>
7 #include <phool/PHNodeIterator.h>
8 #include <phool/PHIODataNode.h>
9 #include <phool/getClass.h>
10 #include <geom_svc/CalibParamXT.h>
12 #include "CalibXT.h"
13 using namespace std;
14 
15 CalibXT::CalibXT(const std::string& name) : SubsysReco(name), m_cal_xt(0), m_cal_int(0)
16 {
17  ;
18 }
19 
21 {
22  if (m_cal_xt ) delete m_cal_xt ;
23  if (m_cal_int) delete m_cal_int;
24 }
25 
27 {
29 }
30 
32 {
33  SQParamDeco* param_deco = findNode::getClass<SQParamDeco>(topNode, "SQParamDeco");
34  SQRun* run_header = findNode::getClass<SQRun >(topNode, "SQRun");
35  if (!param_deco || !run_header) return Fun4AllReturnCodes::ABORTEVENT;
36 
37  if (! m_cal_xt) m_cal_xt = new CalibParamXT();
38  m_cal_xt->SetMapIDbyDB(run_header->get_run_id());
39  m_cal_xt->ReadFromDB();
40  param_deco->set_variable(m_cal_xt->GetParamID(), m_cal_xt->GetMapID());
41 
42  if (! m_cal_int) m_cal_int = new CalibParamInTimeTaiwan();
43  m_cal_int->SetMapIDbyDB(run_header->get_run_id());
44  m_cal_int->ReadFromDB();
45  param_deco->set_variable(m_cal_int->GetParamID(), m_cal_int->GetMapID());
46 
48 }
49 
51 {
52  SQHitVector* hit_vec = findNode::getClass<SQHitVector>(topNode, "SQHitVector");
53  if (! hit_vec) return Fun4AllReturnCodes::ABORTEVENT;
54 
55  for (SQHitVector::Iter it = hit_vec->begin(); it != hit_vec->end(); it++) {
56  SQHit* hit = *it;
57  TGraphErrors* gr_t2x;
58  TGraphErrors* gr_t2dx;
59  int det = hit->get_detector_id();
60  if (m_cal_xt->Find(det, gr_t2x, gr_t2dx)) {
61  int ele = hit->get_element_id();
62  double center, width;
63  if (! m_cal_int->Find(det, ele, center, width)) {
64  cerr << " WARNING: Cannot find the in-time parameter for det=" << det << " ele=" << ele << " in CalibXT.\n";
65  continue;
66  //return Fun4AllReturnCodes::ABORTEVENT;
67  }
68  float t0 = center + width / 2;
69  float drift_time = t0 - hit->get_tdc_time();
70  hit->set_drift_distance(gr_t2x->Eval(drift_time));
72  //cout << "check: " << det << " " << ele << " " << t0 << " " << drift_time << " " << hit->get_drift_distance() << endl;
73  }
74  }
75 
77 }
78 
80 {
82 }
int InitRun(PHCompositeNode *topNode)
Definition: CalibXT.cc:31
virtual ~CalibXT()
Definition: CalibXT.cc:20
An SQ interface class to hold one detector hit.
Definition: SQHit.h:20
virtual ConstIter end() const
Definition: SQHitVector.h:59
bool Find(const short det, const short ele, double &center, double &width)
void SetMapIDbyDB(const std::string map_id)
Definition: RunParamBase.cc:31
void ReadFromDB()
Definition: RunParamBase.cc:97
std::string GetParamID()
Definition: RunParamBase.h:25
CalibXT(const std::string &name="CalibXT")
Definition: CalibXT.cc:15
virtual void set_drift_distance(const float a)
Definition: SQHit.h:58
std::vector< SQHit * >::iterator Iter
Definition: SQHitVector.h:38
virtual void set_variable(const std::string name, const std::string value)=0
virtual short get_detector_id() const
Return the detector ID of this hit.
Definition: SQHit.h:42
virtual float get_tdc_time() const
Return the TDC time (nsec) of this hit.
Definition: SQHit.h:54
An SQ interface class to hold a list of SQHit objects.
Definition: SQHitVector.h:32
std::string GetMapID()
Definition: RunParamBase.h:27
An SQ interface class to hold the run-level info.
Definition: SQRun.h:18
bool Find(const short det, TGraphErrors *&gr_t2x, TGraphErrors *&gr_t2dx)
SQParamDeco.h.
Definition: SQParamDeco.h:16
virtual short get_element_id() const
Return the element ID of this hit.
Definition: SQHit.h:45
virtual ConstIter begin() const
Definition: SQHitVector.h:58
int Init(PHCompositeNode *topNode)
Definition: CalibXT.cc:26
int process_event(PHCompositeNode *topNode)
Definition: CalibXT.cc:50
int End(PHCompositeNode *topNode)
Called at the end of all processing.
Definition: CalibXT.cc:79