]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HMPID/AliHMPIDCalib.cxx
Marker correction
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDCalib.cxx
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
22 ClassImp(AliHMPIDCalib) 
23
24
25 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
26 AliHMPIDCalib::AliHMPIDCalib()
27 {
28   //
29   //constructor
30   //
31   Init();
32 }
33 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
34 AliHMPIDCalib::~AliHMPIDCalib()
35 {
36   //
37   //destructor
38   //
39 }//ctor
40 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
41 void AliHMPIDCalib::Init()
42 {
43   //
44   //Init the q calc.
45   //
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()
59 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
60 void AliHMPIDCalib::FillPedestal(Int_t nDDL,Int_t row, Int_t dil,Int_t adr,Int_t q)
61 {
62   //
63   //Called from the HMPIDda and fills the pedestal tree 
64   //
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
71 }//FillPedestal()
72 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
73 Bool_t AliHMPIDCalib::CalcPedestal(Int_t nDDL, Char_t* name, Int_t nEv)    
74 {
75   //
76   //Calculate pedestal for each pad  
77   //
78   Float_t mean=0,sigma=0;
79   Float_t qs2m=0,qsm2=0;
80   ofstream out;                                           //to write the pedestal text files
81   Int_t inhard;
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);
96         }//adr
97       }//dil
98     }//row
99     out.close();                                          //write pedestal file
100   return kTRUE;
101 }//CaclPedestal()
102 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++