]>
Commit | Line | Data |
---|---|---|
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 | |
21f61e25 | 17 | #include <fstream> |
18 | #include <TTree.h> | |
0f1281b2 | 19 | |
20 | ||
21f61e25 | 21 | |
22 | ClassImp(AliHMPIDCalib) | |
23 | ||
24 | ||
25 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
3e60bb92 | 26 | AliHMPIDCalib::AliHMPIDCalib() |
21f61e25 | 27 | { |
3e60bb92 | 28 | // |
29 | //constructor | |
30 | // | |
21f61e25 | 31 | Init(); |
32 | } | |
33 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
34 | AliHMPIDCalib::~AliHMPIDCalib() | |
35 | { | |
3e60bb92 | 36 | // |
21f61e25 | 37 | //destructor |
3e60bb92 | 38 | // |
39 | }//ctor | |
21f61e25 | 40 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
41 | void AliHMPIDCalib::Init() | |
42 | { | |
21f61e25 | 43 | // |
3e60bb92 | 44 | //Init the q calc. |
21f61e25 | 45 | // |
0f1281b2 | 46 | |
3e60bb92 | 47 | for(Int_t iDDL=0; iDDL< AliHMPIDCalib::kNDDL; iDDL++) |
48 | { | |
49 | faddl[iDDL]=kFALSE; | |
0f1281b2 | 50 | |
51 | for(Int_t ierr=0; ierr < AliHMPIDRawStream::kSumErr; ierr++) fNumOfErr[iDDL][ierr]=0; //reset errors for all DDLs | |
52 | ||
53 | for(Int_t row = 1; row <=AliHMPIDCalib::kNRows; row++){ | |
3e60bb92 | 54 | for(Int_t dil = 1; dil <=AliHMPIDCalib::kNDILOGICAdd; dil++){ |
55 | for(Int_t pad = 0; pad < AliHMPIDCalib::kNPadAdd; pad++){ | |
56 | fsq[iDDL][row][dil][pad]=0; | |
0f1281b2 | 57 | fsq2[iDDL][row][dil][pad]=0; |
58 | } | |
3e60bb92 | 59 | } |
60 | } | |
61 | } | |
62 | }//Init() | |
21f61e25 | 63 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
0f1281b2 | 64 | //void AliHMPIDCalib::FillPedestal(Int_t nDDL,Int_t row, Int_t dil,Int_t adr,Int_t q) |
65 | void AliHMPIDCalib::FillPedestal(Int_t pad,Int_t q) | |
21f61e25 | 66 | { |
67 | // | |
68 | //Called from the HMPIDda and fills the pedestal tree | |
69 | // | |
0f1281b2 | 70 | Int_t nDDL=0, row=0, dil=0, adr=0; |
71 | //The decoding (abs. pad -> ddl,dil,...) is the same as in AliHMPIDDigit::Raw | |
72 | Int_t y2a[6]={5,3,1,0,2,4}; | |
73 | ||
74 | nDDL= 2*AliHMPIDParam::A2C(pad)+AliHMPIDParam::A2P(pad)%2; //DDL# 0..13 | |
75 | Int_t tmp= 1+AliHMPIDParam::A2P(pad)/2*8+AliHMPIDParam::A2Y(pad)/6; //temp variable | |
76 | row= (AliHMPIDParam::A2P(pad)%2)? 25-tmp:tmp; //row r=1..24 | |
77 | dil= 1+AliHMPIDParam::A2X(pad)/8; //DILOGIC | |
78 | adr=y2a[AliHMPIDParam::A2Y(pad)%6]+6*(AliHMPIDParam::A2X(pad)%8); //ADDRESS 0..47 | |
79 | ||
80 | // Printf("AbsPadNum: %d nDDL: %d tmp %d row: %d dil: %d adr: %d",pad,nDDL,tmp,row,dil,adr); | |
81 | //........... decoding done | |
82 | ||
3e60bb92 | 83 | if(q>0) { |
84 | fsq[nDDL][row][dil][adr]+=q; | |
85 | fsq2[nDDL][row][dil][adr]+=(q*q); | |
86 | faddl[nDDL]=kTRUE; | |
87 | } | |
88 | ||
0f1281b2 | 89 | |
90 | ||
91 | ||
21f61e25 | 92 | }//FillPedestal() |
93 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
0f1281b2 | 94 | void AliHMPIDCalib::FillErrors(Int_t nDDL,Int_t nErrType, Int_t nErr) |
95 | { | |
96 | // | |
97 | //Fill decoding errors | |
98 | // | |
99 | // fhDdlDecodErrors[nDDL]->Fill(nErrType,nErr); //select DDL, select bin and add the occurence | |
100 | fNumOfErr[nDDL][nErrType]+=nErr; | |
101 | ||
102 | }//FillErrors() | |
103 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
104 | Bool_t AliHMPIDCalib::WriteErrors(ULong_t runNum, Int_t nDDL, Char_t* name, Int_t /*nEv*/) | |
105 | { | |
106 | // | |
107 | //Write decoding errors to a txt file | |
108 | // | |
109 | ||
110 | if(faddl[nDDL]==kFALSE) return kFALSE; //if ddl is missing no error file is created | |
111 | ofstream outerr; | |
112 | outerr.open(name); //open error file | |
113 | ||
114 | outerr << Form("%d \n",(Int_t)runNum); | |
115 | for(Int_t ierr=1; ierr < AliHMPIDRawStream::kSumErr; ierr++) outerr << Form("%2d\t",fNumOfErr[nDDL][ierr]); | |
116 | outerr << Form("\n"); | |
117 | outerr.close(); //write error file | |
118 | return kTRUE; | |
119 | ||
120 | }//FillErrors() | |
121 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
122 | Bool_t AliHMPIDCalib::CalcPedestal(ULong_t runNum, Int_t nDDL, Char_t* name, Int_t nEv) | |
21f61e25 | 123 | { |
124 | // | |
125 | //Calculate pedestal for each pad | |
126 | // | |
0f1281b2 | 127 | |
128 | 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?! | |
3e60bb92 | 129 | Float_t mean=0,sigma=0; |
130 | Float_t qs2m=0,qsm2=0; | |
21f61e25 | 131 | ofstream out; //to write the pedestal text files |
21f61e25 | 132 | Int_t inhard; |
0f1281b2 | 133 | //Printf("From AliHMPIDCalib::CalcPedestal: faddl[%i]= %i",nDDL,faddl[nDDL]); |
134 | ||
3e60bb92 | 135 | out.open(name); |
0f1281b2 | 136 | out << Form("%d \n",(Int_t)runNum); |
3e60bb92 | 137 | for(Int_t row = 1; row <= AliHMPIDCalib::kNRows; row++){ |
138 | for(Int_t dil = 1; dil <= AliHMPIDCalib::kNDILOGICAdd; dil++){ | |
139 | for(Int_t pad = 0; pad < AliHMPIDCalib::kNPadAdd; pad++){ | |
140 | ||
141 | mean = fsq[nDDL][row][dil][pad]/1.0/nEv; | |
142 | ||
143 | qs2m = fsq2[nDDL][row][dil][pad]/1.0/nEv; | |
144 | qsm2 = TMath::Power(fsq[nDDL][row][dil][pad]/1.0/nEv,2); | |
145 | sigma= TMath::Sqrt(qs2m-qsm2); | |
146 | ||
147 | inhard=((Int_t(mean))<<9)+Int_t(mean+3*sigma); | |
148 | out << Form("%2i %2i %2i %5.2f %5.2f %x\n",row,dil,pad,mean,sigma,inhard); | |
21f61e25 | 149 | }//adr |
150 | }//dil | |
151 | }//row | |
152 | out.close(); //write pedestal file | |
153 | return kTRUE; | |
154 | }//CaclPedestal() | |
155 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |