- new class AliHMPIDCalib added for pedestal calculation
[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//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
26AliHMPIDCalib::AliHMPIDCalib():
27 fPedTree(0x0),
28 fa(-1),
29 fd(-1),
30 fr(-1),
31 fq(-1),
32 fPedHisto(0)
33{
34 Init();
35}
36//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
37AliHMPIDCalib::~AliHMPIDCalib()
38{
39 //destructor
40}
41//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
42void AliHMPIDCalib::Init()
43{
44 for(Int_t iddl=0;iddl<11;iddl++) faddl[iddl]=kFALSE;
45 //
46 // Called to initialize the TTree in which the raw data words will be stored
47 //
48 fPedHisto=new TH1F("fPedHisto","Temporary pedestal",4096,-0.5,4095.5); //init pedestal histo
49 fPedTree = new TTree("PedTree","HMPID Pedestal Tree"); //init pedestal tree
50 fPedTree->Branch("diladd",&fa,"diladd/I");
51 fPedTree->Branch("dilnum",&fd,"dilnum/I");
52 fPedTree->Branch("dilrow",&fr,"dilrow/I");
53 fPedTree->Branch("qdc" ,&fq,"qdc/F ");
54}
55//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
56void AliHMPIDCalib::FillPedestal(Int_t ddl,Int_t row, Int_t dil,Int_t adr,Int_t q)
57{
58 //
59 //Called from the HMPIDda and fills the pedestal tree
60 //
61 fq=q;
62 fr=row;
63 fd=dil;
64 fa=adr;
65 faddl[ddl]=kTRUE;
66 if(fq>-1) fPedTree->Fill();
67}//FillPedestal()
68//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
69Bool_t AliHMPIDCalib::CalcPedestal(Int_t ddl, Char_t* name)
70{
71 //
72 //Calculate pedestal for each pad
73 //
74
75 ofstream out; //to write the pedestal text files
76 Double_t mean,sigma;
77 Int_t inhard;
78 if(faddl[ddl]==kFALSE) return kFALSE; //if ddl is missing no ped file is created (and also for LDC selection). Check with Paolo what he checks for?!
79 out.open(name);
80 for(Int_t row=1; row < 25; row++){
81 for(Int_t dil=1; dil < 11; dil++){
82 for(Int_t adr=0; adr < 48; adr++){
83 fPedHisto->Reset();
84 fPedTree->Draw("fq>>fPedHisto",Form("fr==%d&&fd==%d&&fa==%d",row,dil,adr));
85 mean=fPedHisto->GetMean();
86 sigma=fPedHisto->GetRMS();
87 inhard=((Int_t(mean))<<9)+Int_t(mean+3*sigma);
88 out << Form("%2i %2i %2i %5.2f %5.2f %x\n",row,dil,adr,mean,sigma,inhard);
89 }//adr
90 }//dil
91 }//row
92 out.close(); //write pedestal file
93 return kTRUE;
94}//CaclPedestal()
95//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++