Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OnlMonTrigNim.cc
Go to the documentation of this file.
1 #include <iomanip>
3 #include <TStyle.h>
4 #include <TH2D.h>
8 #include <phool/PHNodeIterator.h>
9 #include <phool/PHIODataNode.h>
10 #include <phool/getClass.h>
11 #include <geom_svc/GeomSvc.h>
12 #include <UtilAna/UtilHist.h>
13 #include "OnlMonServer.h"
14 #include "OnlMonTrigNim.h"
15 using namespace std;
16 
18 {
19  NumCanvases(1);
20  Name("OnlMonTrigNim");
21  Title("NIM Trigger");
22 }
23 
25 {
27 }
28 
30 {
31  h2_count = new TH2D("h2_count", "N of events in which each plane has hit;;", 8, 0.5, 8.5, 10, 0.5, 10.5);
32  for (int ii = 1; ii <= 5; ii++) {
33  ostringstream oss;
34  oss << "NIM " << ii;
35  h2_count->GetYaxis()->SetBinLabel(ii, oss.str().c_str());
36  oss.str("");
37  oss << "FPGA " << ii;
38  h2_count->GetYaxis()->SetBinLabel(ii + 5, oss.str().c_str());
39  }
40  h2_count->GetXaxis()->SetBinLabel(1, "H1X");
41  h2_count->GetXaxis()->SetBinLabel(2, "H1Y");
42  h2_count->GetXaxis()->SetBinLabel(3, "H2X");
43  h2_count->GetXaxis()->SetBinLabel(4, "H2Y");
44  h2_count->GetXaxis()->SetBinLabel(5, "H3X");
45  h2_count->GetXaxis()->SetBinLabel(6, "H4X");
46  h2_count->GetXaxis()->SetBinLabel(7, "H4Y1");
47  h2_count->GetXaxis()->SetBinLabel(8, "H4Y2");
48 
49  RegisterHist(h2_count);
50 
52 }
53 
55 {
56  SQEvent* event = findNode::getClass<SQEvent >(topNode, "SQEvent");
57  SQHitVector* hit_vec = findNode::getClass<SQHitVector>(topNode, "SQHitVector");
58  if (!event || !hit_vec) return Fun4AllReturnCodes::ABORTEVENT;
59 
61  HitListMap_t lhm;
62  for (SQHitVector::ConstIter it = hit_vec->begin(); it != hit_vec->end(); it++) {
63  // We better select good hits here in the fugure
64  lhm[(*it)->get_detector_id()].push_back(*it);
65  }
66 
68  GeomSvc* geom = GeomSvc::instance();
69  bool hit_h1x = lhm.find(geom->getDetectorID("H1B" )) != lhm.end()
70  || lhm.find(geom->getDetectorID("H1T" )) != lhm.end();
71  bool hit_h1y = lhm.find(geom->getDetectorID("H1L" )) != lhm.end()
72  || lhm.find(geom->getDetectorID("H1R" )) != lhm.end();
73  bool hit_h2x = lhm.find(geom->getDetectorID("H2B" )) != lhm.end()
74  || lhm.find(geom->getDetectorID("H2T" )) != lhm.end();
75  bool hit_h2y = lhm.find(geom->getDetectorID("H2L" )) != lhm.end()
76  || lhm.find(geom->getDetectorID("H2R" )) != lhm.end();
77  bool hit_h3x = lhm.find(geom->getDetectorID("H3B" )) != lhm.end()
78  || lhm.find(geom->getDetectorID("H3T" )) != lhm.end();
79  bool hit_h4x = lhm.find(geom->getDetectorID("H4B" )) != lhm.end()
80  || lhm.find(geom->getDetectorID("H4T" )) != lhm.end();
81  bool hit_h4y1 = lhm.find(geom->getDetectorID("H4Y1L")) != lhm.end()
82  || lhm.find(geom->getDetectorID("H4Y1R")) != lhm.end();
83  bool hit_h4y2 = lhm.find(geom->getDetectorID("H4Y2L")) != lhm.end()
84  || lhm.find(geom->getDetectorID("H4Y2R")) != lhm.end();
85 
87  bool trig_flag[10] = {
88  event->get_trigger(SQEvent::NIM1),
89  event->get_trigger(SQEvent::NIM2),
90  event->get_trigger(SQEvent::NIM3),
91  event->get_trigger(SQEvent::NIM4),
92  event->get_trigger(SQEvent::NIM5),
93  event->get_trigger(SQEvent::MATRIX1),
94  event->get_trigger(SQEvent::MATRIX2),
95  event->get_trigger(SQEvent::MATRIX3),
96  event->get_trigger(SQEvent::MATRIX4),
97  event->get_trigger(SQEvent::MATRIX5)
98  };
99  for (int i_trig = 0; i_trig < 10; i_trig++) {
100  if (! trig_flag[i_trig]) continue;
101  h2_count->Fill(0.0, i_trig+1); // Count N of all events in the underflow bin
102  if (hit_h1x ) h2_count->Fill(1, i_trig+1);
103  if (hit_h1y ) h2_count->Fill(2, i_trig+1);
104  if (hit_h2x ) h2_count->Fill(3, i_trig+1);
105  if (hit_h2y ) h2_count->Fill(4, i_trig+1);
106  if (hit_h3x ) h2_count->Fill(5, i_trig+1);
107  if (hit_h4x ) h2_count->Fill(6, i_trig+1);
108  if (hit_h4y1) h2_count->Fill(7, i_trig+1);
109  if (hit_h4y2) h2_count->Fill(8, i_trig+1);
110  }
111 
113 }
114 
116 {
118 }
119 
121 {
122  h2_count = (TH2*)FindMonHist("h2_count");
123  return (h2_count ? 0 : 1);
124 }
125 
127 {
128  static TH2* h2_rate = 0;
129  if (! h2_rate) delete h2_rate;
130  h2_rate = (TH2*)h2_count->Clone("h2_rate");
131  h2_rate->SetTitle("Percent of events in which each plane has hit");
132  for (int iy = 1; iy <= h2_rate->GetNbinsY(); iy++) {
133  double cont0 = h2_rate->GetBinContent(0, iy); // underflow bin
134  if (cont0 <= 0) continue;
135  for (int ix = 1; ix <= h2_rate->GetNbinsX(); ix++) {
136  double cont = h2_rate->GetBinContent(ix, iy);
137  h2_rate->SetBinContent(ix, iy, 100 * cont / cont0);
138  }
139  }
140  h2_rate->GetZaxis()->SetRangeUser(0, 100);
141 
142  OnlMonCanvas* can0 = GetCanvas(0);
143  TPad* pad0 = can0->GetMainPad();
144  pad0->SetGrid();
145  pad0->Divide(1, 2);
146  pad0->cd(1);
147  h2_count->Draw("colz");
148  pad0->cd(2);
149  h2_rate->Draw("colz");
150  h2_rate->SetMarkerSize(2.0); // = text size (1.0 by default)
151  gStyle->SetPaintTextFormat("3.0f");
152  h2_rate->Draw("TEXTsame");
153 
154  if (h2_count->Integral() == 0) {
155  can0->AddMessage("No event.");
157  } else {
159  }
160 
161  return 0;
162 }
std::vector< SQHit * >::const_iterator ConstIter
Definition: SQHitVector.h:37
int InitRunOnlMon(PHCompositeNode *topNode)
int ProcessEventOnlMon(PHCompositeNode *topNode)
int EndOnlMon(PHCompositeNode *topNode)
void SetStatus(const MonStatus_t stat)
Definition: OnlMonCanvas.h:42
int InitOnlMon(PHCompositeNode *topNode)
std::map< short, HitList_t > HitListMap_t
Definition: OnlMonTrigNim.h:11
An SQ interface class to hold a list of SQHit objects.
Definition: SQHitVector.h:32
An SQ interface class to hold one event header.
Definition: SQEvent.h:17
TPad * GetMainPad()
Definition: OnlMonCanvas.cc:74
static GeomSvc * instance()
singlton instance
Definition: GeomSvc.cxx:211
int getDetectorID(const std::string &detectorName) const
Get the plane position.
Definition: GeomSvc.h:184
void AddMessage(const char *msg)
Definition: OnlMonCanvas.cc:50