X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=PHOS%2FAliPHOSCalibHistoProducer.cxx;h=204f6b70a1db60074557be24bafa9763dae21484;hb=09b20ad1c29952cef09057dbfdfdb134149c5127;hp=0b8e6b0b3216526fb3b140fead4edd99c3a8f2ef;hpb=4fc0021f68e147210a5338ca6ae7a43c028ccc7b;p=u%2Fmrichter%2FAliRoot.git diff --git a/PHOS/AliPHOSCalibHistoProducer.cxx b/PHOS/AliPHOSCalibHistoProducer.cxx index 0b8e6b0b321..204f6b70a1d 100644 --- a/PHOS/AliPHOSCalibHistoProducer.cxx +++ b/PHOS/AliPHOSCalibHistoProducer.cxx @@ -28,26 +28,24 @@ #include "AliLog.h" #include "AliPHOSCalibHistoProducer.h" #include "TH1.h" +#include "TH2F.h" #include "TFile.h" -#include "AliRawReader.h" -#include "AliPHOSDigit.h" #include "AliPHOSRawDecoder.h" -#include "AliPHOSRawDigiProducer.h" -#include "AliPHOSGeometry.h" -#include "TClonesArray.h" +#include "AliRawReader.h" ClassImp(AliPHOSCalibHistoProducer) //----------------------------------------------------------------------------- -AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer(AliRawReader* rawReader) : - fRawReader(rawReader),fHistoFile(0),fUpdatingRate(100),fIsOldRCUFormat(kFALSE) +AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer() : + fRawDecoder(0),fHistoFile(0),fUpdatingRate(100),fIsOldRCUFormat(kFALSE), + fEvents(0),fNbins(100),fXlow(0.),fXup(1000.) { - // Constructor: initializes input data stream supplied by rawReader + // Constructor: initializes data members // Checks existence of histograms which might have been left // from the previous runs to continues their filling fHistoFile = new TFile("calibHisto.root","update"); - + for(Int_t module=0; module<5; module++) { for(Int_t column=0; column<56; column++) { for(Int_t row=0; row<64; row++) { @@ -56,86 +54,155 @@ AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer(AliRawReader* rawReader) : TH1F* hist = (TH1F*)fHistoFile->Get(hname); if(hist) fAmpHisto[module][column][row]=hist; - else - fAmpHisto[module][column][row]=0; + else + fAmpHisto[module][column][row] = 0; } } } } -//----------------------------------------------------------------------------- -AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer() : - fRawReader(0),fHistoFile(0),fUpdatingRate(0),fIsOldRCUFormat(kFALSE) +//----------------------------------------------------------------------------- +AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer(Int_t nbinsx, Double_t xlow, Double_t xup) : + fRawDecoder(0),fHistoFile(0),fUpdatingRate(100),fIsOldRCUFormat(kFALSE), + fEvents(0),fNbins(nbinsx),fXlow(xlow),fXup(xup) { - // Default constructor + // Constructor: initializes data members. + // Checks existence of histograms which might have been left + // from the previous runs to continues their filling. + // In addition sets number of bins, low and upper limits common for all histograms. + + fHistoFile = new TFile("calibHisto.root","update"); + + for(Int_t module=0; module<5; module++) { + for(Int_t column=0; column<56; column++) { + for(Int_t row=0; row<64; row++) { + char hname[128]; + sprintf(hname,"mod%dcol%drow%d",module,column,row); + TH1F* hist = (TH1F*)fHistoFile->Get(hname); + if(hist) + fAmpHisto[module][column][row]=hist; + else + fAmpHisto[module][column][row] = 0; + } + } + } } //----------------------------------------------------------------------------- AliPHOSCalibHistoProducer::~AliPHOSCalibHistoProducer() { // Destructor + + UpdateHistoFile(); if(fHistoFile) delete fHistoFile; + } //----------------------------------------------------------------------------- -void AliPHOSCalibHistoProducer::Run() +AliPHOSCalibHistoProducer::AliPHOSCalibHistoProducer(const AliPHOSCalibHistoProducer &histoproducer) : + TObject(histoproducer),fRawDecoder(histoproducer.fRawDecoder),fHistoFile(histoproducer.fHistoFile), + fUpdatingRate(histoproducer.fUpdatingRate),fIsOldRCUFormat(histoproducer.fIsOldRCUFormat), + fEvents(histoproducer.fEvents),fNbins(histoproducer.fNbins),fXlow(histoproducer.fXlow),fXup(histoproducer.fXup) { - // Reads raw data stream and fills amplitude histograms - // The histograms are written to file every fUpdatingRate events + //Copy constructor. - Int_t iEvent = 0; - Int_t runNum = -111; - Int_t relId[4]; - AliPHOSDigit* digit; - Double_t energy; + for(Int_t module=0; module<5; module++) { + for(Int_t column=0; column<56; column++) { + for(Int_t row=0; row<64; row++) { + char hname[128]; + sprintf(hname,"mod%dcol%drow%d",module,column,row); + TH1F* hist = (TH1F*)histoproducer.fHistoFile->Get(hname); + if(hist) + fAmpHisto[module][column][row]= new TH1F(*hist); + else + fAmpHisto[module][column][row]=0; + } + } + } +} - TClonesArray *digits = new TClonesArray("AliPHOSDigit",100); - AliPHOSGeometry* geo = AliPHOSGeometry::GetInstance("IHEP"); +//----------------------------------------------------------------------------- +AliPHOSCalibHistoProducer& AliPHOSCalibHistoProducer::operator= +(const AliPHOSCalibHistoProducer &histoproducer) +{ + //Assignment operator. + + if(this != &histoproducer) { + + fRawDecoder = histoproducer.fRawDecoder; + fHistoFile = histoproducer.fHistoFile; + fUpdatingRate = histoproducer.fUpdatingRate; + fIsOldRCUFormat = histoproducer.fIsOldRCUFormat; + fEvents = histoproducer.fEvents; + fEvents = histoproducer.fEvents; + fNbins = histoproducer.fNbins; + fXlow = histoproducer.fXlow; + fXup = histoproducer.fXup; + + for(Int_t module=0; module<5; module++) { + for(Int_t column=0; column<56; column++) { + for(Int_t row=0; row<64; row++) { + if(fAmpHisto[module][column][row]){ + delete fAmpHisto[module][column][row]; + fAmpHisto[module][column][row] = histoproducer.fAmpHisto[module][column][row]; + } + else + fAmpHisto[module][column][row] = histoproducer.fAmpHisto[module][column][row]; + } + } + } - AliPHOSRawDecoder dc(fRawReader); - if(fIsOldRCUFormat) - dc.SetOldRCUFormat(kTRUE); - // Read raw data event by event + } + + return *this; +} +//----------------------------------------------------------------------------- +void AliPHOSCalibHistoProducer::Run() +{ + // Reads raw data of current event and fills amplitude histograms + // The histograms are written to file every fUpdatingRate events - while (fRawReader->NextEvent()) { - runNum = fRawReader->GetRunNumber(); + if(!fRawDecoder) AliFatal("Raw decoder not set!"); + + Double_t energy; + Int_t mod,col,row; + + if(fIsOldRCUFormat) + fRawDecoder->SetOldRCUFormat(kTRUE); - AliPHOSRawDigiProducer producer; - producer.MakeDigits(digits,&dc); + while(fRawDecoder->NextDigit()) { - for(Int_t iDigit=0; iDigitGetEntries(); iDigit++) { - digit = (AliPHOSDigit*)digits->At(iDigit); - energy = digit->GetEnergy(); // no pedestal subtraction! - geo->AbsToRelNumbering(digit->GetId(),relId); - Int_t mod = relId[0]; - Int_t col = relId[3]; - Int_t row = relId[2]; - - if(fAmpHisto[mod][col][row]) { - fAmpHisto[mod][col][row]->Fill(energy); - } - else { - char hname[128]; - sprintf(hname,"mod%dcol%drow%d",mod,col,row); - fAmpHisto[mod][col][row] = new TH1F(hname,hname,100,0.,1000.); - } + if(fRawDecoder->IsLowGain()) continue; - // update histograms in local file every 100th event - if(iEvent%fUpdatingRate == 0) { - AliInfo(Form("Updating histo file, event %d, run %d\n",iEvent,runNum)); - UpdateHistoFile(); - } + energy = fRawDecoder->GetEnergy(); + + mod = fRawDecoder->GetModule()-1; + col = fRawDecoder->GetColumn()-1; + row = fRawDecoder->GetRow()-1; + + if(fAmpHisto[mod][col][row]) { + fAmpHisto[mod][col][row]->Fill(energy); + } + else { + char hname[128]; + sprintf(hname,"mod%dcol%drow%d",mod,col,row); + fAmpHisto[mod][col][row] = new TH1F(hname,hname,fNbins,fXlow,fXup); + fAmpHisto[mod][col][row]->Fill(energy); } - - iEvent++; } - - UpdateHistoFile(); - digits->Delete(); - delete digits; - delete geo; - AliInfo(Form("%d events of run %d processed.",iEvent,runNum)); + // update histograms in local file every 100th event + if(fEvents != 0 && fEvents%fUpdatingRate == 0) { + AliInfo(Form("Updating histo file, event %d, run %d\n", + fEvents,fRawDecoder->GetRawReader()->GetRunNumber())); + UpdateHistoFile(); + } + + // UpdateHistoFile(); + // AliInfo(Form("%d events of run %d processed.",iEvent,runNum)); + + fEvents++; + } //----------------------------------------------------------------------------- @@ -147,14 +214,22 @@ void AliPHOSCalibHistoProducer::UpdateHistoFile() if(!fHistoFile->IsOpen()) return; TH1F* hist=0; + char hname[128]; + char htitle[128]; for(Int_t module=0; module<5; module++) { + sprintf(hname,"hMeanE%d",module); + sprintf(htitle,"Mean energies in module %d",module); + TH2F hMeanE(hname,htitle,56,0.,56.,64,0.,64); + for(Int_t column=0; column<56; column++) { for(Int_t row=0; row<64; row++) { hist = fAmpHisto[module][column][row]; if(hist) hist->Write(hist->GetName(),TObject::kWriteDelete); + if(hist) hMeanE.SetBinContent(column,row,hist->GetMean()); } } + hMeanE.Write(hMeanE.GetName(),TObject::kWriteDelete); } }