HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HarpoSelectorPileUp.cxx
Go to the documentation of this file.
1 //
2 // File HarpoSelectorPileUp.cxx
3 //
11 #include "HarpoSelectorPileUp.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(HarpoSelectorPileUp);
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 
62  // if(gHDetSet->isExist(PMM2)){
63  // Pmm2Event *anaEvt = static_cast<Pmm2Event *>(fEvt->GetDetEvent(PMM2));
64  // if(anaEvt->GetTriggerType() != 7){ // FIXME
65  // fEvt->GetHeader()->SetEvAnaStatus(-2);
66  // return;
67  // }
68  // }
69 
70  for(Int_t plane = 0; plane<2; plane++){
71  if (!gHDetSet->isExist(plane)) continue;
72  // Process RAW data
73  HarpoDccMap* m = fEvt->GetDccMap(plane);
74  if ( m == NULL ) continue;
75  // Int_t i2 = 0;
76  Double_t qTotIn = 0;
77  Double_t qTotBefore = 0;
78  Double_t qTotAfter = 0;
79  for(Int_t j=0;j<NCHAN;j++){ // Channels
80  for(Int_t i=0;i<NADC;i++){ //Time bins
81  Double_t q = m->GetData(j,i);
82  if(q<0) continue;
83  //std::cout << i << "-";
84  if(i< fTstart ) qTotBefore += q;
85  if( i >fTend) qTotAfter += q;
86  if(i>=fTstart && i<=fTend) qTotIn += q;
87  }
88  }
89 
90  // Info("process","%d: %g %g %g %d %d",plane,qTotBefore,qTotIn,qTotAfter,fTstart,fTend);
91 
92  hQbefore[plane]->Fill(qTotBefore);
93  hQafter[plane]->Fill(qTotAfter);
94  hQin[plane]->Fill(qTotIn);
95  // Double_t data[4];
96  // data[0] = plane;
97  // data[1] = qTotIn;
98  // data[2] = qTotBefore;
99  // data[3] = qTotAfter;
100  HarpoRecoEvent* reco = fEvt->GetRecoEvent();
101  Double_t data[7] = {(Double_t) plane,qTotIn,qTotBefore,qTotAfter,
102  (Float_t) reco->GetXstart(),
103  (Float_t) reco->GetYstart(),
104  (Float_t) reco->GetTstart()};
105  ntuple->Fill(data);
106 
107  if(qTotBefore>fThr || qTotAfter>fThr)
108  fEvt->GetHeader()->SetEvAnaStatus(-2);
109  }
110 
111 }
112 
114 {
115 
116  // Initialise histograms here
117  fTstart = 90;
118  fTend = 430;
119 
120  Long64_t tstart;
121  if( ! gHConfig->Lookup("pileup.tstart",tstart ))
122  Info("Constructor","Use default fTstart %d",fTstart);
123  else
124  fTstart = tstart;
125 
126  Long64_t tend;
127  if( ! gHConfig->Lookup("pileup.tend",tend ))
128  Info("Constructor","Use default fTend %d",fTend);
129  else
130  fTend = tend;
131 
132 
133  fThr = 1e4;
134  Double_t thr;
135  if( ! gHConfig->Lookup("pileup.thr",thr ))
136  Info("Constructor","Use default fThr %g",fThr);
137  else
138  fThr = thr;
139 
140  const Int_t nbinsQcl = 100;
141  Double_t xminQcl = 10;
142  Double_t xmaxQcl = 1e5;
143  Double_t logxminQcl = TMath::Log(xminQcl);
144  Double_t logxmaxQcl = TMath::Log(xmaxQcl);
145  Double_t binwidthQcl = (logxmaxQcl-logxminQcl)/nbinsQcl;
146  Double_t xbinsQcl[nbinsQcl+1];
147  xbinsQcl[0] = xminQcl;
148  for (Int_t i=1;i<=nbinsQcl;i++)
149  xbinsQcl[i] = TMath::Exp(logxminQcl+i*binwidthQcl);
150  hQbefore[0] = new TH1F("hQbeforeX",";Q_{before}",nbinsQcl,xbinsQcl);
151  hQbefore[1] = new TH1F("hQbeforeY",";Q_{before}",nbinsQcl,xbinsQcl);
152  hQafter[0] = new TH1F("hQafterX",";Q_{after}",nbinsQcl,xbinsQcl);
153  hQafter[1] = new TH1F("hQafterY",";Q_{after}",nbinsQcl,xbinsQcl);
154  hQin[0] = new TH1F("hQinX",";Q_{in}",nbinsQcl,xbinsQcl);
155  hQin[1] = new TH1F("hQinY",";Q_{in}",nbinsQcl,xbinsQcl);
156 
157  ntuple = new TNtupleD("ntuple","pile up data","plane:qIn:qBefore:qAfter:xS:yS:tS");
158  ntuple->SetDirectory(0);
159 
160  }
161 
162 void HarpoSelectorPileUp::Save(char * /* mode */)
163  {
164 
165 
166  OpenHistFile("selectorPileup");
167 
168  // Save histograms here
169  hQbefore[0]->Write();
170  hQbefore[1]->Write();
171  hQafter[0]->Write();
172  hQafter[1]->Write();
173  hQin[0]->Write();
174  hQin[1]->Write();
175 
176  ntuple->Write();
177 
178  }
179 
#define NCHAN
Definition: HarpoDccMap.h:16
void print()
Overloaded method which do all job.
Double_t GetData(Int_t i, Int_t j)
Set/Get Data Cell.
Definition: HarpoDccMap.cxx:84
Bool_t isExist(ULong_t det)
Detecror date exist //! Number of Real Detectors.
Definition: HarpoDetSet.h:33
void Save(char *mode=NULL)
Object containing the reconstruction information for one event (with array of HarpoRecoClusters Harpo...
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()
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
#define NADC
Definition: HarpoDccMap.h:18
TDirectory * OpenHistFile(Int_t run, const char *dir, const char *extra="", Int_t update=0)
Definition: HarpoTools.cxx:55
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