1 #include "AliPHOSDA2.h"
6 //----------------------------------------------------------------
7 AliPHOSDA2::AliPHOSDA2(int module) : TNamed(),
8 fHistoFile(0),fFiredCells(0),fMod(module)
11 // Create AliPHOSDA2 ("Bad channels finder") object.
12 // module is the PHOS module number (0..4).
13 // Quality histogram names: module_iX_iZ_gain.
14 // Root file name: PHOS_ModuleX_BCM.root, where X - module number.
17 TString sname="PHOS_Module%d_BCM";
18 snprintf(name,sname.Length(),sname.Data(),fMod);
21 SetTitle("Detector Algorithm to check for PHOS channels quality");
24 TString srootname="%s.root";
25 snprintf(rootname,srootname.Length(),srootname.Data(),GetName());
27 fHistoFile = new TFile(rootname,"recreate"); // new file!
29 for(Int_t iX=0; iX<64; iX++) {
30 for(Int_t iZ=0; iZ<56; iZ++) {
31 for(Int_t iGain=0; iGain<2; iGain++) {
32 fHQuality[iX][iZ][iGain] = 0;
40 fFiredCells = new TH1I("fFiredCells","Number of fired cells per event",100,0,1000);
44 //----------------------------------------------------------------
45 AliPHOSDA2::AliPHOSDA2(Int_t module, TObjArray* oldHistos) : TNamed(),
46 fHistoFile(0),fFiredCells(0),fMod(module)
49 // Create AliPHOSDA2 ("Bad channels finder") object.
50 // module is the PHOS module number (0..4).
51 // Quality histogram names: module_iX_iZ_gain.
52 // Read histograms from array oldHistos (if any).
53 // Do not produce an output file!
56 TString sname="PHOS_Module%d_BCM";
57 snprintf(name,sname.Length(),sname.Data(),fMod);
60 SetTitle("Detector Algorithm to check for PHOS channels quality");
64 TString shname = "%d_%d_%d_%d";
66 for(Int_t iX=0; iX<64; iX++) {
67 for(Int_t iZ=0; iZ<56; iZ++) {
68 for(Int_t iGain=0; iGain<2; iGain++) {
69 snprintf(hname,shname.Length(),shname.Data(),fMod,iX,iZ,iGain);
71 hist1 = (TH1F*)oldHistos->FindObject(hname);
72 if(hist1) fHQuality[iX][iZ][iGain] = hist1;
74 fHQuality[iX][iZ][iGain] = 0;
82 fFiredCells = new TH1I("fFiredCells","Number of fired cells per event",100,0,1000);
86 //-------------------------------------------------------------------
87 AliPHOSDA2::AliPHOSDA2(const AliPHOSDA2& da) : TNamed(da),
88 fHistoFile(0),fFiredCells(0),fMod(da.fMod)
94 TString shname = "%d_%d_%d_%d";
96 for(Int_t iX=0; iX<64; iX++) {
97 for(Int_t iZ=0; iZ<56; iZ++) {
98 for(Int_t iGain=0; iGain<2; iGain++) {
100 snprintf(hname,shname.Length(),shname.Data(),fMod,iX,iZ,iGain);
101 hist1 = (TH1F*)da.fHistoFile->Get(hname);
102 if(hist1) fHQuality[iX][iZ][iGain] = new TH1F(*hist1);
104 fHQuality[iX][iZ][iGain] = 0;
110 fMaps[0] = new TH2F(*da.fMaps[0]);
115 fMaps[1] = new TH2F(*da.fMaps[1]);
119 fHistoFile = new TFile(da.GetName(),"recreate");
120 fFiredCells = new TH1I(*da.fFiredCells);
124 //-------------------------------------------------------------------
125 AliPHOSDA2& AliPHOSDA2::operator= (const AliPHOSDA2& da)
127 //Assignment operator.
131 TString oldname(fHistoFile->GetName());
132 TString newname(da.fHistoFile->GetName());
134 if(oldname != newname) {
136 fHistoFile = new TFile(da.fHistoFile->GetName(),"update");
141 SetName(da.GetName());
142 SetTitle(da.GetTitle());
144 for(Int_t iX=0; iX<64; iX++) {
145 for(Int_t iZ=0; iZ<56; iZ++) {
146 for(Int_t iGain=0; iGain<2; iGain++) {
147 if (fHQuality[iX][iZ][iGain]) delete fHQuality[iX][iZ][iGain];
148 fHQuality[iX][iZ][iGain] = da.fHQuality[iX][iZ][iGain];
155 fMaps[0] = da.fMaps[0];
160 fMaps[1] = da.fMaps[1];
165 fFiredCells = da.fFiredCells;
174 //-------------------------------------------------------------------
175 AliPHOSDA2::~AliPHOSDA2()
180 if(fHistoFile) delete fHistoFile;
184 //-------------------------------------------------------------------
185 void AliPHOSDA2::FillQualityHistograms(Float_t quality[64][56][2])
187 // Fills quality histograms.
188 // _By definition_, qood quality is 0<quality<1,
189 // all outside that is a bad quality.
190 // If no quality value read for particular channel,
191 // the correspondent array entry should be filled by zero.
192 // WARNING: this function should be called once per event!
197 for(Int_t iX=0; iX<64; iX++) {
198 for (Int_t iZ=0; iZ<56; iZ++) {
200 for(Int_t iGain=0; iGain<2; iGain++) {
201 if(!quality[iX][iZ][iGain]) continue;
203 if(fHQuality[iX][iZ][iGain])
204 fHQuality[iX][iZ][iGain]->Fill(quality[iX][iZ][iGain]);
206 sprintf(hname,"%d_%d_%d_%d",fMod,iX,iZ,iGain);
207 sprintf(htitl,"Quality for crystal %d_%d_%d and gain %d",fMod,iX,iZ,iGain);
208 fHQuality[iX][iZ][iGain] = new TH1F(hname,htitl,100,1.e-6,10.);
209 fHQuality[iX][iZ][iGain]->Fill(quality[iX][iZ][iGain]);
218 //-------------------------------------------------------------------
219 void AliPHOSDA2::FillFiredCellsHistogram(Int_t nCells)
221 fFiredCells->Fill(nCells);
224 //-------------------------------------------------------------------
225 void AliPHOSDA2::UpdateHistoFile()
227 // Write histograms to file
229 if(!fHistoFile) return;
230 if(!fHistoFile->IsOpen()) return;
237 sprintf(titl,"Quality map for Low gain");
238 fMaps[0] = new TH2F("gmaplow", titl, 64,0.,64.,56,0.,56.);
244 sprintf(titl,"Quality map for High gain");
245 fMaps[1] = new TH2F("gmaphigh", titl, 64,0.,64.,56,0.,56.);
250 for(Int_t iX=0; iX<64; iX++) {
251 for(Int_t iZ=0; iZ<56; iZ++) {
253 for(Int_t iGain=0; iGain<2; iGain++) {
254 hist1 = fHQuality[iX][iZ][iGain];
256 hist1->Write(hist1->GetName(),TObject::kWriteDelete);
257 Double_t mean = hist1->GetMean();
258 fMaps[iGain]->SetBinContent(iX+1,iZ+1,mean);
265 fMaps[0]->Write(fMaps[0]->GetName(),TObject::kWriteDelete);
266 fMaps[1]->Write(fMaps[1]->GetName(),TObject::kWriteDelete);
268 fFiredCells->Write();