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