#include "AliGenHijingEventHeader.h"
#include "AliRunDigitizer.h"
#include "AliRunLoader.h"
+#include "AliCDBManager.h"
+#include "AliCDBEntry.h"
#include "AliZDCSDigit.h"
#include "AliZDCDigit.h"
#include "AliZDCFragment.h"
#include "AliZDCDigitizer.h"
+class AliCDBStorage;
+class AliZDCCalibData;
+
ClassImp(AliZDCDigitizer)
AliZDCDigitizer::AliZDCDigitizer(AliRunDigitizer* manager):
AliDigitizer(manager)
{
-// Constructor
+ fIsCalibration=0; //By default the simulation doesn't create calib. data
+ // Get calibration data
+ fCalibData = GetCalibData();
+ if(fIsCalibration!=0) printf("\t **** AliZDCDigitizer -> Creating calibration data (pedestals)\n");
}
//____________________________________________________________________________
-Bool_t AliZDCDigitizer::Init()
+AliZDCDigitizer::AliZDCDigitizer(const AliZDCDigitizer &digitizer):
+ AliDigitizer()
{
-// Initialize the digitizer
+ // Copy constructor
- for (Int_t i = 0; i < 3; i++) {
- for(Int_t j = 0; j < 5; j++) {
- fPMGain[i][j] = 100000.;
- }
+ for(Int_t i=0; i<6; i++){
+ for(Int_t j=0; j<5; j++){
+ fPMGain[i][j] = digitizer.fPMGain[i][j];
+ }
}
+ for(Int_t i=0; i<2; i++) fADCRes[i] = digitizer.fADCRes[i];
+ fIsCalibration = digitizer.fIsCalibration;
+ fCalibData = digitizer.fCalibData;
+
+}
-// ADC Caen V965
- fADCRes[0] = 0.0000008; // ADC Resolution high gain: 200 fC/adcCh
- fADCRes[1] = 0.0000064; // ADC Resolution low gain: 25 fC/adcCh
+//____________________________________________________________________________
+Bool_t AliZDCDigitizer::Init()
+{
+ // Initialize the digitizer
+ // NB -> PM gain vs. HV & ADC resolutions will move to DCDB ***************
+ for(Int_t j = 0; j < 5; j++){
+ fPMGain[0][j] = 50000.;
+ fPMGain[1][j] = 100000.;
+ fPMGain[2][j] = 100000.;
+ fPMGain[3][j] = 50000.;
+ fPMGain[4][j] = 100000.;
+ fPMGain[5][j] = 100000.;
+ }
+ // ADC Caen V965
+ fADCRes[0] = 0.0000008; // ADC Resolution high gain: 200 fC/adcCh
+ fADCRes[1] = 0.0000064; // ADC Resolution low gain: 25 fC/adcCh
return kTRUE;
}
//____________________________________________________________________________
void AliZDCDigitizer::Exec(Option_t* /*option*/)
{
-// Execute digitization
-
- Float_t pm[3][5];
- for (Int_t iSector1 = 0; iSector1 < 3; iSector1++)
- for (Int_t iSector2 = 0; iSector2 < 5; iSector2++) {
+ // Execute digitization
+
+ // ------------------------------------------------------------
+ // !!! 2nd ZDC set added (needed for trigger purposes!)
+ // *** 1st 3 arrays are digits from REAL (simulated) hits
+ // *** last 2 are copied from simulated digits
+ // --- pm[0][...] = light in ZN right [C, Q1, Q2, Q3, Q4]
+ // --- pm[1][...] = light in ZP right [C, Q1, Q2, Q3, Q4]
+ // --- pm[2][...] = light in ZEM [x, 1, 2, x, x]
+ // --- pm[3][...] = light in ZN left [C, Q1, Q2, Q3, Q4] ->NEW!
+ // --- pm[4][...] = light in ZP left [C, Q1, Q2, Q3, Q4] ->NEW!
+ // ------------------------------------------------------------
+ Float_t pm[5][5];
+ for(Int_t iSector1=0; iSector1<5; iSector1++)
+ for(Int_t iSector2=0; iSector2<5; iSector2++){
pm[iSector1][iSector2] = 0;
}
- // pm[0][...] = light in ZN [C, Q1, Q2, Q3, Q4]
- // pm[1][...] = light in ZP [C, Q1, Q2, Q3, Q4]
- // pm[2][...] = light in ZEM [x, 1, 2, x, x]
+
+ // ------------------------------------------------------------
+ // ### Out of time ADC added (22 channels)
+ // --- same codification as for signal PTMs (see above)
+ // ------------------------------------------------------------
+ Float_t pmoot[5][5];
+ for(Int_t iSector1=0; iSector1<5; iSector1++)
+ for(Int_t iSector2=0; iSector2<5; iSector2++){
+ pmoot[iSector1][iSector2] = 0;
+ }
// impact parameter and number of spectators
Float_t impPar = -1;
Int_t specP = 0;
// loop over input streams
- for (Int_t iInput = 0; iInput < fManager->GetNinputs(); iInput++) {
+ for(Int_t iInput = 0; iInput<fManager->GetNinputs(); iInput++){
// get run loader and ZDC loader
AliRunLoader* runLoader =
AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput));
AliLoader* loader = runLoader->GetLoader("ZDCLoader");
- if (!loader) continue;
+ if(!loader) continue;
// load sdigits
loader->LoadSDigits();
TTree* treeS = loader->TreeS();
- if (!treeS) continue;
+ if(!treeS) continue;
AliZDCSDigit sdigit;
AliZDCSDigit* psdigit = &sdigit;
treeS->SetBranchAddress("ZDC", &psdigit);
// loop over sdigits
- for (Int_t iSDigit = 0; iSDigit < treeS->GetEntries(); iSDigit++) {
+ for(Int_t iSDigit=0; iSDigit<treeS->GetEntries(); iSDigit++){
treeS->GetEntry(iSDigit);
- if (!psdigit) continue;
-
- if ((sdigit.GetSector(1) < 0) || (sdigit.GetSector(1) > 4)) {
+ //
+ if(!psdigit) continue;
+ if((sdigit.GetSector(1) < 0) || (sdigit.GetSector(1) > 4)){
AliError(Form("\nsector[0] = %d, sector[1] = %d\n",
sdigit.GetSector(0), sdigit.GetSector(1)));
continue;
}
- pm[sdigit.GetSector(0)-1][sdigit.GetSector(1)] += sdigit.GetLightPM();
- //printf("\n\t sector[0] = %d, sector[1] = %d, pm[%d][%d] = %f \n",
- // sdigit.GetSector(0), sdigit.GetSector(1),sdigit.GetSector(0)-1,
- // sdigit.GetSector(1), pm[sdigit.GetSector(0)-1][sdigit.GetSector(1)]); // Chiara debugging!
+ //
+ pm[(sdigit.GetSector(0))-1][sdigit.GetSector(1)] += sdigit.GetLightPM();
+ /*printf("\n\t Detector %d, Tower %d -> pm[%d][%d] = %.0f \n",
+ sdigit.GetSector(0), sdigit.GetSector(1),sdigit.GetSector(0)-1,
+ sdigit.GetSector(1), pm[sdigit.GetSector(0)-1][sdigit.GetSector(1)]); // Chiara debugging!
+ */
}
- // unload sdigits
loader->UnloadSDigits();
// get the impact parameter and the number of spectators in case of hijing
- if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
+ if(!runLoader->GetAliRun()) runLoader->LoadgAlice();
AliHeader* header = runLoader->GetAliRun()->GetHeader();
- if (!header) continue;
+ if(!header) continue;
AliGenEventHeader* genHeader = header->GenEventHeader();
- if (!genHeader) continue;
- if (!genHeader->InheritsFrom(AliGenHijingEventHeader::Class())) continue;
+ if(!genHeader) continue;
+ if(!genHeader->InheritsFrom(AliGenHijingEventHeader::Class())) continue;
impPar = ((AliGenHijingEventHeader*) genHeader)->ImpactParameter();
- // Until there is only 1 ZDC set the # of spectators must be divided by 2!!!
- specN = ((AliGenHijingEventHeader*) genHeader)->Spectatorsn() / 2;
- specP = ((AliGenHijingEventHeader*) genHeader)->Spectatorsp() / 2;
- AliDebug(2, Form("\n b = %f fm, Nspecn = %d, Nspecp = %d\n",
+ //
+ specN = ((AliGenHijingEventHeader*) genHeader)->ProjSpectatorsn();
+ specP = ((AliGenHijingEventHeader*) genHeader)->ProjSpectatorsp();
+ AliDebug(2, Form("\n AliZDCDigitizer -> b = %f fm, Nspecn = %d, Nspecp = %d\n",
impPar, specN, specP));
+ printf("\n\t AliZDCDigitizer -> b = %f fm, NSpecn = %d, NSpecp = %d\n", impPar, specN, specP);
}
// add spectators
- if (impPar >= 0) {
+ if(impPar >= 0) {
Int_t freeSpecN, freeSpecP;
Fragmentation(impPar, specN, specP, freeSpecN, freeSpecP);
+ printf("\n\t AliZDCDigitizer ---- Adding signal for %d free spectator n\n",freeSpecN);
SpectatorSignal(1, freeSpecN, pm);
+ printf("\t AliZDCDigitizer ---- Adding signal for %d free spectator p\n\n",freeSpecP);
SpectatorSignal(2, freeSpecP, pm);
}
+
// get the output run loader and loader
AliRunLoader* runLoader =
AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
AliLoader* loader = runLoader->GetLoader("ZDCLoader");
- if (!loader) {
+ if(!loader) {
AliError("no ZDC loader found");
return;
}
// create the output tree
const char* mode = "update";
- if (runLoader->GetEventNumber() == 0) mode = "recreate";
+ if(runLoader->GetEventNumber() == 0) mode = "recreate";
loader->LoadDigits(mode);
loader->MakeTree("D");
TTree* treeD = loader->TreeD();
treeD->Branch("ZDC", "AliZDCDigit", &pdigit, kBufferSize);
// Create digits
- Int_t sector[2];
- Int_t digi[2];
- for (sector[0] = 1; sector[0] <= 3; sector[0]++)
- for (sector[1] = 0; sector[1] < 5; sector[1]++) {
- if ((sector[0] == 3) && ((sector[1] < 1) || (sector[1] > 2))) continue;
- for (Int_t res = 0; res < 2; res++){
- digi[res] = Phe2ADCch(1, 0, pm[sector[0]-1][sector[1]], res)
- + Pedestal();
- //printf("\n\t sector[0] = %d, sector[1] = %d, digi[%d] = %d\n",
- // sector[0], sector[1], res, digi[res]); // Chiara debugging!
+ Int_t sector[2], sectorL[2];
+ Int_t digi[2], digiL[2], digioot[2];
+ for(sector[0]=1; sector[0]<=3; sector[0]++){
+ for(sector[1]=0; sector[1]<5; sector[1]++){
+ if((sector[0]==3) && ((sector[1]<1) || (sector[1]>2))) continue;
+ for(Int_t res=0; res<2; res++){
+ digi[res] = Phe2ADCch(sector[0], sector[1], pm[sector[0]-1][sector[1]], res)
+ + Pedestal(sector[0], sector[1], res);
+ }
+ /*printf("\t DIGIT added -> det = %d, quad = %d - digi[0,1] = [%d, %d]\n",
+ sector[0], sector[1], digi[0], digi[1]); // Chiara debugging!
+ */
+ //
+ new(pdigit) AliZDCDigit(sector, digi);
+ treeD->Fill();
+ //
+ // --- Adding digits for 2nd ZDC set (left side w.r.t. IP) ---
+ // --- they are copied from right ZDC digits
+ if(sector[0]==1 || sector[0]==2){
+ sectorL[0] = sector[0]+3;
+ sectorL[1] = sector[1];
+ for(Int_t res=0; res<2; res++){
+ digiL[res] = Phe2ADCch(sectorL[0], sectorL[1], pm[sector[0]-1][sector[1]], res)
+ + Pedestal(sectorL[0], sectorL[1], res);
+ }
+ /*printf("\t DIGIT added -> det = %d, quad = %d - digi[0,1] = [%d, %d]\n",
+ sectorL[0], sectorL[1], digiL[0], digiL[1]); // Chiara debugging!
+ */
+ //
+ new(pdigit) AliZDCDigit(sectorL, digiL);
+ treeD->Fill();
}
- new(pdigit) AliZDCDigit(sector, digi);
+ //
+ //printf("\t AliZDCDigitizer -> TreeD has %d entries\n",(Int_t) treeD->GetEntries());
+ }
+ }
+ //
+ // --- Adding digits for out-of-time channels after signal digits
+ for(sector[0]=1; sector[0]<=3; sector[0]++){
+ for(sector[1]=0; sector[1]<5; sector[1]++){
+ if((sector[0]==3) && ((sector[1]<1) || (sector[1]>2))) continue;
+ for(Int_t res=0; res<2; res++){
+ digioot[res] = Pedestal(sector[0], sector[1], res); // out-of-time ADCs
+ }
+ /*printf("\t DIGIToot added -> det = %d, quad = %d - digi[0,1] = [%d, %d]\n",
+ sector[0], sector[1], digioot[0], digioot[1]); // Chiara debugging!
+ */
+ //
+ new(pdigit) AliZDCDigit(sector, digioot);
treeD->Fill();
+ //
+ if(sector[0]==1 || sector[0]==2){
+ sectorL[0] = sector[0]+3;
+ sectorL[1] = sector[1];
+ for(Int_t res=0; res<2; res++){
+ digioot[res] = Pedestal(sectorL[0], sectorL[1], res); // out-of-time ADCs
+ }
+ /*printf("\t DIGIToot added -> det = %d, quad = %d - digi[0,1] = [%d, %d]\n",
+ sectorL[0], sectorL[1], digioot[0], digioot[1]); // Chiara debugging!
+ */
+ //
+ new(pdigit) AliZDCDigit(sectorL, digioot);
+ treeD->Fill();
+ }
+ //
+ //printf("\t AliZDCDigitizer -> TreeD has %d entries\n",(Int_t) treeD->GetEntries());
}
-
+ }
// write the output tree
loader->WriteDigits("OVERWRITE");
loader->UnloadDigits();
Int_t zz[100], nn[100];
AliZDCFragment frag(impPar);
- for (Int_t j=0; j<=99; j++){
+ for(Int_t j=0; j<=99; j++){
zz[j] =0;
nn[j] =0;
}
frag.AttachNeutrons(zz, nn, ztot, ntot);
freeSpecN = specN-ntot-2*nAlpha;
freeSpecP = specP-ztot-2*nAlpha;
+ // Removing deuterons
+ Int_t ndeu = (Int_t) (frag.DeuteronNumber());
+ freeSpecN -= ndeu;
+ //
if(freeSpecN<0) freeSpecN=0;
if(freeSpecP<0) freeSpecP=0;
AliDebug(2, Form("FreeSpn = %d, FreeSpp = %d", freeSpecN, freeSpecP));
// add signal of the spectators
TFile* file = NULL;
- if (SpecType == 1) { // --- Signal for spectator neutrons
- file = TFile::Open("$ALICE/$ALICE_LEVEL/ZDC/ZNsignalntu.root");
- } else if (SpecType == 2) { // --- Signal for spectator protons
- file = TFile::Open("$ALICE/$ALICE_LEVEL/ZDC/ZPsignalntu.root");
+ if(SpecType == 1) { // --- Signal for spectator neutrons
+ file = TFile::Open("$ALICE_ROOT/ZDC/ZNsignalntu.root");
+ } else if(SpecType == 2) { // --- Signal for spectator protons
+ file = TFile::Open("$ALICE_ROOT/ZDC/ZPsignalntu.root");
}
- if (!file || !file->IsOpen()) {
+ if(!file || !file->IsOpen()) {
AliError("Opening of file failed");
return;
}
Float_t *entry, hitsSpec[7];
Int_t pl, i, j, k, iev=0, rnd[125], volume[2];
- for(pl=0;pl<125;pl++){
- rnd[pl] = 0;
- }
- if (numEvents > 125) {
+ for(pl=0;pl<125;pl++) rnd[pl] = 0;
+ if(numEvents > 125) {
AliWarning(Form("numEvents (%d) is larger than 125", numEvents));
numEvents = 125;
}
for(pl=0;pl<numEvents;pl++){
rnd[pl] = (Int_t) (9999*gRandom->Rndm());
- if(rnd[pl] >= 9998) rnd[pl] = 9997;
+ if(rnd[pl] >= 9999) rnd[pl] = 9998;
//printf(" rnd[%d] = %d\n",pl,rnd[pl]);
}
// Sorting vector in ascending order with C function QSORT
if(entry[0] == rnd[iev]){
for(k=0; k<2; k++) volume[k] = (Int_t) entry[k+1];
for(j=0; j<7; j++) hitsSpec[j] = entry[j+3];
-
+ //
Float_t lightQ = hitsSpec[4];
Float_t lightC = hitsSpec[5];
- AliDebug(3, Form("volume = (%d, %d), lightQ = %.3f, lightC = %.3f",
+ AliDebug(3, Form("SpectatorSignal -> vol = (%d, %d), lightQ = %.0f, lightC = %.0f",
volume[0], volume[1], lightQ, lightC));
- if (volume[0] < 3) { // ZN or ZP
+ //printf("\n Volume = (%d, %d), lightQ = %.0f, lightC = %.0f",
+ // volume[0], volume[1], lightQ, lightC);
+ if(volume[0] < 3) { // ZN or ZP
pm[volume[0]-1][0] += lightC;
pm[volume[0]-1][volume[1]] += lightQ;
- } else {
- if (volume[1] == 1) pm[2][1] += lightC;
- else pm[2][2] += lightQ;
- }
-
-
+ //printf("\n pm[%d][0] = %.0f, pm[%d][%d] = %.0f\n",(volume[0]-1),pm[volume[0]-1][0],
+ // (volume[0]-1),volume[1],pm[volume[0]-1][volume[1]]);
+ }
+ else {
+ if(volume[1] == 1) pm[2][1] += lightC; // ZEM 1
+ else pm[2][2] += lightQ; // ZEM 2
+ //printf("\n pm[2][1] = %.0f, pm[2][2] = %.0f\n",pm[2][1],pm[2][2]);
+ }
}
else if(entry[0] > rnd[iev]){
iev++;
Int_t AliZDCDigitizer::Phe2ADCch(Int_t Det, Int_t Quad, Float_t Light,
Int_t Res) const
{
-// Evaluation of the ADC channel corresponding to the light yield Light
+ // Evaluation of the ADC channel corresponding to the light yield Light
+ Int_t vADCch = (Int_t) (Light * fPMGain[Det-1][Quad] * fADCRes[Res]);
+ //printf("\t Phe2ADCch -> det %d quad %d - phe %.0f ADC %d\n", Det,Quad,Light,ADCch);
- return (Int_t) (Light * fPMGain[Det-1][Quad] * fADCRes[Res]);
+ return vADCch;
}
//_____________________________________________________________________________
-Int_t AliZDCDigitizer::Pedestal() const
+Int_t AliZDCDigitizer::Pedestal(Int_t Det, Int_t Quad, Int_t Res) const
{
- // --- Pedestal value -> extracted from a gaussian distribution
- // obtained from the beam test on the ZEM prototype (Aug. 2000)
+ // Returns a pedestal for detector det, PM quad, channel with res.
+ //
+ Float_t PedValue;
+
+ // Normal run
+ if(fIsCalibration == 0){
+ Float_t meanPed, Pedwidth;
+ Int_t index=0;
+ 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
+ meanPed = fCalibData->GetMeanPed(index);
+ Pedwidth = fCalibData->GetMeanPedWidth(index);
+ PedValue = gRandom->Gaus(meanPed,Pedwidth);
+ //
+ /*printf("\t Pedestal -> det = %d, quad = %d, res = %d - Ped[%d] = %d\n",
+ Det, Quad, index,(Int_t) PedValue); // Chiara debugging!
+ */
+ }
+
+ // To create calibration object
+ else PedValue = gRandom->Gaus((40.+10.*gRandom->Rndm()),5.);
+
+
+ return (Int_t) PedValue;
+}
+
+//_____________________________________________________________________________
+AliCDBStorage* AliZDCDigitizer::SetStorage(const char *uri)
+{
+
+ Bool_t deleteManager = kFALSE;
+
+ AliCDBManager *manager = AliCDBManager::Instance();
+ AliCDBStorage *defstorage = manager->GetDefaultStorage();
+
+ if(!defstorage || !(defstorage->Contains("ZDC"))){
+ AliWarning("No default storage set or default storage doesn't contain ZDC!");
+ manager->SetDefaultStorage(uri);
+ deleteManager = kTRUE;
+ }
+
+ AliCDBStorage *storage = manager->GetDefaultStorage();
+
+ if(deleteManager){
+ AliCDBManager::Instance()->UnsetDefaultStorage();
+ defstorage = 0; // the storage is killed by AliCDBManager::Instance()->Destroy()
+ }
+
+ return storage;
+}
- Float_t pedMean = 50.;
- Float_t pedWidth = 5.;
+//_____________________________________________________________________________
+AliZDCCalibData* AliZDCDigitizer::GetCalibData() const
+{
+
+ // Getting calibration object for ZDC set
- return (Int_t) gRandom->Gaus(pedMean, pedWidth);
+ AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Calib/Data");
+ if(!entry) AliFatal("No calibration data loaded!");
+
+ AliZDCCalibData *calibdata = dynamic_cast<AliZDCCalibData*> (entry->GetObject());
+ if(!calibdata) AliFatal("Wrong calibration object in calibration file!");
+
+ return calibdata;
}
+