HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarpoEventSelector.cxx
Go to the documentation of this file.
1 //
2 // File HarpoEventSelector.cxx
3 //
11 #include "HarpoEventSelector.h"
12 #include "HarpoConfig.h"
13 #include "HarpoDetSet.h"
14 #include "HarpoDebug.h"
15 #include "HarpoDccEvent.h"
16 #include "Pmm2Event.h"
17 #include "HarpoEvent.h"
18 #include "HarpoRecoEvent.h"
19 #include "HarpoSimEvent.h"
20 #include "HarpoRecoMonitorGui.h"
21 
22 #include "TFile.h"
23 #include "TStyle.h"
24 #include "TCanvas.h"
25 #include "TLatex.h"
26 #include "TGraph.h"
27 #include "TF1.h"
28 #include "TMath.h"
29 #include "TSystem.h"
30 
31 #include <cstdlib>
32 #include <cstring>
33 #include <cassert>
34 #include <fstream>
35 #include <iostream>
36 
37 using namespace std;
38 
39 
40 ClassImp(HarpoEventSelector);
41 
43  {
44  unsigned int nd; // number of detectors
45  HarpoEventHeader *hdr = fEvt->GetHeader();
46 
47  assert(hdr != NULL);
48  hdr->print();
49 
50  for (nd = 0; nd < gkNDetectors; nd++) {
51  // if (fEvt->isdataExist(nd)) {
52  HarpoDccMap *plane = fEvt->GetDccMap(nd);
53  if (plane != NULL )plane->print();
54  }
55  }
56 
58 {
59  // Bool_t drawEvent = kFALSE;
60  nEvents++;
61  Int_t test = eventselection();
62 
63  fEvt->GetHeader()->SetEvAnaStatus(test);
64  return;
65 }
66 
68 {
69 
70  if (!gHDetSet->isExist(XDCC)) return 0;
71  if (!gHDetSet->isExist(YDCC)) return 0;
72 
73  // Process RAW data
74  Double_t qchmax = 0;
75  for(Int_t ndet=0;ndet<2;ndet++) { // Detectors 0 and 1 = X and Y planes
76  if (!gHDetSet->isExist(ndet)) continue;
77  HarpoDccMap* m = fEvt->GetDccMap(ndet);
78  if ( m == NULL ) continue;
79 
80  for(Int_t j=0;j<NCHAN;j++){ // Channels
81  Double_t qch = 0;
82  for(Int_t i=0;i<NADC;i++){ // Time bins
83  Double_t q = m->GetData(j,i);
84  if(q <= 0) continue;
85  qch += q;
86  }
87  if(qch>qchmax) qchmax = qch;
88  if(qch>50000)
89  Info("eventselection","plane %d, ch %d: QchMax = %g",ndet,j,qch);
90  }
91  }
92  if(qchmax<fQchMax) return -2;
93  else{
94  Info("eventselection","QchMax = %g",qchmax);
95  return 0;
96  }
97 
98 
99 }
100 
102 {
103  fQch = 0;
104  fQchMax = 80000;
105  fChooseQchMax = 0;
106 
107  Double_t qchmax;
108  if( ! gHConfig->Lookup("selecttemplate.qchmax",qchmax ))
109  Info("Constructor","Use default QchMax %.3g",fQchMax);
110  else
111  fQchMax = qchmax;
112 
113 }
114 
115 void HarpoEventSelector::Save(char * /* mode */)
116  {
117 
118 
119  OpenHistFile("eventselector");
120 
121 
122  }
123 
124 
125 
126 void HarpoEventSelector::ConfigFrame(TGMainFrame* fMain, Int_t id)
127 {
128  // in hrecomonitorgui: Creates a popup window for analysis configuration
129  // You must define SetConfig() properly
130 
131  UInt_t xsize = 200;
132  UInt_t ysize2 = 20;
133  UInt_t ysize = 10*ysize2;
134  TGTransientFrame* main = new TGTransientFrame(gClient->GetRoot(), fMain, xsize, ysize);
135  main->Connect("CloseWindow()", "HarpoRecoMonitorGui", main, "CloseWindow()");
136  main->DontCallClose(); // to avoid double deletions.
137 
138  // use hierarchical cleaning
139  main->SetCleanup(kDeepCleanup);
140 
141  TGVerticalFrame* frame = new TGVerticalFrame(main,xsize,ysize,kVerticalFrame);
142 
143  // Object layout options
144  TGLayoutHints* fLayout1 = new TGLayoutHints(kLHintsLeft ,5,5,5,5);
145  TGLayoutHints* fLayout2 = new TGLayoutHints(kLHintsRight ,5,5,5,5);
146  TGLayoutHints* fLayout3 = new TGLayoutHints(kLHintsTop | kLHintsExpandX ,5,5,5,5);
147  TGLayoutHints* fLayout4 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,5,5,5,5);
148 
149  //________ DO NOT MODIFY ABOVE _____________________________
150 
151 
152 
153 
154  // Title of the analysis
155  TGLabel* fAnalysisLabel = new TGLabel(frame, "Template selector");
156 
157  // Create a line for choosing value of parameter
158  TGHorizontalFrame* QchMaxFrame = new TGHorizontalFrame(frame,xsize,ysize2,kHorizontalFrame);
159  TGLabel* QchMaxLabel = new TGLabel(QchMaxFrame, "fQchMax");
160  fChooseQchMax = new TGNumberEntry(QchMaxFrame);
161  fChooseQchMax->SetNumber(fQchMax);
162 
163  main->AddFrame(frame,fLayout4);
164  frame->AddFrame(fAnalysisLabel,fLayout3);
165  frame->AddFrame(QchMaxFrame,fLayout3);
166  QchMaxFrame->AddFrame(QchMaxLabel,fLayout1);
167  QchMaxFrame->AddFrame(fChooseQchMax,fLayout2);
168 
169 
170 
171  //________ DO NOT MODIFY BELOW _____________________________
172  // Button to validate configuration
173  TGTextButton* setConf = new TGTextButton(frame,"Save Config",id);
174  setConf->Associate(fMain);
175 
176  frame->AddFrame(setConf,fLayout3);
177 
178  main->MapSubwindows();
179  main->MapWindow();
180  main->Resize();
181  return;
182 }
183 
184 
186 {
187  // Update the configuration according to the values in the popup window
188 
189  if(!fChooseQchMax) return;
190 
191  fQchMax = fChooseQchMax->GetNumber();
192 }
#define NCHAN
Definition: HarpoDccMap.h:16
Double_t GetData(Int_t i, Int_t j)
Set/Get Data Cell.
Definition: HarpoDccMap.cxx:84
int main(int argc, char **argv)
Definition: drawAnalyse.cxx:25
Bool_t isExist(ULong_t det)
Detecror date exist //! Number of Real Detectors.
Definition: HarpoDetSet.h:33
Dcc Plane X.
Definition: HarpoDet.h:19
virtual void print()
FullEvent Header not scecific to the detectors The class is ....
void ConfigFrame(TGMainFrame *fMain, Int_t id)
Redefine empty default.
virtual void print()
unpacked dcc data The class contains the data map for DCC or Feminos The data is stored as a 2D TMatr...
Definition: HarpoDccMap.h:29
void Save(char *mode=NULL)
Dummy analysis to run as test and example. Give basic histograms of the data.
#define NADC
Definition: HarpoDccMap.h:18
Int_t eventselection()
Redefine empty default.
TDirectory * OpenHistFile(Int_t run, const char *dir, const char *extra="", Int_t update=0)
Definition: HarpoTools.cxx:55
void print()
Overloaded method which do all job.
Unknown Detector.
Definition: HarpoDet.h:18
Bool_t Lookup(const char *path, Bool_t &val)
Lookup function for scalar values.
const ULong_t gkNDetectors
Definition: HarpoDet.h:14
HarpoConfig * gHConfig
R__EXTERN HarpoDetSet * gHDetSet
Definition: HarpoDetSet.h:71