// --- AliRoot header files
#include "AliDetector.h"
-#include "AliRawDataHeader.h"
+#include "AliRawDataHeaderSim.h"
#include "AliRawReader.h"
#include "AliLoader.h"
#include "AliRun.h"
#include "AliZDCDigit.h"
#include "AliZDCDigitizer.h"
#include "AliZDCRawStream.h"
-#include "AliZDCCalibData.h"
+#include "AliZDCPedestals.h"
+#include "AliZDCCalib.h"
#include "AliFstream.h"
ClassImp(AliZDC)
-AliZDC *gAliZDC;
-
//_____________________________________________________________________________
AliZDC::AliZDC() :
AliDetector(),
- fNoShower (0),
- fCalibData (0)
-
+ fNoShower(0),
+ fPedCalib(0),
+ fCalibData(0),
+ fZDCCalibFName("")
{
//
// Default constructor for the Zero Degree Calorimeter base class
AliZDC::AliZDC(const char *name, const char *title) :
AliDetector(name,title),
fNoShower (0),
- fCalibData (0)
-
+ fPedCalib(0),
+ fCalibData(0),
+ fZDCCalibFName("")
{
//
// Standard constructor for the Zero Degree Calorimeter base class
sprintf(senstitle,"ZDC dummy");
SetName(sensname); SetTitle(senstitle);
- gAliZDC = this;
-
}
//____________________________________________________________________________
//
fIshunt = 0;
- gAliZDC = 0;
-
+ delete fPedCalib;
delete fCalibData;
}
//_____________________________________________________________________________
AliZDC::AliZDC(const AliZDC& ZDC) :
- AliDetector("ZDC","ZDC")
+AliDetector("ZDC","ZDC"),
+fNoShower(ZDC.fNoShower),
+fPedCalib(ZDC.fPedCalib),
+fCalibData(ZDC.fCalibData),
+fZDCCalibFName(ZDC.fZDCCalibFName)
{
// copy constructor
- fNoShower = ZDC.fNoShower;
- fCalibData = ZDC.fCalibData;
- fZDCCalibFName = ZDC.fZDCCalibFName;
}
//_____________________________________________________________________________
// assignement operator
if(this!=&ZDC){
fNoShower = ZDC.fNoShower;
+ fPedCalib = ZDC.fPedCalib;
fCalibData = ZDC.fCalibData;
fZDCCalibFName = ZDC.fZDCCalibFName;
} return *this;
// obtain digits at the end of each event
//
- static Float_t primKinEn, xImpact, yImpact, sFlag;
+ static Float_t primKinEn=0., xImpact=0., yImpact=0., sFlag=0.;
+ static Int_t pcPDGcode;
AliZDCHit *newquad, *curprimquad;
newquad = new AliZDCHit(fIshunt, track, vol, hits);
if(fNhits==0){
// First hit -> setting flag for primary or secondary particle
Int_t primary = gAlice->GetMCApp()->GetPrimary(track);
+ //
if(track != primary){
newquad->SetSFlag(1); // SECONDARY particle entering the ZDC
}
primKinEn = newquad->GetPrimKinEn();
xImpact = newquad->GetXImpact();
yImpact = newquad->GetYImpact();
+ pcPDGcode = newquad->GetPDGCode();
}
else{
newquad->SetPrimKinEn(primKinEn);
newquad->SetXImpact(xImpact);
newquad->SetYImpact(yImpact);
newquad->SetSFlag(sFlag);
+ newquad->SetPDGCode(pcPDGcode);
}
Int_t j;
top=gAlice->GetGeometry()->GetNode("alice");
// ZDC
- brik = new TBRIK("S_ZDC","ZDC box","void",300,300,5);
- top->cd();
- node = new TNode("ZDC","ZDC","S_ZDC",0,0,600,"");
- node->SetLineColor(kColorZDC);
- fNodes->Add(node);
+ brik = new TBRIK("S_ZDC","ZDC box","void",300,300,5);
+ top->cd();
+ node = new TNode("ZDC","ZDC","S_ZDC",0,0,600,"");
+ node->SetLineColor(kColorZDC);
+ fNodes->Add(node);
}
//____________________________________________________________________________
{
// Create summable digits from hits
- AliDebug(1,"\n Entering AliZDC::Hits2Digits() ");
+ AliDebug(1,"\n Entering AliZDC::Hits2SDigits() ");
fLoader->LoadHits("read");
fLoader->LoadSDigits("recreate");
// Event loop
for(Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
- Float_t pmCZN = 0, pmCZP = 0, pmQZN[4], pmQZP[4], pmZEM1 = 0, pmZEM2 = 0;
- for(Int_t i = 0; i < 4; i++) pmQZN[i] = pmQZP[i] = 0;
+ Float_t pmCZNC=0, pmCZPC=0, pmCZNA=0, pmCZPA=0, pmZEM1 = 0, pmZEM2 = 0;
+ Float_t pmQZNC[4], pmQZPC[4], pmQZNA[4], pmQZPA[4];
+ for(Int_t i = 0; i < 4; i++) pmQZNC[i] = pmQZPC[i] = pmQZNA[i] = pmQZPA[i] = 0;
runLoader->GetEvent(iEvent);
TTree* treeH = fLoader->TreeH();
sector[0] = zdcHit->GetVolume(0);
sector[1] = zdcHit->GetVolume(1);
- if((sector[1] < 1) || (sector[1] > 4)) {
+ if((sector[1] < 1) || (sector[1] > 5)) {
Error("Hits2SDigits", "sector[0] = %d, sector[1] = %d",
sector[0], sector[1]);
continue;
Float_t lightQ = zdcHit->GetLightPMQ();
Float_t lightC = zdcHit->GetLightPMC();
- if(sector[0] == 1) { //ZN
- pmCZN += lightC;
- pmQZN[sector[1]-1] += lightQ;
- } else if(sector[0] == 2) { //ZP
- pmCZP += lightC;
- pmQZP[sector[1]-1] += lightQ;
- } else if(sector[0] == 3) { //ZEM
+ if(sector[0] == 1) { //ZNC
+ pmCZNC += lightC;
+ pmQZNC[sector[1]-1] += lightQ;
+ }
+ else if(sector[0] == 2) { //ZPC
+ pmCZPC += lightC;
+ pmQZPC[sector[1]-1] += lightQ;
+ }
+ else if(sector[0] == 3) { //ZEM
if(sector[1] == 1) pmZEM1 += lightC;
- else pmZEM2 += lightQ;
+ else pmZEM2 += lightQ;
}
+ if(sector[0] == 4) { //ZNA
+ pmCZNA += lightC;
+ pmQZNA[sector[1]-1] += lightQ;
+ }
+ else if(sector[0] == 5) { //ZPA
+ pmCZPA += lightC;
+ pmQZPA[sector[1]-1] += lightQ;
+ }
}//Hits loop
}
const Int_t kBufferSize = 4000;
treeS->Branch(GetName(), "AliZDCSDigit", &psdigit, kBufferSize);
- // Create sdigits for ZN1
- sector[0] = 1; // Detector = ZN1
+ // Create sdigits for ZNC
+ sector[0] = 1; // Detector = ZNC
sector[1] = 0; // Common PM ADC
- new(psdigit) AliZDCSDigit(sector, pmCZN);
- if(pmCZN > 0) treeS->Fill();
+ new(psdigit) AliZDCSDigit(sector, pmCZNC);
+ if(pmCZNC > 0) treeS->Fill();
for(Int_t j = 0; j < 4; j++) {
sector[1] = j+1; // Towers PM ADCs
- new(psdigit) AliZDCSDigit(sector, pmQZN[j]);
- if(pmQZN[j] > 0) treeS->Fill();
+ new(psdigit) AliZDCSDigit(sector, pmQZNC[j]);
+ if(pmQZNC[j] > 0) treeS->Fill();
}
- // Create sdigits for ZP1
- sector[0] = 2; // Detector = ZP1
+ // Create sdigits for ZPC
+ sector[0] = 2; // Detector = ZPC
sector[1] = 0; // Common PM ADC
- new(psdigit) AliZDCSDigit(sector, pmCZP);
- if(pmCZP > 0) treeS->Fill();
+ new(psdigit) AliZDCSDigit(sector, pmCZPC);
+ if(pmCZPC > 0) treeS->Fill();
for(Int_t j = 0; j < 4; j++) {
sector[1] = j+1; // Towers PM ADCs
- new(psdigit) AliZDCSDigit(sector, pmQZP[j]);
- if(pmQZP[j] > 0) treeS->Fill();
+ new(psdigit) AliZDCSDigit(sector, pmQZPC[j]);
+ if(pmQZPC[j] > 0) treeS->Fill();
}
// Create sdigits for ZEM
new(psdigit) AliZDCSDigit(sector, pmZEM2);
if(pmZEM2 > 0) treeS->Fill();
+ // Create sdigits for ZNA
+ sector[0] = 4; // Detector = ZNA
+ sector[1] = 0; // Common PM ADC
+ new(psdigit) AliZDCSDigit(sector, pmCZNA);
+ if(pmCZNA > 0) treeS->Fill();
+ for(Int_t j = 0; j < 4; j++) {
+ sector[1] = j+1; // Towers PM ADCs
+ new(psdigit) AliZDCSDigit(sector, pmQZNA[j]);
+ if(pmQZNA[j] > 0) treeS->Fill();
+ }
+
+ // Create sdigits for ZPA
+ sector[0] = 5; // Detector = ZPA
+ sector[1] = 0; // Common PM ADC
+ new(psdigit) AliZDCSDigit(sector, pmCZPA);
+ if(pmCZPA > 0) treeS->Fill();
+ for(Int_t j = 0; j < 4; j++) {
+ sector[1] = j+1; // Towers PM ADCs
+ new(psdigit) AliZDCSDigit(sector, pmQZPA[j]);
+ if(pmQZPA[j] > 0) treeS->Fill();
+ }
+
// write the output tree
fLoader->WriteSDigits("OVERWRITE");
}
}
// *** ADC2 (Reference PTMs) or ADC4 (Reference PTMs o.o.t.)
else if(digit.GetSector(1)==5){
- index = 20 + (digit.GetSector(0)-1)*1/3;
- lADCDataChannel = 5 + (digit.GetSector(0)-1)*8/3;
+ index = 20 + (digit.GetSector(0)-1)/3;
+ lADCDataChannel = 5 + 8*(digit.GetSector(0)-1)/3;
//
/*printf("\t AliZDC::Digits2Raw -> idig%d det %d quad %d index %d, ADCch %d ADCVal[%d, %d]\n",
iDigit,digit.GetSector(0),digit.GetSector(1),index,lADCDataChannel,
}
//
/*
- for(Int_t i=0;i<24;i++) printf("\t ADCData1[%d] = %x\n",i,lADCData1[i]);
- for(Int_t i=0;i<20;i++) printf("\t ADCData2[%d] = %x\n",i,lADCData2[i]);
- for(Int_t i=0;i<24;i++) printf("\t ADCData3[%d] = %x\n",i,lADCData3[i]);
- for(Int_t i=0;i<20;i++) printf("\t ADCData4[%d] = %x\n",i,lADCData4[i]);
+ for(Int_t i=0;i<knADCData1;i++) printf("\t ADCData1[%d] = %x\n",i,lADCData1[i]);
+ for(Int_t i=0;i<knADCData2;i++) printf("\t ADCData2[%d] = %x\n",i,lADCData2[i]);
+ for(Int_t i=0;i<knADCData1;i++) printf("\t ADCData3[%d] = %x\n",i,lADCData3[i]);
+ for(Int_t i=0;i<knADCData2;i++) printf("\t ADCData4[%d] = %x\n",i,lADCData4[i]);
*/
// End of Block
AliFstream* file = new AliFstream(fileName);
// write the DDL data header
- AliRawDataHeader header;
+ AliRawDataHeaderSim header;
header.fSize = sizeof(header) +
sizeof(lADCHeader1) + sizeof(lADCData1) + sizeof(lADCEndBlock) +
sizeof(lADCHeader2) + sizeof(lADCData2) + sizeof(lADCEndBlock) +
treeS->Branch("ZDC", "AliZDCSDigit", &psdigit, kBufferSize);
//
AliZDCRawStream rawStream(rawReader);
- Int_t sector[2], ADCRes, ADCRaw, ADCPedSub, nPheVal;
+ Int_t sector[2], resADC, rawADC, corrADC, nPheVal;
Int_t jcount = 0;
while(rawStream.Next()){
if(rawStream.IsADCDataWord()){
//For the moment only in-time SDigits are foreseen (1st 48 raw values)
if(jcount < 48){
for(Int_t j=0; j<2; j++) sector[j] = rawStream.GetSector(j);
- ADCRaw = rawStream.GetADCValue();
- ADCRes = rawStream.GetADCGain();
+ rawADC = rawStream.GetADCValue();
+ resADC = rawStream.GetADCGain();
//printf("\t RAw2SDigits raw%d -> RawADC[%d, %d, %d] read\n",
- // jcount, sector[0], sector[1], ADCRaw);
+ // jcount, sector[0], sector[1], rawADC);
//
- ADCPedSub = ADCRaw - Pedestal(sector[0], sector[1], ADCRes);
- if(ADCPedSub<0) ADCPedSub=0;
- nPheVal = ADCch2Phe(sector[0], sector[1], ADCPedSub, ADCRes);
+ corrADC = rawADC - Pedestal(sector[0], sector[1], resADC);
+ if(corrADC<0) corrADC=0;
+ nPheVal = ADCch2Phe(sector[0], sector[1], corrADC, resADC);
//
//printf("\t \t -> SDigit[%d, %d, %d] created\n",
// sector[0], sector[1], nPheVal);
//
// Getting calibration object for ZDC set
AliCDBManager *man = AliCDBManager::Instance();
- AliCDBEntry *entry = man->Get("ZDC/Calib/Data");
- AliZDCCalibData *CalibData = (AliZDCCalibData*) entry->GetObject();
+ AliCDBEntry *entry = man->Get("ZDC/Calib/Pedestals");
+ AliZDCPedestals *calibPed = (AliZDCPedestals*) entry->GetObject();
//
- if(!CalibData){
+ if(!calibPed){
printf("\t No calibration object found for ZDC!");
return -1;
}
//
- Float_t PedValue;
- Float_t meanPed, Pedwidth;
- Int_t index=0;
+ Int_t index=0, kNch=24;
if(Quad!=5){
- if(Det==1 || Det==2) index = 10*(Det-1)+Quad+5*Res; // ZN1, ZP1
- else if(Det==3) index = 10*(Det-1)+(Quad-1)+Res; // ZEM
- else if(Det==4 || Det==5) index = 10*(Det-2)+Quad+5*Res+4; // ZN2, ZP2
+ if(Det==1) index = Quad+kNch*Res; // ZN1
+ else if(Det==2) index = Quad+5+kNch*Res; // ZP1
+ else if(Det==3) index = Quad+9+kNch*Res; // ZEM
+ else if(Det==4) index = Quad+12+kNch*Res; // ZN2
+ else if(Det==5) index = Quad+17+kNch*Res; // ZP2
}
- else index = 10*(Quad-1)+(Det-1)*1/3+2*Res+4; // Reference PMs
+ else index = (Det-1)/3+22+kNch*Res; // Reference PMs
//
//
- meanPed = CalibData->GetMeanPed(index);
- Pedwidth = CalibData->GetMeanPedWidth(index);
- PedValue = gRandom->Gaus(meanPed,Pedwidth);
+ Float_t meanPed = calibPed->GetMeanPed(index);
+ Float_t pedWidth = calibPed->GetMeanPedWidth(index);
+ Float_t pedValue = gRandom->Gaus(meanPed,pedWidth);
//
- //printf("\t AliZDC::Pedestal - det(%d, %d) - Ped[%d] = %d\n",Det, Quad, index,(Int_t) PedValue); // Chiara debugging!
+ //printf("\t AliZDC::Pedestal - det(%d, %d) - Ped[%d] = %d\n",Det, Quad, index,(Int_t) pedValue); // Chiara debugging!
- return (Int_t) PedValue;
+ return (Int_t) pedValue;
}
Int_t AliZDC::ADCch2Phe(Int_t Det, Int_t Quad, Int_t ADCVal, Int_t Res) const
{
// Evaluation of the no. of phe produced
- Float_t PMGain[6][5];
- Float_t ADCRes[2];
+ Float_t pmGain[6][5];
+ Float_t resADC[2];
for(Int_t j = 0; j < 5; j++){
- PMGain[0][j] = 50000.;
- PMGain[1][j] = 100000.;
- PMGain[2][j] = 100000.;
- PMGain[3][j] = 50000.;
- PMGain[4][j] = 100000.;
- PMGain[5][j] = 100000.;
+ pmGain[0][j] = 50000.;
+ pmGain[1][j] = 100000.;
+ pmGain[2][j] = 100000.;
+ pmGain[3][j] = 50000.;
+ pmGain[4][j] = 100000.;
+ pmGain[5][j] = 100000.;
}
// ADC Caen V965
- ADCRes[0] = 0.0000008; // ADC Resolution high gain: 200 fC/adcCh
- ADCRes[1] = 0.0000064; // ADC Resolution low gain: 25 fC/adcCh
+ resADC[0] = 0.0000008; // ADC Resolution high gain: 200 fC/adcCh
+ resADC[1] = 0.0000064; // ADC Resolution low gain: 25 fC/adcCh
//
- Int_t nPhe = (Int_t) (ADCVal * PMGain[Det-1][Quad] * ADCRes[Res]);
+ Int_t nPhe = (Int_t) (ADCVal * pmGain[Det-1][Quad] * resADC[Res]);
//
//printf("\t AliZDC::ADCch2Phe -> det(%d, %d) - ADC %d phe %d\n",Det,Quad,ADCVal,nPhe);
AliDetector::SetTreeAddress();
}
-
-//________________________________________________________________
-void AliZDC::CreateCalibData()
-{
- //
- //if(fCalibData) delete fCalibData; // delete previous version
- fCalibData = new AliZDCCalibData(GetName());
-}
-//________________________________________________________________
-void AliZDC::WriteCalibData(Int_t option)
-{
- //
- const int kCompressLevel = 9;
- char* fnam = GetZDCCalibFName();
- if(!fnam || fnam[0]=='\0') {
- fnam = gSystem->ExpandPathName("$(ALICE_ROOT)/data/AliZDCCalib.root");
- Warning("WriteCalibData","No File Name is provided, using default %s",fnam);
- }
- TFile* cdfile = TFile::Open(fnam,"UPDATE","",kCompressLevel);
-
- // Writes Calibration Data to current directory.
- // User MUST take care of corresponding file opening and ->cd()... !!!
- // By default, the object is overwritten. Use 0 option for opposite.
- if(option) option = TObject::kOverwrite;
- if(fCalibData) fCalibData->Write(0,option);
- else if(fCalibData) fCalibData->Write(0,option);
-
- cdfile->Close();
- delete cdfile;
-}
-
-//________________________________________________________________
-void AliZDC::LoadCalibData()
-{
- //
- char* fnam = GetZDCCalibFName();
- if(!fnam || fnam[0]=='\0') return;
- if(!gAlice->IsFileAccessible(fnam)) {
- Error("LoadCalibData","ZDC Calibration Data file is not accessible, %s",fnam);
- exit(1);
- }
- TFile* cdfile = TFile::Open(fnam);
-
- // Loads Calibration Data from current directory.
- // User MUST take care of corresponding file opening and ->cd()...!!!
- //
- if(fCalibData) delete fCalibData; // delete previous version
- TString dtname = "Calib_";
- dtname += GetName();
- fCalibData = (AliZDCCalibData*) gDirectory->Get(dtname.Data());
- if(!fCalibData) {
- Error("LoadCalibData","No Calibration data found for %s",GetName());
- exit(1);
- }
-
- cdfile->Close();
- delete cdfile;
-}
-