X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EMCAL%2FAliEMCALDigitizer.cxx;h=e79d100de3286ea4a455ace8df3ef2c06bf9b2ac;hb=e658398a50b3844e1cca15b5eb43fdf2da17f2fe;hp=ff290568d5697085b83b1868a240debebe9ee687;hpb=fe93d36585e5e2a8cfad24ee50a15fb6b2b156f7;p=u%2Fmrichter%2FAliRoot.git diff --git a/EMCAL/AliEMCALDigitizer.cxx b/EMCAL/AliEMCALDigitizer.cxx index ff290568d56..e79d100de32 100644 --- a/EMCAL/AliEMCALDigitizer.cxx +++ b/EMCAL/AliEMCALDigitizer.cxx @@ -18,7 +18,7 @@ //_________________________________________________________________________ // ////////////////////////////////////////////////////////////////////////////// -// Class performs digitization of Summable digits +// Class performs digitization of Summable digits from simulated data // // In addition it performs mixing of summable digits from different events. // @@ -63,8 +63,6 @@ #include #include #include -#include -#include #include #include #include @@ -84,7 +82,6 @@ #include "AliEMCALSDigitizer.h" #include "AliEMCALGeometry.h" #include "AliEMCALTick.h" -#include "AliEMCALHistoUtilities.h" ClassImp(AliEMCALDigitizer) @@ -112,12 +109,11 @@ AliEMCALDigitizer::AliEMCALDigitizer() fEventFolderName(""), fFirstEvent(0), fLastEvent(0), - fControlHists(0), - fHists(0),fCalibData(0x0) + fCalibData(0x0) { // ctor InitParameters() ; - fManager = 0 ; // We work in the standalong mode + fManager = 0 ; // We work in the standalone mode } //____________________________________________________________________________ @@ -143,13 +139,12 @@ AliEMCALDigitizer::AliEMCALDigitizer(TString alirunFileName, TString eventFolder fEventFolderName(eventFolderName), fFirstEvent(0), fLastEvent(0), - fControlHists(0), - fHists(0),fCalibData(0x0) + fCalibData(0x0) { // ctor InitParameters() ; Init() ; - fManager = 0 ; // We work in the standalong mode + fManager = 0 ; // We work in the standalone mode } //____________________________________________________________________________ @@ -175,8 +170,7 @@ AliEMCALDigitizer::AliEMCALDigitizer(const AliEMCALDigitizer & d) fEventFolderName(d.fEventFolderName), fFirstEvent(d.fFirstEvent), fLastEvent(d.fLastEvent), - fControlHists(d.fControlHists), - fHists(d.fHists),fCalibData(d.fCalibData) + fCalibData(d.fCalibData) { // copyy ctor } @@ -204,8 +198,7 @@ AliEMCALDigitizer::AliEMCALDigitizer(AliRunDigitizer * rd) fEventFolderName(0), fFirstEvent(0), fLastEvent(0), - fControlHists(0), - fHists(0),fCalibData(0x0) + fCalibData(0x0) { // ctor Init() is called by RunDigitizer fManager = rd ; @@ -218,9 +211,9 @@ AliEMCALDigitizer::AliEMCALDigitizer(AliRunDigitizer * rd) AliEMCALDigitizer::~AliEMCALDigitizer() { //dtor - if (AliRunLoader::GetRunLoader()) { + if (AliRunLoader::Instance()) { AliLoader *emcalLoader=0; - if ((emcalLoader = AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"))) + if ((emcalLoader = AliRunLoader::Instance()->GetDetectorLoader("EMCAL"))) emcalLoader->CleanDigitizer(); } else @@ -228,7 +221,6 @@ AliEMCALDigitizer::AliEMCALDigitizer(AliRunDigitizer * rd) delete [] fInputFileNames ; delete [] fEventNames ; - if(fHists) delete fHists; } //____________________________________________________________________________ @@ -237,13 +229,18 @@ void AliEMCALDigitizer::Digitize(Int_t event) // Makes the digitization of the collected summable digits // for this it first creates the array of all EMCAL modules - // filled with noise (different for EMC, CPV and PPSD) and - // after that adds contributions from SDigits. This design - // helps to avoid scanning over the list of digits to add - // contribution of any new SDigit. + // filled with noise and after that adds contributions from + // SDigits. This design helps to avoid scanning over the + // list of digits to add contribution of any new SDigit. + // + // JLK 26-Jun-2008 + // Note that SDigit energy info is stored as an amplitude, so we + // must call the Calibrate() method of the SDigitizer to convert it + // back to an energy in GeV before adding it to the Digit + // static int nEMC=0; //max number of digits possible - AliRunLoader *rl = AliRunLoader::GetRunLoader(); + AliRunLoader *rl = AliRunLoader::Instance(); AliEMCALLoader *emcalLoader = dynamic_cast(rl->GetDetectorLoader("EMCAL")); Int_t readEvent = event ; // fManager is data member from AliDigitizer @@ -254,7 +251,8 @@ void AliEMCALDigitizer::Digitize(Int_t event) rl->GetEvent(readEvent); TClonesArray * digits = emcalLoader->Digits() ; - digits->Delete() ; + digits->Delete() ; //correct way to clear array when memory is + //allocated by objects stored in array // Load Geometry AliEMCALGeometry *geom = 0; @@ -324,11 +322,11 @@ void AliEMCALDigitizer::Digitize(Int_t event) AliEMCALDigit * digit ; AliEMCALDigit * curSDigit ; - TClonesArray * ticks = new TClonesArray("AliEMCALTick",1000) ; + // TClonesArray * ticks = new TClonesArray("AliEMCALTick",1000) ; //Put Noise contribution for(absID = 0; absID < nEMC; absID++){ // Nov 30, 2006 by PAI; was from 1 to nEMC - Float_t amp = 0 ; + Float_t energy = 0 ; // amplitude set to zero, noise will be added later new((*digits)[absID]) AliEMCALDigit( -1, -1, absID, 0, TimeOfNoise() ); // absID-1->absID //look if we have to add signal? @@ -336,14 +334,22 @@ void AliEMCALDigitizer::Digitize(Int_t event) if(absID==nextSig){ //Add SDigits from all inputs - ticks->Clear() ; - Int_t contrib = 0 ; - Float_t a = digit->GetAmp() ; - Float_t b = TMath::Abs( a /fTimeSignalLength) ; + // ticks->Clear() ; + //Int_t contrib = 0 ; + + //Follow PHOS and comment out this timing model til a better one + //can be developed - JLK 28-Apr-2008 + + //Float_t a = digit->GetAmp() ; + //Float_t b = TMath::Abs( a /fTimeSignalLength) ; //Mark the beginning of the signal - new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime(),0, b); + //new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime(),0, b); //Mark the end of the signal - new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime()+fTimeSignalLength, -a, -b); + //new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime()+fTimeSignalLength, -a, -b); + + // Calculate time as time of the largest digit + Float_t time = digit->GetTime() ; + Float_t aTime= digit->GetAmp() ; // loop over input for(i = 0; i< fInput ; i++){ //loop over (possible) merge sources @@ -360,13 +366,18 @@ void AliEMCALDigitizer::Digitize(Int_t event) else primaryoffset = i ; curSDigit->ShiftPrimary(primaryoffset) ; - - a = curSDigit->GetAmp() ; - b = a /fTimeSignalLength ; - new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime(),0, b); - new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b); - *digit = *digit + *curSDigit ; //add energies + //Remove old timing model - JLK 28-April-2008 + //a = curSDigit->GetAmp() ; + //b = a /fTimeSignalLength ; + //new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime(),0, b); + //new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b); + if(curSDigit->GetAmp()>aTime) { + aTime = curSDigit->GetAmp(); + time = curSDigit->GetTime(); + } + + *digit = *digit + *curSDigit ; //adds amplitudes of each digit index[i]++ ; if( dynamic_cast(sdigArray->At(i))->GetEntriesFast() > index[i] ) @@ -375,12 +386,14 @@ void AliEMCALDigitizer::Digitize(Int_t event) curSDigit = 0 ; } } + //Here we convert the summed amplitude to an energy in GeV + energy = sDigitizer->Calibrate(digit->GetAmp()) ; // GeV // add fluctuations for photo-electron creation - amp = sDigitizer->Calibrate(digit->GetAmp()) ; // GeV - amp *= static_cast(gRandom->Poisson(fMeanPhotonElectron)) / static_cast(fMeanPhotonElectron) ; + energy *= static_cast(gRandom->Poisson(fMeanPhotonElectron)) / static_cast(fMeanPhotonElectron) ; //calculate and set time - Float_t time = FrontEdgeTime(ticks) ; + //New timing model needed - JLK 28-April-2008 + //Float_t time = FrontEdgeTime(ticks) ; digit->SetTime(time) ; //Find next signal module @@ -395,21 +408,27 @@ void AliEMCALDigitizer::Digitize(Int_t event) } } // add the noise now - amp += TMath::Abs(gRandom->Gaus(0., fPinNoise)) ; - digit->SetAmp(sDigitizer->Digitize(amp)) ; - AliDebug(10,Form(" absID %5i amp %f nextSig %5i\n", - absID, amp, nextSig)); - } // for(absID = 1; absID <= nEMC; absID++) + energy += TMath::Abs(gRandom->Gaus(0., fPinNoise)) ; + // JLK 26-June-2008 + //Now digitize the energy according to the sDigitizer method, + //which merely converts the energy to an integer. Later we will + //check that the stored value matches our allowed dynamic ranges + digit->SetAmp(sDigitizer->Digitize(energy)) ; + AliDebug(10,Form(" absID %5i energy %f nextSig %5i\n", + absID, energy, nextSig)); + } // for(absID = 0; absID < nEMC; absID++) - ticks->Delete() ; - delete ticks ; + //ticks->Delete() ; + //delete ticks ; + //JLK is it better to call Clear() here? delete sdigArray ; //We should not delete its contents //remove digits below thresholds for(i = 0 ; i < nEMC ; i++){ digit = dynamic_cast( digits->At(i) ) ; - Float_t threshold = fDigitThreshold ; + Float_t threshold = fDigitThreshold ; //this is in GeV + //need to calibrate digit amplitude to energy in GeV for comparison if(sDigitizer->Calibrate( digit->GetAmp() ) < threshold) digits->RemoveAt(i) ; else @@ -419,33 +438,31 @@ void AliEMCALDigitizer::Digitize(Int_t event) digits->Compress() ; Int_t ndigits = digits->GetEntriesFast() ; - - //Set indexes in list of digits and fill hists. - AliEMCALHistoUtilities::FillH1(fHists, 0, Double_t(ndigits)); - Float_t energy=0., esum=0.; + + //JLK 26-June-2008 + //After we have done the summing and digitizing to create the + //digits, now we want to calibrate the resulting amplitude to match + //the dynamic range of our real data. + Float_t energy=0; for (i = 0 ; i < ndigits ; i++) { digit = dynamic_cast( digits->At(i) ) ; digit->SetIndexInList(i) ; energy = sDigitizer->Calibrate(digit->GetAmp()) ; - esum += energy; - digit->SetAmp(DigitizeEnergy(energy, digit->GetId()) ) ; // for what ?? - AliEMCALHistoUtilities::FillH1(fHists, 2, double(digit->GetAmp())); - AliEMCALHistoUtilities::FillH1(fHists, 3, double(energy)); - AliEMCALHistoUtilities::FillH1(fHists, 4, double(digit->GetId())); - // if(digit->GetId() == nEMC) { - // printf(" i %i \n", i ); - // digit->Dump(); - // assert(0); - //} + digit->SetAmp(DigitizeEnergy(energy, digit->GetId()) ) ; } - AliEMCALHistoUtilities::FillH1(fHists, 1, esum); + } // //_____________________________________________________________________ Int_t AliEMCALDigitizer::DigitizeEnergy(Float_t energy, Int_t AbsId) { + // JLK 26-June-2008 // Returns digitized value of the energy in a cell absId - + // using the calibration constants stored in the OCDB + // or default values if no CalibData object is found. + // This effectively converts everything to match the dynamic range + // of the real data we will collect + // // Load Geometry const AliEMCALGeometry * geom = AliEMCALGeometry::GetInstance(); @@ -501,7 +518,7 @@ void AliEMCALDigitizer::Exec(Option_t *option) if(strstr(option,"tim")) gBenchmark->Start("EMCALDigitizer"); - AliRunLoader *rl = AliRunLoader::GetRunLoader(); + AliRunLoader *rl = AliRunLoader::Instance(); AliEMCALLoader *emcalLoader = dynamic_cast(rl->GetDetectorLoader("EMCAL")); // Post Digitizer to the white board @@ -569,7 +586,7 @@ Bool_t AliEMCALDigitizer::Init() { // Makes all memory allocations fInit = kTRUE ; - AliEMCALLoader *emcalLoader = dynamic_cast(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL")); + AliEMCALLoader *emcalLoader = dynamic_cast(AliRunLoader::Instance()->GetDetectorLoader("EMCAL")); if ( emcalLoader == 0 ) { Fatal("Init", "Could not obtain the AliEMCALLoader"); @@ -598,7 +615,6 @@ Bool_t AliEMCALDigitizer::Init() //to prevent cleaning of this object while GetEvent is called emcalLoader->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE); - //PH Print(); //Calibration instance fCalibData = emcalLoader->CalibData(); return fInit ; @@ -626,9 +642,7 @@ void AliEMCALDigitizer::InitParameters() fNADCEC = (Int_t) TMath::Power(2,16) ; // number of channels in Tower ADC - 65536 fTimeThreshold = 0.001*10000000 ; // Means 1 MeV in terms of SDigits amplitude ?? - // hists. for control; no hists on default - fControlHists = 0; - fHists = 0; + } //__________________________________________________________________ @@ -659,7 +673,7 @@ void AliEMCALDigitizer::MixWith(TString alirunFileName, TString eventFolderName) return ; } // looking for the file which contains SDigits - AliEMCALLoader *emcalLoader = dynamic_cast(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL")); + AliEMCALLoader *emcalLoader = dynamic_cast(AliRunLoader::Instance()->GetDetectorLoader("EMCAL")); TString fileName( emcalLoader->GetSDigitsFileName() ) ; if ( eventFolderName != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name fileName = fileName.ReplaceAll(".root", "") + "_" + eventFolderName + ".root" ; @@ -721,7 +735,7 @@ void AliEMCALDigitizer::Print(Option_t*)const printf ("Adding SDigits from %s %s\n", fInputFileNames[index].Data(), fileName.Data()) ; } - AliEMCALLoader *emcalLoader = dynamic_cast(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL")); + AliEMCALLoader *emcalLoader = dynamic_cast(AliRunLoader::Instance()->GetDetectorLoader("EMCAL")); printf("\nWriting digits to %s", emcalLoader->GetDigitsFileName().Data()) ; @@ -740,7 +754,7 @@ void AliEMCALDigitizer::PrintDigits(Option_t * option) { //utility method for printing digit information - AliEMCALLoader *emcalLoader = dynamic_cast(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL")); + AliEMCALLoader *emcalLoader = dynamic_cast(AliRunLoader::Instance()->GetDetectorLoader("EMCAL")); TClonesArray * digits = emcalLoader->Digits() ; TClonesArray * sdigits = emcalLoader->SDigits() ; @@ -787,7 +801,7 @@ void AliEMCALDigitizer::Unload() if ((rl = AliRunLoader::GetRunLoader(tempo))) rl->GetDetectorLoader("EMCAL")->UnloadSDigits() ; } - AliEMCALLoader *emcalLoader = dynamic_cast(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL")); + AliEMCALLoader *emcalLoader = dynamic_cast(AliRunLoader::Instance()->GetDetectorLoader("EMCAL")); emcalLoader->UnloadDigits() ; } @@ -803,7 +817,7 @@ void AliEMCALDigitizer::WriteDigits() // and branch "AliEMCALDigitizer", with the same title to keep all the parameters // and names of files, from which digits are made. - AliEMCALLoader *emcalLoader = dynamic_cast(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL")); + AliEMCALLoader *emcalLoader = dynamic_cast(AliRunLoader::Instance()->GetDetectorLoader("EMCAL")); const TClonesArray * digits = emcalLoader->Digits() ; TTree * treeD = emcalLoader->TreeD(); @@ -834,36 +848,5 @@ void AliEMCALDigitizer::WriteDigits() //__________________________________________________________________ void AliEMCALDigitizer::Browse(TBrowser* b) { - if(fHists) b->Add(fHists); TTask::Browse(b); } - -//__________________________________________________________________ -TList *AliEMCALDigitizer::BookControlHists(int var) -{ - // 22-nov-04 - // histograms for monitoring digitizer performance - - Info("BookControlHists"," started "); - gROOT->cd(); - const AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(); - if(var>=1){ - new TH1F("hDigiN", "#EMCAL digits with fAmp > fDigitThreshold", - fNADCEC+1, -0.5, Double_t(fNADCEC)); - new TH1F("HDigiSumEnergy","Sum.EMCAL energy from digi", 1000, 0.0, 200.); - new TH1F("hDigiAmp", "EMCAL digital amplitude", fNADCEC+1, -0.5, Double_t(fNADCEC)); - new TH1F("hDigiEnergy","EMCAL cell energy", 2000, 0.0, 200.); - new TH1F("hDigiAbsId","EMCAL absId cells with fAmp > fDigitThreshold ", - geom->GetNCells(), 0.5, Double_t(geom->GetNCells())+0.5); - } - - fHists = AliEMCALHistoUtilities::MoveHistsToList("EmcalDigiControlHists", kFALSE); - fHists = 0; //huh? JLK 03-Mar-2006 - return fHists; -} - -//__________________________________________________________________ -void AliEMCALDigitizer::SaveHists(const char* name, Bool_t kSingleKey, const char* opt) -{ - AliEMCALHistoUtilities::SaveListOfHists(fHists, name, kSingleKey, opt); -}