--- /dev/null
+// **************************************************************************
+// * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+// * *
+// * Author: The ALICE Off-line Project. *
+// * Contributors are mentioned in the code where appropriate. *
+// * *
+// * Permission to use, copy, modify and distribute this software and its *
+// * documentation strictly for non-commercial purposes is hereby granted *
+// * without fee, provided that the above copyright notice appears in all *
+// * copies and that both the copyright notice and this permission notice *
+// * appear in the supporting documentation. The authors make no claims *
+// * about the suitability of this software for any purpose. It is *
+// * provided "as is" without express or implied warranty. *
+// **************************************************************************
+
+#include "AliHMPIDCalib.h" //class header
+#include "TTreePlayer.h"
+#include <fstream>
+#include <TTree.h>
+//#include "AliHMPIDDigit.h"
+
+ClassImp(AliHMPIDCalib)
+
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+AliHMPIDCalib::AliHMPIDCalib():
+ fPedTree(0x0),
+ fa(-1),
+ fd(-1),
+ fr(-1),
+ fq(-1),
+ fPedHisto(0)
+{
+ Init();
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+AliHMPIDCalib::~AliHMPIDCalib()
+{
+ //destructor
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliHMPIDCalib::Init()
+{
+ for(Int_t iddl=0;iddl<11;iddl++) faddl[iddl]=kFALSE;
+ //
+ // Called to initialize the TTree in which the raw data words will be stored
+ //
+ fPedHisto=new TH1F("fPedHisto","Temporary pedestal",4096,-0.5,4095.5); //init pedestal histo
+ fPedTree = new TTree("PedTree","HMPID Pedestal Tree"); //init pedestal tree
+ fPedTree->Branch("diladd",&fa,"diladd/I");
+ fPedTree->Branch("dilnum",&fd,"dilnum/I");
+ fPedTree->Branch("dilrow",&fr,"dilrow/I");
+ fPedTree->Branch("qdc" ,&fq,"qdc/F ");
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliHMPIDCalib::FillPedestal(Int_t ddl,Int_t row, Int_t dil,Int_t adr,Int_t q)
+{
+ //
+ //Called from the HMPIDda and fills the pedestal tree
+ //
+ fq=q;
+ fr=row;
+ fd=dil;
+ fa=adr;
+ faddl[ddl]=kTRUE;
+ if(fq>-1) fPedTree->Fill();
+}//FillPedestal()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Bool_t AliHMPIDCalib::CalcPedestal(Int_t ddl, Char_t* name)
+{
+ //
+ //Calculate pedestal for each pad
+ //
+
+ ofstream out; //to write the pedestal text files
+ Double_t mean,sigma;
+ Int_t inhard;
+ 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?!
+ out.open(name);
+ for(Int_t row=1; row < 25; row++){
+ for(Int_t dil=1; dil < 11; dil++){
+ for(Int_t adr=0; adr < 48; adr++){
+ fPedHisto->Reset();
+ fPedTree->Draw("fq>>fPedHisto",Form("fr==%d&&fd==%d&&fa==%d",row,dil,adr));
+ mean=fPedHisto->GetMean();
+ sigma=fPedHisto->GetRMS();
+ inhard=((Int_t(mean))<<9)+Int_t(mean+3*sigma);
+ out << Form("%2i %2i %2i %5.2f %5.2f %x\n",row,dil,adr,mean,sigma,inhard);
+ }//adr
+ }//dil
+ }//row
+ out.close(); //write pedestal file
+ return kTRUE;
+}//CaclPedestal()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
--- /dev/null
+#ifndef AliHMPIDCalib_h
+#define AliHMPIDCalib_h
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+// Class of HMPID to manage digits ---> pads
+//.
+//.
+//.
+#include "TTreePlayer.h"
+#include <TTree.h>
+#include <TH1.h>
+
+class AliHMPIDCalib: public TObject {
+
+
+public:
+ AliHMPIDCalib();
+ virtual ~AliHMPIDCalib();
+ void Init();
+ void FillPedestal(Int_t ddl,Int_t row, Int_t dil,Int_t adr,Int_t q);
+ Bool_t CalcPedestal(Int_t ddl, Char_t* name);
+
+
+protected:
+ TTree *fPedTree; //Pedestal Tree
+ Int_t fa; //DILOGIC address
+ Int_t fd; //DILOGIC number
+ Int_t fr; //DILOGIC row
+ Bool_t faddl[11]; //check is ddl is filled
+ Int_t fq; //Qdc value
+ TH1F *fPedHisto; //
+
+ ClassDef(AliHMPIDCalib,1) //HMPID calibration and pedestal class
+};
+#endif
fTracks[0],fTracks[1],fTracks[2],w32,ddl,r,d,a, (AliHMPIDParam::IsOverTh(Q()))?"":"below thr");
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void AliHMPIDDigit::WriteRaw(TObjArray *pDigAll)
-{
-// Write a list of digits for a given chamber in raw data stream
-// Arguments: pDigAll- list of digits
-// Returns: none
- for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){//chambers loop
- AliFstream* ddlL; //output streams, 2 per chamber
- AliFstream* ddlR;
- Int_t cntL=0,cntR=0; //data words counters for DDLs
- AliRawDataHeader header; header.SetAttribute(0); //empty DDL header
-
-// ddlL = new AliFstream(AliDAQ::DdlFileName("HMPID",2*iCh));
-// ddlR = new AliFstream(AliDAQ::DdlFileName("HMPID",2*iCh+1)); //open both DDL of this chamber in parallel
- ddlL = new AliFstream(AliDAQ::DdlFileName("HMPID",2*iCh+1)); //left and right looking at the IP
- ddlR = new AliFstream(AliDAQ::DdlFileName("HMPID",2*iCh)); //open both DDL of this chamber in parallel
- ddlL->WriteBuffer((char*)&header,sizeof(header)); //write dummy header as place holder, actual
- ddlR->WriteBuffer((char*)&header,sizeof(header)); //will be rewritten later when total size of DDL is known
-
- UInt_t w32=0; //32 bits data word
- TClonesArray *pDigCh=(TClonesArray *)pDigAll->At(iCh); //list of digits for current chamber
- for(Int_t iDig=0;iDig<pDigCh->GetEntriesFast();iDig++){//digits loop
- AliHMPIDDigit *pDig=(AliHMPIDDigit*)pDigCh->At(iDig);
- if(pDig->Q() < 1) continue;
- Int_t ddl,r,d,a; //32 bits data word
- pDig->Raw(w32,ddl,r,d,a);
- if(ddl%2){
- ddlL->WriteBuffer((char*)&w32,sizeof(w32)); cntL++;
- }else{
- ddlR->WriteBuffer((char*)&w32,sizeof(w32)); cntR++;
- }
- }//digits loop
-
- header.fSize=sizeof(header)+cntL*sizeof(w32); ddlL->Seekp(0); ddlL->WriteBuffer((char*)&header,sizeof(header)); delete ddlL; //rewrite header with size set to
- header.fSize=sizeof(header)+cntR*sizeof(w32); ddlR->Seekp(0); ddlR->WriteBuffer((char*)&header,sizeof(header)); delete ddlR; //number of bytes and close file
- }//chambers loop
-}//WriteRaw()
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//ctor&dtor
AliHMPIDDigit( ):AliDigit( ),fPad(AliHMPIDParam::Abs(-1,-1,-1,-1)),fQ(-1) {} //default ctor
AliHMPIDDigit(Int_t pad,Int_t q,Int_t *t):AliDigit(t),fPad(pad ),fQ(q ) {} //digit ctor
+ AliHMPIDDigit(Int_t pad,Int_t q ):AliDigit( ),fPad(pad ),fQ(q ) {} //digit ctor
AliHMPIDDigit(const AliHMPIDDigit &d ):AliDigit(d),fPad(d.fPad),fQ(d.fQ) {} //copy ctor
virtual ~AliHMPIDDigit() {} //dtor
//framework part
Int_t Pad ( )const{return fPad;} //absolute id of this pad
Int_t Pc ( )const{return AliHMPIDParam::A2P(fPad);} //PC position number
Float_t Q ( )const{return fQ;} //charge, [QDC]
- inline void Raw (UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)const; //digit->(w32,ddl,r,d,a)
- inline Bool_t Raw (UInt_t w32,Int_t ddl,AliRawReader *pRR); //(w32,ddl)->digit
- inline void Raw (Int_t ddl,Int_t r,Int_t d,Int_t a); //raw->abs pad number
+ inline void Raw(UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)const;
inline Bool_t Set (Int_t c,Int_t p,Int_t x,Int_t y,Int_t tid=0); //manual creation
void SetQ (Float_t q ) {fQ=q;} //manual creation
void SetNsig (Int_t sigmas ) {AliHMPIDParam::fgSigmas=sigmas;} //set n sigmas
- static void WriteRaw (TObjArray *pDigLst ); //write as raw stream
- enum EHMPIDRawError {
- kInvalidRawDataWord = 1
- };
+
protected: //AliDigit has fTracks[3]
// Returns: none
Int_t y2a[6]={5,3,1,0,2,4};
- ddl=2*Ch()+Pc()%2; //DDL# 0..13
+ ddl=2*Ch()+Pc()%2; //DDL# 0..13
Int_t tmp=1+Pc()/2*8+PadPcY()/6; r=(Pc()%2)? 25-tmp:tmp; //row r=1..24
d=1+PadPcX()/8; //DILOGIC# 1..10
a=y2a[PadPcY()%6]+6*(PadPcX()%8); //ADDRESS 0..47
- w32=0;
- //Protection for charge > 4095
- AliBitPacking::PackWord((fQ>4095)?4095:(UInt_t)fQ,w32,0,11); // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq Qdc bits (00..11) counts (0..4095)
- AliBitPacking::PackWord( a ,w32,12,17); // 3322 2222 2222 1111 1111 1000 0000 0000 DILOGIC address bits (12..17) counts (0..47)
- AliBitPacking::PackWord( d ,w32,18,21); // 1098 7654 3210 9876 5432 1098 7654 3210 DILOGIC number bits (18..21) counts (1..10)
- AliBitPacking::PackWord( r ,w32,22,26); // Row number bits (22..26) counts (1..24)
+ w32=0;
+ //Printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+ //
+ //Printf("AliHMPIDDigit::Raw ddl: %d r: %d d: %d a: %d",ddl,r,d,a);
+ //Printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
+// Bool_t isOK=kTRUE; isOK=
+ AliBitPacking::PackWord((fQ>4095)?(UInt_t)4095:(UInt_t)fQ,w32, 0,11); // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq Qdc bits (00..11) counts (0..4095)
+ //Printf("isOK: %d",isOK);
+ //molnarl: Since in simulation the the charge can be > than 4095 but not in real life we need to protect. If fQ>4095 after packing we will get 0 for the charge!
+ assert(0<=a&&a<=47);AliBitPacking::PackWord( a ,w32,12,17); // 3322 2222 2222 1111 1111 1000 0000 0000 DILOGIC address bits (12..17) counts (0..47)
+ assert(1<=d&&d<=10);AliBitPacking::PackWord( d ,w32,18,21); // 1098 7654 3210 9876 5432 1098 7654 3210 DILOGIC number bits (18..21) counts (1..10)
+ assert(1<=r&&r<=24);AliBitPacking::PackWord( r ,w32,22,26); // Row number bits (22..26) counts (1..24)
+ AliBitPacking::PackWord((UInt_t)0, w32,27,27); //To make sure set the 27th bit to Zero so we can distinguis it from the EoE
}
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-Bool_t AliHMPIDDigit::Raw(UInt_t w32,Int_t ddl, AliRawReader *pRR)
-{
-// Converts a given raw data word to a digit
-// Arguments: w32 - 32 bits raw data word
-// ddl - DDL idx 0 1 2 3 4 ... 13
-// Returns: none
- Int_t r = AliBitPacking::UnpackWord(w32,22,26); assert(1<=r&&r<=24); // Row number (1..24)
- Int_t d = AliBitPacking::UnpackWord(w32,18,21); assert(1<=d&&d<=10); // 3322 2222 2222 1111 1111 1000 0000 0000 DILOGIC number (1..10)
- Int_t a = AliBitPacking::UnpackWord(w32,12,17); assert(0<=a&&a<=47); // 1098 7654 3210 9876 5432 1098 7654 3210 DILOGIC address (0..47)
- Int_t q = AliBitPacking::UnpackWord(w32, 0,11); assert(0<=q&&q<=4095); // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq Qdc (0..4095)
- if (r<1 || r>24 || d<1 || d>10 || a<0 || a>47 || q<0 || q>4095) {
- AliWarning(Form("Invalid raw data word %x",w32));
- pRR->AddMajorErrorLog(kInvalidRawDataWord,Form("w=%x",w32));
- return kFALSE;
- }
- Raw(ddl,r,d,a);
- fQ=q;
- return kTRUE;
-}
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void AliHMPIDDigit::Raw(Int_t ddl,Int_t r,Int_t d,Int_t a)
-{
- assert(0<=ddl&&ddl<=13); assert(1<=r&&r<=24); assert(1<=d&&d<=10); assert(0<=a&&a<=47);
- Int_t a2y[6]={3,2,4,1,5,0};//pady for a given address (for single DILOGIC chip)
- Int_t ch=ddl/2;
- Int_t tmp=(r-1)/8; Int_t pc=(ddl%2)? 5-2*tmp:2*tmp;
- Int_t px=(d-1)*8+a/6;
- tmp=(ddl%2)?(24-r):r-1; Int_t py=6*(tmp%8)+a2y[a%6];
- fPad=AliHMPIDParam::Abs(ch,pc,px,py);
-}
-
-
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Bool_t AliHMPIDDigit::Set(Int_t ch,Int_t pc,Int_t px,Int_t py,Int_t tid)
{
fQ=0;
return kFALSE;
}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
#endif
#include "AliHMPIDPreprocessor.h" //header no includes
#include "AliHMPIDDigit.h" //ProcPed()
+#include "AliHMPIDRawStream.h" //ProcPed()
#include <Riostream.h> //ProcPed()
#include <AliLog.h> //all
#include <AliCDBMetaData.h> //ProcPed(), ProcDcs()
gSystem->Exec(Form("tar xf %s",GetFile(kDAQ,"pedestals",((TObjString*)pLdc->At(i))->GetName()))); //untar pedestal files from current LDC
AliHMPIDDigit dig;
+ AliHMPIDRawStream rs;
Int_t nSigCut,r,d,a,hard; Float_t mean,sigma;
for(Int_t ddl=0;ddl<14;ddl++){
infile>>nSigCut; pM->SetUniqueID(nSigCut); //n. of pedestal distribution sigmas used to create zero suppresion table
while(!infile.eof()){
infile>>dec>>r>>d>>a>>mean>>sigma>>hex>>hard;
- dig.Raw(ddl,r,d,a);
+ //dig.Raw(ddl,r,d,a);
+ rs.Raw(ddl,r,d,a);
+ AliHMPIDDigit dig(rs.GetPad(ddl,r,d,a),rs.GetCharge(ddl,r,d,a));
(*pM)(dig.PadChX(),dig.PadChY()) = sigma;
}
infile.close();
#include "AliHMPIDRawStream.h"
#include "AliRawReader.h"
#include "AliLog.h"
-#include "AliDAQ.h"
+
ClassImp(AliHMPIDRawStream)
fRawReader->Reset();
fRawReader->Select("HMPID");
}
-
+//-----------------------------------------------------------------------------
+/*
+AliHMPIDRawStream::AliHMPIDRawStream() :
+ fDDLNumber(-1),
+ fData(NULL),
+ fPosition(-1)
+{
+ // Constructor
+ Init();
+}
+*/
//_____________________________________________________________________________
AliHMPIDRawStream::~AliHMPIDRawStream()
{
{
// Initalize the container
// with the pad charges
- for(Int_t i = 0; i < kNRows; i++)
- for(Int_t j = 0; j < kNDILOGICAdd; j++)
- for(Int_t k = 0; k < kNPadAdd; k++)
- fCharge[i][j][k] = -1;
-}
-
+ for(Int_t h = 0; h < kNDDL; h++) {
+ for(Int_t i = 0; i < kNRows; i++){
+ for(Int_t j = 0; j < kNDILOGICAdd; j++){
+ for(Int_t k = 0; k < kNPadAdd; k++){
+ fCharge[h][i][j][k] = -1;
+ fPad[h][i][j][k]=-1;
+ }
+ }
+ }
+ }
+ fZeroSup=kTRUE;
+}//Init()
//_____________________________________________________________________________
void AliHMPIDRawStream::Reset()
{
// reset raw stream params
-
// Reinitalize the containers
Init();
-
fDDLNumber = -1;
fPosition = -1;
fData = NULL;
-
if (fRawReader) fRawReader->Reset();
}
-
//_____________________________________________________________________________
Bool_t AliHMPIDRawStream::Next()
{
- // read next DDL raw data from the VZERO raw data stream
+ // read next DDL raw data from the HMPID raw data stream
// return kFALSE in case of error or no data left
-
+ AliDebug(1,"Start.");
do {
if (!fRawReader->ReadNextData(fData)) return kFALSE;
} while (fRawReader->GetDataSize() == 0);
-
- if (fRawReader->GetDataSize() != 47148) {
- fRawReader->AddFatalErrorLog(kRawDataSizeErr,Form("size %d != 47148",fRawReader->GetDataSize()));
- AliWarning(Form("Wrong HMPID raw data size: %d, expected 47148 bytes!",fRawReader->GetDataSize()));
- return kTRUE;
+
+ if ( fRawReader->GetDataSize() > 47148) {
+ AliWarning(Form("Raw data event size is larger (%d) than possible for HMPID!!!! ",fRawReader->GetDataSize()));
}
- fDDLNumber = fRawReader->GetDDLID();
- fPosition = 0;
-
- Init();
-
- // Look over rows
- for(Int_t iRow = 1; iRow < kNRows; iRow++) {
- // Read row marker
- UInt_t rowMarker = GetNextWord() & 0x1ffffff;
- if (rowMarker != 0x1ea32a8) {
- fRawReader->AddMajorErrorLog(kRowMarkerErr);
- AliWarning(Form("Wrong row marker %x for row %d, expected 0xx1ea32a8!",rowMarker,iRow));
- return kTRUE;
- }
- UInt_t dilogic = 0, row = 0;
- for(Int_t iDILOGIC = 1; iDILOGIC < kNDILOGICAdd; iDILOGIC++) {
- // Read pad charges
- for(Int_t iPad = 0; iPad < kNPadAdd; iPad++) {
- UInt_t data = GetNextWord();
- row = (data >> 22) & 0x1f;
- if (row < 1 || row >= kNRows) {
- fRawReader->AddMajorErrorLog(kWrongRowErr,Form("row %d",row));
- AliWarning(Form("Wrong row index: %d, expected (1 -> %d)!",row,kNRows));
- row = iRow;
+
+ else if (fRawReader->GetDataSize() == 47148) {
+ fDDLNumber = fRawReader->GetDDLID();
+ fPosition = 0;
+
+ Init();
+
+ // Look over rows
+ for(Int_t iRow = 1; iRow <= kNRows; iRow++) {
+ // Read row marker
+ UInt_t rowMarker = GetNextWord() & 0x1ffffff;
+ if (rowMarker != 0x1ea32a8) {
+ fRawReader->AddMajorErrorLog(kRowMarkerErr);
+ AliWarning(Form("Wrong row marker %x for row %d, expected 0x1ea32a8!",rowMarker,iRow));
+ return kTRUE;
+ }//check for row marker
+ UInt_t dilogic = 0, row = 0;
+ for(Int_t iDILOGIC = 1; iDILOGIC <= kNDILOGICAdd; iDILOGIC++) {
+ // Read pad charges
+ for(Int_t iPad = 0; iPad < kNPadAdd; iPad++) {
+ UInt_t data = GetNextWord();
+ row = (data >> 22) & 0x1f; //row information in raw word is between bits: 22...26
+ if (row < 1 || row > kNRows) {
+ fRawReader->AddMajorErrorLog(kWrongRowErr,Form("row %d",row));
+ AliWarning(Form("Wrong row index: %d, expected (1 -> %d)!",row,kNRows));
+ row = iRow;
+ }
+ dilogic = (data >> 18) & 0xf; //dilogic info in raw word is between bits: 18...21
+ if (dilogic < 1 || dilogic > kNDILOGICAdd) {
+ fRawReader->AddMajorErrorLog(kWrongDilogicErr,Form("dil %d",dilogic));
+ AliWarning(Form("Wrong DILOGIC index: %d, expected (1 -> %d)!",dilogic,kNDILOGICAdd));
+ dilogic = iDILOGIC;
+ }
+ UInt_t pad = (data >> 12) & 0x3f; //pad info in raw word is between bits: 12...17
+ if (pad >= kNPadAdd) {
+ fRawReader->AddMajorErrorLog(kWrongPadErr,Form("pad %d",pad));
+ AliWarning(Form("Wrong pad index: %d, expected (0 -> %d)!",pad,kNPadAdd));
+ pad = iPad;
+ }
+ fCharge[fDDLNumber][row][dilogic][pad] = data & 0xfff;
}
- dilogic = (data >> 18) & 0xf;
- if (dilogic < 1 || dilogic >= kNDILOGICAdd) {
- fRawReader->AddMajorErrorLog(kWrongDilogicErr,Form("dil %d",dilogic));
- AliWarning(Form("Wrong DILOGIC index: %d, expected (1 -> %d)!",dilogic,kNDILOGICAdd));
- dilogic = iDILOGIC;
+ // Now read the end-of-event word
+ UInt_t eOfEvent = GetNextWord() & 0xfffffff;
+ if (!((eOfEvent >> 27) & 0x1)) { //check 27th bit in EoE. It must be 1!
+ fRawReader->AddMajorErrorLog(kEoEFlagErr);
+ AliWarning(Form("Missing end-of-event flag! (%x)",eOfEvent));
+ return kTRUE;
}
- UInt_t pad = (data >> 12) & 0x3f;
- if (pad >= kNPadAdd) {
- fRawReader->AddMajorErrorLog(kWrongPadErr,Form("pad %d",pad));
- AliWarning(Form("Wrong pad index: %d, expected (0 -> %d)!",pad,kNPadAdd));
- pad = iPad;
+ UInt_t wc = eOfEvent & 0x7f;
+ if (wc != 48) {
+ fRawReader->AddMajorErrorLog(kEoESizeErr,Form("eoe size=%d",wc));
+ AliWarning(Form("Wrong end-of-event word-count:%d, expected 48!",wc));
+ return kTRUE;
+ }
+ UInt_t da = (eOfEvent >> 18) & 0xf;
+ if (da != dilogic) {
+ fRawReader->AddMajorErrorLog(kEoEDILOGICErr,Form("eoe dil %d != %d",da,dilogic));
+ AliWarning(Form("Wrong DILOGIC address found in end-of-event: %d, expected %d!",da,dilogic));
+ return kTRUE;
+ }
+ UInt_t ca = (eOfEvent >> 22) & 0x1f;
+ if (ca != row) {
+ fRawReader->AddMajorErrorLog(kEoERowErr,Form("eoe row %d != %d",ca,row));
+ AliWarning(Form("Wrong row index found in end-of-event: %d, expected %d!",ca,row));
+ return kTRUE;
+ }
+ }//DILOGIC loop
+
+ // Read the segment marker
+ // One maker per 8 rows
+
+ if (iRow%8 == 0) {
+ UInt_t segWord = GetNextWord();
+ if ((segWord >> 8) != 0xab0f58) {
+ fRawReader->AddMajorErrorLog(kBadSegWordErr);
+ AliWarning(Form("Wrong segment word signature: %x, expected 0xab0f58!",(segWord >> 8)));
+ return kTRUE;
+ }
+
+ if ((segWord & 0xff) != (((UInt_t)iRow + 7) / 8)) {
+ fRawReader->AddMajorErrorLog(kWrongSegErr,Form("seg %d != %d",segWord & 0xff,(iRow + 7) / 8));
+ AliWarning(Form("Segment index (%d) does not correspond to the one expected from row index (%d)!",segWord & 0xff,(iRow + 7) / 8));
+ return kTRUE;
}
- fCharge[row][dilogic][pad] = data & 0xfff;
- }
- // Now read the end-of-event word
- UInt_t eOfEvent = GetNextWord() & 0xfffffff;
- if (!((eOfEvent >> 27) & 0x1)) {
- fRawReader->AddMajorErrorLog(kEoEFlagErr);
- AliWarning(Form("Missing end-of-event flag! (%x)",eOfEvent));
- return kTRUE;
- }
- UInt_t wc = eOfEvent & 0x7f;
- if (wc != 48) {
- fRawReader->AddMajorErrorLog(kEoESizeErr,Form("eoe size=%d",wc));
- AliWarning(Form("Wrong end-of-event word-count:%d, expected 48!",wc));
- return kTRUE;
- }
- UInt_t da = (eOfEvent >> 18) & 0xf;
- if (da != dilogic) {
- fRawReader->AddMajorErrorLog(kEoEDILOGICErr,Form("eoe dil %d != %d",da,dilogic));
- AliWarning(Form("Wrong DILOGIC address found in end-of-event: %d, expected %d!",da,dilogic));
- return kTRUE;
- }
- UInt_t ca = (eOfEvent >> 22) & 0x1f;
- if (ca != row) {
- fRawReader->AddMajorErrorLog(kEoERowErr,Form("eoe row %d != %d",ca,row));
- AliWarning(Form("Wrong row index found in end-of-event: %d, expected %d!",ca,row));
- return kTRUE;
}
- }
+ }//loop of Row
+ }//Pedestal files selected by data lenght
- // Read the segment marker
- // One maker per 8 rows
- if (iRow%8 == 0) {
- UInt_t segWord = GetNextWord();
- if ((segWord >> 8) != 0xab0f58) {
- fRawReader->AddMajorErrorLog(kBadSegWordErr);
- AliWarning(Form("Wrong segment word signature: %x, expected 0xab0f58!",(segWord >> 8)));
- return kTRUE;
- }
- if ((segWord & 0xff) != (((UInt_t)iRow + 7) / 8)) {
- fRawReader->AddMajorErrorLog(kWrongSegErr,Form("seg %d != %d",segWord & 0xff,(iRow + 7) / 8));
- AliWarning(Form("Segment index (%d) does not correspond to the one expected from row index (%d)!",segWord & 0xff,(iRow + 7) / 8));
+ else { //Raw data size is not 0 and not 47148 (pedestal)
+ fDDLNumber = fRawReader->GetDDLID();
+ fPosition = 0;
+
+ Init();
+
+ // Look over rows
+ for(Int_t iRow = 1; iRow <= kNRows; iRow++) {
+
+ UInt_t rowMarker = GetNextWord(); // Read row marker
+
+ Int_t numRows= rowMarker >> 16 & 0xffffff;
+
+ if ((rowMarker >> 0 & 0xffff) != 0x32a8) {
+ fRawReader->AddMajorErrorLog(kRowMarkerErr);
+ AliWarning(Form("Wrong row marker %x for row %d, expected 0x32a8!",rowMarker,iRow));
return kTRUE;
+ }//check for row marker
+ UInt_t dilogic = 0, row = 0;
+ UInt_t cntData=0;
+ UInt_t cntEoE=0;
+ //molnarl: lets read how many rows we have from the marker; 10 dilogic EoE so we can get the number of data words they should be in order
+ for(Int_t iWordInRow=0; iWordInRow<numRows;iWordInRow++) //loop over words
+ {
+ UInt_t tmpword=GetNextWord();
+ UInt_t eOfEvent = tmpword; // always assume that it is an EoE. If bit
+ if (!((eOfEvent >> 27) & 0x1)) { // if it is not EoE then data!
+ UInt_t data=tmpword;
+ row = (data >> 22) & 0x1f; //row information in raw word is between bits: 22...26
+ if (row < 1 || row > kNRows) { //select bits from 22 and with 0x1f ask for the next 5 bits
+ fRawReader->AddMajorErrorLog(kWrongRowErr,Form("row %d",row));
+ AliWarning(Form("Wrong row index: %d, expected (1 -> %d)!",row,kNRows));
+ // row = iRow;
+ }
+ dilogic = (data >> 18) & 0xf; //dilogic info in raw word is between bits: 18...21
+ if (dilogic < 1 || dilogic > kNDILOGICAdd) {
+ fRawReader->AddMajorErrorLog(kWrongDilogicErr,Form("dil %d",dilogic));
+ AliWarning(Form("Wrong DILOGIC index: %d, expected (1 -> %d)!",dilogic,kNDILOGICAdd));
+ //dilogic = iDILOGIC;
+ }
+ UInt_t pad = (data >> 12) & 0x3f; //pad info in raw word is between bits: 12...17
+ if (pad >= kNPadAdd) {
+ fRawReader->AddMajorErrorLog(kWrongPadErr,Form("pad %d",pad));
+ AliWarning(Form("Wrong pad index: %d, expected (0 -> %d)!",pad,kNPadAdd));
+ //pad = iPad;
+ }
+ fCharge[fDDLNumber][row][dilogic][pad] = data & 0xfff; cntData++;
+
+ }//not EoE but data!
+ //if it is EoE
+ else{
+ //Printf("EoE word");
+ if (!((eOfEvent >> 27) & 0x1)) { //check 27th bit in EoE. It must be 1!
+ fRawReader->AddMajorErrorLog(kEoEFlagErr);
+ AliWarning(Form("Missing end-of-event flag! (%x)",eOfEvent));
+ return kTRUE;
+ }
+ UInt_t wc = eOfEvent & 0x7f;
+ if (wc != cntData) {
+ fRawReader->AddMajorErrorLog(kEoESizeErr,Form("eoe size=%d",wc));
+ AliWarning(Form("Wrong end-of-event word-count:%d, expected 48!",wc));
+ return kTRUE;
+ }
+ UInt_t da = (eOfEvent >> 18) & 0xf;
+ if (cntData!=0 && da != dilogic) {
+ fRawReader->AddMajorErrorLog(kEoEDILOGICErr,Form("eoe dil %d != %d",da,dilogic));
+ AliWarning(Form("Wrong DILOGIC address found in end-of-event: %d, expected %d!",da,dilogic));
+ return kTRUE;
+ }
+ UInt_t ca = (eOfEvent >> 22) & 0x1f;
+ if (cntData!=0 && ca != row) {
+ fRawReader->AddMajorErrorLog(kEoERowErr,Form("eoe row %d != %d",ca,row));
+ AliWarning(Form("Wrong row index found in end-of-event: %d, expected %d!",ca,row));
+ return kTRUE;
+ }
+ cntData=0; cntEoE++;//zero it and wait for new data words
+ } //EoE word
+
+ } //loop over rows within two markers
+
+
+
+ // Read the segment marker
+ // One maker per 8 rows
+
+ if (iRow%8 == 0) {
+ UInt_t segWord = GetNextWord();
+ if ((segWord >> 8) != 0xab0f58) {
+ fRawReader->AddMajorErrorLog(kBadSegWordErr);
+ AliWarning(Form("Wrong segment word signature: %x, expected 0xab0f58!",(segWord >> 8)));
+ return kTRUE;
+ }
+
+ if ((segWord & 0xff) != (((UInt_t)iRow + 7) / 8)) {
+ fRawReader->AddMajorErrorLog(kWrongSegErr,Form("seg %d != %d",segWord & 0xff,(iRow + 7) / 8));
+ AliWarning(Form("Segment index (%d) does not correspond to the one expected from row index (%d)!",segWord & 0xff,(iRow + 7) / 8));
+ return kTRUE;
+ }
}
- }
- }
+ }//loop of Row
+ }//REal data files selected by data lenght
+
+ AliDebug(1,"Stop.");
return kTRUE;
}
// The method is supposed to be endian (platform)
// independent.
if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !");
-
+
UInt_t word = 0;
word |= fData[fPosition++];
word |= fData[fPosition++] << 8;
word |= fData[fPosition++] << 16;
word |= fData[fPosition++] << 24;
-
+
return word;
}
//_____________________________________________________________________________
-Short_t AliHMPIDRawStream::GetCharge(Int_t row, Int_t dilogic, Int_t pad) const
-{
- // The method returns the charge collected
- // in a particular channel
- // Return -1 in case the charge from the channels
- // has not been read or invalid arguments
-
- if (row < 1 || row >= kNRows) {
- AliError(Form("Wrong row index %d!",row));
- return 0;
- }
-
- if (dilogic < 1 || dilogic >= kNDILOGICAdd) {
- AliError(Form("Wrong DILOGIC address %d!",dilogic));
- return 0;
- }
-
- if (pad >= kNPadAdd) {
- AliError(Form("Wrong pad index %d!",pad));
- return 0;
- }
-
- return fCharge[row][dilogic][pad];
-}
///////////////////////////////////////////////////////////////////////////////
#include <TObject.h>
-
+#include <TRandom.h>
+#include "AliHMPIDParam.h"
+#include <AliBitPacking.h>
+#include <AliFstream.h>
+#include "AliHMPIDDigit.h"
+#include "AliDAQ.h"
class AliRawReader;
class AliHMPIDRawStream: public TObject {
public :
AliHMPIDRawStream(AliRawReader* rawReader);
+ AliHMPIDRawStream();
+
virtual ~AliHMPIDRawStream();
- virtual void Reset();
- virtual Bool_t Next();
- void Init();
-
- Int_t GetDDLNumber() const { return fDDLNumber; } // Provide current DDL number
- Short_t GetCharge(Int_t row, Int_t dilogic, Int_t pad) const; // Provide the charge observed in certain row,dilogic,pad channel
-
- enum EHMPIDRawStreamError {
+ virtual void Reset();
+ virtual Bool_t Next();
+ void Init();
+
+ Int_t Ch( Int_t ddl,Int_t row,Int_t dil,Int_t pad ) {return AliHMPIDParam::A2C(fPad[ddl][row][dil][pad]); } //chamber number
+
+ Int_t GetDDLNumber() const { return fDDLNumber; } // Provide current DDL number
+ inline Int_t GetCharge(Int_t ddl,Int_t row, Int_t dilogic, Int_t pad); // Provide the charge observed in certain row,dilogic,pad channel
+ inline Int_t GetPad(Int_t ddl,Int_t row,Int_t dil,Int_t pad); //
+
+ Int_t Pc ( Int_t ddl,Int_t row,Int_t dil,Int_t pad ) {return AliHMPIDParam::A2P(fPad[ddl][row][dil][pad]);} //PC position number
+ Int_t PadPcX ( Int_t ddl,Int_t row,Int_t dil,Int_t pad ) {return AliHMPIDParam::A2X(fPad[ddl][row][dil][pad]);} //pad pc x # 0..79
+ Int_t PadPcY ( Int_t ddl,Int_t row,Int_t dil,Int_t pad ) {return AliHMPIDParam::A2Y(fPad[ddl][row][dil][pad]);} //pad pc y # 0..47
+
+ inline Bool_t SetZeroSup (Bool_t isSup);
+ inline Bool_t GetZeroSup();
+
+ inline void Raw (UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a); //digit->(w32,ddl,r,d,a)
+ inline void Raw (Int_t ddl,Int_t r,Int_t d,Int_t a); //raw->abs pad number
+ inline Bool_t Raw (UInt_t w32,Int_t ddl,AliRawReader *pRR); //(w32,ddl)->digit
+ inline void SetCharge (Int_t ddl,Int_t row,Int_t dil,Int_t pad,Int_t q);
+ inline void WriteRaw (TObjArray *pDigLst ); //write as raw stream
+ inline void WriteRowMarker (AliFstream *ddl,UInt_t size);
+ inline void WriteEoE (AliFstream *ddl,UInt_t row,UInt_t dil,UInt_t wordCnt);
+ inline void WriteSegMarker (AliFstream *ddl,UInt_t row);
+
+// inline TClonesArray ReMap(TClonesArray *pDigIn);
+
+ enum EHMPIDRawStreamError {
kRawDataSizeErr = 1,
kRowMarkerErr = 2,
kWrongRowErr = 3,
kBadSegWordErr = 10,
kWrongSegErr = 11
};
-
+
enum {
- kNRows = 25, // Number of rows (starting from 1 !)
- kNDILOGICAdd = 11, // Number of DILOGIC addresses in a row (starting from 1 !)
- kNPadAdd = 48, // Number of
- kNRowsPerSegment = 8 // Number of rows per segment
+ kNRows = 24, // Number of rows (starting from 1 !)//was25
+ kNDILOGICAdd = 10, // Number of DILOGIC addresses in a row (starting from 1 !) //was11
+ kNPadAdd = 48, // Number of pad row
+ kNRowsPerSegment = 8, // Number of rows per segment
+ kNDDL = 14
};
+ enum EHMPIDRawError {
+ kInvalidRawDataWord = 1
+ };
+
private :
AliHMPIDRawStream& operator = (const AliHMPIDRawStream& stream);
UInt_t GetNextWord();
- Short_t fCharge[kNRows][kNDILOGICAdd][kNPadAdd]; // Array for charge values for all channels in one DDL
+ Int_t fCharge[kNDDL][kNRows+1][kNDILOGICAdd+1][kNPadAdd]; // Array for charge values for all channels in one DDL
+
+ Int_t fPad[kNDDL][kNRows+1][kNDILOGICAdd+1][kNPadAdd]; // Array for abs pad values for all channels in one DDL
+ UInt_t fRawWord[kNDDL][kNRows+1][kNDILOGICAdd+1][kNPadAdd];
+
Int_t fDDLNumber; // index of current DDL number
AliRawReader* fRawReader; // object for reading the raw data
UChar_t* fData; // raw data
Int_t fPosition; // current position in fData
- // Int_t fCount; // counter of words to be read for current trailer
+
+ Bool_t fZeroSup;
ClassDef(AliHMPIDRawStream, 0) // base class for reading HMPID raw digits
};
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliHMPIDRawStream::Raw(UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)
+{
+// Convert raw stream word to raw word format
+// Arguments: w32,ddl,r,d,a where to write the results
+// Returns: none
+ Int_t y2a[6]={5,3,1,0,2,4};
+
+ ddl=2*Ch(ddl,r,d,a)+Pc(ddl,r,d,a)%2; //DDL# 0..13
+ Int_t tmp=1+Pc(ddl,r,d,a)/2*8+PadPcY(ddl,r,d,a)/6; r=(Pc(ddl,r,d,a)%2)? 25-tmp:tmp; //row r=1..24
+ d=1+PadPcX(ddl,r,d,a)/8; //DILOGIC# 1..10
+ a=y2a[PadPcY(ddl,r,d,a)%6]+6*(PadPcX(ddl,r,d,a)%8); //ADDRESS 0..47
+
+ w32=0;
+ AliBitPacking::PackWord((fCharge[ddl][r][d][a]>4095)?4095:(UInt_t)fCharge[ddl][r][d][a],w32, 0,11); // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq Qdc bits (00..11) counts (0..4095)
+ //molnarl: Since in simulation the the charge can be > than 4095 but not in real life we need to protect. If fQ>4095 after packing we will get 0 for the charge!
+ assert(0<=a&&a<=47);AliBitPacking::PackWord( a ,w32,12,17); // 3322 2222 2222 1111 1111 1000 0000 0000 DILOGIC address bits (12..17) counts (0..47)
+ assert(1<=d&&d<=10);AliBitPacking::PackWord( d ,w32,18,21); // 1098 7654 3210 9876 5432 1098 7654 3210 DILOGIC number bits (18..21) counts (1..10)
+ assert(1<=r&&r<=24);AliBitPacking::PackWord( r ,w32,22,26); // Row number bits (22..26) counts (1..24)
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliHMPIDRawStream::Raw(Int_t ddl,Int_t r,Int_t d,Int_t a)
+{
+ //Assign absolute pad ID based on ddl,row,dil,pad
+ //Arguments: DDL, row number, dilogic number, dilogic address(pad)
+ //Returns : nothing
+
+ assert(0<=ddl&&ddl<=13); assert(1<=r&&r<=24); assert(1<=d&&d<=10); assert(0<=a&&a<=47);
+ Int_t a2y[6]={3,2,4,1,5,0};//pady for a given address (for single DILOGIC chip)
+ Int_t ch=ddl/2;
+ Int_t tmp=(r-1)/8; Int_t pc=(ddl%2)? 5-2*tmp:2*tmp;
+ Int_t px=(d-1)*8+a/6;
+ tmp=(ddl%2)?(24-r):r-1; Int_t py=6*(tmp%8)+a2y[a%6];
+ fPad[ddl][r][d][a]=AliHMPIDParam::Abs(ch,pc,px,py);
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Bool_t AliHMPIDRawStream::Raw(UInt_t w32,Int_t ddl, AliRawReader *pRR)
+{
+// Converts a given raw data word to a digit
+// Arguments: w32 - 32 bits raw data word
+// ddl - DDL idx 0 1 2 3 4 ... 13
+// Returns: none
+ Int_t r = AliBitPacking::UnpackWord(w32,22,26); assert(1<=r&&r<=24); // Row number (1..24)
+ Int_t d = AliBitPacking::UnpackWord(w32,18,21); assert(1<=d&&d<=10); // 3322 2222 2222 1111 1111 1000 0000 0000 DILOGIC number (1..10)
+ Int_t a = AliBitPacking::UnpackWord(w32,12,17); assert(0<=a&&a<=47); // 1098 7654 3210 9876 5432 1098 7654 3210 DILOGIC address (0..47)
+ Int_t q = AliBitPacking::UnpackWord(w32, 0,11); assert(0<=q&&q<=4095); // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq Qdc (0..4095)
+ if (r<1 || r>24 || d<1 || d>10 || a<0 || a>47 || q<0 || q>4095) {
+ AliWarning(Form("Invalid raw data word %x",w32));
+ pRR->AddMajorErrorLog(kInvalidRawDataWord,Form("w=%x",w32));
+ return kFALSE;
+ }
+ Raw(ddl,r,d,a);
+ fCharge[ddl][r][d][a]=q;
+ return kTRUE;
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliHMPIDRawStream::SetCharge(Int_t ddl,Int_t row,Int_t dil,Int_t pad,Int_t q)
+{
+ //Setter for the charger in the raw stream
+ //Arguments: DDL, row number, dilogic number, dilogic address(pad), charge
+ //Returns: Charge from the raw stream
+ fCharge[ddl][row][dil][pad]=q;
+ // return fCharge[ddl][row][dil][pad];
+
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Int_t AliHMPIDRawStream::GetPad(Int_t ddl,Int_t row,Int_t dil,Int_t pad)
+{
+ // The method returns the absolute pad number or -1
+ // in case the charge from the channels
+ // has not been read or invalid arguments
+
+ assert(0<=ddl&&ddl<=13);
+ assert(1<=row&&row<=24);
+ assert(1<=dil&&dil<=10);
+ assert(0<=pad&&pad<=47);
+
+ Int_t a2y[6]={3,2,4,1,5,0}; //pady for a given padress (for single DILOGIC chip)
+ Int_t ch=ddl/2;
+ Int_t tmp=(row-1)/8; Int_t pc=(ddl%2)? 5-2*tmp:2*tmp;
+ Int_t px=(dil-1)*8+pad/6;
+ tmp=(ddl%2)?(24-row):row-1;
+ Int_t py=6*(tmp%8)+a2y[pad%6];
+
+ return fPad[ddl][row][dil][pad]=AliHMPIDParam::Abs(ch,pc,px,py);
+}//GetPad()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Int_t AliHMPIDRawStream::GetCharge(Int_t ddl,Int_t row, Int_t dilogic, Int_t pad)
+{
+ // The method returns the charge collected
+ // in a particular channel
+ // Return -1 in case the charge from the channels
+ // has not been read or invalid arguments
+ if (ddl < 0 || ddl > kNDDL) {
+ AliError(Form("Wrong DDL index %d!",ddl));
+ return 0;
+ }
+ if (row < 1 || row > kNRows) {
+ AliError(Form("Wrong row index %d!",row));
+ return 0;
+ }
+
+ if (dilogic < 1 || dilogic > kNDILOGICAdd) {
+ AliError(Form("Wrong DILOGIC address %d!",dilogic));
+ return 0;
+ }
+
+ if (pad >= kNPadAdd) {
+ AliError(Form("Wrong pad index %d!",pad));
+ return 0;
+ }
+
+ return fCharge[ddl][row][dilogic][pad];
+
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliHMPIDRawStream::WriteRowMarker(AliFstream *ddl,UInt_t size)
+{
+ //Writes the row marker for real data and pedestal into the ddl stream
+ //Arguments: ddl stream and the size of the block of the given row, the siye is at least the 10 EoE words!
+ //Returns: nothing
+ UInt_t w32=0;
+ UInt_t marker=12968; //ror marker: 32a8 in hexa; 12968 in decimal
+ AliBitPacking::PackWord(size, w32, 16,31); //number of roaw written after row marker (digits and EoE)
+ AliBitPacking::PackWord(marker,w32,0,15); //32a8=12968
+ ddl->WriteBuffer((char*)&w32,sizeof(w32));
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliHMPIDRawStream::WriteEoE(AliFstream *ddl,UInt_t row,UInt_t dil,UInt_t wordCnt )
+{
+ //Writes the EoE word from real data and pedestals into the ddl stream
+ //Arguments: ddl stream, row number, dilogic number and the number of words before the EoE
+ //Retursns: nothing
+ UInt_t e=1;
+ UInt_t w32=0;
+ assert(1<=row&&row<=24); AliBitPacking::PackWord((UInt_t)row ,w32,22,26); // row number (1...24)
+ assert(1<=dil&&dil<=10); AliBitPacking::PackWord((UInt_t)dil ,w32,18,21); // DILOGIC number (1...10)
+ AliBitPacking::PackWord( e ,w32, 7,17); // event number -- not used
+ AliBitPacking::PackWord((UInt_t)wordCnt ,w32, 0, 6); // word counter (0...47) AliBitPacking::PackWord((UInt_t)1 ,w32,27,27); // bit 27 is always 1 by definition of EoE
+ AliBitPacking::PackWord((UInt_t)1 ,w32,27,27); // bit 27 is always 1 by definition of EoE
+ ddl->WriteBuffer((char*)&w32,sizeof(w32));
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliHMPIDRawStream::WriteSegMarker(AliFstream *ddl,UInt_t row)
+{
+ //Writes the segment marker (after 8 rows) into the ddl stream
+ //Arguments: ddl stream and the segment: row 8 -> 0x5800, row 16 -> 5801, row 24 -> 5802
+ //Retruns: nothing
+ UInt_t w32=0;
+ AliBitPacking::PackWord((UInt_t)43791, w32,16,31); //43791==AB0F
+ AliBitPacking::PackWord((UInt_t)(22528+row/8),w32, 0,15); //22528==5800
+
+ ddl->WriteBuffer((char*)&w32,sizeof(w32));
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Bool_t AliHMPIDRawStream::SetZeroSup (Bool_t isSup)
+{
+ //Prevision to turn OFF zero suppression
+ //Arguments: setter
+ //Returns: switch
+ fZeroSup=isSup;
+ return fZeroSup;
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Bool_t AliHMPIDRawStream::GetZeroSup()
+{
+ if(fZeroSup==kTRUE) return kTRUE;
+ else return kFALSE;
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliHMPIDRawStream::WriteRaw(TObjArray *pDigAll)
+{
+// Write a list of digits for a given chamber in raw data stream
+// Arguments: pDigAll- list of digits
+// Returns: none
+ Int_t ddl,r,d,a; //32 bits data word
+ Int_t cntLpad,cntRpad;
+ Int_t cntLrow,cntRrow;
+ Int_t cntL=0,cntR=0; //data words counters for DDLs
+ Int_t cntLeoe,cntReoe;
+ UInt_t posL,posR;
+ UInt_t cntLseg,cntRseg;
+ Int_t cntRdig=0,cntLdig=0;
+
+ UInt_t posLmarker,posRmarker;
+ Int_t digcnt=0;
+
+ Int_t isDigThere[14][25][11][48];
+
+ for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){//chambers loop
+ cntL=0;cntR=0;
+ for(Int_t iddl=0;iddl<14;iddl++){
+ for(Int_t irow=1;irow<=24;irow++){
+ for(Int_t idil=1;idil<=10;idil++){
+ for(Int_t ipad=0;ipad<48;ipad++){
+ isDigThere[iddl][irow][idil][ipad]=-1;
+ }
+ }
+ }
+ }
+
+ AliFstream* ddlL; //output streams, 2 per chamber
+ AliFstream* ddlR;
+
+ AliRawDataHeader header; header.SetAttribute(0); //empty DDL header
+
+ ddlL = new AliFstream(AliDAQ::DdlFileName("HMPID",2*iCh+1)); //left and right looking at the IP
+ ddlR = new AliFstream(AliDAQ::DdlFileName("HMPID",2*iCh)); //open both DDL of this chamber in parallel
+
+ ddlL->WriteBuffer((char*)&header,sizeof(header)); //write dummy header as place holder, actual
+ ddlR->WriteBuffer((char*)&header,sizeof(header)); //will be rewritten later when total size of DDL is known
+
+ UInt_t w32=0; //32 bits data word
+ digcnt=0;
+
+ TClonesArray *pDigCh=(TClonesArray *)pDigAll->At(iCh); //list of digits for current chamber
+ //Printf("::::::::::::::::::; Number of Digits to write: %d == %d",pDigCh->GetEntriesFast(),pDigCh->GetEntries());
+ for(Int_t iDig=0;iDig<pDigCh->GetEntriesFast();iDig++){//digits loop
+ AliHMPIDDigit *pDig1=(AliHMPIDDigit*)pDigCh->At(iDig);
+ pDig1->Raw(w32,ddl,r,d,a);
+ isDigThere[ddl][r][d][a]=iDig;
+ }
+
+ for(Int_t row = 1; row <= AliHMPIDRawStream::kNRows; row++){ //AliHMPIDRawStream::kNRows=25!
+ cntRrow=0;cntLrow=0;cntLseg=0;cntRseg=0;//
+ cntLeoe=0;cntReoe=0;
+ posLmarker=ddlL->Tellp(); WriteRowMarker(ddlL,(UInt_t)1); cntL++; cntRrow++;
+ posRmarker=ddlR->Tellp(); WriteRowMarker(ddlR,(UInt_t)1); cntR++; cntLrow++;
+ for(Int_t dil = 1; dil <= AliHMPIDRawStream::kNDILOGICAdd; dil++){ //AliHMPIDRawStream::kNDILOGICAdd = 11!
+ cntLpad=0;cntRpad=0;
+ for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){ //AliHMPIDRawStream::kNPadAdd = 48
+ for ( Int_t iddl=2*iCh; iddl<=2*iCh+1;iddl++){
+ if (isDigThere[iddl][row][dil][pad]!=-1) {
+ AliHMPIDDigit *pDig=(AliHMPIDDigit*)pDigCh->At(isDigThere[iddl][row][dil][pad]);
+ pDig->Raw(w32,ddl,r,d,a);
+ if(pDig->Q() < 0 ) continue; //We can turn of the zero sup for pedestal simulation
+ //Printf("::::::::::::::: ddl from Digit : %d",ddl);
+ if(ddl%2){ //write raw digit selecting on DDL
+ ddlL->WriteBuffer((char*)&w32,sizeof(w32)); cntL++; cntLpad++; cntLrow++; cntLdig++;//Printf(" WL: %x isDig: %d",w32,isDigThere[iddl][row][dil][pad]);
+ }else{
+ ddlR->WriteBuffer((char*)&w32,sizeof(w32)); cntR++; cntRpad++; cntRrow++; cntRdig++;//Printf(" WR: %x isDig: %d",w32,isDigThere[iddl][row][dil][pad]);
+ }
+ }//ddl
+ }//isDig
+ }//pad
+ WriteEoE(ddlL,row,dil,cntLpad); cntL++; cntLrow++; cntLeoe++; //molnarl: write EoE markers
+ WriteEoE(ddlR,row,dil,cntRpad); cntR++; cntRrow++; cntReoe++;
+ }//dil
+ if(row%8==0){
+ WriteSegMarker(ddlL,row); cntL++; cntLseg++;
+ WriteSegMarker(ddlR,row); cntR++; cntRseg++;
+ }
+ posL=ddlL->Tellp(); ddlL->Seekp(posLmarker); WriteRowMarker(ddlL,(UInt_t)(cntLrow-1)); ddlL->Seekp(posL); //find the marker position write and go back to the actual position to continue writing
+ posR=ddlR->Tellp(); ddlR->Seekp(posRmarker); WriteRowMarker(ddlR,(UInt_t)(cntRrow-1)); ddlR->Seekp(posR);
+ }//row
+ header.fSize=sizeof(header)+cntL*sizeof(w32); ddlL->Seekp(0); ddlL->WriteBuffer((char*)&header,sizeof(header)); delete ddlL; //rewrite header with size set to
+ header.fSize=sizeof(header)+cntR*sizeof(w32); ddlR->Seekp(0); ddlR->WriteBuffer((char*)&header,sizeof(header)); delete ddlR; //number of bytes and close file
+
+ //Printf("In Ch %d # digits written to LDD %d RDDL %d",iCh,cntLdig,cntRdig);
+
+ }//chambers loop
+}//WriteRaw()
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#endif
while(pRR->NextEvent()){//events loop
pAL->GetEvent(iEvtN++);
pRL->MakeTree("R"); pRich->MakeBranch("R");
-
- for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
- pRR->Select("HMPID",2*iCh,2*iCh+1);//select only DDL files for the current chamber
- UInt_t w32=0;
- while(pRR->ReadNextInt(w32)){//raw records loop (in selected DDL files)
- UInt_t ddl=pRR->GetDDLID(); //returns 0,1,2 ... 13
- dig.Raw(w32,ddl,pRR);
- AliDebug(1,Form("Ch=%i DDL=%i raw=0x%x digit=(%3i,%3i,%3i,%3i) Q=%5.2f",iCh,ddl,w32,dig.Ch(),dig.Pc(),dig.PadPcX(),dig.PadPcY(),dig.Q()));
- if(!IsDigSurvive(&dig)) continue; //sigma cut test
- new((*((TClonesArray*)digLst.At(iCh)))[iDigCnt[iCh]++]) AliHMPIDDigit(dig); //add this digit to the tmp list
- }//raw records loop
- pRR->Reset();
- }//chambers loop
-
- Dig2Clu(&digLst,pRich->CluLst());//cluster finder for all chambers
- for(Int_t i=0;i<7;i++){digLst.At(i)->Delete(); iDigCnt[i]=0;} //clean up list of digits for all chambers
-
- pRL->TreeR()->Fill(); //fill tree for current event
- pRL->WriteRecPoints("OVERWRITE");//write out clusters for current event
- pRich->CluReset();
- }//events loop
+
+ for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
+ AliHMPIDRawStream stream(pRR);
+ while(stream.Next())
+ {
+ UInt_t ddl=stream.GetDDLNumber(); //returns 0,1,2 ... 13
+ if((UInt_t)(2*iCh)==ddl || (UInt_t)(2*iCh+1)==ddl) {
+ for(Int_t row = 1; row <=AliHMPIDRawStream::kNRows; row++){
+ for(Int_t dil = 1; dil <=AliHMPIDRawStream::kNDILOGICAdd; dil++){
+ for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
+ if(stream.GetCharge(ddl,row,dil,pad) < 1) continue;
+ AliHMPIDDigit dig(stream.GetPad(ddl,row,dil,pad),stream.GetCharge(ddl,row,dil,pad));
+ if(!IsDigSurvive(&dig)) continue;
+ new((*((TClonesArray*)digLst.At(iCh)))[iDigCnt[iCh]++]) AliHMPIDDigit(dig); //add this digit to the tmp list
+ }//pad
+ }//dil
+ }//row
+ }//while stream
+ }//ch loop
+ }
+ }
+
pRL->UnloadRecPoints();
}//Reconstruct raw data
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// pDigTree - pointer to Digit tree
// Returns: none
AliDebug(1,"Start.");
- AliHMPIDDigit dig; //tmp digit, raw digit will be converted to it
+// Int_t digcnt=0;
+
+
for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
- pDigTree->Branch(Form("HMPID%d",iCh),&((*fDig)[iCh]),4000,0);
- pRR->Select("HMPID",2*iCh,2*iCh+1);//select only DDL files for the current chamber
+ pDigTree->Branch(Form("HMPID%d",iCh),&((*fDig)[iCh]),4000,0);
+
Int_t iDigCnt=0;
- UInt_t w32=0;
- while(pRR->ReadNextInt(w32)){//raw records loop (in selected DDL files)
- UInt_t ddl=pRR->GetDDLID(); //returns 0,1,2 ... 13
- if(!dig.Raw(w32,ddl,pRR)) continue;
- AliDebug(1,Form("Ch=%i DDL=%i raw=0x%x digit=(%3i,%3i,%3i,%3i) Q=%5.2f",iCh,ddl,w32,dig.Ch(),dig.Pc(),dig.PadPcX(),dig.PadPcY(),dig.Q()));
- if(!IsDigSurvive(&dig)) continue; //sigma cut test
- new((*((TClonesArray*)fDig->At(iCh)))[iDigCnt++]) AliHMPIDDigit(dig); //add this digit to the tmp list
- }//raw records loop
- pRR->Reset();
- }//chambers loop
+ AliHMPIDRawStream stream(pRR);
+ while(stream.Next())
+ {
+
+ UInt_t ddl=stream.GetDDLNumber(); //returns 0,1,2 ... 13
+ if((UInt_t)(2*iCh)==ddl || (UInt_t)(2*iCh+1)==ddl) {
+ for(Int_t row = 1; row <= AliHMPIDRawStream::kNRows; row++){
+ for(Int_t dil = 1; dil <= AliHMPIDRawStream::kNDILOGICAdd; dil++){
+ for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
+ if(stream.GetCharge(ddl,row,dil,pad) < 1) continue;
+ AliHMPIDDigit dig(stream.GetPad(ddl,row,dil,pad),stream.GetCharge(ddl,row,dil,pad));
+ if(!IsDigSurvive(&dig)) continue;
+ new((*((TClonesArray*)fDig->At(iCh)))[iDigCnt++]) AliHMPIDDigit(dig); //add this digit to the tmp list
+ }//pad
+ }//dil
+ }//row
+ }//while
+ }
+ stream.Delete();
+ }
pDigTree->Fill();
+
for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++)fDig->At(iCh)->Clear();
+
AliDebug(1,"Stop.");
}//Reconstruct digits from raw digits
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#include <AliReconstructor.h> //base class
#include "AliHMPIDTracker.h" //CreateTracker()
#include "AliHMPIDDigit.h" //Dig2Clu(), UseDig()
+#include "AliHMPIDRawStream.h" //ConvertDigits()
+
#include <TMatrixF.h> //UseDig()
#include <TClonesArray.h> //UseDig()
#include <TObjArray.h> //SigConv()
#include "AliHMPIDParam.h" //StepManager()
#include "AliHMPIDHit.h" //Hits2SDigs(),StepManager()
#include "AliHMPIDDigit.h" //Digits2Raw(), Raw2SDigits()
+#include "AliHMPIDRawStream.h" //Digits2Raw(), Raw2SDigits()
#include "AliRawReader.h" //Raw2SDigits()
#include <TVirtualMC.h> //StepManager() for gMC
#include <TPDGCode.h> //StepHistory()
}
treeD->GetEntry(0);
- AliHMPIDDigit::WriteRaw(DigLst());
+ //AliHMPIDDigit::WriteRaw(DigLst());
+ AliHMPIDRawStream *pRS;
+ pRS->WriteRaw(DigLst());
GetLoader()->UnloadDigits();
AliDebug(1,"Stop.");
// Interface methode ivoked from AliSimulation to create a list of sdigits from raw digits. Events loop is done in AliSimulation
// Arguments: pRR- raw reader
// Returns: kTRUE on success (currently ignored in AliSimulation::ConvertRaw2SDigits())
- AliHMPIDDigit sdi; //tmp sdigit, raw digit will be converted to it
+ //AliHMPIDDigit sdi; //tmp sdigit, raw digit will be converted to it
if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
TClonesArray *pSdiLst=SdiLst(); Int_t iSdiCnt=0; //tmp list of sdigits for all chambers
- pRR->Select("HMPID",0,13);//select all HMPID DDL files
- UInt_t w32=0;
- while(pRR->ReadNextInt(w32)){//raw records loop (in selected DDL files)
- UInt_t ddl=pRR->GetDDLID(); //returns 0,1,2 ... 13
- if(!sdi.Raw(ddl,w32,pRR)) continue;
- new((*pSdiLst)[iSdiCnt++]) AliHMPIDDigit(sdi); //add this digit to the tmp list
- }//raw records loop
+ AliHMPIDRawStream stream(pRR);
+ while(stream.Next())
+ {
+ UInt_t ddl=stream.GetDDLNumber(); //returns 0,1,2 ... 13
+ for(Int_t row = 1; row <=AliHMPIDRawStream::kNRows; row++){
+ for(Int_t dil = 1; dil <= AliHMPIDRawStream::kNDILOGICAdd; dil++){
+ for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
+ if(stream.GetCharge(ddl,row,dil,pad)<1) continue;
+ AliHMPIDDigit sdi(stream.GetPad(ddl,row,dil,pad),stream.GetCharge(ddl,row,dil,pad));
+ new((*pSdiLst)[iSdiCnt++]) AliHMPIDDigit(sdi); //add this digit to the tmp list
+ }//pad
+ }//dil
+ }//row
+ }
+
GetLoader()->TreeS()->Fill(); GetLoader()->WriteSDigits("OVERWRITE");//write out sdigits
SdiReset();
return kTRUE;
-
// **************************************************************************
// * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
// * *
#include "AliHMPIDParam.h" //StepManager()
#include "AliHMPIDHit.h" //Hits2SDigs(),StepManager()
#include "AliHMPIDDigit.h" //Digits2Raw(), Raw2SDigits()
+#include "AliHMPIDRawStream.h" //Digits2Raw(), Raw2SDigits()
#include "AliRawReader.h" //Raw2SDigits()
#include <TVirtualMC.h> //StepManager() for gMC
#include <TPDGCode.h> //StepHistory()
}
treeD->GetEntry(0);
- AliHMPIDDigit::WriteRaw(DigLst());
-
+
+ AliHMPIDRawStream *pRS;
+ pRS->WriteRaw(DigLst());
+
GetLoader()->UnloadDigits();
AliDebug(1,"Stop.");
}//Digits2Raw()
// Interface methode ivoked from AliSimulation to create a list of sdigits from raw digits. Events loop is done in AliSimulation
// Arguments: pRR- raw reader
// Returns: kTRUE on success (currently ignored in AliSimulation::ConvertRaw2SDigits())
+
AliHMPIDDigit sdi; //tmp sdigit, raw digit will be converted to it
-
if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
TClonesArray *pSdiLst=SdiLst(); Int_t iSdiCnt=0; //tmp list of sdigits for all chambers
- pRR->Select("HMPID",0,13);//select all HMPID DDL files
- UInt_t w32=0;
- while(pRR->ReadNextInt(w32)){//raw records loop (in selected DDL files)
- UInt_t ddl=pRR->GetDDLID(); //returns 0,1,2 ... 13
- if(!sdi.Raw(ddl,w32,pRR)) continue;
- new((*pSdiLst)[iSdiCnt++]) AliHMPIDDigit(sdi); //add this digit to the tmp list
- }//raw records loop
+ AliHMPIDRawStream stream(pRR);
+ while(stream.Next())
+ {
+ UInt_t ddl=stream.GetDDLNumber(); //returns 0,1,2 ... 13
+ for(Int_t row = 1; row <=AliHMPIDRawStream::kNRows; row++){
+ for(Int_t dil = 1; dil <=AliHMPIDRawStream::kNDILOGICAdd; dil++){
+ for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
+ if(stream.GetCharge(ddl,row,dil,pad)<1) continue;
+ AliHMPIDDigit sdi(stream.GetPad(ddl,row,dil,pad),stream.GetCharge(ddl,row,dil,pad));
+ new((*pSdiLst)[iSdiCnt++]) AliHMPIDDigit(sdi); //add this digit to the tmp list
+ }//pad
+ }//dil
+ }//row
+ }
+
GetLoader()->TreeS()->Fill(); GetLoader()->WriteSDigits("OVERWRITE");//write out sdigits
SdiReset();
return kTRUE;
else
if(gMC->IsTrackStop()) flag="stoped in";
-
-
-
Int_t vid=0,copy=0;
TString path=gMC->CurrentVolName(); path.Prepend("-");path.Prepend(gMC->CurrentVolOffName(1));//current volume and his mother are always there
vid=gMC->CurrentVolOffID(2,copy); if(vid) {path.Prepend("-");path.Prepend(gMC->VolName(vid));}
#pragma link C++ class AliHMPIDPreprocessor+;
#pragma link C++ class AliHMPIDQualAssDataMaker+;
#pragma link C++ class AliHMPIDQualAssChecker+;
+#pragma link C++ class AliHMPIDCalib+;
+#pragma link C++ class AliHMPIDRawStream+;
#endif
//AliRoot
#include "AliHMPIDRawStream.h"
+#include "AliHMPIDCalib.h"
#include "AliRawReaderDate.h"
#include "AliBitPacking.h"
#include "TMath.h"
//ROOT
#include "TFile.h"
+#include "TSystem.h"
#include "TKey.h"
#include "TH2S.h"
#include "TObject.h"
#include "TBenchmark.h"
#include "TMath.h"
#include "TRandom.h"
+#include "TTree.h"
+#include "TTreePlayer.h"
+
int main(int argc, char **argv){
daqDA_progressReport(10);
- /* init some counters */
- Double_t SummQ[14][48][11][25], SummQ2[14][48][11][25];
- Int_t nEntries[14][48][11][25];
- Bool_t isDDLOn[14];
- for(Int_t ddl=0;ddl<=13;ddl++) {
- isDDLOn[ddl] = kFALSE;
- for(Int_t row=1;row<=24;row++)
- for(Int_t dil=1;dil<=10;dil++)
- for(Int_t adr=0;adr<=47;adr++)
- {
- SummQ[ddl][adr][dil][row]=0;
- SummQ2[ddl][adr][dil][row]=0;
- nEntries[ddl][adr][dil][row]=0;
- }
- }
-
+ /* init the pedestal calculation */
+ AliHMPIDCalib *pCal=new AliHMPIDCalib();
+ //pCal->Init(); //Init the pedestal calculation
+
/* init event counter */
Int_t iEvtNcal=0;
/* use event - here, just write event id to result file */
eventT=event->eventType;
- if (eventT==PHYSICS_EVENT) {
+ if (eventT==PHYSICS_EVENT) { //we use PHYSICS_EVENT for pedestal not CALIBRATION_EVENT
iEvtNcal++;
AliHMPIDRawStream stream(reader);
while(stream.Next()) {
-
- Int_t ddl = stream.GetDDLNumber();
-
- for(Int_t row=1; row < 25; row++)
- for(Int_t dil=1; dil < 11; dil++)
- for(Int_t adr=0; adr < 48; adr++) {
- Short_t q = stream.GetCharge(row,dil,adr);
- if (q<0) continue;
-
- SummQ[ddl][adr][dil][row] += q;
- SummQ2[ddl][adr][dil][row] += (q*q);
- nEntries[ddl][adr][dil][row]++;
- isDDLOn[ddl] = kTRUE;
- }
+ Int_t ddl=stream.GetDDLNumber();
+ for(Int_t row = 1; row <=AliHMPIDRawStream::kNRows; row++){
+ for(Int_t dil = 1; dil <=AliHMPIDRawStream::kNDILOGICAdd; dil++){
+ for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
+ pCal->FillPedestal(ddl,row,dil,pad,stream.GetCharge(ddl,row,dil,pad));
+ }//pad
+ }//dil
+ }//row
} //raw data loop
delete reader;
daqDA_progressReport(90);
for(Int_t ddl=0; ddl < 14; ddl++) {
- if (!isDDLOn[ddl]) continue;
-
- ofstream out;
- out.open(Form("./HmpidPedDdl%02i.txt",ddl));
-
- for(Int_t row=1; row < 25; row++)
- for(Int_t dil=1; dil < 11; dil++)
- for(Int_t adr=0; adr < 48; adr++) {
-
- Int_t n = nEntries[ddl][adr][dil][row];
- if (!n) {
- printf("No data for channel: %d %d %d %d\n",ddl,adr,dil,row);
- continue;
- }
- Double_t mean = SummQ[ddl][adr][dil][row]/n;
- if ((SummQ2[ddl][adr][dil][row]/n - (SummQ[ddl][adr][dil][row]/n)*(SummQ[ddl][adr][dil][row]/n)) < 0) {
- printf("Invalid sums: %d %d %d %d %f %f\n",row,dil,adr,n,SummQ[ddl][adr][dil][row],SummQ2[ddl][adr][dil][row]);
- return -1;
- }
- Float_t sigma = TMath::Sqrt(SummQ2[ddl][adr][dil][row]/n - (mean*mean));
- Int_t inhard=((Int_t(mean))<<9)+Int_t(mean+3*sigma);
-
- out << Form("%2i %2i %2i %5.2f %5.2f %x\n",row,dil,adr,mean,sigma,inhard);
- }
-
+
+ /* Calculate pedestal for the given ddl, if there is no ddl go t next */
+ if(!pCal->CalcPedestal(ddl,Form("./HmpidPedDdl%02i.txt",ddl))) continue;
+
/* store the result file on FES */
status=daqDA_FES_storeFile(Form("./HmpidPedDdl%02i.txt",ddl),Form("HMPID_DA_Pedestals_ddl=%02i",ddl));
if (status) {
printf("Failed to export file : %d\n",status);
return -1;
}
- }
-
+ }//ddl
/* report progress */
daqDA_progressReport(100);
#pragma link C++ class AliHMPIDReconstructor+;
#pragma link C++ class AliHMPIDTracker+;
#pragma link C++ class AliHMPIDRecon+;
-#pragma link C++ class AliHMPIDRawStream+;
#endif
FILE *fp=fopen(Form("%s.C",sBatchName),"w"); if(!fp){Info("CreateBatch","Cannot open output file: %s.C",sBatchName);return;}
fprintf(fp,"void %s(Int_t iNevt,Bool_t isDbg,char *sCfg)\n{\n",sBatchName);
- fprintf(fp," gSystem->Exec(\"rm -rf hlt hough gphysi* fort* ZZZ*\"); //remove garbage\n");
+ fprintf(fp," gSystem->Exec(\"rm -rf hlt hough gphysi* fort* ZZZ* raw*\"); //remove garbage\n");
fprintf(fp," gBenchmark->Start(\"ALICE\"); TDatime time; //start benchmarking\n\n");
fprintf(fp," if(isDbg) AliLog::SetGlobalDebugLevel(AliLog::kDebug);\n");
//simulation section
- if(fSimB->GetState()){
- fprintf(fp," gSystem->Exec(\"rm -rf *.root \"); //remove previous simulation\n");
+ if(fSimB->GetState()){ fprintf(fp," gSystem->Exec(\"rm -rf *.root \"); //remove previous simulation\n");
+ fprintf(fp," gSystem->Exec(\"rm -rf *.date \"); //remove previous simulation\n");
fprintf(fp," AliSimulation *pSim=new AliSimulation(sCfg); //init simulation\n");
if(fTraB->GetState()) fprintf(fp," pSim->SetRunSimulation(kTRUE); //transport and hits creation\n");
if (fInpBG->GetButton(kNo )->GetState()) fprintf(fp," pRec->SetInput(\"\"); //from digits\n");
else if(fInpBG->GetButton(kDdl)->GetState()) fprintf(fp," pRec->SetInput(\"./\"); //from raw data in DDL format\n");
- else if(fInpBG->GetButton(kDat)->GetState()) fprintf(fp," pRec->SetInput(\"raw.root.date\"); //from raw data in DATE format\n");
+ else if(fInpBG->GetButton(kDat)->GetState()) fprintf(fp," pRec->SetInput(\"raw.date\"); //from raw data in DATE format\n");
else if(fInpBG->GetButton(kRoo)->GetState()) fprintf(fp," pRec->SetInput(\"raw.root\"); //from raw data in ROOT format\n");
if (fCluBG->GetButton(kAll) ->GetState()) fprintf(fp," pRec->SetRunLocalReconstruction(\"%s\"); //clusters for all detectors\n",det.Data());
SRCS:= AliHMPIDHit.cxx AliHMPIDDigit.cxx AliHMPIDCluster.cxx AliHMPIDParam.cxx AliHMPIDPreprocessor.cxx \
- AliHMPIDQualAssDataMaker.cxx AliHMPIDQualAssChecker.cxx
+ AliHMPIDQualAssDataMaker.cxx AliHMPIDQualAssChecker.cxx AliHMPIDCalib.cxx AliHMPIDRawStream.cxx
HDRS:= $(SRCS:.cxx=.h)
DHDR:= HMPIDbaseLinkDef.h
-SRCS:= AliHMPIDReconstructor.cxx AliHMPIDTracker.cxx AliHMPIDRecon.cxx AliHMPIDRawStream.cxx
+SRCS:= AliHMPIDReconstructor.cxx AliHMPIDTracker.cxx AliHMPIDRecon.cxx
HDRS:= $(SRCS:.cxx=.h)
DHDR:= HMPIDrecLinkDef.h