New version of the HMPID DA without the usage of trees (Levente)
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDCalib.cxx
CommitLineData
21f61e25 1// **************************************************************************
2// * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3// * *
4// * Author: The ALICE Off-line Project. *
5// * Contributors are mentioned in the code where appropriate. *
6// * *
7// * Permission to use, copy, modify and distribute this software and its *
8// * documentation strictly for non-commercial purposes is hereby granted *
9// * without fee, provided that the above copyright notice appears in all *
10// * copies and that both the copyright notice and this permission notice *
11// * appear in the supporting documentation. The authors make no claims *
12// * about the suitability of this software for any purpose. It is *
13// * provided "as is" without express or implied warranty. *
14// **************************************************************************
15
16#include "AliHMPIDCalib.h" //class header
17#include "TTreePlayer.h"
18#include <fstream>
19#include <TTree.h>
20//#include "AliHMPIDDigit.h"
21
22ClassImp(AliHMPIDCalib)
23
24
25//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3e60bb92 26AliHMPIDCalib::AliHMPIDCalib()
21f61e25 27{
3e60bb92 28 //
29 //constructor
30 //
21f61e25 31 Init();
32}
33//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
34AliHMPIDCalib::~AliHMPIDCalib()
35{
3e60bb92 36 //
21f61e25 37 //destructor
3e60bb92 38 //
39}//ctor
21f61e25 40//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
41void AliHMPIDCalib::Init()
42{
21f61e25 43 //
3e60bb92 44 //Init the q calc.
21f61e25 45 //
3e60bb92 46 for(Int_t iDDL=0; iDDL< AliHMPIDCalib::kNDDL; iDDL++)
47 {
48 faddl[iDDL]=kFALSE;
49 for(Int_t row = 1; row <=AliHMPIDCalib::kNRows; row++){
50 for(Int_t dil = 1; dil <=AliHMPIDCalib::kNDILOGICAdd; dil++){
51 for(Int_t pad = 0; pad < AliHMPIDCalib::kNPadAdd; pad++){
52 fsq[iDDL][row][dil][pad]=0;
53 fsq2[iDDL][row][dil][pad]=0;
54 }
55 }
56 }
57 }
58}//Init()
21f61e25 59//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3e60bb92 60void AliHMPIDCalib::FillPedestal(Int_t nDDL,Int_t row, Int_t dil,Int_t adr,Int_t q)
21f61e25 61{
62 //
63 //Called from the HMPIDda and fills the pedestal tree
64 //
3e60bb92 65 if(q>0) {
66 fsq[nDDL][row][dil][adr]+=q;
67 fsq2[nDDL][row][dil][adr]+=(q*q);
68 faddl[nDDL]=kTRUE;
69 }
70
21f61e25 71}//FillPedestal()
72//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3e60bb92 73Bool_t AliHMPIDCalib::CalcPedestal(Int_t nDDL, Char_t* name, Int_t nEv)
21f61e25 74{
75 //
76 //Calculate pedestal for each pad
77 //
3e60bb92 78 Float_t mean=0,sigma=0;
79 Float_t qs2m=0,qsm2=0;
21f61e25 80 ofstream out; //to write the pedestal text files
21f61e25 81 Int_t inhard;
3e60bb92 82 if(faddl[nDDL]==kFALSE) return kFALSE; //if ddl is missing no ped file is created (and also for LDC selection). Check with Paolo what he checks for?!
83 out.open(name);
84 for(Int_t row = 1; row <= AliHMPIDCalib::kNRows; row++){
85 for(Int_t dil = 1; dil <= AliHMPIDCalib::kNDILOGICAdd; dil++){
86 for(Int_t pad = 0; pad < AliHMPIDCalib::kNPadAdd; pad++){
87
88 mean = fsq[nDDL][row][dil][pad]/1.0/nEv;
89
90 qs2m = fsq2[nDDL][row][dil][pad]/1.0/nEv;
91 qsm2 = TMath::Power(fsq[nDDL][row][dil][pad]/1.0/nEv,2);
92 sigma= TMath::Sqrt(qs2m-qsm2);
93
94 inhard=((Int_t(mean))<<9)+Int_t(mean+3*sigma);
95 out << Form("%2i %2i %2i %5.2f %5.2f %x\n",row,dil,pad,mean,sigma,inhard);
21f61e25 96 }//adr
97 }//dil
98 }//row
99 out.close(); //write pedestal file
100 return kTRUE;
101}//CaclPedestal()
102//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++