Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CalibInTime.cc
Go to the documentation of this file.
1 #include <iomanip>
2 #include <cmath>
4 #include <interface_main/SQRun.h>
7 #include <phool/PHNodeIterator.h>
8 #include <phool/PHIODataNode.h>
9 #include <phool/getClass.h>
12 #include "CalibInTime.h"
13 using namespace std;
14 
15 CalibInTime::CalibInTime(const std::string& name) : SubsysReco(name), m_cal_taiwan(0), m_cal_v1495(0)
16 {
17  ;
18 }
19 
21 {
22  if (m_cal_taiwan) delete m_cal_taiwan;
23  if (m_cal_v1495 ) delete m_cal_v1495;
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_taiwan) m_cal_taiwan = new CalibParamInTimeTaiwan();
38  m_cal_taiwan->SetMapIDbyDB(run_header->get_run_id());
39  m_cal_taiwan->ReadFromDB();
40  param_deco->set_variable(m_cal_taiwan->GetParamID(), m_cal_taiwan->GetMapID());
41 
42  if (! m_cal_v1495) m_cal_v1495 = new CalibParamInTimeV1495();
43  m_cal_v1495->SetMapIDbyDB(run_header->get_run_id());
44  m_cal_v1495->ReadFromDB();
45  param_deco->set_variable(m_cal_v1495->GetParamID(), m_cal_v1495->GetMapID());
46 
48 }
49 
51 {
52  SQHitVector* hit_vec = findNode::getClass<SQHitVector>(topNode, "SQHitVector");
53  SQHitVector* trig_hit_vec = findNode::getClass<SQHitVector>(topNode, "SQTriggerHitVector");
54  if (!hit_vec || !trig_hit_vec) return Fun4AllReturnCodes::ABORTEVENT;
55 
56  for (SQHitVector::Iter it = hit_vec->begin(); it != hit_vec->end(); it++) {
57  SQHit* hit = *it;
58  int det = hit->get_detector_id();
59  int ele = hit->get_element_id();
60  if (det == 0) continue;
61 
62  double center, width;
63  if (! m_cal_taiwan->Find(det, ele, center, width)) {
64  cerr << " WARNING: Cannot find the in-time parameter for det=" << det << " ele=" << ele << ".\n";
65  hit->set_in_time(false);
66  continue;
67  //return Fun4AllReturnCodes::ABORTEVENT;
68  }
69  hit->set_in_time( fabs(hit->get_tdc_time() - center) <= width / 2 );
70  }
71 
72  for (SQHitVector::Iter it = trig_hit_vec->begin(); it != trig_hit_vec->end(); it++) {
73  SQHit* hit = *it;
74  int det = hit->get_detector_id();
75  int ele = hit->get_element_id();
76  int lvl = hit->get_level();
77  if (det == 0) continue;
78 
79  double center, width;
80  if (! m_cal_v1495->Find(det, ele, lvl, center, width)) {
81  cerr << " WARNING: Cannot find the in-time parameter for trigger det=" << det << " ele=" << ele << " lvl=" << lvl << ".\n";
82  hit->set_in_time(false);
83  continue;
84  //return Fun4AllReturnCodes::ABORTEVENT;
85  }
86  hit->set_in_time( fabs(hit->get_tdc_time() - center) <= width / 2 );
87  }
88 
90 }
91 
93 {
95 }
bool Find(const short det, const short ele, const short lvl, double &center, double &width)
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
int Init(PHCompositeNode *topNode)
Definition: CalibInTime.cc:26
int End(PHCompositeNode *topNode)
Called at the end of all processing.
Definition: CalibInTime.cc:92
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
int process_event(PHCompositeNode *topNode)
Definition: CalibInTime.cc:50
virtual float get_tdc_time() const
Return the TDC time (nsec) of this hit.
Definition: SQHit.h:54
CalibInTime(const std::string &name="CalibInTime")
Definition: CalibInTime.cc:15
An SQ interface class to hold a list of SQHit objects.
Definition: SQHitVector.h:32
virtual void set_in_time(const bool a)
Definition: SQHit.h:91
std::string GetMapID()
Definition: RunParamBase.h:27
An SQ interface class to hold the run-level info.
Definition: SQRun.h:18
virtual ~CalibInTime()
Definition: CalibInTime.cc:20
SQParamDeco.h.
Definition: SQParamDeco.h:16
virtual short get_level() const
Return the trigger level of this hit. Meaningful only if this hit is of V1495 TDC.
Definition: SQHit.h:51
virtual short get_element_id() const
Return the element ID of this hit.
Definition: SQHit.h:45
int InitRun(PHCompositeNode *topNode)
Definition: CalibInTime.cc:31
virtual ConstIter begin() const
Definition: SQHitVector.h:58