Update Regional card structure (Ch. Finck)
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPIDv1.cxx
CommitLineData
6ad0bfa0 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
b2a60966 16/* $Id$ */
17
6ad0bfa0 18//_________________________________________________________________________
b2a60966 19// Implementation version v1 of the PHOS particle identifier
7acf6008 20// Particle identification based on the
148b2bba 21// - RCPV: distance from CPV recpoint to EMCA recpoint.
22// - TOF
23// - PCA: Principal Components Analysis..
24// The identified particle has an identification number corresponding
25// to a 9 bits number:
bc0c084c 26// -Bit 0 to 2: bit set if RCPV > CpvEmcDistance (each bit corresponds
148b2bba 27// to a different efficiency-purity point of the photon identification)
bc0c084c 28// -Bit 3 to 5: bit set if TOF < TimeGate (each bit corresponds
148b2bba 29// to a different efficiency-purity point of the photon identification)
30// -Bit 6 to 9: bit set if Principal Components are
50739f15 31// inside an ellipse defined by the parameters a, b, c, x0 and y0.
148b2bba 32// (each bit corresponds to a different efficiency-purity point of the
50739f15 33// photon identification)
34// The PCA (Principal components analysis) needs a file that contains
35// a previous analysis of the correlations between the particles. This
bc0c084c 36// file is $ALICE_ROOT/PHOS/PCA8pa15_0.5-100.root. Analysis done for
50739f15 37// energies between 0.5 and 100 GeV.
9fa5f1d0 38// A calibrated energy is calculated. The energy of the reconstructed
50739f15 39// cluster is corrected with the formula A + B * E + C * E^2, whose
bc0c084c 40// parameters where obtained through the study of the reconstructed
50739f15 41// energy distribution of monoenergetic photons.
a4e98857 42//
bc0c084c 43// All the parameters (RCPV(2 rows-3 columns),TOF(1r-3c),PCA(5r-4c)
50739f15 44// and calibration(1r-3c))are stored in a file called
45// $ALICE_ROOT/PHOS/Parameters.dat. Each time that AliPHOSPIDv1 is
bc0c084c 46// initialized, this parameters are copied to a Matrix (9,4), a
50739f15 47// TMatrixD object.
7acf6008 48//
a4e98857 49// use case:
50739f15 50// root [0] AliPHOSPIDv1 * p = new AliPHOSPIDv1("galice1.root")
a4e98857 51// Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
50739f15 52// // reading headers from file galice1.root and create RecParticles
53 // TrackSegments and RecPoints are used
54// // set file name for the branch RecParticles
f0a4c9e9 55// root [1] p->ExecuteTask("deb all time")
50739f15 56// // available options
57// // "deb" - prints # of reconstructed particles
58// // "deb all" - prints # and list of RecParticles
59// // "time" - prints benchmarking results
7acf6008 60//
50739f15 61// root [2] AliPHOSPIDv1 * p2 = new AliPHOSPIDv1("galice1.root","v1",kTRUE)
148b2bba 62// Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
50739f15 63// //Split mode.
f0a4c9e9 64// root [3] p2->ExecuteTask()
65//
50739f15 66
f0a4c9e9 67
7acf6008 68//*-- Author: Yves Schutz (SUBATECH) & Gines Martinez (SUBATECH) &
148b2bba 69// Gustavo Conesa April 2002
50739f15 70// PCA redesigned by Gustavo Conesa October 2002:
71// The way of using the PCA has changed. Instead of 2
72// files with the PCA, each one with different energy ranges
73// of application, we use the wide one (0.5-100 GeV), and instead
bc0c084c 74// of fixing 3 ellipses for different ranges of energy, it has been
50739f15 75// studied the dependency of the ellipses parameters with the
76// energy, and they are implemented in the code as a funtion
77// of the energy.
78//
79//
80//
6ad0bfa0 81// --- ROOT system ---
7acf6008 82#include "TROOT.h"
83#include "TTree.h"
84#include "TFile.h"
e3817e5f 85#include "TF2.h"
86#include "TFormula.h"
87#include "TCanvas.h"
88#include "TFolder.h"
7acf6008 89#include "TSystem.h"
90#include "TBenchmark.h"
148b2bba 91#include "TMatrixD.h"
92#include "TPrincipal.h"
e3817e5f 93#include "TSystem.h"
148b2bba 94
6ad0bfa0 95// --- Standard library ---
96
75a6835b 97
6ad0bfa0 98// --- AliRoot header files ---
99
7acf6008 100#include "AliGenerator.h"
e3817e5f 101#include "AliPHOS.h"
26d4b141 102#include "AliPHOSPIDv1.h"
e3817e5f 103#include "AliPHOSClusterizerv1.h"
d956e9b7 104#include "AliPHOSEmcRecPoint.h"
6ad0bfa0 105#include "AliPHOSTrackSegment.h"
e3817e5f 106#include "AliPHOSTrackSegmentMakerv1.h"
6ad0bfa0 107#include "AliPHOSRecParticle.h"
7b7c1533 108#include "AliPHOSGeometry.h"
109#include "AliPHOSGetter.h"
6ad0bfa0 110
26d4b141 111ClassImp( AliPHOSPIDv1)
6ad0bfa0 112
6ad0bfa0 113//____________________________________________________________________________
1cb7c1ee 114AliPHOSPIDv1::AliPHOSPIDv1():AliPHOSPID()
115{
a4e98857 116 // default ctor
148b2bba 117
8d0f3f77 118 InitParameters() ;
92f521a9 119 fDefaultInit = kTRUE ;
7acf6008 120}
121
122//____________________________________________________________________________
88cb7938 123AliPHOSPIDv1::AliPHOSPIDv1(const AliPHOSPIDv1 & pid ):AliPHOSPID(pid)
581354c5 124{
386aef34 125 // ctor
581354c5 126 InitParameters() ;
581354c5 127 Init() ;
581354c5 128
129}
130
131//____________________________________________________________________________
88cb7938 132AliPHOSPIDv1::AliPHOSPIDv1(const TString alirunFileName, const TString eventFolderName):AliPHOSPID(alirunFileName, eventFolderName)
7acf6008 133{
a4e98857 134 //ctor with the indication on where to look for the track segments
7b7c1533 135
8d0f3f77 136 InitParameters() ;
2bd5457f 137 Init() ;
92f521a9 138 fDefaultInit = kFALSE ;
7acf6008 139}
7b7c1533 140
7acf6008 141//____________________________________________________________________________
142AliPHOSPIDv1::~AliPHOSPIDv1()
143{
79bb1b62 144 // dtor
9fa5f1d0 145
e3817e5f 146 delete [] fX ; // Principal input
147 delete [] fPPhoton ; // Photon Principal components
148 delete [] fPPi0 ; // Pi0 Principal components
7acf6008 149}
148b2bba 150//____________________________________________________________________________
a496c46c 151const TString AliPHOSPIDv1::BranchName() const
152{
88cb7938 153
154 return GetName() ;
a496c46c 155}
156
157//____________________________________________________________________________
148b2bba 158void AliPHOSPIDv1::Init()
159{
160 // Make all memory allocations that are not possible in default constructor
161 // Add the PID task to the list of PHOS tasks
a496c46c 162
adcca1e6 163 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
164 if(!gime)
165 gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName.Data()) ;
88cb7938 166
167 if ( !gime->PID() )
168 gime->PostPID(this) ;
148b2bba 169}
8d0f3f77 170
171//____________________________________________________________________________
172void AliPHOSPIDv1::InitParameters()
173{
e3817e5f 174 // Initialize PID parameters
adcca1e6 175 fWrite = kTRUE ;
8d0f3f77 176 fRecParticlesInRun = 0 ;
8d0f3f77 177 fNEvent = 0 ;
8d0f3f77 178 fRecParticlesInRun = 0 ;
9fa5f1d0 179 SetParameters() ; // fill the parameters matrix from parameters file
eabde521 180 SetEventRange(0,-1) ;
cc1fe362 181 // initialisation of response function parameters
182 // Tof
183 // Photons
184 fTphoton[0] = 2.97E-1 ;
185 fTphoton[1] = 1.55E-8 ;
186 fTphoton[2] = 5.40E-10 ;
187 fTFphoton = new TFormula("ToF response to photon" , "gaus") ;
188 fTFphoton->SetParameters( fTphoton[0], fTphoton[1], fTphoton[2]) ;
189 // Electrons
190 fTelectron[0] = 2.73E-1 ;
191 fTelectron[1] = 1.56E-8 ;
192 fTelectron[2] = 5.70E-10 ;
193 fTFelectron = new TFormula("ToF response to electron" , "gaus") ;
194 fTFelectron->SetParameters( fTelectron[0], fTelectron[1], fTelectron[2]) ;
195 //Charged Hadrons
196 fTchargedhadron[0] = 1.58E-1 ;
197 fTchargedhadron[1] = 1.64E-8 ;
198 fTchargedhadron[2] = 3.59E-10 ;
199 fTFchargedhadron = new TFormula("ToF response to charged hadron" , "landau") ;
200 fTFchargedhadron->SetParameters( fTchargedhadron[0], fTchargedhadron[1], fTchargedhadron[2]) ;
201 //Neutral Hadrons
202 fTneutralhadron[0] = 9.62E-1 ;
203 fTneutralhadron[1] = 1.65E-8 ;
204 fTneutralhadron[2] = 6.46E-10 ;
205 fTFneutralhadron = new TFormula("ToF response to neutral hadron" , "landau") ;
206 fTFneutralhadron->SetParameters( fTneutralhadron[0], fTneutralhadron[1], fTneutralhadron[2]) ;
8d0f3f77 207}
208
88cb7938 209//________________________________________________________________________
eabde521 210void AliPHOSPIDv1::Exec(Option_t *option)
88cb7938 211{
eabde521 212 // Steering method to perform particle reconstruction and identification
213 // for the event range from fFirstEvent to fLastEvent.
214 // This range is optionally set by SetEventRange().
215 // if fLastEvent=-1 (by default), then process events until the end.
61d3d6aa 216
88cb7938 217 if(strstr(option,"tim"))
218 gBenchmark->Start("PHOSPID");
219
220 if(strstr(option,"print")) {
221 Print() ;
222 return ;
223 }
224
225
adcca1e6 226 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
88cb7938 227
71cee46d 228 if (fLastEvent == -1)
229 fLastEvent = gime->MaxEvent() - 1 ;
230 else
231 fLastEvent = TMath::Min(fLastEvent,gime->MaxEvent());
eabde521 232 Int_t nEvents = fLastEvent - fFirstEvent + 1;
88cb7938 233
71cee46d 234 Int_t ievent ;
235 for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
88cb7938 236 gime->Event(ievent,"TR") ;
237 if(gime->TrackSegments() && //Skip events, where no track segments made
238 gime->TrackSegments()->GetEntriesFast()) {
239 MakeRecParticles() ;
2cc71c1e 240 MakePID() ;
90cceaf6 241 WriteRecParticles();
88cb7938 242 if(strstr(option,"deb"))
243 PrintRecParticles(option) ;
244 //increment the total number of rec particles per run
245 fRecParticlesInRun += gime->RecParticles()->GetEntriesFast() ;
246 }
247 }
ff417097 248 if(strstr(option,"deb"))
249 PrintRecParticles(option);
88cb7938 250 if(strstr(option,"tim")){
251 gBenchmark->Stop("PHOSPID");
252 Info("Exec", "took %f seconds for PID %f seconds per event",
253 gBenchmark->GetCpuTime("PHOSPID"),
eabde521 254 gBenchmark->GetCpuTime("PHOSPID")/nEvents) ;
88cb7938 255 }
adcca1e6 256 if(fWrite)
257 Unload();
88cb7938 258}
259
1cb7c1ee 260//____________________________________________________________________________
e3817e5f 261const TString AliPHOSPIDv1::GetFileNamePrincipal(TString particle) const
148b2bba 262{
e3817e5f 263 //Get file name that contains the PCA for a particle ("photon or pi0")
264 particle.ToLower();
265 TString name;
266 if (particle=="photon") name = fFileNamePrincipalPhoton ;
267 else if (particle=="pi0" ) name = fFileNamePrincipalPi0 ;
268 else Error("GetFileNamePrincipal","Wrong particle name: %s (choose from pi0/photon)\n",particle.Data());
269 return name;
270}
bc0c084c 271
e3817e5f 272//____________________________________________________________________________
fc7e2f43 273Float_t AliPHOSPIDv1::GetParameterCalibration(Int_t i) const
e3817e5f 274{
275 // Get the i-th parameter "Calibration"
276 Float_t param = 0.;
277 if (i>2 || i<0)
278 Error("GetParameterCalibration","Invalid parameter number: %d",i);
9fa5f1d0 279 else
e3817e5f 280 param = (*fParameters)(0,i);
281 return param;
282}
bc0c084c 283
e3817e5f 284//____________________________________________________________________________
fc7e2f43 285Float_t AliPHOSPIDv1::GetCalibratedEnergy(Float_t e) const
88cb7938 286{
287// It calibrates Energy depending on the recpoint energy.
288// The energy of the reconstructed cluster is corrected with
289// the formula A + B* E + C* E^2, whose parameters where obtained
290// through the study of the reconstructed energy distribution of
291// monoenergetic photons.
292
293 Float_t p[]={0.,0.,0.};
294 for (Int_t i=0; i<3; i++) p[i] = GetParameterCalibration(i);
295 Float_t enerec = p[0] + p[1]*e + p[2]*e*e;
296 return enerec ;
297
298}
299
300//____________________________________________________________________________
fc7e2f43 301Float_t AliPHOSPIDv1::GetParameterCpv2Emc(Int_t i, TString axis) const
e3817e5f 302{
303 // Get the i-th parameter "CPV-EMC distance" for the specified axis
304 Float_t param = 0.;
305 if(i>2 || i<0)
306 Error("GetParameterCpv2Emc","Invalid parameter number: %d",i);
307 else {
308 axis.ToLower();
309 if (axis == "x") param = (*fParameters)(1,i);
310 else if (axis == "z") param = (*fParameters)(2,i);
311 else Error("GetParameterCpv2Emc","Invalid axis name: %s",axis.Data());
312 }
313 return param;
314}
315
316//____________________________________________________________________________
fc7e2f43 317Float_t AliPHOSPIDv1::GetCpv2EmcDistanceCut(TString axis, Float_t e) const
e3817e5f 318{
88cb7938 319 // Get CpvtoEmcDistance Cut depending on the cluster energy, axis and
320 // Purity-Efficiency point
321
322 axis.ToLower();
323 Float_t p[]={0.,0.,0.};
324 for (Int_t i=0; i<3; i++) p[i] = GetParameterCpv2Emc(i,axis);
325 Float_t sig = p[0] + TMath::Exp(p[1] - p[2]*e);
326 return sig;
e3817e5f 327}
328
88cb7938 329//____________________________________________________________________________
fc7e2f43 330Float_t AliPHOSPIDv1::GetEllipseParameter(TString particle, TString param, Float_t e) const
88cb7938 331{
332 // Calculates the parameter param of the ellipse
e3817e5f 333
334 particle.ToLower();
335 param. ToLower();
88cb7938 336 Float_t p[4]={0.,0.,0.,0.};
337 Float_t value = 0.0;
338 for (Int_t i=0; i<4; i++) p[i] = GetParameterToCalculateEllipse(particle,param,i);
339 if (particle == "photon") {
340 if (param.Contains("a")) e = TMath::Min((Double_t)e,70.);
341 else if (param.Contains("b")) e = TMath::Min((Double_t)e,70.);
342 else if (param.Contains("x0")) e = TMath::Max((Double_t)e,1.1);
343 }
e3817e5f 344
443caba9 345 if (particle == "photon")
346 value = p[0]/TMath::Sqrt(e) + p[1]*e + p[2]*e*e + p[3];
347 else if (particle == "pi0")
348 value = p[0] + p[1]*e + p[2]*e*e;
349
88cb7938 350 return value;
e3817e5f 351}
352
353//_____________________________________________________________________________
fc7e2f43 354Float_t AliPHOSPIDv1::GetParameterPhotonBoundary (Int_t i) const
e3817e5f 355{
356 // Get the parameter "i" to calculate the boundary on the moment M2x
357 // for photons at high p_T
358 Float_t param = 0;
359 if (i>3 || i<0)
360 Error("GetParameterPhotonBoundary","Wrong parameter number: %d\n",i);
361 else
362 param = (*fParameters)(14,i) ;
363 return param;
148b2bba 364}
e3817e5f 365
148b2bba 366//____________________________________________________________________________
fc7e2f43 367Float_t AliPHOSPIDv1::GetParameterPi0Boundary (Int_t i) const
e3817e5f 368{
369 // Get the parameter "i" to calculate the boundary on the moment M2x
370 // for pi0 at high p_T
371 Float_t param = 0;
372 if (i>2 || i<0)
373 Error("GetParameterPi0Boundary","Wrong parameter number: %d\n",i);
374 else
375 param = (*fParameters)(15,i) ;
376 return param;
377}
148b2bba 378
e3817e5f 379//____________________________________________________________________________
fc7e2f43 380Float_t AliPHOSPIDv1::GetParameterTimeGate(Int_t i) const
e3817e5f 381{
88cb7938 382 // Get TimeGate parameter depending on Purity-Efficiency i:
383 // i=0 - Low purity, i=1 - Medium purity, i=2 - High purity
384 Float_t param = 0.;
e3817e5f 385 if(i>2 || i<0)
88cb7938 386 Error("GetParameterTimeGate","Invalid Efficiency-Purity choice %d",i);
e3817e5f 387 else
88cb7938 388 param = (*fParameters)(3,i) ;
389 return param;
e3817e5f 390}
391
e3817e5f 392//_____________________________________________________________________________
fc7e2f43 393Float_t AliPHOSPIDv1::GetParameterToCalculateEllipse(TString particle, TString param, Int_t i) const
88cb7938 394{
395 // Get the parameter "i" that is needed to calculate the ellipse
396 // parameter "param" for the particle "particle" ("photon" or "pi0")
397
e3817e5f 398 particle.ToLower();
399 param. ToLower();
88cb7938 400 Int_t offset = -1;
e3817e5f 401 if (particle == "photon") offset=0;
402 else if (particle == "pi0") offset=5;
403 else
88cb7938 404 Error("GetParameterToCalculateEllipse","Wrong particle name: %s (choose from pi0/photon)\n",particle.Data());
405
406 Int_t p= -1;
407 Float_t par = 0;
e3817e5f 408
409 if (param.Contains("a")) p=4+offset;
410 else if(param.Contains("b")) p=5+offset;
411 else if(param.Contains("c")) p=6+offset;
412 else if(param.Contains("x0"))p=7+offset;
413 else if(param.Contains("y0"))p=8+offset;
12022e83 414
88cb7938 415 if (i>4 || i<0)
416 Error("GetParameterToCalculateEllipse", "No parameter with index", i) ;
417 else if (p==-1)
418 Error("GetParameterToCalculateEllipse", "No parameter with name %s", param.Data() ) ;
12022e83 419 else
88cb7938 420 par = (*fParameters)(p,i) ;
421
422 return par;
12022e83 423}
424
12022e83 425
426//____________________________________________________________________________
8d4608b5 427Float_t AliPHOSPIDv1::GetDistance(AliPHOSEmcRecPoint * emc,AliPHOSCpvRecPoint * cpv, Option_t * axis)const
69183710 428{
429 // Calculates the distance between the EMC RecPoint and the PPSD RecPoint
148b2bba 430
88cb7938 431 const AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ;
69183710 432 TVector3 vecEmc ;
7acf6008 433 TVector3 vecCpv ;
148b2bba 434 if(cpv){
435 emc->GetLocalPosition(vecEmc) ;
436 cpv->GetLocalPosition(vecCpv) ;
2bb500e5 437
148b2bba 438 if(emc->GetPHOSMod() == cpv->GetPHOSMod()){
439 // Correct to difference in CPV and EMC position due to different distance to center.
440 // we assume, that particle moves from center
441 Float_t dCPV = geom->GetIPtoOuterCoverDistance();
442 Float_t dEMC = geom->GetIPtoCrystalSurface() ;
443 dEMC = dEMC / dCPV ;
444 vecCpv = dEMC * vecCpv - vecEmc ;
e3817e5f 445 if (axis == "X") return vecCpv.X();
446 if (axis == "Y") return vecCpv.Y();
447 if (axis == "Z") return vecCpv.Z();
448 if (axis == "R") return vecCpv.Mag();
449 }
148b2bba 450 return 100000000 ;
451 }
7acf6008 452 return 100000000 ;
69183710 453}
bc0c084c 454//____________________________________________________________________________
8d4608b5 455Int_t AliPHOSPIDv1::GetCPVBit(AliPHOSEmcRecPoint * emc,AliPHOSCpvRecPoint * cpv, Int_t effPur, Float_t e) const
bc0c084c 456{
e3817e5f 457 if(effPur>2 || effPur<0)
458 Error("GetCPVBit","Invalid Efficiency-Purity choice %d",effPur);
bc0c084c 459
e3817e5f 460 Float_t sigX = GetCpv2EmcDistanceCut("X",e);
461 Float_t sigZ = GetCpv2EmcDistanceCut("Z",e);
bc0c084c 462
463 Float_t deltaX = TMath::Abs(GetDistance(emc, cpv, "X"));
464 Float_t deltaZ = TMath::Abs(GetDistance(emc, cpv, "Z"));
8d4608b5 465
e3817e5f 466 if((deltaX>sigX*(effPur+1))|(deltaZ>sigZ*(effPur+1)))
bc0c084c 467 return 1;//Neutral
468 else
469 return 0;//Charged
bc0c084c 470}
69183710 471
69183710 472//____________________________________________________________________________
fc7e2f43 473Int_t AliPHOSPIDv1::GetPrincipalBit(TString particle, const Double_t* p, Int_t effPur, Float_t e)const
148b2bba 474{
50739f15 475 //Is the particle inside de PCA ellipse?
581354c5 476
e3817e5f 477 particle.ToLower();
478 Int_t prinbit = 0 ;
479 Float_t a = GetEllipseParameter(particle,"a" , e);
480 Float_t b = GetEllipseParameter(particle,"b" , e);
481 Float_t c = GetEllipseParameter(particle,"c" , e);
482 Float_t x0 = GetEllipseParameter(particle,"x0", e);
483 Float_t y0 = GetEllipseParameter(particle,"y0", e);
484
485 Float_t r = TMath::Power((p[0] - x0)/a,2) +
486 TMath::Power((p[1] - y0)/b,2) +
487 c*(p[0] - x0)*(p[1] - y0)/(a*b) ;
50739f15 488 //3 different ellipses defined
e3817e5f 489 if((effPur==2) && (r<1./2.)) prinbit= 1;
490 if((effPur==1) && (r<2. )) prinbit= 1;
491 if((effPur==0) && (r<9./2.)) prinbit= 1;
50739f15 492
581354c5 493 if(r<0)
e3817e5f 494 Error("GetPrincipalBit", "Negative square?") ;
1f0e7ccd 495
496 return prinbit;
148b2bba 497
148b2bba 498}
1f0e7ccd 499//____________________________________________________________________________
fc7e2f43 500Int_t AliPHOSPIDv1::GetHardPhotonBit(AliPHOSEmcRecPoint * emc) const
1f0e7ccd 501{
e3817e5f 502 // Set bit for identified hard photons (E > 30 GeV)
503 // if the second moment M2x is below the boundary
504
505 Float_t e = emc->GetEnergy();
506 if (e < 30.0) return 0;
507 Float_t m2x = emc->GetM2x();
508 Float_t m2xBoundary = GetParameterPhotonBoundary(0) *
509 TMath::Exp(-TMath::Power(e-GetParameterPhotonBoundary(1),2)/2.0/
510 TMath::Power(GetParameterPhotonBoundary(2),2)) +
511 GetParameterPhotonBoundary(3);
61d3d6aa 512 //Info("GetHardPhotonBit","E=%f, m2x=%f, boundary=%f",e,m2x,m2xBoundary);
e3817e5f 513 if (m2x < m2xBoundary)
514 return 1;// A hard photon
515 else
516 return 0;// Not a hard photon
1f0e7ccd 517}
92f521a9 518
e3817e5f 519//____________________________________________________________________________
fc7e2f43 520Int_t AliPHOSPIDv1::GetHardPi0Bit(AliPHOSEmcRecPoint * emc) const
e3817e5f 521{
522 // Set bit for identified hard pi0 (E > 30 GeV)
523 // if the second moment M2x is above the boundary
524
525 Float_t e = emc->GetEnergy();
526 if (e < 30.0) return 0;
527 Float_t m2x = emc->GetM2x();
528 Float_t m2xBoundary = GetParameterPi0Boundary(0) +
529 e * GetParameterPi0Boundary(1);
61d3d6aa 530 //Info("GetHardPi0Bit","E=%f, m2x=%f, boundary=%f",e,m2x,m2xBoundary);
e3817e5f 531 if (m2x > m2xBoundary)
532 return 1;// A hard pi0
bc0c084c 533 else
e3817e5f 534 return 0;// Not a hard pi0
f0a4c9e9 535}
e3817e5f 536
537//____________________________________________________________________________
8d4608b5 538TVector3 AliPHOSPIDv1::GetMomentumDirection(AliPHOSEmcRecPoint * emc, AliPHOSCpvRecPoint * )const
88cb7938 539{
540 // Calculates the momentum direction:
541 // 1. if only a EMC RecPoint, direction is given by IP and this RecPoint
542 // 2. if a EMC RecPoint and CPV RecPoint, direction is given by the line through the 2 recpoints
543 // However because of the poor position resolution of PPSD the direction is always taken as if we were
544 // in case 1.
f0a4c9e9 545
88cb7938 546 TVector3 dir(0,0,0) ;
9688c1dd 547
88cb7938 548 TVector3 emcglobalpos ;
549 TMatrix dummy ;
bf8f1fbd 550
88cb7938 551 emc->GetGlobalPosition(emcglobalpos, dummy) ;
bf8f1fbd 552
e3817e5f 553
88cb7938 554 dir = emcglobalpos ;
88cb7938 555 dir.SetMag(1.) ;
e3817e5f 556
88cb7938 557 //account correction to the position of IP
558 Float_t xo,yo,zo ; //Coordinates of the origin
adcca1e6 559 if(gAlice && gAlice->GetMCApp() && gAlice->Generator())
560 gAlice->Generator()->GetOrigin(xo,yo,zo) ;
561 else{
562 xo=yo=zo=0.;
563 }
88cb7938 564 TVector3 origin(xo,yo,zo);
565 dir = dir - origin ;
e3817e5f 566
88cb7938 567 return dir ;
7acf6008 568}
7b7c1533 569
570//____________________________________________________________________________
2cc71c1e 571void AliPHOSPIDv1::MakePID()
572{
573 // construct the PID weight from a Bayesian Method
574
575 Int_t index ;
cc1fe362 576 const Int_t kSPECIES = AliESDtrack::kSPECIESN ;
577 Double_t pid[kSPECIES] = {0., 0., 0., 0., 0., 0.} ;
2cc71c1e 578 Int_t nparticles = AliPHOSGetter::Instance()->RecParticles()->GetEntriesFast() ;
53ab54c8 579// const Int_t kMAXPARTICLES = 2000 ;
580// if (nparticles >= kMAXPARTICLES)
581// Error("MakePID", "Change size of MAXPARTICLES") ;
582// Double_t stof[kSPECIES][kMAXPARTICLES] ;
583 Double_t * stof[kSPECIES];
584 for (Int_t i =0; i< kSPECIES; i++)
585 stof[i] = new Double_t[nparticles];
586
cc1fe362 587 // make the normalized distribution of pid for this event
588 // w(pid) in the Bayesian formulation
2cc71c1e 589 for(index = 0 ; index < nparticles ; index ++) {
590 AliPHOSRecParticle * recpar = AliPHOSGetter::Instance()->RecParticle(index) ;
cc1fe362 591
592 pid[AliESDtrack::kKaon0] = 0 ;
593
594 if (recpar->IsPhoton() || recpar->IsHardPhoton())
595 pid[AliESDtrack::kPhoton]++ ;
596
597 else if (recpar->IsPi0() || recpar->IsHardPi0())
598 pid[AliESDtrack::kPi0]++ ;
599
600 else if (recpar->IsElectron()) {
601 pid[AliESDtrack::kElectron]++ ;
602 pid[AliESDtrack::kMuon]++ ;
603 }
604
605 else if (recpar->IsChargedHadron()){
606 pid[AliESDtrack::kPion]++ ;
607 pid[AliESDtrack::kKaon]++ ;
608 pid[AliESDtrack::kProton]++ ;
609 }
610
611 else if (recpar->IsNeutralHadron())
612 pid[AliESDtrack::kNeutron]++ ;
613
614 else if (recpar->IsEleCon())
615 pid[AliESDtrack::kEleCon]++ ;
616
617 // now get the signals probability
618 // s(pid) in the Bayesian formulation
619 // Tof
adcca1e6 620
cc1fe362 621 stof[AliESDtrack::kPhoton][index] = fTFphoton->Eval(recpar->ToF()) ;
622 stof[AliESDtrack::kPi0][index] = fTFphoton->Eval(recpar->ToF()) ; // pi0 are detected via decay photon
623 stof[AliESDtrack::kElectron][index] = fTFelectron->Eval(recpar->ToF()) ;
624 stof[AliESDtrack::kPion][index] = fTFchargedhadron->Eval(recpar->ToF()) ;
625 stof[AliESDtrack::kKaon][index] = fTFchargedhadron->Eval(recpar->ToF()) ;
626 stof[AliESDtrack::kProton][index] = fTFchargedhadron->Eval(recpar->ToF()) ;
627 stof[AliESDtrack::kNeutron][index] = fTFneutralhadron->Eval(recpar->ToF()) ;
628 stof[AliESDtrack::kEleCon][index] = fTFphoton->Eval(recpar->ToF()) ; // a conversion electron has the photon ToF
629 stof[AliESDtrack::kKaon0][index] = 0 ; // do not know yet what to to with K0
6e1e6e35 630 stof[AliESDtrack::kMuon][index] = 0 ; // do not know yet what to do with muon
adcca1e6 631
cc1fe362 632 }
633 for (index = 0 ; index < kSPECIES ; index++)
634 pid[index] /= nparticles ;
635
636
637 for(index = 0 ; index < nparticles ; index ++) {
638 // calculates the Bayesian weight
639 Int_t jndex ;
640 Double_t wn = 0.0 ;
641 for (jndex = 0 ; jndex < kSPECIES ; jndex++)
642 wn += stof[jndex][index] * pid[jndex] ;
643 AliPHOSRecParticle * recpar = AliPHOSGetter::Instance()->RecParticle(index) ;
e74ea0e9 644 if (TMath::Abs(wn)>0)
645 for (jndex = 0 ; jndex < kSPECIES ; jndex++) {
646 recpar->SetPID(jndex, stof[jndex][index] * pid[jndex] / wn) ;
647 }
2cc71c1e 648 }
53ab54c8 649 for (Int_t i =0; i< kSPECIES; i++)
650 delete [] stof[i];
2cc71c1e 651}
652
653//____________________________________________________________________________
e3817e5f 654void AliPHOSPIDv1::MakeRecParticles()
655{
b2a60966 656 // Makes a RecParticle out of a TrackSegment
148b2bba 657
88cb7938 658 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
fbf811ec 659 TObjArray * emcRecPoints = gime->EmcRecPoints() ;
660 TObjArray * cpvRecPoints = gime->CpvRecPoints() ;
661 TClonesArray * trackSegments = gime->TrackSegments() ;
148b2bba 662 if ( !emcRecPoints || !cpvRecPoints || !trackSegments ) {
f1611b7c 663 Fatal("MakeRecParticles", "RecPoints or TrackSegments not found !") ;
148b2bba 664 }
fbf811ec 665 TClonesArray * recParticles = gime->RecParticles() ;
01a599c9 666 recParticles->Clear();
148b2bba 667
7b7c1533 668 TIter next(trackSegments) ;
7acf6008 669 AliPHOSTrackSegment * ts ;
6ad0bfa0 670 Int_t index = 0 ;
09fc14a0 671 AliPHOSRecParticle * rp ;
7acf6008 672 while ( (ts = (AliPHOSTrackSegment *)next()) ) {
fad3e5b9 673
7b7c1533 674 new( (*recParticles)[index] ) AliPHOSRecParticle() ;
675 rp = (AliPHOSRecParticle *)recParticles->At(index) ;
f0a4c9e9 676 rp->SetTrackSegment(index) ;
9688c1dd 677 rp->SetIndexInList(index) ;
148b2bba 678
7acf6008 679 AliPHOSEmcRecPoint * emc = 0 ;
680 if(ts->GetEmcIndex()>=0)
7b7c1533 681 emc = (AliPHOSEmcRecPoint *) emcRecPoints->At(ts->GetEmcIndex()) ;
fad3e5b9 682
8d4608b5 683 AliPHOSCpvRecPoint * cpv = 0 ;
7acf6008 684 if(ts->GetCpvIndex()>=0)
8d4608b5 685 cpv = (AliPHOSCpvRecPoint *) cpvRecPoints->At(ts->GetCpvIndex()) ;
fad3e5b9 686
bd76890a 687 Int_t track = 0 ;
688 track = ts->GetTrackIndex() ;
689
148b2bba 690 // Now set type (reconstructed) of the particle
691
692 // Choose the cluster energy range
9fa5f1d0 693
fbf811ec 694 if (!emc) {
f1611b7c 695 Fatal("MakeRecParticles", "-> emc(%d) = %d", ts->GetEmcIndex(), emc ) ;
fbf811ec 696 }
50739f15 697
e3817e5f 698 Float_t e = emc->GetEnergy() ;
bc0c084c 699
6f969528 700 Float_t lambda[2] ;
701 emc->GetElipsAxis(lambda) ;
50739f15 702
703 if((lambda[0]>0.01) && (lambda[1]>0.01)){
704 // Looking PCA. Define and calculate the data (X),
bc0c084c 705 // introduce in the function X2P that gives the components (P).
706
e3817e5f 707 Float_t Spher = 0. ;
708 Float_t Emaxdtotal = 0. ;
50739f15 709
bc0c084c 710 if((lambda[0]+lambda[1])!=0)
e3817e5f 711 Spher=fabs(lambda[0]-lambda[1])/(lambda[0]+lambda[1]);
50739f15 712
e3817e5f 713 Emaxdtotal=emc->GetMaximalEnergy()/emc->GetEnergy();
50739f15 714
715 fX[0] = lambda[0] ;
716 fX[1] = lambda[1] ;
717 fX[2] = emc->GetDispersion() ;
e3817e5f 718 fX[3] = Spher ;
50739f15 719 fX[4] = emc->GetMultiplicity() ;
e3817e5f 720 fX[5] = Emaxdtotal ;
50739f15 721 fX[6] = emc->GetCoreEnergy() ;
722
e3817e5f 723 fPrincipalPhoton->X2P(fX,fPPhoton);
724 fPrincipalPi0 ->X2P(fX,fPPi0);
1f0e7ccd 725
50739f15 726 }
727 else{
e3817e5f 728 fPPhoton[0]=-100.0; //We do not accept clusters with
729 fPPhoton[1]=-100.0; //one cell as a photon-like
730 fPPi0[0] =-100.0;
731 fPPi0[1] =-100.0;
50739f15 732 }
733
2cc71c1e 734 Float_t time = emc->GetTime() ;
735 rp->SetTof(time) ;
9fa5f1d0 736
bc0c084c 737 // Loop of Efficiency-Purity (the 3 points of purity or efficiency
738 // are taken into account to set the particle identification)
e3817e5f 739 for(Int_t effPur = 0; effPur < 3 ; effPur++){
50739f15 740
bc0c084c 741 // Looking at the CPV detector. If RCPV greater than CpvEmcDistance,
742 // 1st,2nd or 3rd bit (depending on the efficiency-purity point )
743 // is set to 1
e3817e5f 744 if(GetCPVBit(emc, cpv, effPur,e) == 1 )
745 rp->SetPIDBit(effPur) ;
f0a4c9e9 746
50739f15 747 // Looking the TOF. If TOF smaller than gate, 4th, 5th or 6th
748 // bit (depending on the efficiency-purity point )is set to 1
2cc71c1e 749 if(time< (*fParameters)(3,effPur))
e3817e5f 750 rp->SetPIDBit(effPur+3) ;
2cc71c1e 751
e3817e5f 752 //Photon PCA
50739f15 753 //If we are inside the ellipse, 7th, 8th or 9th
754 // bit (depending on the efficiency-purity point )is set to 1
e3817e5f 755 if(GetPrincipalBit("photon",fPPhoton,effPur,e) == 1)
756 rp->SetPIDBit(effPur+6) ;
1f0e7ccd 757
e3817e5f 758 //Pi0 PCA
1f0e7ccd 759 //If we are inside the ellipse, 10th, 11th or 12th
760 // bit (depending on the efficiency-purity point )is set to 1
e3817e5f 761 if(GetPrincipalBit("pi0" ,fPPi0 ,effPur,e) == 1)
762 rp->SetPIDBit(effPur+9) ;
f0a4c9e9 763 }
e3817e5f 764 if(GetHardPhotonBit(emc))
765 rp->SetPIDBit(12) ;
766 if(GetHardPi0Bit (emc))
767 rp->SetPIDBit(13) ;
1f0e7ccd 768
bd76890a 769 if(track >= 0)
770 rp->SetPIDBit(14) ;
771
9fa5f1d0 772 //Set momentum, energy and other parameters
50739f15 773 Float_t encal = GetCalibratedEnergy(e);
9fa5f1d0 774 TVector3 dir = GetMomentumDirection(emc,cpv) ;
775 dir.SetMag(encal) ;
776 rp->SetMomentum(dir.X(),dir.Y(),dir.Z(),encal) ;
777 rp->SetCalcMass(0);
e0ed2e49 778 rp->Name(); //If photon sets the particle pdg name to gamma
e747b8da 779 rp->SetProductionVertex(0,0,0,0);
780 rp->SetFirstMother(-1);
781 rp->SetLastMother(-1);
782 rp->SetFirstDaughter(-1);
783 rp->SetLastDaughter(-1);
784 rp->SetPolarisation(0,0,0);
d956e9b7 785 //Set the position in global coordinate system from the RecPoint
786 AliPHOSGeometry * geom = gime->PHOSGeometry() ;
787 AliPHOSTrackSegment * ts = gime->TrackSegment(rp->GetPHOSTSIndex()) ;
788 AliPHOSEmcRecPoint * erp = gime->EmcRecPoint(ts->GetEmcIndex()) ;
789 TVector3 pos ;
790 geom->GetGlobal(erp, pos) ;
791 rp->SetPos(pos);
6ad0bfa0 792 index++ ;
793 }
6ad0bfa0 794}
e3817e5f 795
09fc14a0 796//____________________________________________________________________________
88cb7938 797void AliPHOSPIDv1::Print() const
09fc14a0 798{
b2a60966 799 // Print the parameters used for the particle type identification
bc0c084c 800
88cb7938 801 Info("Print", "=============== AliPHOSPIDv1 ================") ;
802 printf("Making PID\n") ;
803 printf(" Pricipal analysis file from 0.5 to 100 %s\n", fFileNamePrincipalPhoton.Data() ) ;
804 printf(" Name of parameters file %s\n", fFileNameParameters.Data() ) ;
805 printf(" Matrix of Parameters: 14x4\n") ;
806 printf(" Energy Calibration 1x3 [3 parametres to calibrate energy: A + B* E + C * E^2]\n") ;
807 printf(" RCPV 2x3 rows x and z, columns function cut parameters\n") ;
808 printf(" TOF 1x3 [High Eff-Low Pur,Medium Eff-Pur, Low Eff-High Pur]\n") ;
809 printf(" PCA 5x4 [5 ellipse parametres and 4 parametres to calculate them: A/Sqrt(E) + B* E + C * E^2 + D]\n") ;
810 Printf(" Pi0 PCA 5x3 [5 ellipse parametres and 3 parametres to calculate them: A + B* E + C * E^2]\n") ;
50739f15 811 fParameters->Print() ;
09fc14a0 812}
813
8d0f3f77 814
69183710 815
7acf6008 816//____________________________________________________________________________
a4e98857 817void AliPHOSPIDv1::PrintRecParticles(Option_t * option)
818{
dd5c4038 819 // Print table of reconstructed particles
820
88cb7938 821 AliPHOSGetter *gime = AliPHOSGetter::Instance() ;
bf8f1fbd 822
88cb7938 823 TClonesArray * recParticles = gime->RecParticles() ;
21cd0c07 824
825 TString message ;
3bf72d32 826 message = "\nevent " ;
827 message += gAlice->GetEvNumber() ;
828 message += " found " ;
829 message += recParticles->GetEntriesFast();
830 message += " RecParticles\n" ;
831
7acf6008 832 if(strstr(option,"all")) { // printing found TS
3bf72d32 833 message += "\n PARTICLE Index \n" ;
7acf6008 834
835 Int_t index ;
7b7c1533 836 for (index = 0 ; index < recParticles->GetEntries() ; index++) {
21cd0c07 837 AliPHOSRecParticle * rp = (AliPHOSRecParticle * ) recParticles->At(index) ;
3bf72d32 838 message += "\n" ;
839 message += rp->Name().Data() ;
840 message += " " ;
841 message += rp->GetIndexInList() ;
842 message += " " ;
843 message += rp->GetType() ;
7acf6008 844 }
3bf72d32 845 }
846 Info("Print", message.Data() ) ;
69183710 847}
88cb7938 848
849//____________________________________________________________________________
850void AliPHOSPIDv1::SetParameters()
851{
852 // PCA : To do the Principal Components Analysis it is necessary
853 // the Principal file, which is opened here
854 fX = new double[7]; // Data for the PCA
855 fPPhoton = new double[7]; // Eigenvalues of the PCA
856 fPPi0 = new double[7]; // Eigenvalues of the Pi0 PCA
857
858 // Read photon principals from the photon file
859
860 fFileNamePrincipalPhoton = "$ALICE_ROOT/PHOS/PCA8pa15_0.5-100.root" ;
861 TFile f( fFileNamePrincipalPhoton.Data(), "read" ) ;
862 fPrincipalPhoton = dynamic_cast<TPrincipal*> (f.Get("principal")) ;
863 f.Close() ;
864
865 // Read pi0 principals from the pi0 file
866
867 fFileNamePrincipalPi0 = "$ALICE_ROOT/PHOS/PCA_pi0_40-120.root" ;
868 TFile fPi0( fFileNamePrincipalPi0.Data(), "read" ) ;
869 fPrincipalPi0 = dynamic_cast<TPrincipal*> (fPi0.Get("principal")) ;
870 fPi0.Close() ;
871
872 // Open parameters file and initialization of the Parameters matrix.
873 // In the File Parameters.dat are all the parameters. These are introduced
874 // in a matrix of 16x4
875 //
876 // All the parameters defined in this file are, in order of row:
877 // line 0 : calibration
878 // lines 1,2 : CPV rectangular cat for X and Z
879 // line 3 : TOF cut
880 // lines 4-8 : parameters to calculate photon PCA ellipse
881 // lines 9-13: parameters to calculate pi0 PCA ellipse
882 // lines 14-15: parameters to calculate border for high-pt photons and pi0
883
884 fFileNameParameters = gSystem->ExpandPathName("$ALICE_ROOT/PHOS/Parameters.dat");
885 fParameters = new TMatrix(16,4) ;
886 const Int_t maxLeng=255;
887 char string[maxLeng];
888
889 // Open a text file with PID parameters
890 FILE *fd = fopen(fFileNameParameters.Data(),"r");
891 if (!fd)
892 Fatal("SetParameter","File %s with a PID parameters cannot be opened\n",
893 fFileNameParameters.Data());
894
895 Int_t i=0;
896 // Read parameter file line-by-line and skip empty line and comments
897 while (fgets(string,maxLeng,fd) != NULL) {
898 if (string[0] == '\n' ) continue;
899 if (string[0] == '!' ) continue;
900 sscanf(string, "%f %f %f %f",
901 &(*fParameters)(i,0), &(*fParameters)(i,1),
902 &(*fParameters)(i,2), &(*fParameters)(i,3));
903 i++;
2cc71c1e 904 //Info("SetParameters", "line %d: %s",i,string);
88cb7938 905 }
906 fclose(fd);
907}
908
909//____________________________________________________________________________
910void AliPHOSPIDv1::SetParameterCalibration(Int_t i,Float_t param)
911{
912 // Set parameter "Calibration" i to a value param
913 if(i>2 || i<0)
914 Error("SetParameterCalibration","Invalid parameter number: %d",i);
915 else
916 (*fParameters)(0,i) = param ;
917}
918
919//____________________________________________________________________________
920void AliPHOSPIDv1::SetParameterCpv2Emc(Int_t i, TString axis, Float_t cut)
921{
922 // Set the parameters to calculate Cpv-to-Emc Distance Cut depending on
923 // Purity-Efficiency point i
924
925 if(i>2 || i<0)
926 Error("SetParameterCpv2Emc","Invalid parameter number: %d",i);
927 else {
928 axis.ToLower();
929 if (axis == "x") (*fParameters)(1,i) = cut;
930 else if (axis == "z") (*fParameters)(2,i) = cut;
931 else Error("SetParameterCpv2Emc","Invalid axis name: %s",axis.Data());
932 }
933}
934
935//____________________________________________________________________________
936void AliPHOSPIDv1::SetParameterPhotonBoundary(Int_t i,Float_t param)
937{
938 // Set parameter "Hard photon boundary" i to a value param
939 if(i>4 || i<0)
940 Error("SetParameterPhotonBoundary","Invalid parameter number: %d",i);
941 else
942 (*fParameters)(14,i) = param ;
943}
944
945//____________________________________________________________________________
946void AliPHOSPIDv1::SetParameterPi0Boundary(Int_t i,Float_t param)
947{
948 // Set parameter "Hard pi0 boundary" i to a value param
949 if(i>1 || i<0)
950 Error("SetParameterPi0Boundary","Invalid parameter number: %d",i);
951 else
952 (*fParameters)(15,i) = param ;
953}
954
955//_____________________________________________________________________________
956void AliPHOSPIDv1::SetParameterTimeGate(Int_t i, Float_t gate)
957{
958 // Set the parameter TimeGate depending on Purity-Efficiency point i
959 if (i>2 || i<0)
960 Error("SetParameterTimeGate","Invalid Efficiency-Purity choice %d",i);
961 else
962 (*fParameters)(3,i)= gate ;
963}
964
965//_____________________________________________________________________________
966void AliPHOSPIDv1::SetParameterToCalculateEllipse(TString particle, TString param, Int_t i, Float_t par)
967{
968 // Set the parameter "i" that is needed to calculate the ellipse
969 // parameter "param" for a particle "particle"
970
971 particle.ToLower();
972 param. ToLower();
973 Int_t p= -1;
974 Int_t offset=0;
975
976 if (particle == "photon") offset=0;
977 else if (particle == "pi0") offset=5;
978 else
979 Error("SetParameterToCalculateEllipse","Wrong particle name: %s (choose from pi0/photon)\n",particle.Data());
980
981 if (param.Contains("a")) p=4+offset;
982 else if(param.Contains("b")) p=5+offset;
983 else if(param.Contains("c")) p=6+offset;
984 else if(param.Contains("x0"))p=7+offset;
985 else if(param.Contains("y0"))p=8+offset;
986 if((i>4)||(i<0))
987 Error("SetEllipseParameter", "No parameter with index %d", i) ;
988 else if(p==-1)
989 Error("SetEllipseParameter", "No parameter with name %s", param.Data() ) ;
990 else
991 (*fParameters)(p,i) = par ;
992}
993
994//____________________________________________________________________________
995void AliPHOSPIDv1::Unload()
996{
997 AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
998 gime->PhosLoader()->UnloadRecPoints() ;
999 gime->PhosLoader()->UnloadTracks() ;
1000 gime->PhosLoader()->UnloadRecParticles() ;
1001}
1002
1003//____________________________________________________________________________
90cceaf6 1004void AliPHOSPIDv1::WriteRecParticles()
88cb7938 1005{
1006
1007 AliPHOSGetter *gime = AliPHOSGetter::Instance() ;
1008
1009 TClonesArray * recParticles = gime->RecParticles() ;
1010 recParticles->Expand(recParticles->GetEntriesFast() ) ;
adcca1e6 1011 if(fWrite){
1012 TTree * treeP = gime->TreeP();
1013
1014 //First rp
1015 Int_t bufferSize = 32000 ;
1016 TBranch * rpBranch = treeP->Branch("PHOSRP",&recParticles,bufferSize);
1017 rpBranch->SetTitle(BranchName());
1018
1019 rpBranch->Fill() ;
1020
1021 gime->WriteRecParticles("OVERWRITE");
1022 gime->WritePID("OVERWRITE");
1023 }
88cb7938 1024}
1025