16 #include <ktracker/SRecEvent.h>
26 m_file_name(
"output.root"),
39 std::cout <<
"Fun4AllVectEventOutputManager::OpenFile(): Attempting to open file: " << m_file_name <<
" with tree: " << m_tree_name << std::endl;
40 m_file =
new TFile(m_file_name.c_str(),
"RECREATE");
42 if (!m_file || m_file->IsZombie()) {
43 std::cerr <<
"Error: Could not create file " << m_file_name << std::endl;
46 std::cout <<
"File " << m_file->GetName() <<
" opened successfully." << std::endl;
49 m_tree =
new TTree(m_tree_name.c_str(),
"Tree for storing events");
51 std::cerr <<
"Error: Could not create tree " << m_tree_name << std::endl;
54 std::cout <<
"Tree " << m_tree->GetName() <<
" created successfully." << std::endl;
57 m_tree->Branch(
"runID", &runID,
"runID/I");
58 m_tree->Branch(
"spillID", &spillID,
"spillID/I");
59 m_tree->Branch(
"eventID", &eventID,
"eventID/I");
60 m_tree->Branch(
"rfID", &rfID,
"rfID/I");
61 m_tree->Branch(
"turnID", &turnID,
"turnID/I");
62 m_tree->Branch(
"rfIntensities", rfIntensities,
"rfIntensities[33]/I");
63 m_tree->Branch(
"fpgaTriggers", fpgaTriggers,
"fpgaTriggers[5]/I");
64 m_tree->Branch(
"nimTriggers", nimTriggers,
"nimTriggers[5]/I");
66 m_tree->Branch(
"detectorIDs", &detectorIDs);
67 m_tree->Branch(
"elementIDs", &elementIDs);
68 m_tree->Branch(
"tdcTimes", &tdcTimes);
69 m_tree->Branch(
"driftDistances", &driftDistances);
70 m_tree->Branch(
"hitsInTime", &hitsInTime);
72 m_tree->Branch(
"triggerDetectorIDs", &triggerDetectorIDs);
73 m_tree->Branch(
"triggerElementIDs", &triggerElementIDs);
74 m_tree->Branch(
"triggerTdcTimes", &triggerTdcTimes);
75 m_tree->Branch(
"triggerDriftDistances", &triggerDriftDistances);
76 m_tree->Branch(
"triggerHitsInTime", &triggerHitsInTime);
79 m_evt = findNode::getClass<SQEvent>(startNode,
"SQEvent");
80 m_hit_vec = findNode::getClass<SQHitVector>(startNode,
"SQHitVector");
81 m_trig_hit_vec = findNode::getClass<SQHitVector>(startNode,
"SQTriggerHitVector");
87 if (!m_file || !m_tree) {
110 for (
int i = -16; i < 16; ++i) {
116 for (
int ihit = 0; ihit < m_hit_vec->
size(); ++ihit) {
117 SQHit* hit = m_hit_vec->
at(ihit);
127 if (m_trig_hit_vec) {
128 for (
int ihit = 0; ihit < m_trig_hit_vec->
size(); ++ihit) {
129 SQHit* hit = m_trig_hit_vec->
at(ihit);
134 triggerHitsInTime.push_back(hit->
is_in_time());
144 std::cout <<
"Fun4AllVectEventOutputManager::CloseFile(): Closing file: " << m_file_name << std::endl;
155 driftDistances.clear();
158 triggerDetectorIDs.clear();
159 triggerElementIDs.clear();
160 triggerTdcTimes.clear();
161 triggerDriftDistances.clear();
162 triggerHitsInTime.clear();
virtual int Write(PHCompositeNode *startNode)
write starting from given node
virtual ~Fun4AllVectEventOutputManager()
Fun4AllVectEventOutputManager(const std::string &myname="UNIVERSALOUT")
int OpenFile(PHCompositeNode *startNode)
virtual int get_run_id() const =0
Return the run ID.
virtual int get_qie_rf_intensity(const short i) const =0
Return the i-th QIE RF intensity, where i=-16...+16.
virtual bool get_trigger(const SQEvent::TriggerMask i) const =0
Return the trigger bit (fired or not) of the selected trigger channel.
virtual int get_qie_turn_id() const =0
Return the QIE turn ID.
virtual int get_qie_rf_id() const =0
Return the QIE RF ID.
virtual int get_spill_id() const =0
Return the spill ID.
virtual int get_event_id() const =0
Return the event ID, which is unique per run.
virtual const SQHit * at(const size_t idkey) const =0
virtual size_t size() const =0
An SQ interface class to hold one detector hit.
virtual float get_drift_distance() const
Return the drift distance of this hit. Probably the value is not properly set at present....
virtual bool is_in_time() const
Return 'true' if this hit is in the time window.
virtual short get_element_id() const
Return the element ID of this hit.
virtual float get_tdc_time() const
Return the TDC time (nsec) of this hit.
virtual short get_detector_id() const
Return the detector ID of this hit.