HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarpoSelectorVertex.cxx
Go to the documentation of this file.
1 //
2 // File HarpoSelectorVertex.cxx
3 //
11 #include "HarpoSelectorVertex.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 #include "TVector3.h"
31 
32 #include <cstdlib>
33 #include <cstring>
34 #include <cassert>
35 #include <fstream>
36 #include <iostream>
37 
38 using namespace std;
39 
40 
41 ClassImp(HarpoSelectorVertex);
42 
44  {
45  unsigned int nd; // number of detectors
46  HarpoEventHeader *hdr = fEvt->GetHeader();
47 
48  assert(hdr != NULL);
49  hdr->print();
50 
51  for (nd = 0; nd < gkNDetectors; nd++) {
52  // if (fEvt->isdataExist(nd)) {
53  HarpoDccMap *plane = fEvt->GetDccMap(nd);
54  if (plane != NULL )plane->print();
55  }
56  }
57 
59 {
60  // Bool_t drawEvent = kFALSE;
61  nEvents++;
62  Int_t test = eventselection();
63 
64  fEvt->GetHeader()->SetEvAnaStatus(test);
65  Info("process","********** EvAnaStatus = %d *********",test);
66 
67  return;
68 }
69 
71 {
72  if (!gHDetSet->isExist(XDCC)) return 0;
73  if (!gHDetSet->isExist(YDCC)) return 0;
74  if(!fEvt->GetRecoEvent()) return 0;
75 
76 
77  TVector3 pgamma = TVector3(fDx,fDy,1).Unit();
78  TVector3 ppola = (TVector3(0,1,0).Cross(pgamma)).Unit();
79 
80  HarpoRecoEvent* reco = fEvt->GetRecoEvent();
81 
82  //Double_t xStart[2] = {-1,-1};
83  Double_t zStart[2] = {1000,1000};
84  TClonesArray* clArray = reco->GetClustersArray();
85  Int_t nCl = clArray->GetEntries();
86  for(Int_t iCl = 0; iCl<nCl; iCl++){
87  HarpoRecoClusters* cl = (HarpoRecoClusters*)clArray->At(iCl);
88  Int_t plane = cl->GetPlane();
89  if(cl->GetZ()<zStart[plane]){
90  // xStart[plane] = cl->GetX();
91  zStart[plane] = cl->GetZ();
92  }
93  }
94 
95  // if(gHDetSet->isExist(PMM2)){
96  // Pmm2Event *anaEvt = static_cast<Pmm2Event *>(fEvt->GetDetEvent(PMM2));
97  // }
98 
99  Double_t fTstart = 90;
100  Double_t fTend = 430;
101  Double_t fThr = 1e4;
102  for(Int_t plane = 0; plane<2; plane++){
103  if (!gHDetSet->isExist(plane)) continue;
104  // Process RAW data
105  HarpoDccMap* m = fEvt->GetDccMap(plane);
106  if ( m == NULL ) continue;
107  //Int_t i2 = 0;
108  Double_t qTotIn = 0;
109  Double_t qTotBefore = 0;
110  Double_t qTotAfter = 0;
111  for(Int_t j=0;j<NCHAN;j++){ // Channels
112  for(Int_t i=0;i<NADC;i++){ //Time bins
113  Double_t q = m->GetData(j,i);
114  if(q<0) continue;
115  if(i< fTstart ) qTotBefore += q;
116  if( i >fTend) qTotAfter += q;
117  if(i>=fTstart && i<=fTend) qTotIn += q;
118  }
119  }
120  if(qTotBefore>fThr || qTotAfter>fThr)
121  return -2;
122  }
123 
124 
125  TClonesArray* vArray = reco->GetVertex3DArray();
126  Int_t nV = vArray->GetEntries();
127  for(Int_t iV = 0; iV<nV; iV++){
128  HarpoRecoVertex3D* vertex = (HarpoRecoVertex3D*)vArray->At(iV);
129 
130  TVector3 p1 = vertex->GetP1Vertex3D();
131  TVector3 p2 = vertex->GetP2Vertex3D();
132  Double_t x0 = vertex->GetXvertex3D();
133  Double_t y0 = vertex->GetYvertex3D();
134  Double_t z0 = vertex->GetZvertex3D();
135 
136  Double_t u1u2 = (p1.Unit()).Dot(p2.Unit());
137  Double_t thetapm=TMath::ACos(u1u2);
138 
139  TVector3 ppola2 = ppola.Cross(pgamma);
140  TVector3 pPlus = TVector3(p1.Dot(pgamma.Unit()),p1.Dot(ppola.Unit()),p1.Dot(ppola2.Unit()));
141  TVector3 pMinus = TVector3(p2.Dot(pgamma.Unit()),p2.Dot(ppola.Unit()),p2.Dot(ppola2.Unit()));
142  Double_t omegapm = atan2((pPlus.Px()*pMinus.Py() - pMinus.Px()*pPlus.Py()),
143  (pPlus.Px()*pMinus.Pz() - pMinus.Px()*pPlus.Pz()));
144 
145  TVector3 psum = p1 + p2;
146  if(!(z0>120 && z0<350 && !(z0>255 && z0<270) && x0>5 && x0<283 && y0>5 && y0<283))
147  continue;
148  if(TMath::Abs(x0-142-fDx*z0)>20) continue;
149  if(TMath::Abs(y0-150-fDy*z0)>20) continue;
150  Info("eventselection","X: %g, Y: %g, Z: %g",x0,y0,z0);
151  if(thetapm == 0)
152  Info("eventselection","omega (thetapm == 0): %g %g %g",x0,y0,z0);
153 
154  if(thetapm>=fThetaMax) continue;
155  if(thetapm<=fThetaMin) continue;
156 
157  Info("eventselection","omega: %g, theta: %g (%g, %g, %g)",omegapm, thetapm,p1.Mag(),p2.Mag(),u1u2);
158 
159  return 0;
160  }
161 
162 
163  return -2;
164 
165 
166 }
167 
169 {
170 
171  // Initialise histograms here
172 
173  fThetaMin = 0;
174  fThetaMax = 0.2;
175  fDx = 0;
176  fDy = 0;
177  fChooseDx = 0;
178 
179  // Int_t fNbins = 500;
180  // Double_t fQmin = 10, fQmax = 1e7;
181 
182  // Long64_t Nbins;
183  // if( ! gHConfig->Lookup("template.nbins",Nbins ))
184  // Info("Constructor","Use default fnbinr %d",fNbins);
185  // else
186  // fNbins = Nbins;
187 
188  // Double_t thetaMin;
189  // if( ! gHConfig->Lookup("template.qmin",qmin ))
190  // Info("Constructor","Use default Qmin %.3g",fQmin);
191  // else
192  // fQmin = qmin;
193 
194  // Double_t qmax;
195  // if( ! gHConfig->Lookup("template.qmax",qmax ))
196  // Info("Constructor","Use default Qmax %.3g",fQmax);
197  // else
198  // fQmax = qmax;
199 
200 
201 
202 
203  }
204 
205 void HarpoSelectorVertex::Save(char * /* mode */)
206  {
207 
208  // OpenHistFile("eventselector");
209 
210  // Save histograms here
211 
212  }
213 
214 
215 void HarpoSelectorVertex::ConfigFrame(TGMainFrame* fMain, Int_t id)
216 {
217  // in hrecomonitorgui: Creates a popup window for analysis configuration
218  // You must define SetConfig() properly
219 
220  UInt_t xsize = 200;
221  UInt_t ysize2 = 20;
222  UInt_t ysize = 10*ysize2;
223  TGTransientFrame* main = new TGTransientFrame(gClient->GetRoot(), fMain, xsize, ysize);
224  main->Connect("CloseWindow()", "HarpoRecoMonitorGui", main, "CloseWindow()");
225  main->DontCallClose(); // to avoid double deletions.
226 
227  // use hierarchical cleaning
228  main->SetCleanup(kDeepCleanup);
229 
230  TGVerticalFrame* frame = new TGVerticalFrame(main,xsize,ysize,kVerticalFrame);
231 
232  // Object layout options
233  TGLayoutHints* fLayout1 = new TGLayoutHints(kLHintsLeft ,5,5,5,5);
234  TGLayoutHints* fLayout2 = new TGLayoutHints(kLHintsRight ,5,5,5,5);
235  TGLayoutHints* fLayout3 = new TGLayoutHints(kLHintsTop | kLHintsExpandX ,5,5,5,5);
236  TGLayoutHints* fLayout4 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,5,5,5,5);
237 
238  //________ DO NOT MODIFY ABOVE _____________________________
239 
240 
241 
242 
243  // Title of the analysis
244  TGLabel* fAnalysisLabel = new TGLabel(frame, "Template analysis");
245 
246  // Create a line for choosing value of parameter
247  TGHorizontalFrame* DxFrame = new TGHorizontalFrame(frame,xsize,ysize2,kHorizontalFrame);
248  TGLabel* DxLabel = new TGLabel(DxFrame, "fDx");
249  fChooseDx = new TGNumberEntry(DxFrame);
250  fChooseDx->SetNumber(fDx);
251  TGHorizontalFrame* DyFrame = new TGHorizontalFrame(frame,xsize,ysize2,kHorizontalFrame);
252  TGLabel* DyLabel = new TGLabel(DyFrame, "fDy");
253  fChooseDy = new TGNumberEntry(DyFrame);
254  fChooseDy->SetNumber(fDy);
255  TGHorizontalFrame* ThetaMinFrame = new TGHorizontalFrame(frame,xsize,ysize2,kHorizontalFrame);
256  TGLabel* ThetaMinLabel = new TGLabel(ThetaMinFrame, "fThetaMin");
257  fChooseThetaMin = new TGNumberEntry(ThetaMinFrame);
258  fChooseThetaMin->SetNumber(fThetaMin);
259  TGHorizontalFrame* ThetaMaxFrame = new TGHorizontalFrame(frame,xsize,ysize2,kHorizontalFrame);
260  TGLabel* ThetaMaxLabel = new TGLabel(ThetaMaxFrame, "fThetaMax");
261  fChooseThetaMax = new TGNumberEntry(ThetaMaxFrame);
262  fChooseThetaMax->SetNumber(fThetaMax);
263 
264  main->AddFrame(frame,fLayout4);
265  frame->AddFrame(fAnalysisLabel,fLayout3);
266  frame->AddFrame(DxFrame,fLayout3);
267  DxFrame->AddFrame(DxLabel,fLayout1);
268  DxFrame->AddFrame(fChooseDx,fLayout2);
269  frame->AddFrame(DyFrame,fLayout3);
270  DyFrame->AddFrame(DyLabel,fLayout1);
271  DyFrame->AddFrame(fChooseDy,fLayout2);
272  frame->AddFrame(ThetaMinFrame,fLayout3);
273  ThetaMinFrame->AddFrame(ThetaMinLabel,fLayout1);
274  ThetaMinFrame->AddFrame(fChooseThetaMin,fLayout2);
275  frame->AddFrame(ThetaMaxFrame,fLayout3);
276  ThetaMaxFrame->AddFrame(ThetaMaxLabel,fLayout1);
277  ThetaMaxFrame->AddFrame(fChooseThetaMax,fLayout2);
278 
279 
280 
281  //________ DO NOT MODIFY BELOW _____________________________
282  // Button to validate configuration
283  TGTextButton* setConf = new TGTextButton(frame,"Save Config",id);
284  setConf->Associate(fMain);
285 
286  frame->AddFrame(setConf,fLayout3);
287 
288  main->MapSubwindows();
289  main->MapWindow();
290  main->Resize();
291  return;
292 }
293 
294 
295 
297 {
298  // Update the configuration according to the values in the popup window
299 
300  if(!fChooseDx) return;
301 
302  fDx = fChooseDx->GetNumber();
303  fDy = fChooseDy->GetNumber();
304  fThetaMin = fChooseThetaMin->GetNumber();
305  fThetaMax = fChooseThetaMax->GetNumber();
306 }
Double_t GetZvertex3D()
Double_t GetYvertex3D()
#define NCHAN
Definition: HarpoDccMap.h:16
TVector3 GetP2Vertex3D()
Int_t eventselection()
Redefine empty default.
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
Object containing the reconstruction information for one event (with array of HarpoRecoClusters Harpo...
void Save(char *mode=NULL)
Dummy analysis to run as test and example. Give basic histograms of the data.
virtual void print()
FullEvent Header not scecific to the detectors The class is ....
virtual void print()
Cluster object, containing position, charge and quality information.
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
TVector3 GetP1Vertex3D()
#define NADC
Definition: HarpoDccMap.h:18
void ConfigFrame(TGMainFrame *fMain, Int_t id)
Redefine empty default.
Unknown Detector.
Definition: HarpoDet.h:18
void print()
Overloaded method which do all job.
TClonesArray * GetVertex3DArray()
const ULong_t gkNDetectors
Definition: HarpoDet.h:14
TClonesArray * GetClustersArray()
R__EXTERN HarpoDetSet * gHDetSet
Definition: HarpoDetSet.h:71
Double_t GetXvertex3D()
3D vertex object, containing position, angle and associated 2D vertexes, and quality info ...