HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarpoAnalyseEtrack.cxx
Go to the documentation of this file.
1 //
2 // File HarpoAnalyseEtrack.cxx
3 //
11 #include "HarpoAnalyseEtrack.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 "TpcSimMCEvent.h"
21 #include "MakeNiceHisto.h"
22 
23 #include "TFile.h"
24 #include "TStyle.h"
25 #include "TCanvas.h"
26 #include "TRootEmbeddedCanvas.h"
27 #include "TLatex.h"
28 #include "TGraph.h"
29 #include "TF1.h"
30 #include "TMath.h"
31 #include "TGLabel.h"
32 #include "TSystem.h"
33 
34 #include <cstdlib>
35 #include <cstring>
36 #include <cassert>
37 #include <fstream>
38 #include <iostream>
39 
40 ClassImp(HarpoAnalyseEtrack);
41 
43  {
44  unsigned int nd; // number of detectors
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  Info("PROCESS","START %ld",nEvents);
62  //???????????????????????????????
63  if(fEvt->GetRecoEvent()){ // Reconstructed data (clusters, tracks, matched tracks)
64  HarpoRecoEvent* reco = fEvt->GetRecoEvent();
65  // Clusters in the event (both X and Y directions)
66  TClonesArray* trArray = reco->GetKalmanTracksArray();
67  Int_t nTr = trArray->GetEntries();
68  // 2D Vertexes in the event (both X and Y directions)
69  TClonesArray* vArray = reco->GetVertexArray();
70  //Int_t nV = vArray->GetEntries();
71  TClonesArray* v3DArray = reco->GetVertex3DArray();
72  Int_t nV3D = v3DArray->GetEntries();
73  //std::cout << nV3D << " " << nV << " " << nTr << std::endl;
74  for(Int_t iV3D = 0; iV3D<nV3D; iV3D++){
75  HarpoRecoVertex3D* vertex3D = (HarpoRecoVertex3D*)v3DArray->At(iV3D);
76  Int_t iVx = vertex3D->GetVertexX();
77  Int_t iVy = vertex3D->GetVertexX();
78  HarpoRecoVertex* vertexX = (HarpoRecoVertex*)vArray->At(iVx);
79  HarpoRecoVertex* vertexY = (HarpoRecoVertex*)vArray->At(iVy);
80  Int_t idTrack[2][2];
81  idTrack[XPLANE][0] = vertexX->GetTr1Vertex1();
82  idTrack[XPLANE][1] = vertexX->GetTr2Vertex2();
83  idTrack[YPLANE][0] = vertexY->GetTr1Vertex1();
84  idTrack[YPLANE][1] = vertexY->GetTr2Vertex2();
85  Double_t chi2[8][2][2];
86  Int_t ncl[2][2];
87  for(Int_t plane = 0; plane<2; plane++){
88  for(Int_t i = 0; i<2; i++){
89  for(Int_t j = 0; j<8; j++)
90  chi2[j][plane][i] = -1;
91  ncl[plane][i] = -1;
92  }
93  }
94  // for(Int_t plane = 0; plane<2; plane++){
95  // for(Int_t i = 0; i<2; i++){
96  // Info("process","%d %d %d",plane,i,idTrack[plane][i]);
97  // }
98  // }
99  for(Int_t itr = 0; itr<nTr; itr++){
100  HarpoRecoKalmanTracks* track = (HarpoRecoKalmanTracks*)trArray->At(itr);
101  for(Int_t plane = 0; plane<2; plane++){
102  for(Int_t i = 0; i<2; i++){
103  if(track->GetPlane()==plane && track->GetNtrack()==idTrack[plane][i]){
104  ncl[plane][i] = track->GetNclusterTrack();
105  chi2[0][plane][i] = track->GetXstart();
106  chi2[1][plane][i] = track->GetZstart();
107  chi2[2][plane][i] = track->GetPxStart();
108  chi2[3][plane][i] = track->GetPzStart();
109  chi2[4][plane][i] = track->GetXend();
110  chi2[5][plane][i] = track->GetZend();
111  chi2[6][plane][i] = track->GetPxEnd();
112  chi2[7][plane][i] = track->GetPzEnd();
113 
114  //Info("process","%d %d %g",plane,idTrack[plane][i],chi2[plane][i]);
115  }
116  }
117  }
118  }
119 
120  hChi2_XY->Fill(chi2[0][0][0],chi2[0][1][0]);
121  hChi2_XY->Fill(chi2[0][0][1],chi2[0][1][1]);
122  hChi2_3D->Fill(0.5*(chi2[0][0][1]+chi2[0][1][1]));
123  hChi2_3D->Fill(0.5*(chi2[0][0][0]+chi2[0][1][0]));
124  for(Int_t i = 0; i<2; i++){
125  Double_t data[18];
126  for(Int_t j = 0; j<18; j++) data[j] = -2;
127  data[0] = ncl[0][i];
128  data[1] = ncl[1][i];
129  for(Int_t j = 0; j<8; j++){
130  //if(ncl[0][i]<j+4 || ncl[1][i] < j+4) break;
131  data[2*j+2] = chi2[j][0][i];
132  data[2*j+3] = chi2[j][1][i];
133  }
134  std::cerr << nEvents << " ";
135  for(Int_t j = 0; j<18; j++)
136  std::cerr << data[j] << " ";
137  std::cerr << std::endl;
138  fNtuple->Fill(data);
139 
140  }
141  }
142  }
143 
144 
145 
146 
147  // if (gHDetSet->isExist(SIMDET)){
148  // HarpoSimEvent *simEvt = (HarpoSimEvent *)(fEvt->GetDetEvent(SIMDET));
149  // Int_t nIonTr = simEvt->GetNtracks();
150  // for(Int_t i = 0; i<nIonTr; i++){
151  // TpcSimIonisationTrack* tr = simEvt->GetIonisationTrack(i);
152  // Int_t nPoints = tr->GetNpoints();
153  // for(Int_t j = 0; j<nPoints; j++){
154  // TpcSimIonisationPoint* point = tr->GetPoint(j);
155  // hNeSim->Fill(point->GetNe());
156  // }
157  // }
158  // TpcSimMCEvent* mcEvent = simEvt->GetMCEvent();
159  // Int_t nMCtr = mcEvent->GetNtracks();
160  // data[4] = nMCtr;
161  // for(Int_t i = 0; i<nMCtr; i++){
162  // TpcSimMCTrack* track = mcEvent->GetTrack(i);
163  // hPsim->Fill(track->GetPx(),track->GetPy(),track->GetPz());
164  // }
165  // }
166 
167 
168 }
169 
171 {
172 
173  fChooseNbins = 0;
174 
175  // Initialise histograms here
176 
177  hChi2_XY = new TH2F("hChi2_XY","",500,0,TMath::Pi(),500,0,TMath::Pi());
178  hChi2_3D = new TH1F("hChi2_3D","",500,0,TMath::Pi());
179 
180  // fNtuple = new TNtupleD("fNtuple","","chi2X:chi2Y:nClX:nClY");
181  fNtuple = new TNtupleD("fNtuple","","nClX:nClY:chi2X:chi2Y:chi2X2:chi2Y2:chi2X3:chi2Y3:chi2X4:chi2Y4:chi2X5:chi2Y5:chi2X6:chi2Y6:chi2X7:chi2Y7:chi2X8:chi2Y8");
182 
183  }
184 
185  void HarpoAnalyseEtrack::Save(char * /* mode */)
186  {
187 
188  OpenHistFile("template");
189 
190  // Save histograms here
191  hChi2_XY->Write();
192  hChi2_3D->Write();
193  fNtuple->Write();
194  }
195 
196 
197 
198 void HarpoAnalyseEtrack::DisplayAnalysis(TRootEmbeddedCanvas* ecTab, TGListBox* /* infobox */)
199 {
200  // in hrecomonitorgui: fills the canvas on the "Analysis" tab
201  TCanvas* c = ecTab->GetCanvas();
202  c->GetPad(1)->Delete();
203  c->GetPad(2)->Delete();
204  c->Divide(2);
205 
206  for(Int_t plane = 0; plane<2;plane++){
207  TVirtualPad* cMap = c->GetPad(plane+1);
208  HarpoDccMap* m = fEvt->GetDccMap(plane);
209  TH2F* h = new TH2F("h","",512,0,512,288,0,288);
210  for(Int_t i=1;i<NADC;i++){ //Time bins
211  for(Int_t j=0;j<NCHAN;j++){ // Channels
212  Double_t q = m->GetData(j,i);
213  h->SetBinContent(i+1,j+1,q);
214  }
215  }
216  h->SetMinimum(0);
217  MakeNiceHisto(h,cMap,"colz");
218  h->Delete();
219  }
220 
221  c->Update();
222 }
223 
224 
225 void HarpoAnalyseEtrack::ConfigFrame(TGMainFrame* fMain, Int_t id)
226 {
227  // in hrecomonitorgui: Creates a popup window for analysis configuration
228  // You must define SetConfig() properly
229 
230  UInt_t xsize = 200;
231  UInt_t ysize2 = 20;
232  UInt_t ysize = 10*ysize2;
233  TGTransientFrame* main = new TGTransientFrame(gClient->GetRoot(), fMain, xsize, ysize);
234  main->Connect("CloseWindow()", "HarpoRecoMonitorGui", main, "CloseWindow()");
235  main->DontCallClose(); // to avoid double deletions.
236 
237  // use hierarchical cleaning
238  main->SetCleanup(kDeepCleanup);
239 
240  TGVerticalFrame* frame = new TGVerticalFrame(main,xsize,ysize,kVerticalFrame);
241 
242  // Object layout options
243  TGLayoutHints* fLayout1 = new TGLayoutHints(kLHintsLeft ,5,5,5,5);
244  TGLayoutHints* fLayout2 = new TGLayoutHints(kLHintsRight ,5,5,5,5);
245  TGLayoutHints* fLayout3 = new TGLayoutHints(kLHintsTop | kLHintsExpandX ,5,5,5,5);
246  TGLayoutHints* fLayout4 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,5,5,5,5);
247 
248  //________ DO NOT MODIFY ABOVE _____________________________
249 
250 
251 
252 
253  // Title of the analysis
254  TGLabel* fAnalysisLabel = new TGLabel(frame, "Template analysis");
255 
256  // Create a line for choosing value of parameter
257  TGHorizontalFrame* nBinsFrame = new TGHorizontalFrame(frame,xsize,ysize2,kHorizontalFrame);
258  TGLabel* nBinsLabel = new TGLabel(nBinsFrame, "fNbins");
259  fChooseNbins = new TGNumberEntry(nBinsFrame);
260  // fChooseNbins->SetNumber(fNbins);
261 
262  main->AddFrame(frame,fLayout4);
263  frame->AddFrame(fAnalysisLabel,fLayout3);
264  frame->AddFrame(nBinsFrame,fLayout3);
265  nBinsFrame->AddFrame(nBinsLabel,fLayout1);
266  nBinsFrame->AddFrame(fChooseNbins,fLayout2);
267 
268 
269 
270  //________ DO NOT MODIFY BELOW _____________________________
271  // Button to validate configuration
272  TGTextButton* setConf = new TGTextButton(frame,"Save Config",id);
273  setConf->Associate(fMain);
274 
275  frame->AddFrame(setConf,fLayout3);
276 
277  main->MapSubwindows();
278  main->MapWindow();
279  main->Resize();
280  return;
281 }
282 
283 
284 
286 {
287  // Update the configuration according to the values in the popup window
288 
289  if(!fChooseNbins) return;
290 
291  // fNbins = fChooseNbins->GetNumber();
292 }
HarpoRecoEvent * GetRecoEvent()
Definition: HarpoEvent.h:46
TClonesArray * GetKalmanTracksArray()
#define XPLANE
Definition: HarpoConfig.h:24
#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
Double_t GetXend()
Object containing the reconstruction information for one event (with array of HarpoRecoClusters Harpo...
2D vertex object, containing position, angle and associated track numbers, and quality info ...
virtual void print()
FullEvent Header not scecific to the detectors The class is ....
TClonesArray * GetVertexArray()
Dummy analysis to run as test and example. Give basic histograms of the data.
virtual void print()
HarpoRecoTracks object, Obtained with Kalman filter.
TFile * OpenHistFile(const char *ananame)
void Save(char *mode=NULL)
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 print()
Overloaded method which do all job.
Double_t GetZstart()
TVirtualPad * MakeNiceHisto(TH1 *hist, TVirtualPad *c1, const char *opt, Bool_t copy)
void ConfigFrame(TGMainFrame *fMain, Int_t id)
#define NADC
Definition: HarpoDccMap.h:18
#define YPLANE
Definition: HarpoConfig.h:25
TClonesArray * GetVertex3DArray()
void DisplayAnalysis(TRootEmbeddedCanvas *ecTab, TGListBox *infobox)
Redefine empty default.
HarpoEventHeader * GetHeader()
Definition: HarpoEvent.cxx:80
HarpoEvent * fEvt
Definition: HarpoAnalyse.h:70
ULong_t nEvents
Definition: HarpoAnalyse.h:75
Double_t GetXstart()
const ULong_t gkNDetectors
Definition: HarpoDet.h:14
HarpoDccMap * GetDccMap(Long_t plane=XDCC)
Definition: HarpoEvent.cxx:108
Int_t GetNclusterTrack()
TGNumberEntry * fChooseNbins
Double_t GetZend()
3D vertex object, containing position, angle and associated 2D vertexes, and quality info ...