HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarpoSelectorStraightTracks.cxx
Go to the documentation of this file.
1 //
2 // File HarpoSelectorStraightTracks.cxx
3 //
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 
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  Int_t stat = eventselection();
60  // if(stat==0) Info("process","Status = %d",stat);
61  fEvt->GetHeader()->SetEvAnaStatus(stat);
62  if(stat==0)
63  nEvents++;
64 
65  return;
66 }
67 
69 {
70 
71  // if(nEvents%100 == 0)
72  // std::cout << "Event " << nEvents << std::endl;
73 
74  // Process Reconstructed data (clusters, tracks, matched tracks)
75  HarpoRecoEvent* reco = fEvt->GetRecoEvent();
76  TClonesArray* trArray = reco->GetHoughTracksArray();
77  // TClonesArray* matchArray = reco->GetMatchingArray();
78  // Int_t nMatch = matchArray->GetEntries();
79  // if(nMatch<=0) return -2;
80  // if(nMatch!=1) return -2;
81  Int_t nTrX = 0, nTrY = 0;
82 
83  const Int_t nTr = trArray->GetEntries();
84  Int_t test = 0;
85  for(Int_t itr = 0; itr<nTr; itr++){
86  HarpoRecoHoughTracks* tr = (HarpoRecoHoughTracks*)trArray->At(itr);
87  Int_t plane = tr->GetPlane();
88  if(plane == XPLANE) nTrX++;
89  else if(plane == YPLANE) nTrY++;
90  else continue;
91  Double_t sigRho = tr->GetSigrho();
92  hSigmaRho[plane]->Fill(sigRho);
93  if(sigRho>fSigmaRhoMax){
94  if(gHarpoDebug>1)
95  Info("eventselection","Sigrho = %g", sigRho);
96  test=-2;
97  }else
98  hSigmaRhoCut[plane]->Fill(sigRho);
99  Double_t sigTheta = tr->GetSigtheta();
100  hSigmaTheta[plane]->Fill(sigTheta);
101  if(sigTheta>fSigmaThetaMax){
102  if(gHarpoDebug>1)
103  Info("eventselection","Sigtheta = %g", sigTheta);
104  test=-2;
105  }else
106  hSigmaThetaCut[plane]->Fill(sigTheta);
107  Double_t angle = tr->GetAngleTrack();
108  hAngle[plane]->Fill(angle);
109  if(TMath::Abs(angle)<fThetaMin || TMath::Abs(angle)>fThetaMax){
110  if(gHarpoDebug>1)
111  Info("eventselection","Angle = %g", angle);
112  test=-2;
113  }else
114  hAngleCut[plane]->Fill(angle);
115 
116  if(gHarpoDebug>1)
117  Info("eventselection","Sigrho = %g, Sigtheta = %g, Angle = %g", sigRho, sigTheta, angle);
118  }
119 
120 
121  // if(!(nTrX == nMatch && nTrY == nMatch))
122  if(!(nTrX == 1 && nTrY == 1)){
123  if(gHarpoDebug>1)
124  Info("eventselection","nTrX = %d nTrY = %d",nTrX,nTrY);
125  test=-2;
126  }
127 
128  return test;
129 }
130 
132 {
133 
134  fSigmaRhoMax = 5.;
135  fSigmaThetaMax = 0.4;
136  fThetaMin = 0.03;
137  fThetaMax = 0.3;
138 
139  Double_t sigmaRhoMax;
140  if( ! gHConfig->Lookup("SelectorStraightTracks.sigmaRhoMax",sigmaRhoMax))
141  Info("Constructor","Use default sigmaRhoMax %.3g",fSigmaRhoMax);
142  else
143  fSigmaRhoMax = sigmaRhoMax;
144  Double_t sigmaThetaMax;
145  if( ! gHConfig->Lookup("SelectorStraightTracks.sigmaThetaMax",sigmaThetaMax))
146  Info("Constructor","Use default sigmaThetaMax %.3g",fSigmaThetaMax);
147  else
148  fSigmaThetaMax = sigmaThetaMax;
149  Double_t thetaMax;
150  if( ! gHConfig->Lookup("SelectorStraightTracks.thetaMax",thetaMax))
151  Info("Constructor","Use default thetaMax %.3g",fThetaMax);
152  else
153  fThetaMax = thetaMax;
154  Double_t thetaMin;
155  if( ! gHConfig->Lookup("SelectorStraightTracks.thetaMin",thetaMin))
156  Info("Constructor","Use default thetaMin %.3g",fThetaMin);
157  else
158  fThetaMin = thetaMin;
159 
160  hAngle[0] = new TH1F("hAngleX",";#theta",200,-TMath::Pi(),TMath::Pi());
161  hAngleCut[0] = new TH1F("hAngleCutX",";#theta",200,-TMath::Pi(),TMath::Pi());
162  hSigmaRho[0] = new TH1F("hSigmaRhoX",";#sigma_{#rho}",200,0,50);
163  hSigmaRhoCut[0] = new TH1F("hSigmaRhoCutX",";#sigma_{#rho}",200,0,50);
164  hSigmaTheta[0] = new TH1F("hSigmaThetaX",";#sigma_{#theta}",200,0,TMath::Pi());
165  hSigmaThetaCut[0] = new TH1F("hSigmaThetaCutX",";#sigma_{#theta}",200,0,TMath::Pi());
166  hAngle[1] = new TH1F("hAngleY",";#theta",200,-TMath::Pi(),TMath::Pi());
167  hAngleCut[1] = new TH1F("hAngleCutY",";#theta",200,-TMath::Pi(),TMath::Pi());
168  hSigmaRho[1] = new TH1F("hSigmaRhoY",";#sigma_{#rho}",200,0,50);
169  hSigmaRhoCut[1] = new TH1F("hSigmaRhoCutY",";#sigma_{#rho}",200,0,50);
170  hSigmaTheta[1] = new TH1F("hSigmaThetaY",";#sigma_{#theta}",200,0,TMath::Pi());
171  hSigmaThetaCut[1] = new TH1F("hSigmaThetaCutY",";#sigma_{#theta}",200,0,TMath::Pi());
172 
173  }
174 
175 void HarpoSelectorStraightTracks::Save(char * /* mode */ )
176  {
177 
178  Info("Save","N selected events = %ld",nEvents);
179 
180  OpenHistFile("selectorStraightTracks");
181 
182  // Save histograms here
183  for(Int_t plane = 0; plane<2; plane++){
184  hAngle[plane]->Write();
185  hAngleCut[plane]->Write();
186  hSigmaRho[plane]->Write();
187  hSigmaRhoCut[plane]->Write();
188  hSigmaTheta[plane]->Write();
189  hSigmaThetaCut[plane]->Write();
190  }
191 
192 
193  }
194 
#define XPLANE
Definition: HarpoConfig.h:24
TClonesArray * GetHoughTracksArray()
Double_t GetAngleTrack()
Object containing the reconstruction information for one event (with array of HarpoRecoClusters Harpo...
virtual void print()
FullEvent Header not scecific to the detectors The class is ....
virtual void print()
Dummy analysis to run as test and example. Give basic histograms of the data.
Int_t eventselection()
Redefine empty default.
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
TDirectory * OpenHistFile(Int_t run, const char *dir, const char *extra="", Int_t update=0)
Definition: HarpoTools.cxx:55
Long64_t gHarpoDebug
Definition: HarpoDebug.cxx:9
#define YPLANE
Definition: HarpoConfig.h:25
Bool_t Lookup(const char *path, Bool_t &val)
Lookup function for scalar values.
void print()
Overloaded method which do all job.
const ULong_t gkNDetectors
Definition: HarpoDet.h:14
HarpoConfig * gHConfig
HarpoRecoTracks object, obtained with Hough tracking method.