FairRoot/PandaRoot
PndDrcRecoLookupMap.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndDrcRecoLookupMap source file -----
3 // ----- Created 10/11/10 by Maria Patsyuk -----
4 // ----- -----
5 // ----- -----
6 // -------------------------------------------------------------------------
7 #include <fstream>
8 #include <iostream>
9 #include "stdio.h"
10 
11 #include "PndGeoDrc.h"
12 #include "PndDrcRecoLookupMap.h"
13 #include "FairRootManager.h"
14 #include "PndMCTrack.h"
15 #include "PndDrcBarPoint.h"
16 #include "PndDrcPDPoint.h"
17 #include "PndDrcHit.h"
18 #include "PndDrcPDHit.h"
19 #include "TVector3.h"
20 #include "TRandom.h"
21 #include "FairRunAna.h"
22 #include "FairRuntimeDb.h"
23 #include "FairBaseParSet.h"
24 #include "FairGeoVolume.h"
25 #include "TString.h"
26 #include "FairGeoTransform.h"
27 #include "FairGeoVector.h"
28 #include "FairGeoMedium.h"
29 #include "FairGeoNode.h"
30 
31 #include "PndGeoDrcPar.h"
32 #include "TFormula.h"
33 #include "TMath.h"
34 #include "TParticlePDG.h"
35 #include "TDatabasePDG.h"
36 #include "TPDGCode.h"
37 #include "TGeoManager.h"
38 #include "TCanvas.h"
39 #include "TFile.h"
40 #include "TLegend.h"
41 #include "TStyle.h"
42 #include "TF1.h"
43 #include "TExec.h"
44 #include "TLine.h"
45 #include "TPolyLine.h"
46 //#include "PndChPho.h"
47 #include "PndDrcLutInfo.h"
48 #include "PndDrcDigiPar.h"
49 #include "TVectorD.h"
50 
51 using std::endl;
52 using std::cout;
53 
54 // ----- Default constructor -------------------------------------------
56 :FairTask("PndDrcRecoLookupMap")
57 {
58  fGeo = new PndGeoDrc();
59  fGeoH=NULL;
60  fDigiPar = NULL;
61 }
62 // ----- Standard constructor with verbosity level -------------------------------------------
63 
65  :FairTask("PndDrcRecoLookupMap")
66 {
67  fVerbose = verbose;
68  fGeo = new PndGeoDrc();
69  fGeoH=NULL;
70  fDigiPar = NULL;
71 }
72 // ----- Destructor ----------------------------------------------------
74 {
75  if (fGeo) delete fGeo;
76  if (fGeoH) delete fGeoH;
77  fHistoList->Delete();
78  delete fHistoList;
79 }
80 
81 // ----- Initialization -----------------------------------------------
83 {
84  cout << " ---------- INITIALIZATION ------------" << endl;
85  nevents = 0;
86  // Get RootManager
87  FairRootManager* ioman = FairRootManager::Instance();
88  if ( ! ioman ) {
89  cout << "-E- PndDrcRecoLookupMap::Init: "
90  << "RootManager not instantiated!" << endl;
91  return kFATAL;
92  }
93 
94  // Get input array
95  fMCArray = (TClonesArray*) ioman->GetObject("MCTrack");
96  if ( ! fMCArray ) {
97  cout << "-W- PndDrcRecoLookupMap::Init: "
98  << "No MCTrack array!" << endl;
99  return kERROR;
100  }
101  // Get input array
102  fBarPointArray = (TClonesArray*) ioman->GetObject("DrcBarPoint");
103  if ( ! fBarPointArray ) {
104  cout << "-W- PndDrcRecoLookupMap::Init: "
105  << "No DrcBarPoint array!" << endl;
106  return kERROR;
107  }
108  // Get Photon point array
109  fPDPointArray = (TClonesArray*) ioman->GetObject("DrcPDPoint");
110  if ( ! fPDPointArray ) {
111  cout << "-W- PndDrcRecoLookupMap::Init: "
112  << "No DrcPDPoint array!" << endl;
113  return kERROR;
114  }
115 /* // Get input array
116  fHitArray = (TClonesArray*) ioman->GetObject("DrcHit");
117  if ( ! fHitArray ) {
118  cout << "-W- PndDrcRecoLookupMap::Init: "
119  << "No DrcHit array!" << endl;
120  return kERROR;
121  }
122 */
123 
124  // Get digi array
125  fDigiArray = (TClonesArray*) ioman->GetObject("DrcDigi");
126  if ( ! fDigiArray ) {
127  cout << "-W- PndDrcRecoLookupMap::Init: " << "No DrcDigi array!" << endl;
128  return kERROR;
129  }
130 
131  // Get input array
132  fPDHitArray = (TClonesArray*) ioman->GetObject("DrcPDHit");
133  if ( ! fPDHitArray ) {
134  cout << "-W- PndDrcRecoLookupMap::Init: "
135  << "No DrcPDHit array!" << endl;
136  return kERROR;
137  }
138 
139  // Create and register output array
140  // fChPhoArray = new TClonesArray("PndChPho");
141  // ioman->Register("ChPho","Drc",fChPhoArray, kTRUE);
142  fDrcLutInfoArray = new TClonesArray("PndDrcLutInfo");
143  ioman->Register("DrcLutInfo","Drc",fDrcLutInfoArray, kTRUE);
144 
145  // Get parameters:
146  fpi = TMath::Pi();
147 
148  fR = fGeo->radius();
149  fzup = fGeo->barBoxZUp();
150  fzdown = fGeo->barBoxZDown();
152  fBboxNum = fGeo->BBoxNum();
153  fBarNum = fGeo->barNum();
155  fBarBoxGap = fGeo->BBoxGap();
156  //fLength = (180. - 2.*fPipehAngle - fBarBoxGap/fR*(fBboxNum/2. - 1.)/fpi*180.)/(fBboxNum/2.) * fR/ 180.*fpi;
157  fDphi = 2.*(180. - 2*fPipehAngle)/ fBboxNum; //[degrees]
158  fLSide = fGeo->Lside();//(180. - 2.*fPipehAngle - fBarBoxGap/fR*(fBboxNum/2. - 1.)/fpi*180.)/(fBboxNum/2.) * fR/ 180.*fpi;
159  fBarWidth = fGeo->BarWidth();//fLSide/fBarNum;
160 
161  // vectors of bar surfaces:
162  fnX1.SetXYZ(-1., 0.,0.);
163  fnY1.SetXYZ( 0., 1.,0.);
164 
165  // Time resolution as a function of photon path
166  timeres = new TF1("timeres","[0] + [1]*x", 0., 1000.);
167  timeres->SetParameters(23.2773, 1.11008);
168 
169  cout << "-I- PndDrcRecoLookupMap: Intialization successfull" << endl;
170  CreateHisto();
171  return kSUCCESS;
172 
173 }
174 
175 // ----- Private method SetParContainers -------------------------------
177 
178  // Get run and runtime database
179  FairRunAna* run = FairRunAna::Instance();
180  if ( ! run ) Fatal("SetParContainers", "No analysis run");
181 
182  FairRuntimeDb* db = run->GetRuntimeDb();
183  if ( ! db ) Fatal("SetParContainers", "No runtime database");
184 
185  // Get DIRC digitisation parameter container
186  fDigiPar = (PndDrcDigiPar*)(db->getContainer("DIRCLookupTable"));
187  cout << "-I- PndDrcRecoLookupMap::SetParContainers(). read parameters" << endl;
188  cout<<"read them!"<<endl;
189  //cout << "-I- PndDrcRecoLookupMap: Number of hit pixels "<< fDigiPar->GetNHitPixels()<< endl;
190  cout << "-I- PndDrcRecoLookupMap: Number of hit pixels "<< fDigiPar->GetNAmbiguities()<< endl;
191 
192  if ( fGeoH == NULL ) fGeoH = PndGeoHandling::Instance();
194  if(fVerbose>1) Info("SetParContainers","done.");
195  return;
196 }
197 // -------------------------------------------------------------------------
198 
199 // ----- Execution of Task ---------------------------------------------
200 void PndDrcRecoLookupMap::Exec(Option_t*ion)
201 {
202  //if ( ! fChPhoArray ) Fatal("Exec", "No fChPhoArray");
203  //fChPhoArray->Clear();
205 
206  nevents++;
207  fDetectorID = 0;
208 
209  cout<<"EVENT # "<<nevents<<endl;
210  // fNHits = 0;
211  //ProcessBarHit();
213  //ProcessPhotonMC();
214 }
215 
216 //--------------Process Photon MC Points----------------------------------------------------
218 {
219  if (fVerbose > 0) {
220  cout <<"PndDrcRecoLookupMap: Number of Detected MC Tracks : "<<fMCArray->GetEntries()<<endl;
221  PndMCTrack* ptr = NULL;
222  PndMCTrack* trMr=NULL;
223 
224  }
225 }
226 //--------------Process Bar Hits----------------------------------------------------
228 {
229  PndDrcBarPoint* pt=NULL;
230  PndDrcHit* hit=NULL;
231  PndMCTrack* tr = NULL;
232 
233  for(Int_t j=0; j<fHitArray->GetEntriesFast(); j++) {
234  hit = (PndDrcHit*)fHitArray->At(j);
235  Int_t mcRef= hit->GetRefIndex();
236  pt= (PndDrcBarPoint*)fBarPointArray->At(mcRef);
237 
238  Int_t chtrID= pt->GetTrackID();
239  tr = (PndMCTrack*)fMCArray->At(chtrID);
240 
241  cout<<"nother track px = "<<pt->GetPx()<<", py = "<<pt->GetPy()<<endl;
242 
243  }
244 }
245 
246 //--------------Process Photon Hits----------------------------------------------------
248 {
249  //Int_t nofChPho = 0;
250  PndDrcLutInfo lutinfo;
251 
252  PndDrcPDPoint* Ppt=NULL;
253  PndDrcPDHit* pdhit=NULL;
254  PndMCTrack* tr = NULL;
255  PndMCTrack* trMr;
256 
257  if (fVerbose > 0) {
258  cout <<"PndDrcRecoLookupMap: Number of Detected Photon MCPDPoints : "<<fPDPointArray->GetEntries()<<endl;
259  cout <<"PndDrcRecoLookupMap: Number of Detected Photon PDHits : "<<fPDHitArray->GetEntries()<<endl;
260  }
261 
262  // Loop over PndDrcPDHits
263  for(Int_t k=0; k<fPDHitArray->GetEntriesFast(); k++) {
264 
265  pdhit = (PndDrcPDHit*)fPDHitArray->At(k);
266 
267  Int_t mcPDRef= pdhit->GetRefIndex();
268 
269  Ppt = (PndDrcPDPoint*)fPDPointArray->At(mcPDRef);
270 
271  PndDrcBarPoint *fBarPoint= (PndDrcBarPoint*)fBarPointArray->At(Ppt->GetBarPointID());
272  fBarId = fBarPoint->GetDetectorID();
273  //cout<<"bar name - "<<fGeoH->GetPath(fBarId)<<endl;
274 
275  Int_t trID= Ppt->GetTrackID();
276  tr = (PndMCTrack*)fMCArray->At(trID);
277 
278  Int_t trMID=tr->GetMotherID();
279 
280  //if(trMID > -1){
281  trMr = (PndMCTrack*)fMCArray->At(trMID);
282  trMr->GetMomentum().Print();
283 
284  Int_t trMpdg=trMr->GetPdgCode();
285 
286  if(trMr->GetMotherID()==-1){ // charged track is a primary
287 
288  lutinfo.SetChPartPdg(trMpdg);
289 
290  // expected cherenkov angle
291  Double_t Mrmass;
292  Int_t MoSign;
293  if(fabs(trMpdg) == 11){Mrmass = 0.000511; MoSign = 1;}
294  if(fabs(trMpdg) == 13){Mrmass = 0.105658; MoSign = 1;}
295  if(fabs(trMpdg) == 211){Mrmass = 0.139570; MoSign = -1;}
296  if(fabs(trMpdg) == 321){Mrmass = 0.49368; MoSign = -1;}
297  if(fabs(trMpdg) == 2212){Mrmass = 0.938; MoSign = -1;}
298  if(fabs(trMpdg) == 50000050){Mrmass = 0.0; MoSign = -1;}
299  Double_t Mrmom = trMr->GetMomentum().Mag();
300  CHexp = acos(sqrt(pow(Mrmom,2) + pow(Mrmass,2))/Mrmom/fGeo->nQuartz());
301  lutinfo.SetCherenkovMC(CHexp);
302  cout<<"+++++++++++++++++++++++++++"<<endl;
303  cout<<"CH expected = "<<CHexp<<endl;
304 
305  fxPHit= pdhit->GetX();
306  fyPHit= pdhit->GetY();
307  fzPHit= pdhit->GetZ();
308  ftime = pdhit->GetTime();
309 
310  //get the pixel id
311  fpixID = pdhit->GetDetectorID();
312  cout<<"hit id "<<fpixID<<", x = "<<pdhit->GetX()<<", y = "<<pdhit->GetY()<<", time = "<<ftime<<endl;
313 
314  Double_t xPPoi= Ppt->GetX();
315  Double_t yPPoi= Ppt->GetY();
316 
317  lutinfo.SetPath(Ppt->GetLength());
318 
319  // momentum of a photon on the PD Plane
320  fPphoPD.SetXYZ(Ppt->GetPx(), Ppt->GetPy(), Ppt->GetPz());
321  //cout<<"Photon momentum on the PDplane: "<<endl;
322  //fPphoPD.Print();
323 
324  {
325  // mother momentum/direction
326  fPMo.SetXYZ(trMr->GetMomentum().X(), trMr->GetMomentum().Y(), trMr->GetMomentum().Z());
327  //fPMo.Print();
328  lutinfo.SetChPartDir(fPMo);
329  cout<<"mother phi = "<<fPMo.Phi()/3.1415*180.<<endl;
330  if(fB > 0.){
331  Double_t PtMo = sqrt(pow(trMr->GetMomentum().X(),2)+pow(trMr->GetMomentum().Y(),2));
332  Double_t Rratio = fR*fR/2./pow((PtMo/0.29979/fB)*100.,2);
333  //Double_t phi_extra = fPMo.Phi() + trMpdg/fabs(trMpdg) * acos(1. - Rratio); // muon - ; proton +
334  Double_t phi_extra = fPMo.Phi() + MoSign * trMpdg/fabs(trMpdg) * acos(1. - Rratio); // muon - ; proton +
335  //fHAngleInBDeg = 0.5 * trMpdg/fabs(trMpdg) * (acos(1. - Rratio) /TMath::Pi())*180.;
336  fHAngleInBDeg = 0.5 * MoSign * trMpdg/fabs(trMpdg) * (acos(1. - Rratio) /TMath::Pi())*180.;
337  // cout<<"B = "<<fB<<", R = "<<fR<<", trMpdg = "<<trMpdg<<", half angle in B = "<<fHAngleInBDeg<<endl;
338  fPMo.SetPhi(phi_extra);
339  }
340  lutinfo.SetChPartDirInBar2(fPMo);
341  }
342 
343  {
344  fBarPoint->Momentum(fPMo);
345  lutinfo.SetChPartDirInBar(fPMo);
346  }
347 
348 
349  cout<<"Mother vector (global cs) : "<<endl;
350  TVector3 motherMom = fPMo.Unit();
351  motherMom.Print();
352 
353  // initial momentum of the photon
354  fPphoInit.SetXYZ(tr->GetMomentum().X(), tr->GetMomentum().Y(), tr->GetMomentum().Z());
355  cout<<"Initial momentum of the photon :"<<endl;
356  fPphoInit.Print();
357 
358  // real = generated cherenkov angle
359  CHreal = fPphoInit.Angle(fPMo);
360  lutinfo.SetCherenkovReal(CHreal);
361  //cout<<"CH real (generated) = "<<CHreal<<endl;
362 
363  Double_t etot = sqrt(pow(fPphoPD.X(),2) + pow(fPphoPD.Y(),2) +pow(fPphoPD.Z(),2));
364  flambdah=197.0*2.0*TMath::Pi()/(etot*1.0E9);//wavelength of photon in nm
365  lutinfo.SetLambda(flambdah);
366 
367  // production point of the photon
369 
370  //cout<<"start: phi = "<<fStartVertex.Phi()<<endl;
371  //fStartVertex.Print();
372  ftime0 = tr->GetStartTime()/1.0E9;
373  lutinfo.SetTime(ftime-ftime0);
374 
375  //cout<<"fstart time = "<<ftime0<<endl;
376  //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
377  // proceed only if photon was born in the bar for which the LUT is used!!!
378  //if(fStartVertex.Phi() >0./180.*fpi && fStartVertex.Phi() < 6./180.*fpi){
379  if(fPphoInit.Z() > 0. || fPphoInit.Z() < 0.){ // reflected photons
380 
381  // Transformation of the photon initial direction to the local bar coodr system:
382  // to get to the bar coord system.
384  cout<<"PhiRot = "<<fPhiRot/fpi*180.<<", Mother phi = "<<fPMo.Phi()/fpi*180.<<endl;
385 
386  // Photon initial momentum in the bar coord. syst.
387  fPphoB = fPphoInit.Unit();
388  fPphoB.RotateZ(-fPhiRot);
389  fkxBar = -fPphoB.Y();
390  fkyBar = fPphoB.X();
391  fkzBar = fPphoB.Z();
392  fPphoB.SetXYZ(fkxBar, fkyBar, fkzBar);
393  cout<<"photon momentum in the bar = "<<endl;
394  fPphoB.Print();
395  TVector3 fPpB = (fGeoH->MasterToLocalShortId(fPphoInit, fBarId) - fGeoH->MasterToLocalShortId((0.,0.,0.),fBarId)).Unit();
396  fPpB.Print();
397 
398  // mother momentum in the bar' (and bar) coord syst:
399  fPMoB = fPMo.Unit();
400  fPMoB.RotateZ(-fPhiRot);
401  cout<<"Mother vector (bar' cs): "<<endl;
402  fPMoB.Print();
403  fPxMoBar = -fPMoB.Y();
404  fPyMoBar = fPMoB.X();
405  fPzMoBar = fPMoB.Z();
406  TVector3 PMoBar;
407  PMoBar.SetXYZ(fPxMoBar, fPyMoBar, fPzMoBar);
408  TVector3 PMBar = (fGeoH->MasterToLocalShortId(fPMo, fBarId) - fGeoH->MasterToLocalShortId((0.,0.,0.),fBarId)).Unit();
409  PMBar.Print();
410 
411  // to find Cherenkov Phi (NOT THETA!!!):
412  TVector3 kB;
413  kB.SetXYZ(fkxBar, fkyBar, fkzBar);
414 
415  // use lookups to get the kXbar and kYbar of photons:
417  //cout<<"N pixels = "<<NHitPix<<endl;
419  cout<<"N amb = "<<NAmb<<endl;
421  Double_t par[NPixPar];
422 
423  if (fDigiPar->GetParamsForPixel(fpixID, par) == kFALSE) {
424  cout<<"NO SUCH HIT IN LUT!!!"<<endl;
425  continue;
426  }
427 
428  cout<<"LOOKUP!!!!"<<endl;
429  //cout<<"N Hit Pix = "<<NHitPix<<endl;
430  //cout<<"N Amb = "<<NAmb<<endl;
431  cout<<"NPixPar = "<<NPixPar<<endl;
432 /* cout<<"par 0 = "<<par[0]<<endl; // kx
433  cout<<"par 1 = "<<par[1]<<endl; // ky
434  cout<<"par 2 = "<<par[2]<<endl; // kxB
435  cout<<"par 3 = "<<par[3]<<endl; // kyB
436  cout<<"par 4 = "<<par[4]<<endl; // kxU1
437  cout<<"par 5 = "<<par[5]<<endl; // kyU1
438  cout<<"par 6 = "<<par[6]<<endl; // kxU2
439  cout<<"par 7 = "<<par[7]<<endl; // kyU2
440  cout<<"par 8 = "<<par[8]<<endl; // kxU3
441  cout<<"par 9 = "<<par[9]<<endl; // kyU3
442  cout<<"par 10 = "<<par[10]<<endl; // kxBU1
443  cout<<"par 11 = "<<par[11]<<endl; // kyBU1
444  cout<<"par 12 = "<<par[12]<<endl; // kxBU2
445  cout<<"par 13 = "<<par[13]<<endl; // kyBU2
446  cout<<"par 14 = "<<par[14]<<endl; // kxBU3
447  cout<<"par 15 = "<<par[15]<<endl; // kyBU3
448  cout<<"par 16 = "<<par[16]<<endl; // kxUB
449  cout<<"par 17 = "<<par[17]<<endl; // kyUB
450  cout<<"par 18= "<<par[18]<<endl; // kxUU
451  cout<<"par 19= "<<par[19]<<endl; // kyUU
452  cout<<"par 20= "<<par[20]<<endl; // kxUUU
453  cout<<"par 21= "<<par[21]<<endl; // kyUUU
454  cout<<"par 22= "<<par[22]<<endl; // kxBUU
455  cout<<"par 23= "<<par[23]<<endl; // kyBUU
456  cout<<"par 24= "<<par[24]<<endl; // kxBUB
457  cout<<"par 25= "<<par[25]<<endl; // kyBUB
458  cout<<"par 26= "<<par[26]<<endl; // kxUBU
459  cout<<"par 27= "<<par[27]<<endl; // kyUBU
460 */
461  // fill in NPixPar/2 * 1 ambiguities:
462  Double_t kX, kY, kZ;
463  std::vector<TVector3> ambig;
464  std::vector<Double_t> CHreco;
465  std::vector<Double_t> Tamb;
466  std::vector<Double_t> Path;
467 
468  // length of the vector should be the same as NumAmb*8 !!!!!
469  Int_t NumAmb = NAmb; //=14
470  TVectorD CHdiff(8*NumAmb);
471  TVectorD Adiff(8*NumAmb); // vector to store angle diff btw real and reco photons
472 
473  for(Int_t i=0; i<NumAmb; i++){
474  // in bar' coordinate system
475  kX = par[i*2]; // kXD
476  kY = par[i*2 + 1]; // kYD
477  kZ = -sqrt(1. - pow(kX,2.) - pow(kY,2.));
478  //cout<<"mom: x = "<<fPMoB.X()<<", y = "<<fPMoB.Y()<<", z = "<<fPMoB.Z()<<endl;
479  fkBar.SetXYZ(kX, kY, kZ);
480  //cout<<"photon from LUT in bar' coordinate system: "<<endl;
481  fkBar.Print();
482 
483  for(Int_t jamb=0; jamb <8; jamb++){
484  if(jamb == 1){fkBar.SetXYZ(-kX, kY, kZ);}
485  if(jamb == 2){fkBar.SetXYZ(kX, -kY, kZ);}
486  if(jamb == 3){fkBar.SetXYZ(kX, kY, -kZ);}
487  if(jamb == 4){fkBar.SetXYZ(-kX, -kY, kZ);}
488  if(jamb == 5){fkBar.SetXYZ(kX, -kY, -kZ);}
489  if(jamb == 6){fkBar.SetXYZ(-kX, kY, -kZ);}
490  if(jamb == 7){fkBar.SetXYZ(-kX, -kY, -kZ);}
491 
492  // check if there is such enrty in the LUT and if the ambiguity fulfills the total internal reflection requitrement
493  if((kX != 0. && kY != 0.) && ((fkBar.Cross(fnX1)).Mag() > 1.00028/fGeo->nQuartz() ||
494  (fkBar.Cross(fnY1)).Mag() > 1.00028/fGeo->nQuartz())){
495  ambig.push_back(fkBar);
496  CHreco.push_back(fkBar.Angle(PMoBar));
497  CHdiff(8*i+jamb) = fabs(CHreco[8*i+jamb] - CHexp);
498  Tamb.push_back(RecoAmbigTime(fkBar, fStartVertex, &fPath, 0));
499  Path.push_back(fPath);
500  Adiff(8*i+jamb) = fkBar.Angle(fPphoB);
501  //cout<<"reco ch angle = "<<fkBar.Angle(PMoBar)<<endl;
502  //cout<<"number of bounces = "<<NumberOfBounces(fStartVertex, fPphoB, fBarId)<<endl;
503  //cout<<"CHdiff = "<<CHdiff(8*i+jamb)<<", CHreco"<<8*i+jamb<<" = "<<CHreco[8*i+jamb]<<endl;
504 
505  //fill lutinfo only with credible information:
506  lutinfo.AddAngle(fkBar.Angle(PMoBar));
507  lutinfo.AddTime(RecoAmbigTime(fkBar, fStartVertex, &fPath, 0));
508  lutinfo.AddPath(fPath);
509  lutinfo.AddChDiff(CHreco[8*i+jamb] - CHexp);
510  //cout<<"fkBar = "<<endl;
511  //fkBar.Print();
512  lutinfo.AddNOfBounces(NumberOfBounces(fStartVertex, fkBar/*fPphoB*/, fBarId));
513 
514  fkBarXHist->Fill(kX, fPphoB.X());
515  fkBarYHist->Fill(kY, fPphoB.Y());
516  }else{
517  ambig.push_back((0.,0.,0.));
518  CHreco.push_back(-999.);
519  CHdiff(8*i+jamb) = -999.;
520  Tamb.push_back(-999.);
521  Path.push_back(-999.);
522  Adiff(8*i+jamb) = -999.;
523  }
524  }// for
525  }
526 
527  // F I L L T H E H I S T O S
528  fhPDHits->Fill(xPPoi, yPPoi);//(fxPHit, fyPHit);
529  fhPDTime->Fill(ftime-ftime0); // substract production time of a photon
530 
531  fhRecoT1->Fill(flambdah, Ppt->GetLength()/(ftime-ftime0));
532 
533  fhCHreal->Fill(CHreal);
534  fhLam->Fill(flambdah);
535 
536  if(fB > 0.){
537  fMapHist->Fill(fPMo.Theta()/fpi*180.,fPMo.Phi()/fpi*180. - fHAngleInBDeg); // assuming that R = 50 cm
538  }
539  if(fB == 0.){
540  fMapHist->Fill(fPMo.Theta()/fpi*180.,fPMo.Phi()/fpi*180.);
541  }
542  cout<<"fMAPHIST is filled in theta="<<fPMo.Theta()/fpi*180.<<", phi ="<<fPMo.Phi()/fpi*180. - fHAngleInBDeg<<endl;
543  cout<<"mother phi angle = "<<fPMo.Phi()/fpi*180.<<endl;
544  cout<<"mother phi in the name of histo = "<<(Int_t)(fPMo.Phi()/fpi*180.*100.)<<endl;
545  //#############################################
546  TString PhiT = Form("t%g_phi%d", fPMo.Theta()/fpi*180., (Int_t)(fPMo.Phi()/fpi*180.*100.));
547  TString PhiTCut = Form("t%g_phi%d_cut", fPMo.Theta()/fpi*180., (Int_t)(fPMo.Phi()/fpi*180.*100.));
548  TString PhiTWeight = Form("t%g_phi%d_weight", fPMo.Theta()/fpi*180., (Int_t)(fPMo.Phi()/fpi*180.*100.));
549  TString Nbo = Form("t%g_phi%d_nbo", fPMo.Theta()/fpi*180., (Int_t)(fPMo.Phi()/fpi*180.*100.));
550 
551  Int_t currPhiTh = PhiThetaPoints.size();
552  for ( Int_t ihi = 0 ; ihi < PhiThetaPoints.size() ; ihi++ ) {
553  if ( PhiT == PhiThetaPoints[ihi]->GetName() ) {
554  currPhiTh = ihi;
555  break;
556  }
557  }
558  if ( currPhiTh == PhiThetaPoints.size() ) {
559  Int_t nbins = (Int_t)(2.*fWidth/0.005);
560  TH1F* newThetaPhiPoint = new TH1F(PhiT.Data(),"Cherenkov angle difference for theta", nbins, -fWidth,fWidth);
561  PhiThetaPoints.push_back(newThetaPhiPoint);
562  TH1F* newThetaPhiPointCut = new TH1F(PhiTCut.Data(),"Cherenkov angle difference for theta with time cut", nbins, -fWidth,fWidth);
563  PhiThetaPointsCut.push_back(newThetaPhiPointCut);
564  TH1F* newThetaPhiPointWeight = new TH1F(PhiTWeight.Data(),"Cherenkov angle difference for theta with time weights", nbins, -fWidth,fWidth);
565  PhiThetaPointsWeight.push_back(newThetaPhiPointWeight);
566  TH1F* newNbo = new TH1F(Nbo.Data(), "Number of bounces", 1000,0.,500.);
567  NboPoints.push_back(newNbo);
568  }
569  //PhiThetaPoints[currPhiTh]->Fill();
570  //#############################################
571 
572  // fill N bounces for all photons:
573  NboPoints[currPhiTh]->Fill(NumberOfBounces(fStartVertex, fPphoB, fBarId));
575  // fill all the ambiguities with weights:
576  // WEIGHTS ARE BASED ON TIMING!!!!!
577  for(Int_t j=0; j< CHreco.size(); j++){
578  fWeight = exp(- pow(Tamb[j] - ftime + ftime0, 2.)/2./pow(timeres->Eval(Path[j])/1000.,2.));
579  //cout<<"CHreco = "<<CHreco[j]<<", d time = "<<Tamb[j]-ftime + ftime0<<", weight = "<<fWeight<<endl;
580 
581  // using time cuts
582  if(fabs(CHdiff(j)) < fWidth){
583  PhiThetaPoints[currPhiTh]->Fill(CHreco[j]-CHexp,1.);
584  //fhDiff->Fill(CHreco(j)-CHexp,1./fInvSum/CHdiff(j));
585  fhDiff->Fill(CHreco[j]-CHexp,1.);
586  //fhDTime->Fill(Tamb[j] - ftime + ftime0);
587  //cout<<"CHreco = "<<CHreco[j]<<", time = "<<Tamb[j]<<", path = "<<Path[j]<<endl;
588  //cout<<"time resolution at this path = "<<timeres->Eval(Path[j])/1000.<<", d t = "<<Tamb[j] - ftime + ftime0<<endl;
589  //cout<<"histo "<<PhiThetaPoints[currPhiTh]->GetName()<<" filled with"<<CHreco[j]-CHexp<<endl;
590  // using time cuts
591  if(fabs(Tamb[j] - ftime + ftime0) < fNSigma* timeres->Eval(Path[j])/1000.){
592  PhiThetaPointsCut[currPhiTh]->Fill(CHreco[j]-CHexp);
593  //fhDTimeCut->Fill(Tamb[j] - ftime + ftime0);
594  }
595  //using weights based on time
596  PhiThetaPointsWeight[currPhiTh]->Fill(CHreco[j]-CHexp, fWeight);
597  //fhDTimeWeight->Fill(Tamb[j] - ftime + ftime0, fWeight);
598 
599  //cout<<"diff was filled with "<<CHreco(j)-CHexp<<endl;
600  }
601  }
602 
603  // new ((*fChPhoArray)[nofChPho++]) PndChPho(fxPHit,fyPHit,fzPHit,ftime,flambdah, // fPphoB,fPMo,fPphoInit,fPphoPD);
604  //} // if kxBar
605  } // if start vertex lies within the right bar!
606  }// photon from primary particle
607 
608  }// photon hits
609  new ((*fDrcLutInfoArray)[fDrcLutInfoArray->GetEntriesFast()]) PndDrcLutInfo(lutinfo);
610 }
611 //----------------------------------------------------------------------------------------------
612 Double_t PndDrcRecoLookupMap::InBarCoordSyst(TVector3 start, TVector3 *v1, TVector3 *v2, TVector3 *v3, TVector3 *v4){
613  Double_t startPhi = start.Phi()/fpi*180.; // [degrees]
614  //cout<<"-I- InBarCoordinateSystem: start phi = "<<start.Phi()/fpi*180.<<endl;
615  if(startPhi < 0.){startPhi = 360. + startPhi;}
616  //if(startPhi > 360.){startPhi = startPhi - 360.;}
617  //cout<<"-I- InBarCoordinateSystem: start phi = "<<startPhi<<endl;
618  //Double_t dphi = 2.*(180. - 2*fPipehAngle)/ fBboxNum; //[degrees]
619  //cout<<"-I- InBarCoordinateSystem: dphi = "<<dphi<<endl;
620  Double_t PhiRot = 0.; //[degrees]
621  if(startPhi >= 0. && startPhi < 90.){
622  PhiRot = TMath::Floor(startPhi/fDphi) *fDphi + fDphi/2.;
623  }
624  if(startPhi >= 90. && startPhi < 270.){
625  PhiRot = 90. + fPipehAngle + TMath::Floor((startPhi-90.-fPipehAngle)/fDphi) *fDphi + fDphi/2.;
626  }
627  if(startPhi >= 270. && startPhi < 360.){
628  PhiRot = 270. + fPipehAngle + TMath::Floor((startPhi-270.-fPipehAngle)/fDphi) *fDphi + fDphi/2.;
629  }
630  //cout<<"-I- InBarCoordinateSystem: PhiRot = "<<PhiRot<<endl;
631 
632  TVector3 ver1, ver2, ver3, ver4;
633  ver1.SetXYZ(fR-(fHThick), fLSide/2. ,0.);
634  ver2.SetXYZ(fR+(fHThick), fLSide/2. ,0.);
635  ver3.SetXYZ(fR+(fHThick), -fLSide/2. ,0.);
636  ver4.SetXYZ(fR-(fHThick), -fLSide/2. ,0.);
637 
638  ver1.RotateZ(PhiRot/180.*fpi);
639  ver2.RotateZ(PhiRot/180.*fpi);
640  ver3.RotateZ(PhiRot/180.*fpi);
641  ver4.RotateZ(PhiRot/180.*fpi);
642 
643  *v1 = ver1;
644  *v2 = ver2;
645  *v3 = ver3;
646  *v4 = ver4;
647 
648  return PhiRot/180.*fpi;
649 }
650 //--------------------------------------------------------------------------------------------
652 
653  // this function is used for photon hits to create LUTs, so that hits in front of target pipe area
654  // are treated as additional small LUTs
655 
656  TVector3 hit;
657  hit.SetXYZ(xhit, yhit, 0.);
658  Double_t phi = hit.Phi()*180./fpi;
659  if(phi < 0.){phi = 360. + hit.Phi()*180./fpi;}
660  if(phi >= 0. && phi < 90.-fPipehAngle){
661  //return 13.+TMath::Floor(phi/fDphi);
662  return 1.+TMath::Floor((90.-fPipehAngle-phi)/fDphi);
663  }
664  if(phi >= 90.+fPipehAngle && phi<270.-fPipehAngle){
665  //return TMath::Floor((phi-2.*fPipehAngle)/fDphi) - 3.;
666  return 9.+TMath::Floor((270.-fPipehAngle-phi)/fDphi);
667  }
668  if(phi >= 270.+fPipehAngle){
669  //return TMath::Floor((phi-4.*fPipehAngle)/fDphi) - 3.;
670  return 5.+TMath::Floor((360.-phi)/fDphi);
671  }
672  // small areas in front of the target pipe:
673  if(phi >= 90.-fPipehAngle && phi < 90.+fPipehAngle){
674  return 17.;
675  }
676  if(phi >= 270.-fPipehAngle && phi < 270.-fPipehAngle){
677  return 18.;
678  }
679 }
680 
681 //------ Find Nubmer of Bounces --------------------------------------
682 Int_t PndDrcRecoLookupMap::NumberOfBounces(TVector3 start, TVector3 dir, Int_t barId){
683  // start - photon production point in global coord system
684  // dir - photon direction in bar coord system
685 
686  //cout<<"-I- NumberOfBounces: dir"<<endl;
687  //dir.Print();
688  //cout<<"-I- NumberOfBounces: start"<<endl;
689  //start.Print();
690 
691  // Find coordinates of X0, Y0:
692  Double_t Z0, X0, Y0;
693  if(dir.Theta() < 3.1415/2.){
694  Z0 = -(fabs(fzup) + 2.*fzdown - start.Z());
695  }
696  if(dir.Theta() >= 3.1415/2.){
697  Z0 = -(start.Z() - fzup);
698  }
699  X0 = Z0*TMath::Tan(dir.Theta())*TMath::Cos(dir.Phi());
700  Y0 = Z0*TMath::Tan(dir.Theta())*TMath::Sin(dir.Phi());
701  //cout<<"-I- NumberOfBounces: tan th = "<<TMath::Tan(dir.Theta())<<", sin ph = "<<TMath::Sin(dir.Phi())<<", cos ph = "<<TMath::Cos(dir.Phi())<<endl;
702  //cout<<"-I- NumberOfBounces: X0 = "<<X0<<", Y0 = "<<Y0<<", Z0 = "<<Z0<<endl;
703 
704  // Find the start position of the photon with respect to the middle of the bar:
705  TVector3 startLocal = fGeoH->MasterToLocalShortId(start, barId);
706  //cout<<"-I- NumberOfBounces: Xen = "<<startLocal.X() + fBarWidth/2.<<", Yen = "<<startLocal.Y() + fHThick<<endl;
707 
708  // Find the number of bounces in each direction
709  Double_t N1, N2;
710  FindOutPoint(X0, startLocal.X() + fBarWidth/2., fBarWidth, &N1, 0);
711  FindOutPoint(Y0, startLocal.Y() + fHThick, 2.*fHThick, &N2, 0);
712  //cout<<"-I- NumberOfBounces: N1 = "<<N1<<", N2 = "<<N2<<endl;
713 
714  return (Int_t)N1+N2;
715 }
716 
717 //----------------------------------------------------------------------------------------------------------
719  Double_t m=99.;
720  Double_t n=TMath::Floor(x0/a);
721  m = n;
722  if(printt){std::cout<<"n = "<<n<<", NN = "<<*NN<<", x0 = "<<x0<<", a = "<<a<<std::endl;}
723  Double_t x1 = x0 - n*a;
724  if(x0 < 0.){x1 = x0 - (n+1)*a;}
725  if(printt){std::cout<<"xy = "<< x1<<std::endl;}
726  Double_t xK = 0.;
727  if((m/2. - TMath::Floor(m/2.)) == 0.) { // 4etnoe
728  if(print){std::cout<<"odd==0"<<std::endl;}
729  if(x0 >= 0. && x1 + xEn <= a){xK = x1 + xEn;}
730  if(x0 >= 0. && x1 + xEn > a){xK = 2*a - x1 - xEn; n = 1. + n;}
731  if(x0 < 0. && x1 + xEn >= 0.){xK = a - (x1 + xEn); n = -1. -n;}
732  if(x0 < 0. && x1 + xEn < 0.) {xK = a + x1 + xEn; n = -n;}
733  if(printt){std::cout<<"xK = "<< xK<<", n = "<<n<<std::endl;}
734 
735  }
736 
737  if((m/2. - TMath::Floor(m/2.)) != 0.) { // ne4etnoe
738  if(print){std::cout<<"even!=0"<<std::endl;}
739  if(x0 >= 0. && x1 + xEn <= a){xK = a - (x1 + xEn);}
740  if(x0 >= 0. && x1 + xEn > a){xK = x1 + xEn - a; n = 1. + n;}
741  if(x0 < 0. && x1 + xEn >= 0.){xK = x1 + xEn; n = -1. -n;}
742  if(x0 < 0. && x1 + xEn < 0.) {xK = - (x1 + xEn); n = -n;}
743  if(printt){std::cout<<"xK = "<< xK<<", n = "<<n<<std::endl;}
744 
745  }
746 
747  *NN = n;
748  return xK;
749 }
750 
751 //-------------------------------------------------------------------------------------------
752 void PndDrcRecoLookupMap::DrawBarBox(TVector3 v1, TVector3 v2, TVector3 v3, TVector3 v4){
753  Double_t xx[5];
754  Double_t yy[5];
755  xx[0] = v1.X(); xx[1] = v2.X(); xx[2] = v3.X(); xx[3] = v4.X(); xx[4] = v1.X();
756  yy[0] = v1.Y(); yy[1] = v2.Y(); yy[2] = v3.Y(); yy[3] = v4.Y(); yy[4] = v1.Y();
757  TPolyLine *p6 =new TPolyLine(5,xx,yy);
758  p6->SetLineWidth(2);
759  p6->Draw("same");
760 }
761 
762 //--------------------------------------------------------------------------------------------
763 Double_t PndDrcRecoLookupMap::RecoAmbigTime(TVector3 kb, TVector3 start, Double_t *l, Bool_t printout){ // [ns]
764 
765  // group velocities for oil and quartz for Noil and Nquartz assuming that mean lambda = 410 nm:
766  //Double_t nOil = fGeo->nEV();
767  Double_t u_oil = 19.8;//30./nOil;
768  //Double_t u_quartz = 30./1.46907; // for lambda = 410 nm
769  //Double_t u_quartz = 30./1.47012; // for lambda = 400 nm
770  //Double_t u_quartz = 30./1.46838; // for lambda = 417 nm
771  //Double_t u_quartz = 30./1.47125; // for lambda = 390 nm
772  //Double_t u_quartz = 30./1.47248; // for lambda = 380 nm
773  Double_t u_quartz = 19.8;//30./fNquartz;//1.47805; // for lambda = 370 nm
774 
775  // kb - photon momentum at the production point, first calculate path in QUARTZ BAR:
776  // assume that there are only DIRECT photons!!!
777 
778  // path in quartz:
779  Double_t Z0 = 0.;
780  Double_t kz = 0.;
781  if(kb.Z() < 0.){Z0 = start.Z() - fGeo->barBoxZUp(); kz = kb.Z();}
782  if(kb.Z() >= 0.){Z0 = 2.*fGeo->barBoxZDown() - fGeo->barBoxZUp() - start.Z(); kz = -kb.Z();}
783 
784  if(printout){
785  cout<<"-I- Reco ambig Time: Zstart = "<<start.Z()<<", Z0 = "<<Z0<<endl;
786  }
787 
788  Double_t L0 = Z0/fabs(cos(kb.Theta()));
789  kb.SetZ(kz);
790  Double_t thetaOil = asin(fGeo->nQuartz()/fGeo->nEV()*sin(kb.Theta()));
791  if(printout){
792  cout<<"RECO ambig TIME: thetas are: quartz = "<<kb.Theta()/fpi*180.<<", oil = "<<thetaOil/fpi*180.<<endl;
793  }
794  kb.SetTheta(thetaOil);
795  Double_t Z1 = fGeo->EVlen();
796  Double_t L1 = Z1/fabs(cos(kb.Theta())); // path in oil
797 
798  if(printout){
799  cout<<"-I- Reco ambig Time: Zev = "<<fGeo->EVlen()<<endl;
800  cout<<"-I- Reco ambig Time: L0 = "<<L0<<", L1 = "<<L1<<endl;
801  cout<<"-I- Reco ambig Time: time is "<< L0/u_quartz + L1/u_oil <<endl; // 19.5 cm/ns - average (lambda) group speed
802  }
803 
804  *l = L0 + L1;
805 
806  return L0/u_quartz + L1/u_oil; //[ns]
807 }
808 
810 {
811  // Histogram list
812  fHistoList = new TList();
813 
814  fhPDTime = new TH1D("fhPDTime","Time of photons in ns",1000,0,100);
815  fhRecoT1 = new TH2F("fhRecoT1","Reconstructed group velocity using MC track path [ns]", 500, 200.,700., 1000, 0., 40.);
816  fhPDHits = new TH2D("fhPDHits","Photon hits on the PD plane", 2500, -250, 250, 2500, -250, 250);
817 
818  fhDiff = new TH1F("fhDiff","Difference btw reco and expected Cherenkov Angle", 50, -fWidth, fWidth);
819 
820  fhCHreal = new TH1F("fhCHreal","Generated cherenkov angle", 100, 0.7, 0.9);
821  fhLam = new TH1F("fhLam","Lambda of detected Cherenkov photons", 480, 200., 800.);
822 
823  fhNboLam = new TH2F("fhNboLam", "Nbo as a function of lambda", 600, 200.,800., 100, 0.,500.);
824 
825  fHistoList->Add(fhPDTime);
826  fHistoList->Add(fhPDHits);
827  fHistoList->Add(fhDiff);
828  fHistoList->Add(fhCHreal);
829  fHistoList->Add(fhLam);
830  // also add temp histos
831  fHistoList->Add(fhRecoT1);
832  fHistoList->Add(fhNboLam);
833 
834  fPixelSize = 0.65;
835 
836  fMapHist = new TH2F("fMapHist","Photon yield",30,2.5,152.5,20,0.35,20.35);// 3 bars 41,0.35,20.85); //25,0.5,25.5);
837  fSigHist = new TH2F("fSigHist","fSigHist",30,2.5,152.5, 20,0.35,20.35);// 3 bars 41,0.35,20.85);//7 bars("fSigHist","fSigHist",30,2.5,152.5, 25,0.5,25.5);// 5 bars in bar box
838  fCheHist = new TH2F("fCheHist","fCheHist",30,2.5,152.5, 20,0.35,20.35);// 3 bars 41,0.35,20.85); //("fCheHist","fCheHist",30,2.5,152.5, 25,0.5,25.5);
839  fkBarXHist = new TH2F("fkBarXHist","fkBarXHist",200,-1.,1.,200,-1.,1.);
840  fkBarYHist = new TH2F("fkBarYHist","fkBarYHist",200,-1.,1.,200,-1.,1.);
841  fHistoList->Add(fMapHist);
842  fHistoList->Add(fSigHist);
843  fHistoList->Add(fCheHist);
844  fHistoList->Add(fkBarXHist);
845  fHistoList->Add(fkBarYHist);
846 }
847 
848 //------------------Write to File----------------------------------------------
850 {
851  fOutputName.Append(":/");
852  gDirectory->cd(fOutputName);
853  //gDirectory->cd("13_t90_500ev_l0_oil_5_HIT.root:/");
854 
855  gDirectory->mkdir("diff");
856  gDirectory->cd("diff");
857  for(int i=0; i<PhiThetaPoints.size();i++){
858  PhiThetaPoints[i]->Write();
859  }
860 
861  gDirectory->cd("../");
862  gDirectory->mkdir("diffCut");
863  gDirectory->cd("diffCut");
864  for(int i=0; i<PhiThetaPointsCut.size();i++){
865  PhiThetaPointsCut[i]->Write();
866  }
867 
868  gDirectory->cd("../");
869  gDirectory->mkdir("diffWeight");
870  gDirectory->cd("diffWeight");
871  for(int i=0; i<PhiThetaPointsWeight.size();i++){
872  PhiThetaPointsWeight[i]->Write();
873  }
874 
875  gDirectory->cd("../");
876  gDirectory->mkdir("Nbounces");
877  gDirectory->cd("Nbounces");
878  for(int i=0; i<NboPoints.size();i++){
879  NboPoints[i]->Write();
880  }
881  gDirectory->cd("../");
882  TIter next(fHistoList);
883  while ( TH1* histo = ((TH1*)next()) ) histo->Write();
884 
885 }
886 
887 // ----- Finish Task ---------------------------------------------------
889 {
890  cout << "-I- PndDrcRecoLookupMap: Finish" << endl;
891 
892  // creating a map in every pixel
893  Double_t sig = 0., chr = 0.;
894  TString hnam, num1, num2, num3;
895  Float_t xx, yy;
896  for(int i=0; i<PhiThetaPoints.size(); i++){
897 
898  TF1* fit = new TF1("fit","gaus(0)+pol1(3)");
899  fit->SetParameters(10.,-0.001,0.017,1.,1.);
900  PhiThetaPoints[i]->Fit("fit","V","");
901  sig = fabs(fit->GetParameter(2));
902  chr = fit->GetParameter(1);
903  hnam = PhiThetaPoints[i]->GetName();
904  //cout<<"hnam - "<<hnam<<endl;
905  num1 = hnam;
906  num1.Remove(0,1);
907  num1.Remove(num1.Index("_"), (num1.Length()-num1.Index("_")));
908  xx = num1.Atof();
909  //cout<<"t = "<<xx<<endl;
910  num2 = hnam;
911  num2.Remove(0,num2.Index("i")+1);
912  yy = num2.Atof()/100.-fHAngleInBDeg;
913  //cout<<"phi = "<<yy<<endl;
914  cout<<"i = "<<i<<endl;
915  fSigHist->Fill(xx,yy,sig);
916  cout<<"SigHIST was filled with "<<sig<<" in phi = "<<yy <<", theta - "<<xx <<endl;
917  fCheHist->Fill(xx, yy, chr);
918  }
919 /*
920  // fill diff map with low value to avoid the background color
921  for(Int_t i=0; i<fMapHist->GetXaxis()->GetNbins(); i++){
922  for(Int_t j=0; j<fMapHist->GetYaxis()->GetNbins(); j++){
923  if(fMapHist->GetBinContent(i+1,j+1) == 0.){
924  fMapHist->SetBinContent(i+1, j+1, -10.);
925  }
926  }
927  }
928 */
929  WriteToFile();
930  DrawHisto();
931 }
932 
933 //----------------------------------------------------------------
935 {
936 gStyle->SetOptFit(0111);
937 
938 TCanvas *C1 = new TCanvas("C1","Time", 500,500);
939 C1->Divide(1,2);
940 C1->cd(1);
941 fhPDTime->Draw();
942 C1->cd(2);
943 fhRecoT1->Draw();
944 
945 TCanvas *C2 = new TCanvas("C2","PD Plane", 500, 500);
946 fhPDHits->SetMarkerStyle(20);
947 fhPDHits->SetMarkerSize(0.25);
948 //fhPDHits->SetMarkerColor(2);
949 fhPDHits->Draw();
950 
951 TCanvas *C3 = new TCanvas("C3","Diff", 500,500);
952 fhDiff->GetXaxis()->SetTitle("[rad]");
953 fhDiff->SetLineWidth(3);
954 fhDiff->Draw();
955 
956 // C A N V A S W I T H M A P S (lambda and NEntries of pixels)
957 
958 TCanvas *C8= new TCanvas("C8","Nentries map",500,500);
959 SetPlotStyle();
960 gStyle->SetOptStat(11);
961 fMapHist->GetXaxis()->SetTitle("#Theta_{track} [degrees]");
962 fMapHist->GetYaxis()->SetTitle("#phi_{track} [degrees]");
963 fMapHist->GetZaxis()->SetTitle("nEntries");
964 //fMapHist->Draw("LEGO2Z");
965 fMapHist->Scale(0.05);
966 fMapHist->Draw("COL2Z");
967 //DrawDetectorLayout();
968 //DrawBarBox(fBBver1,fBBver2,fBBver3,fBBver4);
969 
970 
971 TCanvas *C9= new TCanvas("C9","Mean CHreco map",500,500);
972 SetPlotStyle();
973 gStyle->SetOptStat(11);
974 fCheHist->GetXaxis()->SetTitle("#theta track angle [degrees]");
975 fCheHist->GetYaxis()->SetTitle("#phi track angle [degrees]");
976 fCheHist->GetZaxis()->SetTitle("<CHreco - CHexp> [rad]");
977 //fCheHist->Draw("LEGO2Z");
978 fCheHist->Draw("COL2Z");
979 //DrawDetectorLayout();
980 //DrawBarBox(fBBver1,fBBver2,fBBver3,fBBver4);
981 
982 TCanvas *C10= new TCanvas("C10","Sigma map",500,500);
983 SetPlotStyle();
984 gStyle->SetOptStat(11);
985 //fSigHist->SetMinimum(-0.2);
986 //fSigHist->SetMaximum(0.2);
987 fSigHist->GetXaxis()->SetTitle("#theta track angle [degrees]");
988 fSigHist->GetYaxis()->SetTitle("#phi track angle [degrees]");
989 fSigHist->GetZaxis()->SetTitle("#sigma_{CHreco - CHexp}");
990 fSigHist->Draw("COL2Z");
991 //DrawDetectorLayout();
992 //DrawBarBox(fBBver1,fBBver2,fBBver3,fBBver4);
993 
994 TCanvas *C11= new TCanvas("C11","kBar LUT & kBar gen",500,500);
995 C11->Divide(2,1);
996 C11->cd(1);
997 fkBarXHist->GetXaxis()->SetTitle("kxBar from LUT");
998 fkBarXHist->GetYaxis()->SetTitle("kxBar generated");
999 fkBarXHist->Draw();
1000 TLine *l1 =new TLine(1.,1.,-1.,-1.);
1001 TLine *l2 = new TLine(-1.,1.,1.,-1.);
1002 l1->SetLineColor(8);
1003 l2->SetLineColor(8);
1004 l1->Draw("same");
1005 l2->Draw("same");
1006 C11->cd(2);
1007 fkBarYHist->GetXaxis()->SetTitle("kyBar from LUT");
1008 fkBarYHist->GetYaxis()->SetTitle("kyBar generated");
1009 fkBarYHist->Draw();
1010 l1->Draw("same");
1011 l2->Draw("same");
1012 
1013 TCanvas *C12= new TCanvas("C12","Lam & CHreal",500,500);
1014 C12->Divide(1,2);
1015 C12->cd(1);
1016 fhCHreal->Draw();
1017 C12->cd(2);
1018 fhLam->Draw();
1019 
1020 }
1021 
1022 // -------------------------------------------------------------------------
void SetChPartDirInBar2(TVector3 val)
friend F32vec4 acos(const F32vec4 &a)
Definition: P4_F32vec4.h:113
Double_t x0
Definition: checkhelixhit.C:70
void AddChDiff(Double_t val)
Double_t nEV()
Definition: PndGeoDrc.h:76
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
Int_t GetNPixelParam()
Definition: PndDrcDigiPar.h:45
Int_t run
Definition: autocutx.C:47
TClonesArray * fPDPointArray
friend F32vec4 exp(const F32vec4 &a)
Definition: P4_F32vec4.h:109
Double_t BBoxNum()
Definition: PndGeoDrc.h:136
Int_t i
Definition: run_full.C:25
__m128 m
Definition: P4_F32vec4.h:28
PndGeoDrc * fGeo
Basic geometry data of barrel DRC.
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
Double_t Lside()
Definition: PndGeoDrc.h:184
Bool_t GetParamsForPixel(Int_t, Double_t *)
Int_t GetPdgCode() const
Definition: PndMCTrack.h:73
#define verbose
virtual void SetParContainers()
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:111
Double_t EVlen()
Definition: PndGeoDrc.h:127
Double_t BarWidth()
Definition: PndGeoDrc.h:100
static T Sin(const T &x)
Definition: PndCAMath.h:42
int n
Double_t RecoAmbigTime(TVector3, TVector3, Double_t *, Bool_t)
Double_t par[3]
Double_t SectorNum(Double_t, Double_t)
TVector3 GetMomentum() const
Definition: PndMCTrack.h:78
void SetChPartPdg(Int_t val)
float Tan(float x)
Definition: PndCAMath.h:165
void SetChPartDirInBar(TVector3 val)
Double_t BBoxGap()
Definition: PndGeoDrc.h:130
std::vector< TH1F * > PhiThetaPointsCut
static T Cos(const T &x)
Definition: PndCAMath.h:43
Double_t barBoxZDown()
Definition: PndGeoDrc.h:104
std::vector< TH1F * > PhiThetaPoints
virtual Double_t GetTime()
Definition: PndDrcPDHit.h:55
TString pt(TString pts, TString exts="px py pz")
Definition: invexp.C:133
void SetCherenkovReal(Double_t val)
Double_t PipehAngle()
Definition: PndGeoDrc.h:139
Int_t GetBarPointID() const
Definition: PndDrcPDPoint.h:56
virtual Int_t GetRefIndex()
Definition: PndDrcPDHit.h:57
PndDrcDigiPar * fDigiPar
Int_t a
Definition: anaLmdDigi.C:126
TClonesArray * fDrcLutInfoArray
Double_t barBoxZUp()
Definition: PndGeoDrc.h:108
void AddAngle(Double_t val)
void SetChPartDir(TVector3 val)
std::vector< TH1F * > PhiThetaPointsWeight
Double_t
virtual void Exec(Option_t *option)
Double_t nQuartz()
Definition: PndGeoDrc.h:70
void AddTime(Double_t val)
void AddNOfBounces(Double_t val)
int nbins
Definition: full_core_ntp.C:33
TClonesArray * fBarPointArray
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
void SetCherenkovMC(Double_t val)
static PndGeoHandling * Instance()
TVector3 MasterToLocalShortId(const TVector3 &master, const Int_t &shortId)
Double_t InBarCoordSyst(TVector3, TVector3 *, TVector3 *, TVector3 *, TVector3 *)
Int_t GetNAmbiguities()
Definition: PndDrcDigiPar.h:44
Int_t GetNHitPixels()
Definition: PndDrcDigiPar.h:43
void SetVerbose(Int_t v)
int hit(Int_t nEvents=0, TString inFile="sim.root", TString parFile="par.root", TString inDigi="digi.root", TString outFile="hit.root", Int_t timeBased=0)
Definition: hit.C:1
Double_t barHalfThick()
Definition: PndGeoDrc.h:96
TClonesArray * fPDHitArray
Digitization Parameter Class for DIRC barrel part.
Definition: PndDrcDigiPar.h:29
virtual InitStatus Init()
TVector3 v1
Definition: bump_analys.C:40
Double_t FindOutPoint(Double_t, Double_t, Double_t, Double_t *, Bool_t)
virtual Int_t GetRefIndex()
Definition: PndDrcHit.h:44
ClassImp(PndAnaContFact)
TVector3 v2
Definition: bump_analys.C:40
PndGeoHandling * fGeoH
void AddPath(Double_t val)
virtual void SetParContainers()
TVector3 GetStartVertex() const
Definition: PndMCTrack.h:76
void DrawBarBox(TVector3, TVector3, TVector3, TVector3)
Int_t GetMotherID() const
Definition: PndMCTrack.h:74
static int next[96]
Definition: ranlxd.cxx:374
std::vector< TH1F * > NboPoints
Int_t NumberOfBounces(TVector3, TVector3, Int_t)
Double_t Pi
Double_t barNum()
Definition: PndGeoDrc.h:124
Int_t L1[1]
Definition: Pnd_Hc_ee7G.C:50
Double_t GetStartTime() const
Definition: PndMCTrack.h:77
Double_t radius()
Definition: PndGeoDrc.h:92