]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALRecPointsQaESDSelector.cxx
Test beam raw data reading
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALRecPointsQaESDSelector.cxx
CommitLineData
16d3c94d 1/**************************************************************************
0fc11500 2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
16d3c94d 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
8ada0ffe 16/* $Log$
b217491f 17/* Revision 1.5 2007/10/15 18:04:07 pavlinov
18/* quick fix
19/*
9e02e8c6 20/* Revision 1.4 2007/10/15 15:50:58 pavlinov
21/* fixed code violation
22/*
7227086e 23/* Revision 1.3 2007/10/09 08:46:10 hristov
24/* The data members fEMCALClusterCluster and fPHOSCluster are removed from AliESDCaloCluster, the fClusterType is used to select PHOS or EMCAL clusters. Changes, needed to use correctly the new AliESDCaloCluster. (Christian)
25/*
8ada0ffe 26/* Revision 1.2 2007/09/11 19:38:15 pavlinov
27/* added pi0 calibration, linearity, shower profile
28/*co: warning: `/* $Log' is obsolescent; use ` * $Log'.
0fc11500 29 * Revision 1.1 2007/08/08 15:58:01 hristov
30 * New calibration classes. (Aleksei)
31 * */
16d3c94d 32//_________________________________________________________________________
33// This is selector for making a set of histogramms from ESD for rec.points
34//*-- Authors: Aleksei Pavlinov (WSU)
0fc11500 35//*-- Feb 17, 2007 - Sep 11, 2007
16d3c94d 36//*-- Pi0 calibration
0fc11500 37//*-- Recalibration, linearity, shower profile
16d3c94d 38//_________________________________________________________________________
39
40#include "AliEMCALRecPointsQaESDSelector.h"
41#include "AliEMCALFolder.h"
42#include "AliEMCALSuperModule.h"
43#include "AliEMCALCell.h"
0fc11500 44#include "AliEMCALCellInfo.h"
16d3c94d 45#include "AliEMCALPi0SelectionParam.h"
46#include "AliEMCALHistoUtilities.h"
47#include "AliEMCALCalibCoefs.h"
48#include "AliEMCALGeometry.h"
49#include "AliLog.h"
50#include "AliESD.h"
51#include "AliEMCALRecPoint.h"
0fc11500 52#include "AliRunLoader.h"
53#include "AliStack.h"
54#include "jetfinder/AliEMCALJetMicroDst.h" // Sgpdge
55#include "AliEMCALDigit.h"
56
57#include <iostream>
58#include <iomanip>
59#include <fstream>
16d3c94d 60#include <assert.h>
61#include <map>
62#include <string>
63
64#include <TROOT.h>
65#include <TStyle.h>
66#include <TSystem.h>
67#include <TCanvas.h>
68#include <TVector3.h>
69#include <TLorentzVector.h>
0fc11500 70#include <TParticle.h>
16d3c94d 71#include <TChain.h>
72#include <TFile.h>
73#include <TH1F.h>
0fc11500 74#include <TH1D.h>
75#include <TH2F.h>
16d3c94d 76#include <TF1.h>
77#include <TMath.h>
16d3c94d 78#include <TBrowser.h>
0fc11500 79#include <TList.h>
80#include <TCanvas.h>
81#include <TLine.h>
82#include <TObjString.h>
83#include <TArrayI.h>
84#include <TGraphErrors.h>
85#include <TLegend.h>
86#include <TLegendEntry.h>
87#include <TNtuple.h>
16d3c94d 88
89using namespace std;
90
91typedef AliEMCALHistoUtilities u;
92
7227086e 93AliEMCALGeometry* AliEMCALRecPointsQaESDSelector::fgEmcalGeo=0;
94Int_t AliEMCALRecPointsQaESDSelector::fgNmaxCell = 4*12*24*11;
0fc11500 95
7227086e 96Double_t AliEMCALRecPointsQaESDSelector::fgDistEff = 3.;
97Double_t AliEMCALRecPointsQaESDSelector::fgW0 = 4.5;
98Double_t AliEMCALRecPointsQaESDSelector::fgSlopePhiShift = 0.01; // ?? just guess
0fc11500 99
7227086e 100AliEMCALFolder* AliEMCALRecPointsQaESDSelector::fgEMCAL = 0;
101AliEMCALFolder* AliEMCALRecPointsQaESDSelector::fgEMCALOld = 0;
0fc11500 102
7227086e 103Char_t **AliEMCALRecPointsQaESDSelector::fgAnaOpt=0;
104Int_t AliEMCALRecPointsQaESDSelector::fgNanaOpt = 0;
0fc11500 105enum keyOpt{
106 kCORR1,
107 kRECALIB,
108 kIDEAL,
109 kPI0,
110 kGAMMA,
111 kKINE,
112 kPROF,
113 kFIT,
114 //--
115 kEND
116};
7227086e 117
0fc11500 118// Enumeration variables
119// enum {kUndefined=-1, kLed=0, kBeam=1};
120// enum {kPatchResponse=0, kClusterResponse=1};
121// enum {kSkip=0, kSaveToMemory=1};
122
16d3c94d 123ClassImp(AliEMCALRecPointsQaESDSelector)
124
16d3c94d 125AliEMCALRecPointsQaESDSelector::AliEMCALRecPointsQaESDSelector() :
126 AliSelector(),
0fc11500 127 fPmom(0),
16d3c94d 128 fChain(0),
129 fLofHistsPC(0),
130 fLofHistsRP(0),
0fc11500 131 fLKineVsRP(0),
132 fLShowerProfile(0),
133 fCellsInfo(0),
16d3c94d 134 fEmcalPool(0),
0fc11500 135 fRunOpts(0),
136 fArrOpts(0),
137 fKeyOpts(0)
16d3c94d 138{
139 //
140 // Constructor. Initialization of pointers
141 //
7227086e 142 Char_t *anaOpt[]={
b217491f 143 "CORR1", // GetCorrectedEnergyForGamma1(Double_t eRec);
7227086e 144 "RECALIB",
145 "IDEAL",
146 "PI0",
147 "GAMMA",
148 "KINE", // reading kine file
149 "PROF", // Shower profile: phi direction now
150 "FIT" // define parameters : deff, w0 and phislope
151 };
152
153 fgNanaOpt = sizeof(anaOpt) / sizeof(Char_t*);
154 fgAnaOpt = new Char_t*[fgNanaOpt];
155 for(int i=0; i<fgNanaOpt; i++) fgAnaOpt[i] = anaOpt[i];
16d3c94d 156}
157
158AliEMCALRecPointsQaESDSelector::~AliEMCALRecPointsQaESDSelector()
159{
160 //
161 // Destructor
162 //
163
164 // histograms are in the output list and deleted when the output
165 // list is deleted by the TSelector dtor
166}
167
168void AliEMCALRecPointsQaESDSelector::Begin(TTree* tree)
169{
170 // Begin function
171
172 AliSelector::Begin(tree);
173}
174
16d3c94d 175void AliEMCALRecPointsQaESDSelector::SlaveBegin(TTree* tree)
176{
177 // The SlaveBegin() function is called after the Begin() function.
178 // When running with PROOF SlaveBegin() is called on each slave server.
179 // The tree argument is deprecated (on PROOF 0 is passed).
180
181 printf("**** <I> Slave Begin \n **** ");
182
183 AliSelector::SlaveBegin(tree);
184}
185
0fc11500 186void AliEMCALRecPointsQaESDSelector::Init(TTree* tree)
187{
188 // Init function
189
190 AliSelector::Init(tree);
191}
192Bool_t AliEMCALRecPointsQaESDSelector::Notify()
193{
194 // The Notify() function is called when a new file is opened. This
195 // can be either for a new TTree in a TChain or when when a new TTree
196 // is started when using PROOF. Typically here the branch pointers
197 // will be retrieved. It is normaly not necessary to make changes
198 // to the generated code, but the routine can be extended by the
199 // user if needed.
200
201 return AliSelector::Notify();
202}
203
16d3c94d 204void AliEMCALRecPointsQaESDSelector::InitStructure(Int_t it)
205{
7227086e 206 //
207 // Initialize the common structure of selector
208 //
209 fgEmcalGeo = AliEMCALGeometry::GetInstance("SHISH_TRD1_CURRENT_2X2"); // initialize geometry just once
210 fCellsInfo = AliEMCALCellInfo::GetTableForGeometry(fgEmcalGeo);
0fc11500 211
212 if(fRunOpts.Length()>0) CheckRunOpts();
16d3c94d 213
0fc11500 214 Int_t key = 0;
215 if(GetKeyOptsValue(kGAMMA)) key = 1;
216 fLofHistsRP = DefineHistsOfRP("RP", fPmom, key);
217 fLofHistsPC = DefineHistsOfRP("PseudoCl", fPmom);
16d3c94d 218
0fc11500 219 fEmcalPool = new TFolder("PoolOfEMCAL","");
220 if(it <= 1) {
7227086e 221 fgEMCAL = new AliEMCALFolder(it); // folder for first itteration
222 fEmcalPool->Add(fgEMCAL);
16d3c94d 223 }
0fc11500 224 //if(it<=0) SetName("GammaSel"); // For convinience
225 //else SetName("Pi0Sel");
226 if(GetKeyOptsValue(kKINE)) fLKineVsRP = DefineHistsOfKineVsRP("KineVsRP",fPmom, key);
227 if(GetKeyOptsValue(kPROF)) fLShowerProfile = DefineHistsForShowerProfile("ProfY", fPmom);
228}
229
230void AliEMCALRecPointsQaESDSelector::CheckRunOpts()
231{
7227086e 232 // Check run options
0fc11500 233 fRunOpts.ToUpper();
234 int nopt = u::ParseString(fRunOpts, fArrOpts);
7227086e 235 printf("<I> AliEMCALRecPointsQaESDSelector::CheckRunOpts() analyze %i(%i) options : fgNanaOpt %i\n",
236 nopt, fArrOpts.GetEntries(), fgNanaOpt);
0fc11500 237 if(nopt <=0) return;
238
7227086e 239 fKeyOpts = new TArrayI(fgNanaOpt);
240 for(Int_t i=0; i<fgNanaOpt; i++) (*fKeyOpts)[i] = 0;
0fc11500 241
242 for(Int_t i=0; i<fArrOpts.GetEntries(); i++ ) {
243 TObjString *o = (TObjString*)fArrOpts.At(i);
244
245 TString runOpt = o->String();
246 Int_t indj=-1;
247
7227086e 248 for(Int_t j=0; j<fgNanaOpt; j++) {
249 TString opt = fgAnaOpt[j];
0fc11500 250 if(runOpt.Contains(opt,TString::kIgnoreCase)) {
251 indj = j;
252 break;
253 }
254 }
255 if(indj<0) {
256 printf("<E> option |%s| unavailable **\n",
257 runOpt.Data());
258 assert(0);
259 } else {
260 (*fKeyOpts)[indj] = 1;
261 printf("<I> option |%s| is valid : number %i : |%s| \n",
7227086e 262 runOpt.Data(), indj, fgAnaOpt[indj]);
0fc11500 263 }
264 }
265}
266
267Int_t AliEMCALRecPointsQaESDSelector::GetKeyOptsValue(Int_t key)
268{
7227086e 269 // Oct 14, 2007
0fc11500 270 static Int_t val=0;
271 val = 0;
272 if(fKeyOpts && key>=0 && key<fKeyOpts->GetSize()) {
273 val = fKeyOpts->At(key);
274 }
7227086e 275 // printf(" key %i : val %i : opt %s \n", key, val, fgAnaOpt[key]);
0fc11500 276 return val;
16d3c94d 277}
278
279Bool_t AliEMCALRecPointsQaESDSelector::Process(Long64_t entry)
280{
281 // The Process() function is called for each entry in the tree (or possibly
282 // keyed object in the case of PROOF) to be processed. The entry argument
283 // specifies which entry in the currently loaded tree is to be processed.
284 // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
285 // to read either all or the required parts of the data. When processing
286 // keyed objects with PROOF, the object is already loaded and is available
287 // via the fObject pointer.
288 //
289 // This function should contain the "body" of the analysis. It can contain
290 // simple or elaborate selection criteria, run algorithms on the data
291 // of the event and typically fill histograms.
292
293 // WARNING when a selector is used with a TChain, you must use
294 // the pointer to the current TTree to call GetEntry(entry).
295 // The entry is always the local entry number in the current tree.
296 // Assuming that fTree is the pointer to the TChain being processed,
297 // use fTree->GetTree()->GetEntry(entry).
298
0fc11500 299 if (AliSelector::Process(entry) == kFALSE) {
300 AliDebug(AliLog::kError, Form("Entry %i is not available ",entry));
16d3c94d 301 return kFALSE;
0fc11500 302 }
303
304 // esd->ReadFromTree(tree);
305 // AliESDEvent * esd = new AliESDEvent();
16d3c94d 306
307 // Check prerequisites
308 if (!fESD)
309 {
310 AliDebug(AliLog::kError, "ESD branch not available");
311 return kFALSE;
312 }
0fc11500 313
b217491f 314 static AliEMCALPi0SelectionParRec* rPar = GetEmcalFolder()->GetPi0SelectionParRow(0);
16d3c94d 315
316 static Int_t nEmcalClusters, indOfFirstEmcalRP, nEmcalRP,nEmcalPseudoClusters;
317 nEmcalClusters = fESD->GetNumberOfEMCALClusters();
318 indOfFirstEmcalRP = fESD->GetFirstEMCALCluster();
319 u::FillH1(fLofHistsRP, 1, double(indOfFirstEmcalRP));
320
7227086e 321 static AliRunLoader* rl = 0;
0fc11500 322 static Int_t nev = 0; // Temporary - 0nly for reading one file now !!
323
16d3c94d 324 static AliESDCaloCluster *cl = 0;
325 nEmcalRP = nEmcalPseudoClusters = 0;
326 TList *l=0;
327 double eDigi=0;
328
329 TClonesArray lvM1("TLorentzVector", 100); // for convenience; 100 is enough now
330 TArrayI indLv(100); // index of RP
331
332 static TLorentzVector v, vcl;
333 int nrp = 0; // # of RP for gg analysis
0fc11500 334 static Double_t erec=0., ecorr=0.0;
16d3c94d 335 for(int i=indOfFirstEmcalRP; i<indOfFirstEmcalRP+nEmcalClusters; i++) {
336 cl = fESD->GetCaloCluster(i);
8ada0ffe 337 if(cl->GetClusterType() == AliESDCaloCluster::kEMCALPseudoCluster) {
16d3c94d 338 nEmcalPseudoClusters++;
339 l = fLofHistsPC;
8ada0ffe 340 } else if(cl->GetClusterType() == AliESDCaloCluster::kEMCALClusterv1){
16d3c94d 341 nEmcalRP++;
7227086e 342 if(fgEMCAL->GetIterationNumber()>1||GetKeyOptsValue(kIDEAL)||GetKeyOptsValue(kRECALIB)||GetKeyOptsValue(kFIT)) {
0fc11500 343 AliEMCALRecPoint *rp=0;
7227086e 344 if(GetKeyOptsValue(kFIT) == kFALSE) fgDistEff = -1.; // No fitting ; Sep 4, 2007
0fc11500 345 if(GetKeyOptsValue(kIDEAL)) {
7227086e 346 rp = AliEMCALFolder::GetRecPoint(cl, fgEMCAL->GetCCFirst(), 0, fLofHistsRP, fgDistEff, fgW0, fgSlopePhiShift);
0fc11500 347 } else {
7227086e 348 rp = AliEMCALFolder::GetRecPoint(cl, fgEMCAL->GetCCFirst(), fgEMCAL->GetCCIn(), fLofHistsRP, fgDistEff, fgW0, fgSlopePhiShift);
0fc11500 349 }
350 if(GetKeyOptsValue(kPROF)) {
351 FillHistsForShowerProfile( GetListShowerProfile(), rp, GetCellsInfo());
352 }
b217491f 353 //if(rp->GetPointEnergy()>=rPar->fEOfRpMin && u::GetLorentzVectorFromRecPoint(v, rp)) {
16d3c94d 354 if(u::GetLorentzVectorFromRecPoint(v, rp)) { // comparing with RP
0fc11500 355 if(GetKeyOptsValue(kCORR1)) {
356 erec = v.Rho();
b217491f 357 ecorr = u::GetCorrectedEnergyForGamma1(erec);
0fc11500 358 v.SetRho(ecorr);
359 v.SetE(ecorr); // This is gamma
360 //printf("<1> erec %f | ecorr %f \n", erec, ecorr);
361 }
16d3c94d 362 new(lvM1[nrp]) TLorentzVector(v);
363 indLv[nrp] = i;
364 nrp++;
365 // Conroling of recalibration
366 u::GetLorentzVectorFromESDCluster(vcl, cl);
367 u::FillH1(fLofHistsRP, 11, vcl.P()-v.P());
368 u::FillH1(fLofHistsRP, 12, TMath::RadToDeg()*(vcl.Theta()-v.Theta()));
369 u::FillH1(fLofHistsRP, 13, TMath::RadToDeg()*(vcl.Phi()-v.Phi()));
0fc11500 370
371 u::FillH1(fLofHistsRP, 16, v.P());
372 u::FillH2(fLofHistsRP, 17, vcl.P(), vcl.P()-v.P());
16d3c94d 373 l = 0; // no filling
0fc11500 374 if(GetKeyOptsValue(kIDEAL) || GetKeyOptsValue(kRECALIB)) l = fLofHistsRP;
16d3c94d 375 }
0fc11500 376 if(rp) delete rp;
16d3c94d 377 } else { // first iteration
b217491f 378 // if(cl->E()>=rPar->fEOfRpMin && u::GetLorentzVectorFromESDCluster(v, cl)) {
16d3c94d 379 if(u::GetLorentzVectorFromESDCluster(v, cl)) { // comparing with RP
380 // cut 0.4 GeV may be high !
0fc11500 381 if(GetKeyOptsValue(kCORR1)) {
382 erec = v.Rho();
b217491f 383 ecorr = u::GetCorrectedEnergyForGamma1(erec);
0fc11500 384 v.SetRho(ecorr);
385 v.SetE(ecorr); // This is gamma now
386 // printf("<2> erec %f | ecorr %f \n", erec, ecorr);
387 // printf(" v.Rho() %f \n", v.Rho());
388 }
16d3c94d 389 new(lvM1[nrp]) TLorentzVector(v);
390 indLv[nrp] = i;
391 nrp++;
392 l = fLofHistsRP;
393 }
394 }
395
396 } else {
397 printf(" wrong cluster type : %i\n", cl->GetClusterType());
398 assert(0);
399 }
400 u::FillH1(l, 2, double(cl->GetClusterType()));
401
402 u::FillH1(l, 3, double(cl->GetNumberOfDigits()));
403 u::FillH1(l, 4, double(cl->E()));
404 // Cycle on digits (towers)
405 Short_t *digiAmpl = cl->GetDigitAmplitude()->GetArray();
406 Short_t *digiTime = cl->GetDigitTime()->GetArray();
407 Short_t *digiAbsId = cl->GetDigitIndex()->GetArray();
408 for(int id=0; id<cl->GetNumberOfDigits(); id++) {
409 eDigi = double(digiAmpl[id]) / 500.; // See AliEMCALClusterizerv1
410 // if(eDigi <= 0.0) { // sometimes it is happen
8ada0ffe 411 //if(eDigi > 10.0 && cl->GetClusterType() == AliESDCaloCluster::kEMCALClusterv1) {
16d3c94d 412 // printf(" %i digiAmpl %i : %f \n", id, int(digiAmpl[id]), eDigi);
413 //}
414 u::FillH1(l, 5, eDigi);
415 u::FillH1(l, 6, double(digiTime[id]));
416 u::FillH1(l, 7, double(digiAbsId[id]));
7227086e 417 if(int(digiAbsId[id]) >= fgNmaxCell) {
16d3c94d 418 printf(" id %i : digiAbsId[id] %i (%i) : %s \n",
7227086e 419 id, int(digiAbsId[id]), fgNmaxCell, l->GetName());
16d3c94d 420 }
421 }
422 }
423 u::FillH1(fLofHistsRP, 0, double(nEmcalRP));
424 u::FillH1(fLofHistsPC, 0, double(nEmcalPseudoClusters));
425
426 static TLorentzVector *lv1=0, *lv2=0, lgg;
0fc11500 427 for(int i1=0; i1<nrp; i1++){
428 lv1 = (TLorentzVector*)lvM1.At(i1);
429 u::FillH1(fLofHistsRP, 18, lv1->P());
430 }
16d3c94d 431 static Double_t mgg, pgg;
432 mgg = pgg = 0.;
433 nrp = lvM1.GetEntriesFast();
434 if(nrp >= 2) {
435 // eff.mass analysis
436 for(int i1=0; i1<nrp-1; i1++){
437 lv1 = (TLorentzVector*)lvM1.At(i1);
438 for(int i2=i1+1; i2<nrp; i2++){
439 lv2 = (TLorentzVector*)lvM1.At(i2);
440 lgg = (*lv1) + (*lv2);
441 mgg = lgg.M(); // eff.mass
442 pgg = lgg.P(); // momentum
443 u::FillH1(fLofHistsRP, 8, mgg);
444
b217491f 445 if((mgg>=rPar->fMassGGMin && mgg<=rPar->fMassGGMax)) {// pi0 candidates
446 if((pgg>=rPar->fMomPi0Min && pgg>=rPar->fMomPi0Min)) {
7227086e 447 if(fgEMCAL && fgEMCAL->GetIterationNumber()>=1) {
448 fgEMCAL->FillPi0Candidate(mgg,fESD->GetCaloCluster(indLv[i1]),fESD->GetCaloCluster(indLv[i2]));
0fc11500 449 u::FillH1(fLofHistsRP, 9, pgg);
450 u::FillH1(fLofHistsRP,10, lv1->P());
451 u::FillH1(fLofHistsRP,10, lv2->P());
452 }
16d3c94d 453 }
454 }
455 }
456 }
457 }
458
0fc11500 459 // static Int_t fileNumber = 0;
460 static TString curFileName;
461 // if(GetKeyOptsValue(kKINE) && nev<fChain->GetEntries()) {
462 if(GetKeyOptsValue(kKINE)) {
463 // Get galice.root file in current directory
464 if(nev%1000==0) {
465 printf(" current file |%s|\n", fChain->GetCurrentFile()->GetName());
466 curFileName = fChain->GetCurrentFile()->GetName();
467 curFileName.ReplaceAll("AliESDs.","galice.");
468 }
7227086e 469 rl = u::InitKinematics(nev, curFileName.Data());
0fc11500 470 // Compare kineamtics vs EMCal clusters
7227086e 471 FillHistsOfKineVsRP(fLKineVsRP, rl, lvM1);
0fc11500 472 }
473
16d3c94d 474 lvM1.Delete();
475
476 if(nEmcalClusters != (nEmcalRP+nEmcalPseudoClusters))
477 Info("Process","nEmcalClusters %i : RP %i + PC %i ",nEmcalClusters, nEmcalRP, nEmcalPseudoClusters);
478
0fc11500 479 nev++;
480
16d3c94d 481 return kTRUE;
482}
483
484void AliEMCALRecPointsQaESDSelector::SlaveTerminate()
485{
486 // The SlaveTerminate() function is called after all entries or objects
487 // have been processed. When running with PROOF SlaveTerminate() is called
488 // on each slave server.
489
490 AliSelector::SlaveTerminate();
491
492 // Add the histograms to the output on each slave server
493 if (!fOutput)
494 {
495 AliDebug(AliLog::kError, Form("ERROR: Output list not initialized."));
496 return;
497 }
498
499 // fOutput->Add(fMultiplicity);
500}
501
502void AliEMCALRecPointsQaESDSelector::Terminate()
503{
504 // The Terminate() function is the last function to be called during
505 // a query. It always runs on the client, it can be used to present
506 // the results graphically or save the results to file.
507
508 AliSelector::Terminate();
16d3c94d 509
16d3c94d 510 PrintInfo();
511}
0fc11500 512
16d3c94d 513//
0fc11500 514TList *AliEMCALRecPointsQaESDSelector::DefineHistsOfRP(const char *name,Double_t p,Int_t keyOpt)
16d3c94d 515{
7227086e 516 //
517 // Define histogramms of rec.points
518 //
0fc11500 519 printf("<I> DefineHistsOfRP :%s : p %f : keyOpt %i \n", name, p, keyOpt);
7227086e 520 Double_t adcChannelEC = 0.0153; // ~15mev per adc count
0fc11500 521 Double_t xma = p*1.4, xmi=0.0, step=0.0, xmic=xmi, xmac = xma;
522 if(xma<0) xma = 20.;
523 Int_t nmax=1000, scale=4, nmaxc = nmax;
16d3c94d 524
525 gROOT->cd();
526 TH1::AddDirectory(1);
527 new TH1F("00_EmcalMultiplicity", "multiplicity of EMCAL ", 201, -0.5, 200.5); // real and pseudo
528 new TH1F("01_IndexOfFirstEmcal", "index of first emcal rec.points ", 201, -0.5, 200.5);
529
530 new TH1F("02_NumberOf", "number of ", 6, -0.5, 5.5);
531 new TH1F("03_NumberOfDigitsIn", "number of digits(towers) in rec.points ", 101, -0.5, 100.5);
16d3c94d 532
0fc11500 533 if(keyOpt==1 && p>0.1) {
534 if (p>=100.) scale=12;
535 else if(p>=50.) scale=10;
536 else if(p>=30.) scale=8;
537 xma = p + scale*(0.15*TMath::Sqrt(p));
538 xmi = p - scale*(0.15*TMath::Sqrt(p));
539 step = (xma-xmi)/nmax;
540 }
541
542 if(step < 0.0153) {
7227086e 543 nmax = int((xma-xmi) / adcChannelEC)+1;
544 xma = xmi + adcChannelEC*nmax;
0fc11500 545 }
546 new TH1F("04_EnergyOf", "energy of ", nmax, xmi, xma);
547 nmaxc = nmax; xmic=xmi; xmac = xma;
548
549 nmax = 10000;
7227086e 550 xmi = adcChannelEC/2.; xma = xmi + adcChannelEC*nmax;
16d3c94d 551 // All energy(momentum) unit is GeV if don't notice
0fc11500 552 new TH1F("05_DigitEnergyIn", "digit energy in ", nmaxc, xmic, xmac);
16d3c94d 553 new TH1F("06_DigitTimeIn", "digit time in 10ps(0.01ns) ", 1000, 0.0, 3.e+3); // ns/100 = 10 ps
7227086e 554 new TH1F("07_DigitAbsIdIn", "digit abs id in ", fgNmaxCell, -0.5, double(fgNmaxCell)-0.5);
16d3c94d 555 new TH1F("08_EffMass", "effective mass of #gamma,#gamma(m_{#pi^{0}}=134.9766 MeV)", 100, 0.0, 0.5);
556 new TH1F("09_MomOfPi0Candidate", "momentum of #pi^{0} candidates (0.085 <mgg<0.185)", 600, 0.0, 30.0);
557 new TH1F("10_MomOfRpPi0Candidate", "momentum of RP for #pi^{0} candidates (0.085 <mgg<0.185)", 600, 0.0, 30.0);
558 // Recalibration staf
0fc11500 559 Double_t pmax=11., dpmax=0.20;
560 if(p>0.1) {
561 pmax=p*1.2;
562 dpmax *= p;
563 }
564 new TH1F("11_MomClESD-RpRecalib", "difference of momentum cl(ESD) - rp(Recalib)", 100, -.01, dpmax);
16d3c94d 565 new TH1F("12_ThetaClESD-RpRecalib", "difference of #theta cl(ESD) - rp(Recalib) in degree", 100, -0.05, +0.05);
566 new TH1F("13_PhiClESD-RpRecalib", "difference of #phi cl(ESD) - rp(Recalib) in degree ", 100, -0.05, +0.05);
567 // Digi
568 new TH1F("14_EDigiRecalib", "energy of digits after recalibration", 2000, 0.0, 20.);
0fc11500 569 // AliEMCALGeometry* g = AliEMCALGeometry::GetInstance();
7227086e 570 new TH1F("15_AbsIdRecalib", "abs Id of digits after recalibration", fgEmcalGeo->GetNCells(),-0.5,Double_t(fgEmcalGeo->GetNCells())-0.5);
0fc11500 571 new TH1F("16_EnergyOfRecalibRp_", "energy of recalibrated rec.points", nmaxc, xmic, xmac); // Jul 12, 2007
572 new TH2F("17_ShiftRecalib_", "E(clESD) - E(recalib)", 110,0.0, pmax, 50,0.0,dpmax); // Jul 13, 2007
16d3c94d 573
0fc11500 574 // Corrected staff
575 new TH1F("18_EnergyOfCorrectedLV", "energy of corrected LV", nmaxc, xmic, xmac);
576
577 TString st = Form("ListOfHists%s_P=%5.1f",name,p);
578 st.ReplaceAll(" ","");
579 TList *l = u::MoveHistsToList(st.Data(), kFALSE);
580 st = Form("%s_P=%5.1f",name,p);
581 st.ReplaceAll(" ","");
582 u::AddToNameAndTitleToList(l, st.Data(), st.Data());
583
584 return l;
585}
586
587TList* AliEMCALRecPointsQaESDSelector::DefineHistsOfKineVsRP(const char *name, Double_t p, Int_t keyOpt)
588{
7227086e 589 //
590 // Define histogramms for comparing a initial kinematics with rec.points
591 //
592 printf("<I> DefineHistsOfKineVsRP :%s : p %f : keyOpt %i \n", name, p, keyOpt);
0fc11500 593
594 gROOT->cd();
595 TH1::AddDirectory(1);
596 new TH1F("00_hVx",Form("Vx of primary vertex"), 100, -5., +5.); // 00
597 new TH1F("01_hVy",Form("Vy of primary vertex"), 100, -5., +5.); // 01
598 new TH1F("02_hVz",Form("Vz of primary vertex"), 100, -50., +50.); // 02
599
7227086e 600 // Double_t adcChannelEC = 0.0153; // ~15mev per adc count
0fc11500 601 Double_t xma = p*1.4, xmi=0.0, sig=0.15*TMath::Sqrt(p);
602 // Double_t step=0.0, xmic=xmi, xmac = xma;
603 if(xma<0) xma = 20.;
604 //Int_t nmax=1000;
605 // scale=4, nmaxc = nmax;
606
607 new TH1F("03_hGidPrimar", "Geant Id of primary particle ", 101, 0.5, 100.5); // 03
608 new TH1F("04_hPmomPrim","momentum of primary particle", 100, xmi, xma); // 04
609 new TH1F("05_hEtaPrim","#eta of primary particle ", 200, -1., 1.); // 05
610 new TH1F("06_hPhiPrim","#phi of primary particle ", 63*2, 0.0,TMath::Pi()*2.); // 06
611 new TH1F("07_hThetaPrim","#theta of primary particle", 63, 0.0,TMath::Pi()); // 07
612 new TH1F("08_hPhiPrimInDegree","#phi of primary particle in degree", 120, 75.0, 195.0); // 08
613 new TH1F("09_hThetaPrimInDegree","#theta of primary particle in degree", 90, 45., 135.); // 09
614
615 // Particle vs cluster
616 new TH1F("10_hE(P)-E(RP)"," E(p) - E(RP) ", 100, -10.*sig, 10.*sig); // 10
617
618 new TH1F("11_hPvsRpAngleInDegree","angle between P and RP (in degree)", 110, 0.0, 1.0); // 11
619 double dphi=0.5; // for fitting
620 new TH1F("12_hPvsRpDPhiInDegree","dif(#phi) between P and RP (in degree)", 100, -dphi, dphi); // 12
621 new TH1F("13_hPvsRpDThetaInDegree","dif(#theta) between P and RP (in degree)", 100, -0.5, 0.5); // 13
622
623 new TH1F("14_hPvsRpDPhiInDegree","dif(#phi) between P and RP (in degree) right part of SM", 100, -dphi, +dphi); // 14
624 new TH1F("15_hPvsRpDPhiInDegree","dif(#phi) between P and RP (in degree) left part of SM", 100, -dphi, dphi); // 15
625
626 new TH1F("16_hPvsRpDThetaInDegree","dif(#theta) between P and RP (even index)", 100, -0.5, 0.5); // 16
627 new TH1F("17_hPvsRpDThetaInDegree","dif(#theta) between P and RP (odd index)", 100, -0.5, 0.5); // 17
628
629 TString st = Form("ListOfHists%s_P=%5.1f",name,p);
630 st.ReplaceAll(" ","");
631 TList *l = u::MoveHistsToList(st.Data(), kFALSE);
632 st = Form("%s_P=%5.1f",name,p);
633 st.ReplaceAll(" ","");
634 u::AddToNameAndTitleToList(l, st.Data(), st.Data());
635 return l;
636}
637
638TList *AliEMCALRecPointsQaESDSelector::DefineHistsForShowerProfile(const char *name, Double_t p)
639{
640 // Aug 1, 2007 - shower profile business as in testbeam analysis
641 // Phi direction here is Y direction in testbeam
642 printf("<I> DefineHistsForShowerProfile: %s : p %f \n",
643 name, p);
644
645 gROOT->cd();
646 TH1::AddDirectory(1);
647
648 // Cell unit
649 new TH1F("00_hPHiMean"," mean in #phi direction ", 24*10, 0.0, 24.);
650 new TH1F("01_hPHiLog"," mean with log in #phi direction ", 24*10, 0.0, 24.);
651 new TH2F("02_XmeanVsXlog", "xmean vs xlog", 240,0.0, 24.,240,0.0, 24.);
652 new TH2F("03_XmeanVsXlog", "xmean vs xlog (system of cell with max energy, first half on #eta)",
653 50,-0.5,+0.5, 100,-1.,+1.);
654 new TH2F("04_XmeanVsXlog", "xmean vs xlog (system of cell with max energy, second half on #eta)",
655 50,-0.5,+0.5, 100,-1.,+1.);
656
657 new TH2F("05_PhiShowerProfile", " #phi shower profile - cumulative distribution",
658 6*25,-3.,3., 201, -0.0025, 1.0025); // 00; x direction in cell unit
659
660 TString st = Form("L%s_P=%5.1f",name,p);
661 st.ReplaceAll(" ","");
662 TList *l = u::MoveHistsToList(st.Data(), kFALSE);
663 st = Form("%s_P=%5.1f",name,p);
664 st.ReplaceAll(" ","");
665 u::AddToNameAndTitleToList(l, st.Data(), st.Data());
16d3c94d 666
667 return l;
668}
669
7227086e 670void AliEMCALRecPointsQaESDSelector::FillHistsOfKineVsRP(TList *l, AliRunLoader* rl, TClonesArray &lvM)
0fc11500 671{
672 //
673 // lvM - array of TLorentzVector's which was cretaef from AliESDCaloCluster's
674 //
675
7227086e 676 if(l==0 || rl==0) return;
0fc11500 677
678 // TNtuple for qucik analysis
679 static TNtuple *nt=0;
680 if(nt==0) {
681 gROOT->cd();
682 Int_t bsize = int(1.e+7);
683 nt = new TNtuple("angle","angle ntuple for quick analysis",
684 "dPhi:dTheta:phiP:thetaP", bsize);
685 gROOT->GetListOfBrowsables()->Add(nt);
686 }
687 static AliStack* st=0;
688 static TParticle *p=0;
689 static Int_t gid=0, ic=0, pdg=0, i=0;
690 gid = ic = pdg = 0;
691
7227086e 692 st = rl->Stack();
0fc11500 693 if(st == 0) return;
694 // first primary particle
695 p = st->Particle(0);
696 if(p == 0) return;
697
698 u::FillH1(l, ic++, p->Vx());
699 u::FillH1(l, ic++, p->Vy());
700 u::FillH1(l, ic++, p->Vz());
701
702 pdg = p->GetPdgCode();
703 //gid = gMC->IdFromPDG(pdg); // gMc should be defined
704 AliEMCALJetMicroDst::Sgpdge(pdg,gid); // temporary
705
706 u::FillH1(l, ic++, Double_t(gid));
707 u::FillH1(l, ic++, p->P());
708 u::FillH1(l, ic++, p->Eta());
709 u::FillH1(l, ic++, TVector2::Phi_0_2pi(p->Phi()) );
710 u::FillH1(l, ic++, p->Theta());
711 // In degree
712 u::FillH1(l, ic++, TVector2::Phi_0_2pi(p->Phi())*TMath::RadToDeg());
713 u::FillH1(l, ic++, p->Theta()*TMath::RadToDeg()); // 09
714
715 if(lvM.GetEntriesFast() == 0) return;
716 //
717 // Initial kinematics vs Calo clusters
718 //
719 static TLorentzVector *lv = 0, lvp;
720 lvp.SetPxPyPzE(p->Px(),p->Py(),p->Pz(),p->Energy()); // Particle
721
722 Double_t angle = 0.0, angleMin = 180.0, eDiff=0.0, dPhi=0., dTheta=0., phiP=0.0, thetaP=0.0;
723 Int_t indMin = 0;
724 phiP = lvp.Phi() * TMath::RadToDeg();
725 if (phiP<81. || phiP>99.) return; // cut phi boundaries
726 thetaP = lvp.Theta() * TMath::RadToDeg();
727 if (thetaP<56. || thetaP>89.) return; // cut theta boundaries
728
729 for(i=0; i<lvM.GetEntriesFast(); i++) {
730 lv = (TLorentzVector*)lvM.At(i);
731 angle = lv->Angle(lvp.Vect())*TMath::RadToDeg();
732 if(angleMin > angle) {
733 angleMin = angle;
734 indMin = i;
735 }
736 }
737 lv = (TLorentzVector*)lvM.At(indMin);
738 eDiff = lvp.E() - lv->E();
739 u::FillH1(l, ic++, eDiff);
740
741 dPhi = TVector2::Phi_mpi_pi(lvp.Phi()-lv->Phi())*TMath::RadToDeg();
742 dTheta = TVector2::Phi_mpi_pi(lvp.Theta()-lv->Theta())*TMath::RadToDeg();
743 u::FillH1(l, ic++, angleMin);
744 u::FillH1(l, ic++, dPhi);
745 u::FillH1(l, ic++, dTheta);
746
747 if (phiP>=81. && phiP<=90.) {
748 u::FillH1(l, 14, dPhi);
749 } else if(phiP> 90. && phiP<=99.) {
750 u::FillH1(l, 15, dPhi);
751 }
752 // Unfinished - have to get absid of digit with max energy
753 u::FillH1(l, 16, dTheta);
754 u::FillH1(l, 17, dTheta);
755 if(nt) {
756 nt->Fill(dPhi,dTheta,phiP,thetaP);
757 /*
758 tv__tree = (TTree *) gROOT->FindObject("angle");
759 tv__tree->Draw("dPhi:phiP","abs(dPhi)<0.5","", 9182, 0);
760 tv__tree->Draw("dTheta:thetaP","abs(dTheta)<0.5","", 9182, 0);
761 */
762 }
763}
764
765void AliEMCALRecPointsQaESDSelector::FillHistsForShowerProfile
766(TList *l, AliEMCALRecPoint *rp, AliEMCALCellInfo * t)
767{
768 // Aug 1, 2007
769 if(l==0 || rp==0 || t==0) return;
770 // --
771 static Double_t xmean=0., xlog=0.;
b217491f 772 static AliEMCALCellIndexes rMax;
0fc11500 773 static Int_t phiSize;
774
775 if(rp->GetPointEnergy() < 1.0) return;
776 //if(rp->GetPointEnergy() > 8.0) return; // discard merged clusters for pi0 case
777
778 EvalLocalPhiPosition(1., rp, t, xmean, phiSize, rMax);
779 if(phiSize == 0) return; // just one row in cell directions
780
781 EvalLocalPhiPosition(5.5, rp, t, xlog, phiSize, rMax);
b217491f 782 if(rMax.fIPhi>1.5&&rMax.fIPhi<21.5 && rMax.fIEta>1.5&&rMax.fIEta<46.5) {
0fc11500 783 u::FillH1(l, 0, xmean);
784 u::FillH1(l, 1, xlog);
785 u::FillH2(l, 2, xlog, xmean);
786 // Select two central modules
b217491f 787 if((rMax.fIPhim==5 || rMax.fIPhim==6)){
0fc11500 788 // Transition to system of cell with max energy
b217491f 789 xmean -= (double(rMax.fIPhi)+0.5);
790 xlog -= (double(rMax.fIPhi)+0.5);
791 if(rMax.fIEtam>=2 && rMax.fIEtam<=12){ // approximatively first half on eta
0fc11500 792 u::FillH2(l, 3, xlog, xmean);
793 } else {// approximatively second half on eta
794 u::FillH2(l, 4, xlog, xmean);
795 }
796 }
797 }
798}
799
b217491f 800void AliEMCALRecPointsQaESDSelector::EvalLocalPhiPosition(const Double_t wlog, const AliEMCALRecPoint *rp, const AliEMCALCellInfo* t, Double_t &xcog, Int_t &phiSize, AliEMCALCellIndexes &rMax)
0fc11500 801{
802 // wlog = 1 - usual center of gravity; >1 - with logarithmic weight.
803 // digits - array of digits
804 // t -
805 //==
806 // xcog - position of center of gravity in cell unit
807 if(wlog<1.0 || rp==0 || t==0) return;
808 xcog = 0;
809
810 static Double_t wtot=0., w=0., edigi=0., e=0., edigiMax=0.;
811 static Int_t absid = 0, phiMin=0, phiMax=0;
b217491f 812 static AliEMCALCellIndexes* r=0;
0fc11500 813
814 e = rp->GetPointEnergy();
815 wtot = 0.0;
816 edigiMax=0.;
817
818 phiMin = 23; phiMax = 0;
819 for(Int_t iDigit=0; iDigit<rp->GetMultiplicity(); iDigit++) {
820 absid = rp->GetAbsId()[iDigit];
821 edigi = rp->GetEnergiesList()[iDigit];
822 if(wlog > 1.0) w = TMath::Max( 0., wlog + TMath::Log(edigi/e));
823 else w = edigi; // just energy
824
825 r = t->GetTable(absid);
b217491f 826 xcog += w*(Double_t(r->fIPhi) + 0.5);
0fc11500 827 wtot += w;
828 if(edigi > edigiMax) {
829 edigiMax = edigi;
830 rMax = (*r);
831 }
b217491f 832 if(phiMin > r->fIPhi) phiMin = r->fIPhi;
833 if(phiMax < r->fIPhi) phiMax = r->fIPhi;
0fc11500 834 }
835 xcog /= wtot;
836 phiSize = phiMax - phiMin;
837 // printf("phiSize %i \n", phiSize);
838}
16d3c94d 839/* unused now
840TList *AliEMCALRecPointsQaESDSelector::DefineHistsOfTowers(const char *name)
841{
842 //
843 // ESD: towers information was saved to pseudo clusters
844 //
845 gROOT->cd();
846 TH1::AddDirectory(1);
847 new TH1F("00_EmcalMultiplicity", "multiplicity of EMCAL ", 201, -0.5, 200.5); // number of pseudo RP
848
849 new TH1F("01_EnergyOf", "energy of ", 1000, 0.0, 100.);
850
851 TList *l = u::MoveHistsToList(Form("ListOfHists%s",name, " - ESD"), kFALSE);
852 u::AddToNameAndTitleToList(l, name, name);
853
854 return l;
855}
856*/
857
858void AliEMCALRecPointsQaESDSelector::FitEffMassHist()
859{
860 TH1* h = (TH1*)fLofHistsRP->At(8);
861 AliEMCALCell::FitHist(h, GetName(), "draw");
862}
863
864void AliEMCALRecPointsQaESDSelector::PrintInfo()
865{
866 // Service routine
0fc11500 867 printf("\n %i Entrie(s) | Option(s) |%s| \n", GetOptsArray().GetEntries(), fRunOpts.Data());
7227086e 868 for(int i=0; i<fgNanaOpt; i++) {
869 if(GetKeyOptsValue(i)) printf(" %i |%s| \n", i, fgAnaOpt[i]);
0fc11500 870 }
871
16d3c94d 872 TList *l[2] = {fLofHistsPC, fLofHistsRP};
873 printf("\n");
874 for(int i=0; i<2; i++){
875 TH1F *h = (TH1F*)l[i]->At(2);
876 printf(" %s \t: %i \n", h->GetTitle(), int(h->GetEntries()));
877 }
7227086e 878 printf(" fgDistEff %f fgW0 %f fgSlopePhiShift %f \n", fgDistEff, fgW0, fgSlopePhiShift);
0fc11500 879}
880
881void AliEMCALRecPointsQaESDSelector::SetMomentum(Double_t p)
882{ // Jul 9, 2007
883 fPmom = p;
884 // SetName(Form("%s_p_%f5.1", GetName(), p));
16d3c94d 885}
886
0fc11500 887
16d3c94d 888AliEMCALFolder* AliEMCALRecPointsQaESDSelector::CreateEmcalFolder(const Int_t it)
889{
7227086e 890 //
891 // Create emcal folder for iteration number it
892 //
16d3c94d 893 AliEMCALFolder* newFolder = new AliEMCALFolder(it); // folder for iteration #it
894 if(it>1) {
7227086e 895 fgEMCALOld = fgEMCAL;
896 AliEMCALCalibCoefs* tabOldOut = fgEMCALOld->GetCCOut();
16d3c94d 897 AliEMCALCalibCoefs* tabNewIn = new AliEMCALCalibCoefs(*tabOldOut);
b217491f 898 tabNewIn->SetName(AliEMCALFolder::GetCCinName().Data());
16d3c94d 899 newFolder->Add(tabNewIn);
900 }
901 fEmcalPool->Add(newFolder);
7227086e 902 fgEMCAL = newFolder;
16d3c94d 903
7227086e 904 return fgEMCAL;
16d3c94d 905}
906
907AliEMCALFolder* AliEMCALRecPointsQaESDSelector::GetEmcalOldFolder(const Int_t nsm)
908{
7227086e 909 // Return emcal folder with number nsm
16d3c94d 910 AliEMCALFolder* folder=0;
0fc11500 911 if(fEmcalPool) folder = (AliEMCALFolder*)fEmcalPool->FindObject(Form("EMCAL_%2.2i",nsm));
16d3c94d 912 return folder;
913}
914
915
916void AliEMCALRecPointsQaESDSelector::SetEmcalFolder(AliEMCALFolder* folder)
917{
7227086e 918 fgEMCAL = folder;
919 fEmcalPool->Add(fgEMCAL);
16d3c94d 920}
921
922void AliEMCALRecPointsQaESDSelector::SetEmcalOldFolder(AliEMCALFolder* folder)
923{
7227086e 924 fgEMCALOld = folder;
925 fEmcalPool->Add(fgEMCALOld);
16d3c94d 926}
927
928void AliEMCALRecPointsQaESDSelector::Browse(TBrowser* b)
929{
7227086e 930 // What we see at browser
16d3c94d 931 if(fESD) b->Add(fESD);
16d3c94d 932 if(fChain) b->Add(fChain);
933 if(fEmcalPool) b->Add(fEmcalPool);
7227086e 934 if(fgEmcalGeo) b->Add(fgEmcalGeo);
0fc11500 935 if(fCellsInfo) b->Add(fCellsInfo);
936 //
937 if(fLofHistsPC) b->Add(fLofHistsPC);
938 if(fLofHistsRP) b->Add(fLofHistsRP);
939 if(fLKineVsRP) b->Add(fLKineVsRP);
940 if(fLShowerProfile) b->Add(fLShowerProfile);
16d3c94d 941 // if(u) b->Add(u);
942}
943
944Bool_t AliEMCALRecPointsQaESDSelector::IsFolder() const
945{
946 if(fESD || fLofHistsRP || fEmcalPool) return kTRUE;
947 return kFALSE;
948}
949
0fc11500 950void AliEMCALRecPointsQaESDSelector::Save(Int_t ver, const char *optIO)
7227086e 951{
952 // Aug 3, 2007
953 // Save selector to file
0fc11500 954 TString dir("/home/pavlinov/ALICE/SHISHKEBAB/RF/CALIB/"); // Root directory for saving
955 TString nf=dir;
956 if(GetKeyOptsValue(kPROF)) {
957 nf += "PROF/PROFILE_";
958 nf += ver;
959 nf += ".root";
960 TFile f(nf.Data(), optIO);
961 if(f.IsOpen()) {
962 this->Write();
963 f.Close();
964 printf("<I> Save selectort to file |%s| : optIO %s \n",nf.Data(), optIO);
965 } else {
966 printf("<W> File %s exits ! Increase version : ver %i !\n", nf.Data(), ver);
967 }
968 } else {
969 printf("No PROF option -> no saving now !\n");
970 }
971}
972
973AliEMCALRecPointsQaESDSelector* AliEMCALRecPointsQaESDSelector::ReadSelector(const char* nf)
974{
7227086e 975 // Read selector to file
0fc11500 976 AliEMCALRecPointsQaESDSelector* selector=0;
977
978 TH1::AddDirectory(0);
979 TFile f(nf,"READ");
980 if(f.IsOpen()) {
981 TObject *o = f.Get("AliEMCALRecPointsQaESDSelector");
982 if(o) selector = dynamic_cast<AliEMCALRecPointsQaESDSelector *>(o);
983 }
7227086e 984 // printf("<I> read selector %p : file |%s| \n", selector, nf);
0fc11500 985 return selector;
986}
987
16d3c94d 988void AliEMCALRecPointsQaESDSelector::ReadAllEmcalFolders()
989{
7227086e 990 // Oct 14, 2007
16d3c94d 991 if(fEmcalPool==0) {
0fc11500 992 fEmcalPool = new TFolder("PoolOfEMCAL","");
16d3c94d 993 for(Int_t it=1; it<=10; it++){
b217491f 994 AliEMCALFolder* fold = AliEMCALFolder::ReadFolder(Form("EMCALFOLDER_It%i_fit.root",it), "READ");
995 // AliEMCALFolder* fold = AliEMCALFolder::Read(Form("EMCALFOLDER_It%i_fit.root",it), "READ");
16d3c94d 996 if(fold) fEmcalPool->Add(fold);
997 }
998 }
999}
1000
1001void AliEMCALRecPointsQaESDSelector::PictVsIterNumber(const Int_t ind, const Int_t nsm)
1002{
1003 // Jun 27, 2007 - unfinished; which picture is the best
1004 if(ind<0 || ind>5) return;
1005 gROOT->cd();
1006 TH1::AddDirectory(1);
1007
1008 Int_t itMax = 10, it=0;
1009 map <int, char*> indName;
1010 indName[0] = "eff.mass";
1011 indName[3] = "mass of #pi_{0}";
1012 indName[4] = "resolution of #pi_{0}";
1013 indName[5] = "chi^{2}/ndf";
1014
1015 TH1F *hout = new TH1F(indName[ind], indName[ind], itMax, 0.5, double(itMax)+0.5);
1016
1017 TH1::AddDirectory(0);
1018 Double_t content, error;
0fc11500 1019 TList* col = (TList*)fEmcalPool->GetListOfFolders();
1020 for(Int_t i=0; i<col->GetSize(); i++) { // cycle on EMCAL folders
1021 AliEMCALFolder* folder = static_cast<AliEMCALFolder*>(col->At(i));
16d3c94d 1022 if(folder==0) continue;
1023 it = folder->GetIterationNumber();
1024
1025 AliEMCALSuperModule* sm = folder->GetSuperModule(nsm);
1026 if(sm==0) continue;
1027
1028 TList* l = sm->GetHists();
1029 if(l==0) continue;
1030
1031 TH1F *hin = (TH1F*)l->At(ind);
1032 if(hin==0) continue;
1033
1034 if(ind !=0 ) {
1035 content = hin->GetMean();
1036 error = hin->GetRMS();
1037 } else {
1038 sm->FitEffMassHist();
1039 TF1 *f = (TF1*)hin->GetListOfFunctions()->At(0);
1040 content = error = -1.;
1041 if(f) {
1042 // content = f->GetParameter(1);
1043 //error = f->GetParameter(2);
1044 content = f->GetParameter(2);
1045 error = f->GetParError(2);
1046 }
1047 }
1048
1049 if(content > 0.0) {
1050 hout->SetBinContent(it, content);
1051 hout->SetBinError(it, error);
1052 printf(" it %i content %f +/- %f \n", it, content, error);
1053 }
1054 }
1055
1056 u::DrawHist(hout,2);
1057 hout->SetMinimum(0.0);
1058
1059}
0fc11500 1060
1061TH1F* AliEMCALRecPointsQaESDSelector::FitHistOfRecPointEnergy(const char *opt)
1062{
7227086e 1063 // Fit hist of rec.point energy
0fc11500 1064 TH1::AddDirectory(0);
1065
7227086e 1066 TString sopt(opt);
1067 sopt.ToUpper();
0fc11500 1068
1069 Int_t ind = 4, ind2 = 16;
1070 if(GetKeyOptsValue(kIDEAL)) {
1071 ind = 16; // Jul 12, 2007
1072 ind2 = 4;
1073 } else if(GetKeyOptsValue(kCORR1)) {
1074 ind = 18;
1075 ind2 = 4;
1076 }
1077 TH1F *hold = (TH1F*)fLofHistsRP->At(ind), *h=0;
1078 if(hold == 0) return 0;
1079 if(hold->GetEntries() <10.) return hold;
1080
7227086e 1081 if(sopt.Contains("CLONE")) {
0fc11500 1082 TString newName(Form("C_%s",hold->GetName()));
1083 h = (TH1F*)hold->Clone(newName.Data());
1084 printf(" Clone hist %s -> |%s|%s| \n",hold->GetName(),h->GetName(),h->GetTitle());
1085 } else {
1086 h = hold;
1087 }
1088 TH1F* h2 = (TH1F*)fLofHistsRP->At(ind2);
1089
1090 Double_t xmax = h->GetXaxis()->GetXmax(), xmin = 0.4*xmax;;
1091 TF1 *g = u::Gausi("fRecPointE", xmin, xmax, h);
1092 g->SetLineColor(kRed);
1093 gStyle->SetOptFit(111);
1094
1095 h->Fit(g,"N","", xmin, xmax);
1096 printf(" (1) xmin %f : xmax %f \n", xmin, xmax);
1097
1098 xmin = g->GetParameter(1) - 4.*g->GetParameter(2);
1099 xmax = g->GetParameter(1) + 4.*g->GetParameter(2);
1100 h->Fit(g,"Q+","", xmin, xmax);
1101 u::DrawHist(h2,1, 1, "same",2);
1102 printf(" (2) xmin %f : xmax %f \n", xmin, xmax);
1103
1104 return h;
1105}
1106
1107TCanvas *AliEMCALRecPointsQaESDSelector::Linearity(TList *l, int ifun)
7227086e 1108{
1109 // Jul 10, 2007
1110 // Draw picture of EMCal linearity
0fc11500 1111 if(l==0) {
1112 printf("<E> AliEMCALRecPointsQaESDSelector::Linearity :TList is zero ! Bye ! \n");
1113 return 0;
1114 }
1115 Double_t p[9]={0.5, 1., 3., 5., 10., 20., 30., 50., 100.}, ep[9];
1116 // see macro rHits.C ->defineSampleFraction
1117 TH1F* hErecOverEin = new TH1F("hErecOverEin","Ratio E_{rec}/E_{#gamma} vs E_{#gamma}", 101,0.5,101.5);
1118 // Fill hist
1119 TArrayD invRat(9), eInvRat(9), erec(9),derec(9), residual(9);
1120 TArrayD res(9), eres(9); // resolution
1121 Int_t np=9;
1122 for(Int_t var=0; var<9; var++){
1123 TH1F *h = (TH1F*)l->At(var);
1124 TF1 *f = (TF1*)h->GetListOfFunctions()->At(0);
1125 Double_t mean = f->GetParameter(1);
1126 Double_t emean = f->GetParError(1);
1127
1128 Int_t bin = hErecOverEin->FindBin(p[var]);
1129 hErecOverEin->SetBinContent(bin, mean/p[var]);
1130 hErecOverEin->SetBinError(bin, emean/p[var]);
1131 //
1132 invRat[var] = p[var]/mean;
1133 eInvRat[var] = emean/p[var]*invRat[var];
1134 erec[var] = mean;
1135 derec[var] = emean;
1136 // Resolution in %
1137 res[var] = 100.*f->GetParameter(2)/p[var];
1138 eres[var] = 100.*f->GetParError(2)/p[var];
1139 ep[var] = 0.0;
1140 }
1141
1142 TCanvas *c = new TCanvas("Linearity","Linearity", 20,20, 700, 500);
1143 gStyle->SetOptStat(0);
1144 if(0) { // E(rec) / E(gamma)
1145 u::DrawHist(hErecOverEin,2);
1146 hErecOverEin->SetMinimum(0.984);
1147 hErecOverEin->SetMaximum(1.001);
1148 }
1149 Int_t markerColor=1;
1150 char *fun="", *optFit="";
1151 TF1 *f = 0;
1152 if(0) {
1153 if(ifun==-5) {
1154 fun = "fun5"; optFit="R+";
1155 f = new TF1(fun,"([0]*(x-7.5)*(x-7.5))*exp([1]+[2]*x+[3]*x*x)+1.", 0.0, 100.);
1156 f->FixParameter(0, 1.95380e-05);
1157 // f->SetParameter(0, 1.95380e-05);
1158 // f->SetParameter(1, 1.0);
1159 } else if(ifun==-4) {
1160 fun = "fun4"; optFit="R+";
1161 f = new TF1(fun,"([0]*(x-7.5)*(x-7.5))*([1]+[2]*abs(x)+[3]*(x-[4])*(x-[4]))+1.", 0.0, 100.);
1162 f->FixParameter(0, 1.95380e-05);
1163 f->SetParameter(4, 50.);
1164 // f = new TF1(fun,"exp(([0]+[1]*x)*(x-[2])*(x-[3]))", 0.0, 100.);
1165 //f = new TF1(fun,"([0]+[1]*x)*(x-[2])*(x-[3])", 0.0, 100.);
1166 //f->SetParameter(0, 1.);
1167 //f->SetParameter(1, 1.);
1168
1169 // f->SetParameter(2, 5.);
1170 //f->SetParLimits(2, 3.,8.);
1171 //f->SetParameter(3, 10.);
1172 //f->SetParLimits(3, 9.,15.);
1173 //f->SetParameter(2, 2.e-4);
1174 } else if(ifun==-3) {
1175 fun = "fun3"; optFit="R+";
1176 f = new TF1(fun,"[0]+[1]*x+[2]*x*x+[3]*x*x*x", 0.0, 11.);
1177 } else if(ifun==-2) {
1178 fun = "fun2"; optFit="R+";
1179
1180 /*
1181 f = new TF1(fun,"[0]*(x-7.5)+[1]*(x-7.5)*(x-7.5)+[2]", 0.0, 10.1);
1182 f->SetParameter(0, 5.98727e-04);
1183 f->SetParameter(1, 2.12045e-04);
1184 f->SetParameter(2, 1.);
1185 */
1186 f = new TF1(fun,"[0]+[1]*x+[2]*x*x", 9.0, 100.1);
1187 } else if(ifun==-1) {
1188 fun = "fun0"; optFit="R+";
1189 f = new TF1(fun,"[0]", 0.0, 100.1);
1190 } else if(ifun>=2) {
1191 fun = Form("pol%i",ifun);
1192 optFit="+";
1193 }
1194 TGraphErrors *gr = u::DrawGraphErrors(np, erec.GetArray(),invRat.GetArray(),derec.GetArray(),eInvRat.GetArray(),
1195 // markerColor,21+markerColor,"AP", " Ratio E_{#gamma}/E_{Rec} ", "E_{Rec} "," E_{#gamma}/E_{Rec}",
1196 markerColor,21+markerColor,"AP", " Ratio E_{#gamma}/E_{Rec}^{corr} ", "E_{Rec}^{corr} "," E_{#gamma}/E_{Rec}^{corr}",
1197 ifun, optFit, fun);
1198 gr->GetHistogram()->SetAxisRange(0.0,100.);
1199 // double xmi=0.999, xma=1.017;
1200 double xmi=0.995, xma=1.005;
1201 gr->GetHistogram()->SetMaximum(xma);
1202 gr->GetHistogram()->SetMinimum(xmi);
1203 gr->GetHistogram()->SetTitleOffset(1.4,"y");
1204 if(ifun==0) {
b217491f 1205 f = new TF1("fres", "AliEMCALHistoUtilities::EnergyCorrectionForGamma1(x)", 0., 101.);
0fc11500 1206 f->Draw("same");
1207 }
1208 }
1209 TLine *line = new TLine(0.0,1.0, 100.,1.0);
1210 line->Draw();
1211
1212 if(0) {
1213 c->Clear();
1214 for(int i=0; i<9; i++) {
b217491f 1215 residual[i] = 100.*(invRat[i] - u::GetCorrectionCoefficientForGamma1(erec[i])); // in percent
0fc11500 1216 printf(" erec %f : residual %5.3f \n", erec[i], residual[i]);
1217 }
1218 markerColor = 2;
1219 TGraphErrors *gr2=u::DrawGraphErrors(np, erec.GetArray(),residual.GetArray(),derec.GetArray(),eInvRat.GetArray(),
1220 markerColor,21+markerColor,"AP"," residual in %, rec.point level", "E_{Rec} "," residual in %",
1221 -1, "", 0);
1222 gr2->GetHistogram()->SetAxisRange(0.0,100.);
1223 gr2->GetHistogram()->SetMaximum(0.2);
1224 gr2->GetHistogram()->SetMinimum(-0.1);
1225 line = new TLine(0.0,0.0, 101.,0.0);
1226 line->Draw();
1227 TLatex *lat = u::Lat("linearity better 0.2% after correction",20., 0.15, 12, 0.06, 1);
1228 if(lat);
1229 }
1230 if(1) {
1231 TString latexName;
1232 c->Clear();
1233 gStyle->SetOptFit(111);
1234 markerColor = 1;
1235 ifun = -11;
1236 f = u::GetResolutionFunction("FRES2", latexName);
1237 f->SetNpx(10000);
1238 f->SetLineColor(kBlack);
1239
1240 TGraphErrors *gr3=u::DrawGraphErrors(np, p,res.GetArray(), ep, eres.GetArray(),
1241 markerColor,21+markerColor,"AP"," resolution in %, rec.point level","E_{#gamma} "," resolution in %",
1242 ifun, "+", f->GetName());
1243 gr3->GetHistogram()->SetAxisRange(0.0,101.);
1244 gr3->GetHistogram()->SetMaximum(14.);
1245 gr3->GetHistogram()->SetMinimum(0.0);
1246 gr3->SetMarkerSize(1.5);
1247
1248 TLatex *lat = u::Lat(latexName.Data(),82., 11., 12, 0.06, 1);
1249 if(lat);
1250 // Exp. data
1251 TF1 *fexp = new TF1(*f);
1252 fexp->SetName("fexp");
1253 fexp->SetParameter(0, 2.168);
1254 fexp->SetParameter(1, 8.818);
1255 fexp->SetLineWidth(1);
1256 fexp->SetLineColor(kRed);
1257 fexp->SetLineStyle(1);
1258 fexp->Draw("same");
1259
1260 TLegend *leg = new TLegend(0.21,0.36, 0.68,0.82);
1261 leg->AddEntry(gr3, "MC data", "P");
1262 leg->AddEntry(f, "fit of MC data", "L");
1263 TLegendEntry *ent3 = leg->AddEntry(fexp, "#splitline{fit of exp.data}{FNAL, Nov 2005}", "L");
1264 ent3->SetTextColor(fexp->GetLineColor());
1265 leg->Draw();
1266 }
1267 c->Update();
1268
1269 return c;
1270}
1271
1272TCanvas *AliEMCALRecPointsQaESDSelector::DrawKineVsRP(TList *l)
7227086e 1273{
1274 //Jul 25, 2007
0fc11500 1275 if(l==0) {
1276 printf("<W> AliEMCALRecPointsQaESDSelector::DrawKineVsRP : TList is zero ! \n");
1277 return 0;
1278 }
1279 TCanvas *c = new TCanvas("KineVsRP","KineVsRP", 20,20, 700, 500);
1280 gStyle->SetOptStat(1110);
1281 c->Divide(2,2);
1282
1283 c->cd(1);
1284 TH1F* h1 = (TH1F*)l->At(10);
1285 u::DrawHist(h1,2);
1286
1287 c->cd(2);
1288 TH1F* h2 = (TH1F*)l->At(11);
1289 u::DrawHist(h2,2);
1290
1291 c->cd(3);
1292 TH1F* h3 = (TH1F*)l->At(12);
1293 u::DrawHist(h3,2);
1294 u::DrawHist((TH1F*)l->At(14), 1,kRed,"same");
1295 u::DrawHist((TH1F*)l->At(15), 1,kGreen,"same");
1296
1297 c->cd(4);
1298 TH1F* h4 = (TH1F*)l->At(13);
1299 u::DrawHist(h4, 2);
1300 u::DrawHist((TH1F*)l->At(16), 1,kRed,"same");
1301 u::DrawHist((TH1F*)l->At(17), 1,kGreen,"same");
1302
1303 /*
1304 TH1F* h2 = (TH1F*)l->At(11);
1305 u::DrawHist(h2,2);
1306 */
1307
1308 c->Update();
1309 return c;
1310}
1311
1312TCanvas* AliEMCALRecPointsQaESDSelector::DrawMeanVsLog(TH2F *h2)
1313{
1314 // h - input histogramm : mean vds log coordinates
1315 if(h2==0) return 0;
1316
1317 TCanvas *c = new TCanvas("KineVsRP","KineVsRP", 20,20, 700, 500);
1318
1319 TH1F *hid1 = new TH1F("h1","h1 title ", h2->GetNbinsX(),
1320 h2->GetXaxis()->GetXmin(), h2->GetXaxis()->GetXmax());
1321
1322 gROOT->cd();
1323 TH1::AddDirectory(1);
1324 TString newName;
1325 for(int ix=1; ix<=h2->GetNbinsX();ix++) {
1326 newName = "hd_"; newName += ix;
1327 TH1D *hd = h2->ProjectionY(newName.Data(),ix,ix);
1328 if(hd->Integral()>=4.) {
1329 // lhd->Add(hd);
1330 hid1->SetBinContent(ix, hd->GetMean());
1331 hid1->SetBinError(ix, hd->GetRMS());
1332 }
1333 }
1334 TF1 *f1 = new TF1("fcg", "0.5*TMath::SinH(x/[0])/TMath::SinH(0.5/[0])", -0.5, 0.5);
1335 f1->SetParameter(0,0.13);
1336 f1->SetLineColor(kRed);
1337 f1->SetLineWidth(1);
1338
1339 gStyle->SetOptStat(0);
1340 gStyle->SetOptFit(111);
1341 hid1->Fit(f1,"R+");
1342
1343 u::DrawHist(hid1,2);
1344
1345//u::DrawHist(h2,2);
1346
1347 c->Update();
1348 return c;
1349}
1350
1351TCanvas* AliEMCALRecPointsQaESDSelector::DrawPhiEtaAnglesDistribution(const char* gn)
1352{
1353 // Aug 6, 2007
1354 // Proper geometry should be defined already
1355 // dTheta distibution has two peaks which coresponding different cells inside module !
1356
1357 TCanvas *c = new TCanvas("Geometry","Geometry", 20,20, 700, 500);
1358 c->Divide(2,2);
1359
7227086e 1360 if(fgEmcalGeo==0) fgEmcalGeo = AliEMCALGeometry::GetInstance(gn);
0fc11500 1361
1362 gROOT->cd();
1363 TH1::AddDirectory(1);
1364 TH1F *hDtheta = new TH1F("hDtheta","#Delta#theta in one SM", 60, -2.0, +1.0); // in degree
b217491f 1365 TH2F *hDtheta2 = new TH2F("hDtheta2","#Delta#theta vs fIEta of cell", 48, -0.5, 47.5, 60,-2.0,+1.0);
0fc11500 1366
1367 TH1F *hDphi = new TH1F("hDphi","#Delta#ph in one SM", 2000, -10.0, +10.0); // in degree
1368
1369 TVector3 vg3;
1370 AliEMCALCellInfo* t = GetCellsInfo();
1371 Double_t thetaCell=0., thetaModule=0.;
1372 Double_t phiCell=0., dphi=0.;
1373
1374 for(int absid=0; absid<12*24*4; absid++){
b217491f 1375 AliEMCALCellIndexes *r = t->GetTable(absid);
7227086e 1376 fgEmcalGeo->GetGlobal(absid, vg3);
0fc11500 1377
1378 thetaCell = vg3.Theta()*TMath::RadToDeg();
b217491f 1379 thetaModule = 90. - 1.5*r->fIEtam;
0fc11500 1380 hDtheta->Fill(thetaCell - thetaModule);
b217491f 1381 hDtheta2->Fill(double(r->fIEta), thetaCell - thetaModule);
0fc11500 1382
1383 phiCell = vg3.Phi()*TMath::RadToDeg();
1384 dphi = phiCell - 90.;
1385 hDphi->Fill(dphi);
1386 }
1387
1388 c->cd(1);
1389 u::DrawHist(hDtheta,2);
1390 c->cd(2);
1391 u::DrawHist(hDtheta2,2);
1392 c->cd(3);
1393 u::DrawHist(hDphi,2);
1394
1395 c->Update();
1396 return c;
1397}
1398
1399TCanvas* AliEMCALRecPointsQaESDSelector::DrawDeffVsEnergy()
1400{
1401 // Aug 31, 2007 - obsolete
1402 Double_t p[]={0.5, 1.0, 3., 5., 10., 20.,30.,50.,100.};
1403 Double_t ep[]={0., 0., 0., 0., 0., 0., 0., 0., 0.};
1404 // 2 pars
1405 Double_t deff[]={9.07515, 10.0835, 11.2032, 11.4229, 12.3578, 13.0332, 13.3281, 13.7910, 14.3319};
1406 Double_t edeff[]={2.69645e-03, 3.52180e-03, 4.19236e-02, 1.21201e-01, 1.58886e-01, 3.96680e-01, 3.29985e-02, 1.17113e-01, 5.22763e-01};
1407 //
1408 Double_t w0[]={3.44679e+00, 3.82714e+00, 4.15035e+0, 4.36650e+00, 4.51511e+00, 4.65590, 4.63289e+00, 4.66568, 4.68125};
1409 Double_t ew0[]={7.58982e-01, 1.26420e-02, 2.36129e-10, 1.21201e-01, 2.12999e-01, 7.95650e-02, 6.15307e-03, 1.88803e-01, 5.18022e-05};
1410 int np=sizeof(p)/sizeof(Double_t);
1411 printf("<I> AliEMCALRecPointsQaESDSelector::DrawDeffVsEnergy() | np %i \n", np);
1412
1413 TCanvas *c = new TCanvas("Deff","Deff", 20,20, 700, 500);
1414 c->Divide(2,1);
1415
1416 Int_t markerColor=1;
1417 c->cd(1);
1418 TF1 *fdeff= new TF1("fdeff","[0]+[1]*log(x)",0.4, 100.4);
1419 if(fdeff);
1420 TGraphErrors *gr = u::DrawGraphErrors(np, p,deff, ep, edeff,
1421 markerColor,21+markerColor,"AP"," D_{eff} vs E_{#gamma} ","E_{#gamma} "," D_{eff} in cm ",
1422 -1, "", 0);
1423 // -1, "+", fdeff->GetName());
1424 gr->GetHistogram()->SetMaximum(15.);
1425 gPad->SetLogx(1);
1426
1427 c->cd(2);
1428 TGraphErrors *gr2 = u::DrawGraphErrors(np, p,w0, ep, ew0,
1429 markerColor,21+markerColor,"AP"," w_{0} vs E_{#gamma} ","E_{#gamma} "," w_{0} ",
1430 -1, "", 0);
1431
1432 gr2->GetHistogram()->SetMaximum(5.);
1433 gPad->SetLogx(1);
1434
1435 c->Update();
1436 return c;
1437}
1438
1439TCanvas* AliEMCALRecPointsQaESDSelector::DrawDeffVsEnergy2(const char *opt)
1440{
1441 // Aug 28, 2008 - read pars and pars errors from files
1442 Double_t p[]={0.5, 1.0, 3., 5., 10., 20.,30.,50.,100.};
1443 Double_t ep[]={0., 0., 0., 0., 0., 0., 0., 0., 0.};
1444 // 2 pars
1445 Double_t deff[9], edeff[9], w0[9], ew0[9]; // max size now
7227086e 1446 TString sopt(opt);
0fc11500 1447
1448 int np = sizeof(p)/sizeof(Double_t);
1449 printf("<I> AliEMCALRecPointsQaESDSelector::DrawDeffVsEnergy2() | np %i \n", np);
1450 ReadParsDeffAndW0("/data/r22b/ALICE/CALIB/FIT/", deff, edeff, w0, ew0, 1);
1451
1452 TCanvas *c = new TCanvas("Deff","Deff", 20,20, 700, 500);
1453 c->Divide(2,1);
1454
1455 TF1 *fdeff = 0, *fw0 = 0;
1456 TString optFit(""), funName("");
7227086e 1457 if(sopt.Contains("fit1")) {
0fc11500 1458 fdeff= new TF1("fdeff","[0]+[1]*log(x)",0.1, 101.);
1459 fdeff->SetLineColor(kRed);
1460 fdeff->SetLineWidth(1);
1461
1462 /* good description - "[0]/(1.+exp([1]*x))"
1463 1 p0 4.82208e+00 9.93617e-04 -0.00000e+00 7.16648e-06
1464 2 p1 -7.79655e-01 4.07500e-03 -0.00000e+00 2.01009e-03
1465 better description - "[0]/(1.+exp([1]*(x-[2])))" (like the Woods-Saxon potential)
1466 1 p0 4.83713e+00 1.00437e-03 -6.98984e-10 4.90371e-07
1467 2 p1 -2.77970e-01 3.35587e-03 -1.79239e-09 2.67312e-07
1468 3 p2 4.41116e+00 8.72191e-02 1.82791e-04 1.55643e-05
1469 */
1470 fw0= new TF1("fw0","[0]/(1.+exp([1]*(x+[2])))",0.1, 101.);
1471 fw0->SetLineColor(kRed);
1472 fw0->SetLineWidth(1);
1473 fw0->SetParameter(0, 4.8);
1474 fw0->SetParameter(1, -2.77970e-01);
1475 fw0->SetParameter(2, 4.41116);
1476 optFit = "+";
1477 }
1478 if(fdeff) funName = fdeff->GetName();
1479
1480 Int_t markerColor=1;
1481 c->cd(1);
1482 gStyle->SetOptFit(111);
1483 TGraphErrors *gr = u::DrawGraphErrors(np, p,deff, ep, edeff,
1484 markerColor,21+markerColor,"AP"," D_{eff} vs E_{#gamma} ","E_{#gamma} "," D_{eff} in cm ",
1485 -1, optFit.Data(), funName.Data());
1486 gr->GetHistogram()->SetMaximum(15.);
1487 gPad->SetLogx(1);
1488 TLegend *leg1 = new TLegend(0.12,0.76, 0.70,0.90);
1489 TLegendEntry *le1 = leg1->AddEntry(fdeff, Form("%s",fdeff->GetTitle()), "lp");
1490 //TLegendEntry *le1 = leg1->AddEntry(fdeff, Form("%4.2f+%4.2f*log(E_{#gamma})",
1491 //fdeff->GetParameter(0),fdeff->GetParameter(1)), "lp");
1492 le1->SetTextColor(fdeff->GetLineColor());
1493 leg1->Draw();
1494
1495 c->cd(2);
1496 gStyle->SetOptFit(111);
1497 if(fw0) funName = fw0->GetName();
1498 TGraphErrors *gr2 = u::DrawGraphErrors(np, p,w0, ep, ew0,
1499 markerColor,21+markerColor,"AP"," w_{0} vs E_{#gamma} ","E_{#gamma} "," w_{0} ",
1500 -1, optFit.Data(), funName.Data());
1501
1502 gr2->GetHistogram()->SetMaximum(5.);
1503
1504 TLegend *leg2 = new TLegend(0.17,0.6, 0.99,0.72);
1505 TLegendEntry *le2 = leg2->AddEntry(fw0, Form("%s",fw0->GetTitle()), "lp");
1506 //TLegendEntry *le2 = leg2->AddEntry(fw0, Form("#frac{%4.2f}{1.+exp(%4.2f*(x+%4.2f)}",
1507 //fw0->GetParameter(0),fw0->GetParameter(1),fw0->GetParameter(2)), "lp");
1508 le2->SetTextColor(fw0->GetLineColor());
1509 leg2->Draw();
1510 //gPad->SetLogx(1);
1511
1512 c->Update();
1513 return c;
1514}
1515
1516void AliEMCALRecPointsQaESDSelector::ReadParsDeffAndW0
1517(const char *dirName, double *deff, double *edeff, double *w0, double *ew0, const Int_t pri)
1518{
7227086e 1519 // read pars and W0
0fc11500 1520 int strategy = 0, itmp=0;
1521 char line[100];
1522 for(int var=11; var<=19; var++){
1523 int ind = var -11;
1524 ifstream fin;
1525 TString fname = Form("%s/fitVar%iStrategy%i.txt", dirName, var, strategy);
1526 //printf(" open file %s \n", fname.Data());
1527 fin.open(fname.Data());
1528
1529 for(int i=1; i<=2; i++) { // skip to lines
1530 fin.getline(line,100).eof();
1531 if(pri>=2) printf("%s \n", line);
1532 }
1533
1534 fin >> itmp >> deff[ind] >> edeff[ind];
1535 fin >> itmp >> w0[ind] >> ew0[ind];
1536 if(pri>=1)
1537 printf(" %i def %f+/-%f : def %f+/-%f\n", ind, deff[ind],edeff[ind],w0[ind],ew0[ind]);
1538 fin.getline(line,100).eof(); // skip last line
1539 fin.close();
1540 }
1541}
1542
1543TCanvas* AliEMCALRecPointsQaESDSelector::DrawSpaceResolution()
1544{
1545 // Sep 4, 2007;
1546 // Space resolution vs optimised space resolution
1547 Double_t p[]={0.5, 1.0, 3., 5., 10., 20.,30.,50.,100.};
1548 Double_t ep[]={0., 0., 0., 0., 0., 0., 0., 0., 0.};
1549 Double_t spAng[]={0.1877, 0.1351, 0.08144, 0.06331, 0.05384, 0.04876, 0.04706, 0.04656, 0.04726};
1550 Double_t rmsSpAng[]={0.1033, 0.07685, 0.05235, 0.03992, 0.04012, 0.04257, 0.03472, 0.02814, 0.02784};
1551 Double_t spAngOpt[]={0.1733, 0.1311, 0.07961, 0.06401, 0.05347, 0.04618, 0.04288, 0.04, 0.03802};
1552 Double_t rmsSpAngOpt[]={0.09476, 0.07472, 0.05011, 0.04242, 0.04075, 0.04304, 0.03545, 0.02744, 0.02593};
1553
1554 int np=sizeof(p)/sizeof(Double_t);
1555 printf("<I> AliEMCALRecPointsQaESDSelector::DrawSpaceResolution() | np %i \n", np);
1556
1557 Double_t* eSpAng = new Double_t[np];
1558 Double_t* eSpAngOpt = new Double_t[np];
7227086e 1559 Double_t cc=TMath::Sqrt(8000.), cc2 = 1000.*TMath::DegToRad();
0fc11500 1560 for(int i=0; i<np; i++){
7227086e 1561 spAng[i] *= cc2;
1562 rmsSpAng[i] *= cc2;
1563 spAngOpt[i] *= cc2;
1564 rmsSpAngOpt[i] *= cc2;
0fc11500 1565
7227086e 1566 eSpAng[i] = spAng[i]/cc;
1567 eSpAngOpt[i] = spAngOpt[i]/cc;
0fc11500 1568 }
1569
1570 TCanvas *c = new TCanvas("Deff","Deff", 20,20, 700, 500);
1571 //c->Divide(2,1);
1572
1573 c->cd(1);
1574 gStyle->SetOptFit(111);
1575
1576 TGraphErrors *gr = u::DrawGraphErrors(np, p,spAng, ep, eSpAng,
1577 kBlack, 21,"AP","Angle resolution (mrad) vs E_{#gamma} ","E_{#gamma} "," anlgle resolution (mrad) ",
1578 -1, "", 0);
1579 gr->GetHistogram()->SetMaximum(4.);
1580 gr->GetHistogram()->SetMinimum(0.6);
1581 gPad->SetLogx(1);
1582 gPad->SetLogy(1);
1583
1584 TF1 *fang = new TF1("fang","[0]+[1]/sqrt(x)",0.1, 101.);
1585 fang->SetLineColor(kRed);
1586 fang->SetLineWidth(1);
1587
1588 TGraphErrors *gr2 = u::DrawGraphErrors(np, p,spAngOpt, ep, eSpAngOpt,
1589 kRed,22,"P"," space vs E_{#gamma} ","E_{#gamma} "," anlgle resolution (mrad) ",
1590 -1, "+", fang->GetName());
1591 TLegend *leg1 = new TLegend(0.40,0.57, 0.92,0.87);
1592 TLegendEntry *le1 = leg1->AddEntry(gr, "Initial angle resolution", "p");
1593 le1->SetTextColor(gr->GetLineColor());
1594
1595 TLegendEntry *le2 = leg1->AddEntry(gr2, "Optimized angle resolution", "p");
1596 le2->SetTextColor(gr2->GetLineColor());
1597
1598 TLegendEntry *le3 = leg1->AddEntry(fang,
1599 Form("%3.2f+#frac{%4.2f}{#sqrt{E}}",fang->GetParameter(0),fang->GetParameter(1)), "lp");
1600 le3->SetTextColor(fang->GetLineColor());
1601
1602 leg1->Draw();
1603
1604 c->Update();
1605
1606 return c;
1607}
1608
1609void AliEMCALRecPointsQaESDSelector::ResetAllListOfHists()
1610{
7227086e 1611 // Reset all list of hits
0fc11500 1612 u::ResetListOfHists(fLofHistsPC);
1613 u::ResetListOfHists(fLofHistsRP);
1614 u::ResetListOfHists(fLKineVsRP);
1615 u::ResetListOfHists(fLShowerProfile);
1616}
1617
1618void AliEMCALRecPointsQaESDSelector::ReloadChain(Long64_t entry)
7227086e 1619{
1620 // Oct 14, 2007 - unused now
0fc11500 1621 if(fChain) {
1622 fChain->LoadTree(entry);
1623 }
1624}
1625
1626void AliEMCALRecPointsQaESDSelector::GetInitialParsForFit(const Int_t var, Double_t &deff, Double_t &w0, Double_t &phislope, const int phiCase)
1627{
1628 // int phiCase=0; // 0 or 1
1629 phislope = 0.001;
1630 if(var==11) { // stay here
1631 deff = 9.07515;
1632 w0 = 3.44679;
1633 } else if(var==12) {
1634 deff = 1.00835e+01;
1635 w0 = 3.82714e+00;
1636 } else if(var==13) {
1637 deff = 1.12032e+01;
1638 w0 = 4.15035e+00;
1639 } else if(var==14) {
1640 deff = 1.14229e+01;
1641 w0 = 4.36650;
1642 } else if(var==15) {
1643 deff = 1.21361e+01;
1644 w0 = 4.72875;
1645 } else if(var==16) {
1646 deff = 1.28096e+01;
1647 w0 = 4.81753e+00;
1648 } else if(var==17) {
1649 deff = 1.33281e+01;
1650 w0 = 4.63289e+00;
1651 } else if(var==18) {
1652 deff = 1.37910e+01;
1653 w0 = 4.66568;
1654 } else if(var==19) {// Aug 15, 2007
1655 switch (phiCase) {
1656 case 0: // phislope was defined than deff and w0 were fixed
1657 deff = 1.43319e+01;
1658 w0 = 4.69279;
1659 phislope = 2.41419e-04;
1660 break;
1661 case 1: // all parameters free
1662 deff = 1.46327e+01;
1663 w0 = 4.68125;
1664 phislope = 8.95559e-04;
1665 break;
1666 }
1667 } else {
1668 printf("<E> var % i -> no definition ! \n", var);
1669 assert(0);
1670 }
1671 printf("<I> AliEMCALRecPointsQaESDSelector::GetInitialParForFit()\n deff %f w0 %f phislope %f \n",
1672 deff,w0, phislope);
1673}