From 7e1d9a9beae0963e1dd00eb0dd517f88140c11ef Mon Sep 17 00:00:00 2001 From: gconesab Date: Fri, 1 Oct 2010 14:11:29 +0000 Subject: [PATCH] Coverity corrections --- EMCAL/AliEMCALAodCluster.cxx | 15 ++- EMCAL/AliEMCALClusterizerNxN.cxx | 88 ++++++------ EMCAL/AliEMCALDigitizer.cxx | 146 ++++++++++---------- EMCAL/AliEMCALEMCGeometry.cxx | 5 +- EMCAL/AliEMCALGeoUtils.cxx | 7 +- EMCAL/AliEMCALPIDUtils.cxx | 7 +- EMCAL/AliEMCALQAChecker.cxx | 31 ++--- EMCAL/AliEMCALReconstructor.cxx | 28 ++-- EMCAL/AliEMCALSDigitizer.cxx | 183 ++++++++++++++----------- EMCAL/AliEMCALSurvey.cxx | 221 ++++++++++++++++--------------- 10 files changed, 401 insertions(+), 330 deletions(-) diff --git a/EMCAL/AliEMCALAodCluster.cxx b/EMCAL/AliEMCALAodCluster.cxx index fe017383668..f8bfc5c3def 100644 --- a/EMCAL/AliEMCALAodCluster.cxx +++ b/EMCAL/AliEMCALAodCluster.cxx @@ -67,8 +67,7 @@ void AliEMCALAodCluster::Recalibrate(AliEMCALCalibData * calibData, AliAODCaloCe return ; AliEMCALGeometry * emcalgeo = AliEMCALGeometry::GetInstance(emcalGeoName) ; - if(!emcalgeo) - AliFatal("AliEMCALGeometry was not constructed\n") ; + if(emcalgeo){ Double32_t * cellsAmpFraction = GetCellsAmplitudeFraction(); Int_t iSupMod = -1; @@ -94,6 +93,10 @@ void AliEMCALAodCluster::Recalibrate(AliEMCALCalibData * calibData, AliAODCaloCe SetCellsAmplitudeFraction(cellsAmpFraction); fRecalibrated=kTRUE; + + } + else AliFatal("AliEMCALGeometry was not constructed\n") ; + } //____________________________________________________________________________ void AliEMCALAodCluster::EvalAll(Float_t logWeight, TString geoname){ @@ -177,8 +180,7 @@ void AliEMCALAodCluster::EvalPositionAndShowerShape(Float_t logWeight, TString e Double_t zmean = 0.; AliEMCALGeometry * emcalgeo = AliEMCALGeometry::GetInstance(emcalGeoName) ; - if(!emcalgeo) - AliFatal("AliEMCALGeometry was not constructed\n") ; + if(emcalgeo){ Double_t dist = TmaxInCm(E(),0); for(Int_t iDigit=0; iDigit < GetNCells(); iDigit++) { @@ -268,6 +270,11 @@ void AliEMCALAodCluster::EvalPositionAndShowerShape(Float_t logWeight, TString e SetDispersion(TMath::Sqrt(d)) ; else SetDispersion(0) ; + } + else { + AliFatal("AliEMCALGeometry was not constructed\n") ; + } + } diff --git a/EMCAL/AliEMCALClusterizerNxN.cxx b/EMCAL/AliEMCALClusterizerNxN.cxx index be588f3948d..cca2fc87e63 100644 --- a/EMCAL/AliEMCALClusterizerNxN.cxx +++ b/EMCAL/AliEMCALClusterizerNxN.cxx @@ -142,8 +142,12 @@ void AliEMCALClusterizerNxN::Digits2Clusters(Option_t * option) for(index = 0; index < fRecPoints->GetEntries(); index++) { - (dynamic_cast(fRecPoints->At(index)))->SetIndexInList(index) ; - (dynamic_cast(fRecPoints->At(index)))->Print(); + AliEMCALRecPoint * rp = dynamic_cast(fRecPoints->At(index)); + if(rp){ + rp->SetIndexInList(index) ; + rp->Print(); + } + else AliFatal("RecPoint NULL!!"); } fTreeR->Fill(); @@ -359,45 +363,51 @@ void AliEMCALClusterizerNxN::MakeUnfolding() { // Unfolds clusters using the shape of an ElectroMagnetic shower // Performs unfolding of all clusters - + if(fNumberOfECAClusters > 0){ - if (fGeom==0) - AliFatal("Did not get geometry from EMCALLoader") ; - Int_t nModulesToUnfold = fGeom->GetNCells(); - - Int_t numberofNotUnfolded = fNumberOfECAClusters ; - Int_t index ; - for(index = 0 ; index < numberofNotUnfolded ; index++){ - - AliEMCALRecPoint * recPoint = dynamic_cast( fRecPoints->At(index) ) ; - - TVector3 gpos; - Int_t absId; - recPoint->GetGlobalPosition(gpos); - fGeom->GetAbsCellIdFromEtaPhi(gpos.Eta(),gpos.Phi(),absId); - if(absId > nModulesToUnfold) - break ; - - Int_t nMultipl = recPoint->GetMultiplicity() ; - AliEMCALDigit ** maxAt = new AliEMCALDigit*[nMultipl] ; - Float_t * maxAtEnergy = new Float_t[nMultipl] ; - Int_t nMax = recPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fECALocMaxCut,fDigitsArr) ; - - if( nMax > 1 ) { // if cluster is very flat (no pronounced maximum) then nMax = 0 - //UnfoldCluster(recPoint, nMax, maxAt, maxAtEnergy) ; - fRecPoints->Remove(recPoint); - fRecPoints->Compress() ; - index-- ; - fNumberOfECAClusters-- ; - numberofNotUnfolded-- ; - } - else{ - recPoint->SetNExMax(1) ; //Only one local maximum - } - - delete[] maxAt ; - delete[] maxAtEnergy ; + + if (fGeom){ + + Int_t nModulesToUnfold = fGeom->GetNCells(); + + Int_t numberofNotUnfolded = fNumberOfECAClusters ; + Int_t index ; + for(index = 0 ; index < numberofNotUnfolded ; index++){ + + AliEMCALRecPoint * recPoint = dynamic_cast( fRecPoints->At(index) ) ; + if(recPoint){ + TVector3 gpos; + Int_t absId; + recPoint->GetGlobalPosition(gpos); + fGeom->GetAbsCellIdFromEtaPhi(gpos.Eta(),gpos.Phi(),absId); + if(absId > nModulesToUnfold) + break ; + + Int_t nMultipl = recPoint->GetMultiplicity() ; + AliEMCALDigit ** maxAt = new AliEMCALDigit*[nMultipl] ; + Float_t * maxAtEnergy = new Float_t[nMultipl] ; + Int_t nMax = recPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fECALocMaxCut,fDigitsArr) ; + + if( nMax > 1 ) { // if cluster is very flat (no pronounced maximum) then nMax = 0 + //UnfoldCluster(recPoint, nMax, maxAt, maxAtEnergy) ; + fRecPoints->Remove(recPoint); + fRecPoints->Compress() ; + index-- ; + fNumberOfECAClusters-- ; + numberofNotUnfolded-- ; + } + else{ + recPoint->SetNExMax(1) ; //Only one local maximum + } + + delete[] maxAt ; + delete[] maxAtEnergy ; + } + else AliFatal("Could not get RecPoint!") ; + }//loop } + else AliFatal("Could not get geometry from EMCALLoader!") ; + } // End of Unfolding of clusters } diff --git a/EMCAL/AliEMCALDigitizer.cxx b/EMCAL/AliEMCALDigitizer.cxx index 619c093d909..011b4419438 100644 --- a/EMCAL/AliEMCALDigitizer.cxx +++ b/EMCAL/AliEMCALDigitizer.cxx @@ -288,6 +288,8 @@ void AliEMCALDigitizer::Digitize(Int_t event) AliRunLoader *rl = AliRunLoader::Instance(); AliEMCALLoader *emcalLoader = dynamic_cast(rl->GetDetectorLoader("EMCAL")); + + if(emcalLoader){ Int_t readEvent = event ; // fManager is data member from AliDigitizer if (fManager) @@ -295,7 +297,7 @@ void AliEMCALDigitizer::Digitize(Int_t event) AliDebug(1,Form("Adding event %d from input stream 0 %s %s", readEvent, GetTitle(), fEventFolderName.Data())) ; rl->GetEvent(readEvent); - + TClonesArray * digits = emcalLoader->Digits() ; digits->Delete() ; //correct way to clear array when memory is //allocated by objects stored in array @@ -363,9 +365,9 @@ void AliEMCALDigitizer::Digitize(Int_t event) sdigits = dynamic_cast(sdigArray->At(i)) ; if(sdigits){ if (sdigits->GetEntriesFast() ){ - if(dynamic_cast(sdigits->At(0))){ - - Int_t curNext = dynamic_cast(sdigits->At(0))->GetId() ; + AliEMCALDigit *sd = dynamic_cast(sdigits->At(0)); + if(sd){ + Int_t curNext = sd->GetId() ; if(curNext < nextSig) nextSig = curNext ; AliDebug(1,Form("input %i : #sdigits %i \n", @@ -429,11 +431,12 @@ void AliEMCALDigitizer::Digitize(Int_t event) // loop over input for(i = 0; i< fInput ; i++){ //loop over (possible) merge sources - if(dynamic_cast(sdigArray->At(i))) { - Int_t sDigitEntries = dynamic_cast(sdigArray->At(i))->GetEntriesFast(); + TClonesArray* sdtclarr = dynamic_cast(sdigArray->At(i)); + if(sdtclarr) { + Int_t sDigitEntries = sdtclarr->GetEntriesFast(); if(sDigitEntries > index[i] ) - curSDigit = dynamic_cast(dynamic_cast(sdigArray->At(i))->At(index[i])) ; + curSDigit = dynamic_cast(sdtclarr->At(index[i])) ; else curSDigit = 0 ; @@ -461,7 +464,7 @@ void AliEMCALDigitizer::Digitize(Int_t event) index[i]++ ; if( sDigitEntries > index[i] ) - curSDigit = dynamic_cast(dynamic_cast(sdigArray->At(i))->At(index[i])) ; + curSDigit = dynamic_cast(sdtclarr->At(index[i])) ; else curSDigit = 0 ; }// while @@ -484,8 +487,9 @@ void AliEMCALDigitizer::Digitize(Int_t event) sdigits = dynamic_cast(sdigArray->At(i)) ; if(sdigits){ Int_t curNext = nextSig ; - if(sdigits->GetEntriesFast() > index[i] && dynamic_cast(sdigits->At(index[i]))){ - curNext = dynamic_cast(sdigits->At(index[i]))->GetId() ; + AliEMCALDigit * tmpdigit = dynamic_cast(sdigits->At(index[i])); + if(sdigits->GetEntriesFast() > index[i] && tmpdigit){ + curNext = tmpdigit->GetId() ; } if(curNext < nextSig) nextSig = curNext ; }// sdigits exist @@ -554,6 +558,9 @@ void AliEMCALDigitizer::Digitize(Int_t event) }//Digit loop }//SDigitizer not null + } + else AliFatal("EMCALLoader is NULL!") ; + } // //_____________________________________________________________________ @@ -714,73 +721,76 @@ void AliEMCALDigitizer::Digits2FastOR(TClonesArray* digitsTMP, TClonesArray* dig AliFatal("Did not get the Loader"); } else { - AliEMCALGeometry* geom = dynamic_cast(run->GetDetector("EMCAL"))->GetGeometry(); - - // build FOR from simulated digits - // and xfer to the corresponding TRU input (mapping) - - TClonesArray* digits = emcalLoader->Digits(); - - TIter NextDigit(digits); - while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit()) - { - Int_t id = digit->GetId(); + AliEMCAL* emcal = dynamic_cast(run->GetDetector("EMCAL")); + if(emcal){ + AliEMCALGeometry* geom = emcal->GetGeometry(); - Int_t trgid; - if (geom && geom->GetFastORIndexFromCellIndex(id , trgid)) + // build FOR from simulated digits + // and xfer to the corresponding TRU input (mapping) + + TClonesArray* digits = emcalLoader->Digits(); + + TIter NextDigit(digits); + while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit()) { - AliDebug(1,Form("trigger digit id: %d from cell id: %d\n",trgid,id)); - - AliEMCALDigit* d = static_cast(digitsTMP->At(trgid)); + Int_t id = digit->GetId(); - if (!d) - { - new((*digitsTMP)[trgid]) AliEMCALDigit(*digit); - d = (AliEMCALDigit*)digitsTMP->At(trgid); - d->SetId(trgid); - } - else - { - *d = *d + *digit; - } + Int_t trgid; + if (geom && geom->GetFastORIndexFromCellIndex(id , trgid)) + { + AliDebug(1,Form("trigger digit id: %d from cell id: %d\n",trgid,id)); + + AliEMCALDigit* d = static_cast(digitsTMP->At(trgid)); + + if (!d) + { + new((*digitsTMP)[trgid]) AliEMCALDigit(*digit); + d = (AliEMCALDigit*)digitsTMP->At(trgid); + d->SetId(trgid); + } + else + { + *d = *d + *digit; + } + } } - } - - if (AliDebugLevel()) printf("Number of TRG digits: %d\n",digitsTMP->GetEntriesFast()); - - Int_t nSamples = 32; - Int_t *timeSamples = new Int_t[nSamples]; - - NextDigit = TIter(digitsTMP); - while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit()) - { - if (digit) + + if (AliDebugLevel()) printf("Number of TRG digits: %d\n",digitsTMP->GetEntriesFast()); + + Int_t nSamples = 32; + Int_t *timeSamples = new Int_t[nSamples]; + + NextDigit = TIter(digitsTMP); + while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit()) { - Int_t id = digit->GetId(); - Float_t time = digit->GetTime(); - - Double_t depositedEnergy = 0.; - for (Int_t j = 1; j <= digit->GetNprimary(); j++) depositedEnergy += digit->GetDEPrimary(j); - - if (AliDebugLevel()) printf("Deposited Energy: %f\n", depositedEnergy); - - // FIXME: Check digit time! - if (depositedEnergy) - { - DigitalFastOR(time, depositedEnergy, timeSamples, nSamples); + if (digit) + { + Int_t id = digit->GetId(); + Float_t time = digit->GetTime(); - for (Int_t j=0;jGetNprimary(); j++) depositedEnergy += digit->GetDEPrimary(j); + + if (AliDebugLevel()) printf("Deposited Energy: %f\n", depositedEnergy); + + // FIXME: Check digit time! + if (depositedEnergy) { - timeSamples[j] = ((j << 12) & 0xFF000) | (timeSamples[j] & 0xFFF); + DigitalFastOR(time, depositedEnergy, timeSamples, nSamples); + + for (Int_t j=0;jGetEntriesFast()]) AliEMCALRawDigit(id, timeSamples, nSamples); } - - new((*digitsTRG)[digitsTRG->GetEntriesFast()]) AliEMCALRawDigit(id, timeSamples, nSamples); - } + } } - } - - delete [] timeSamples; - + + delete [] timeSamples; + }// AliEMCAL exists + else AliFatal("Could not get AliEMCAL"); }// loader exists } diff --git a/EMCAL/AliEMCALEMCGeometry.cxx b/EMCAL/AliEMCALEMCGeometry.cxx index 630c69f73fa..07bbc8b338a 100644 --- a/EMCAL/AliEMCALEMCGeometry.cxx +++ b/EMCAL/AliEMCALEMCGeometry.cxx @@ -90,7 +90,7 @@ AliEMCALEMCGeometry::AliEMCALEMCGeometry() // default ctor only for internal usage (singleton) // must be kept public for root persistency purposes, // but should never be called by the outside world - + fParSM[0]=0; fParSM[1]=0; fParSM[2]=0; AliDebug(2, "AliEMCALEMCGeometry : default ctor "); } //______________________________________________________________________ @@ -192,6 +192,9 @@ AliEMCALEMCGeometry::AliEMCALEMCGeometry(const AliEMCALEMCGeometry& geom) fTubsTurnAngle(geom.fTubsTurnAngle) { //copy ctor + fParSM[0]=geom.fParSM[0]; + fParSM[1]=geom.fParSM[1]; + fParSM[2]=geom.fParSM[2]; } //______________________________________________________________________ diff --git a/EMCAL/AliEMCALGeoUtils.cxx b/EMCAL/AliEMCALGeoUtils.cxx index da5b2d8e6bb..7eebde908dd 100644 --- a/EMCAL/AliEMCALGeoUtils.cxx +++ b/EMCAL/AliEMCALGeoUtils.cxx @@ -1270,13 +1270,14 @@ const TGeoHMatrix * AliEMCALGeoUtils::GetMatrixForSuperModule(Int_t smod) const // TGeoHMatrix* m = gGeoManager->GetCurrentMatrix(); if(gGeoManager){ - char path[255] ; - sprintf(path,"/ALIC_1/XEN1_1/SMOD_%d",smod+1) ; + const Int_t buffersize = 255; + char path[buffersize] ; + snprintf(path,buffersize,"/ALIC_1/XEN1_1/SMOD_%d",smod+1) ; //TString volpath = "ALIC_1/XEN1_1/SMOD_"; //volpath += smod+1; if(fKey110DEG && smod >= 10){ - sprintf(path,"/ALIC_1/XEN1_1/SM10_%d",smod-10+1) ; + snprintf(path,buffersize,"/ALIC_1/XEN1_1/SM10_%d",smod-10+1) ; //volpath = "ALIC_1/XEN1_1/SM10_"; //volpath += smod-10+1; } diff --git a/EMCAL/AliEMCALPIDUtils.cxx b/EMCAL/AliEMCALPIDUtils.cxx index 3975b94884c..bae8bccddaa 100644 --- a/EMCAL/AliEMCALPIDUtils.cxx +++ b/EMCAL/AliEMCALPIDUtils.cxx @@ -411,9 +411,10 @@ void AliEMCALPIDUtils::SetLowFluxParam() fGamma[i][j] = fHadron[i][j] = fPiZero[i][j] = 0.; fGamma1to10[i][j] = fHadron1to10[i][j] = 0.; } - fGammaEnergyProb[i] = fGammaEnergyProb[i]; - fPiZeroEnergyProb[i] = fPiZeroEnergyProb[i]; - fHadronEnergyProb[i] = fHadronEnergyProb[i]; + //Why we had the next 3 lines? + //fGammaEnergyProb[i] = fGammaEnergyProb[i]; + //fPiZeroEnergyProb[i] = fPiZeroEnergyProb[i]; + //fHadronEnergyProb[i] = fHadronEnergyProb[i]; } // New parameterization for lambda0^2 (=x): f(x) = normLandau*TMath::Landau(x,mpvLandau,widthLandau)+normgaus*TMath::Gaus(x,meangaus,sigmagaus) diff --git a/EMCAL/AliEMCALQAChecker.cxx b/EMCAL/AliEMCALQAChecker.cxx index c36bcc1d339..54089f98f95 100644 --- a/EMCAL/AliEMCALQAChecker.cxx +++ b/EMCAL/AliEMCALQAChecker.cxx @@ -211,21 +211,22 @@ void AliEMCALQAChecker::CheckRaws(Double_t * test, TObjArray ** list) printf("%2.2f %% towers out of range [0.8, 1.2]\n", (1-rv)*100); if(fText){ fText->Clear() ; - } - fText->AddText(Form("%2.2f %% towers out of range [0.8, 1.2]", (1-rv)*100)); - if (rv < 0.9) { - test[specie] = 0.9 ; - // 2 lines text info for quality - fText->SetFillColor(2) ; - fText->AddText(Form("EMCAL = NOK, CALL EXPERTS!!!")); - } - else { - test[specie] = 0.1 ; - fText->SetFillColor(3) ; - fText->AddText(Form("EMCAL = OK, ENJOY...")); - } - //hdata->Reset("ICE"); - //ratio->Reset("ICE"); + + fText->AddText(Form("%2.2f %% towers out of range [0.8, 1.2]", (1-rv)*100)); + if (rv < 0.9) { + test[specie] = 0.9 ; + // 2 lines text info for quality + fText->SetFillColor(2) ; + fText->AddText(Form("EMCAL = NOK, CALL EXPERTS!!!")); + } + else { + test[specie] = 0.1 ; + fText->SetFillColor(3) ; + fText->AddText(Form("EMCAL = OK, ENJOY...")); + } + //hdata->Reset("ICE"); + //ratio->Reset("ICE"); + }//fText } } //finish the checking } diff --git a/EMCAL/AliEMCALReconstructor.cxx b/EMCAL/AliEMCALReconstructor.cxx index 3ca709513a7..566cf6f2985 100644 --- a/EMCAL/AliEMCALReconstructor.cxx +++ b/EMCAL/AliEMCALReconstructor.cxx @@ -88,9 +88,12 @@ AliEMCALReconstructor::AliEMCALReconstructor() //To make sure we match with the geometry in a simulation file, //let's try to get it first. If not, take the default geometry AliRunLoader *rl = AliRunLoader::Instance(); - if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL")) { - fGeom = dynamic_cast(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry(); - } else { + if (rl->GetAliRun()){ + AliEMCAL * emcal = dynamic_cast(rl->GetAliRun()->GetDetector("EMCAL")); + if(emcal) fGeom = emcal->GetGeometry(); + } + + if(!fGeom) { AliInfo(Form("Using default geometry in reconstruction")); fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName()); } @@ -176,22 +179,24 @@ void AliEMCALReconstructor::InitClusterizer() AliEMCALRecParam *recParam = NULL; AliCDBEntry *entry = (AliCDBEntry*) - AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam"); + AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam"); //Get The reco param for the default event specie if (entry) recParam = (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(0); - if(!recParam) + if(!recParam){ AliFatal("RecoParam not found in CDB!"); - - if (recParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1) + } + else{ + if (recParam->GetClusterizerFlag() == AliEMCALRecParam::kClusterizerv1) { fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData,fPedestalData); } - else + else { fgClusterizer = new AliEMCALClusterizerNxN(fGeom, fCalibData,fPedestalData); } + } } @@ -559,11 +564,12 @@ void AliEMCALReconstructor::FillMisalMatrixes(AliESDEvent* esd)const{ return ; } //Note, that owner of copied marixes will be header - char path[255] ; + const Int_t bufsize = 255; + char path[bufsize] ; TGeoHMatrix * m = 0x0; for(Int_t sm = 0; sm < fGeom->GetNumberOfSuperModules(); sm++){ - sprintf(path,"/ALIC_1/XEN1_1/SMOD_%d",sm+1) ; //In Geometry modules numbered 1,2,.,5 - if(sm >= 10) sprintf(path,"/ALIC_1/XEN1_1/SM10_%d",sm-10+1) ; + snprintf(path,bufsize,"/ALIC_1/XEN1_1/SMOD_%d",sm+1) ; //In Geometry modules numbered 1,2,.,5 + if(sm >= 10) snprintf(path,bufsize,"/ALIC_1/XEN1_1/SM10_%d",sm-10+1) ; if (gGeoManager->CheckPath(path)){ gGeoManager->cd(path); diff --git a/EMCAL/AliEMCALSDigitizer.cxx b/EMCAL/AliEMCALSDigitizer.cxx index 5ddce2827fe..eab20f7ab56 100644 --- a/EMCAL/AliEMCALSDigitizer.cxx +++ b/EMCAL/AliEMCALSDigitizer.cxx @@ -251,7 +251,7 @@ void AliEMCALSDigitizer::Exec(Option_t *option) if (!fInit) { // to prevent overwrite existing file AliError( Form("Give a version name different from %s", fEventFolderName.Data()) ) ; return ; - } + } if (fLastEvent == -1) fLastEvent = rl->GetNumberOfEvents() - 1 ; @@ -272,7 +272,7 @@ void AliEMCALSDigitizer::Exec(Option_t *option) emcalLoader->MakeSDigitsContainer(); treeS = emcalLoader->TreeS(); } - + TClonesArray * sdigits = emcalLoader->SDigits() ; sdigits->Clear("C"); @@ -288,52 +288,64 @@ void AliEMCALSDigitizer::Exec(Option_t *option) //if(fHits)fHits->Clear(); branchH->SetAddress(&fHits); for (iTrack = 0; iTrack < nTrack; iTrack++) { - branchH->GetEntry(iTrack); - Int_t nHit = fHits->GetEntriesFast(); - for(iHit = 0; iHit< nHit;iHit++){ - - AliEMCALHit * hit = dynamic_cast(fHits->At(iHit)) ; - AliEMCALDigit * curSDigit = 0 ; - AliEMCALDigit * sdigit = 0 ; - Bool_t newsdigit = kTRUE; - - // hit->GetId() - Absolute Id number EMCAL segment - if(geom->CheckAbsCellId(hit->GetId())) { // was IsInECA(hit->GetId()) - energy = hit->GetEnergy() * fSampling; // 23-nov-04 - if(energy > fECPrimThreshold ) - // Assign primary number only if deposited energy is significant - curSDigit = new AliEMCALDigit(hit->GetPrimary(), - hit->GetIparent(), hit->GetId(), - Digitize(energy), hit->GetTime(),kFALSE, - -1, 0,0,energy ) ; - else - curSDigit = new AliEMCALDigit(-1, - -1, - hit->GetId(), - Digitize(energy), hit->GetTime(),kFALSE, - -1, 0,0,energy ) ; - } else { - Warning("Exec"," abs id %i is bad \n", hit->GetId()); - newsdigit = kFALSE; - curSDigit = 0; - } - - if(curSDigit != 0){ - for(Int_t check= 0; check < nSdigits ; check++) { - sdigit = dynamic_cast(sdigits->At(check)) ; - - if( sdigit->GetId() == curSDigit->GetId()) { // Are we in the same ECAL tower ? - *sdigit = *sdigit + *curSDigit; - newsdigit = kFALSE; - } - } - } - if (newsdigit) { - new((*sdigits)[nSdigits]) AliEMCALDigit(*curSDigit); - nSdigits++ ; - } - delete curSDigit ; - } // loop over all hits (hit = deposited energy/entering particle) + branchH->GetEntry(iTrack); + + if(fHits){ + + Int_t nHit = fHits->GetEntriesFast(); + for(iHit = 0; iHit< nHit;iHit++){ + + AliEMCALHit * hit = dynamic_cast(fHits->At(iHit)) ; + AliEMCALDigit * curSDigit = 0 ; + AliEMCALDigit * sdigit = 0 ; + Bool_t newsdigit = kTRUE; + + // hit->GetId() - Absolute Id number EMCAL segment + if(hit){ + if(geom->CheckAbsCellId(hit->GetId())) { // was IsInECA(hit->GetId()) + energy = hit->GetEnergy() * fSampling; // 23-nov-04 + if(energy > fECPrimThreshold ) + // Assign primary number only if deposited energy is significant + curSDigit = new AliEMCALDigit(hit->GetPrimary(), + hit->GetIparent(), hit->GetId(), + Digitize(energy), hit->GetTime(),kFALSE, + -1, 0,0,energy ) ; + else + curSDigit = new AliEMCALDigit(-1, + -1, + hit->GetId(), + Digitize(energy), hit->GetTime(),kFALSE, + -1, 0,0,energy ) ; + } else { + Warning("Exec"," abs id %i is bad \n", hit->GetId()); + newsdigit = kFALSE; + curSDigit = 0; + } + + if(curSDigit != 0){ + for(Int_t check= 0; check < nSdigits ; check++) { + sdigit = dynamic_cast(sdigits->At(check)) ; + + if( sdigit->GetId() == curSDigit->GetId()) { // Are we in the same ECAL tower ? + *sdigit = *sdigit + *curSDigit; + newsdigit = kFALSE; + } + } + } + if (newsdigit) { + new((*sdigits)[nSdigits]) AliEMCALDigit(*curSDigit); + nSdigits++ ; + } + delete curSDigit ; + + }// hit exists + else AliFatal("Hit is NULL!"); + + } // loop over all hits (hit = deposited energy/entering particle) + + }//fHits is not NULL + else AliFatal("fHit is NULL!"); + sdigits->Sort() ; nSdigits = sdigits->GetEntriesFast() ; @@ -341,7 +353,8 @@ void AliEMCALSDigitizer::Exec(Option_t *option) for (iSDigit = 0 ; iSDigit < sdigits->GetEntriesFast() ; iSDigit++) { AliEMCALDigit * sdigit = dynamic_cast(sdigits->At(iSDigit)) ; - sdigit->SetIndexInList(iSDigit) ; + if(sdigit)sdigit->SetIndexInList(iSDigit) ; + else AliFatal("sdigit is NULL!"); } if(fHits)fHits->Clear(); }//track loop @@ -374,7 +387,7 @@ void AliEMCALSDigitizer::Exec(Option_t *option) if(strstr(option,"tim")){ gBenchmark->Stop("EMCALSDigitizer"); printf("\n Exec: took %f seconds for SDigitizing %f seconds per event\n", - gBenchmark->GetCpuTime("EMCALSDigitizer"), gBenchmark->GetCpuTime("EMCALSDigitizer")/nEvents ) ; + gBenchmark->GetCpuTime("EMCALSDigitizer"), gBenchmark->GetCpuTime("EMCALSDigitizer")/nEvents ) ; } } @@ -459,37 +472,44 @@ Bool_t AliEMCALSDigitizer::operator==( AliEMCALSDigitizer const &sd )const void AliEMCALSDigitizer::PrintSDigits(Option_t * option) { //Prints list of digits produced at the current pass of AliEMCALDigitizer - - AliEMCALLoader *rl = dynamic_cast(AliRunLoader::Instance()->GetDetectorLoader("EMCAL")); - const TClonesArray * sdigits = rl->SDigits() ; - printf("\n") ; - printf("event %i", rl->GetRunLoader()->GetEventNumber()); - printf(" Number of entries in SDigits list %i", sdigits->GetEntriesFast()); - if(strstr(option,"all")||strstr(option,"EMC")){ + AliEMCALLoader *rl = dynamic_cast(AliRunLoader::Instance()->GetDetectorLoader("EMCAL")); + if(rl){ + const TClonesArray * sdigits = rl->SDigits() ; - //loop over digits - AliEMCALDigit * digit; - printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ; - Int_t index = 0; - Float_t isum = 0.; - char * tempo = new char[8192]; - for (index = 0 ; index < sdigits->GetEntries() ; index++) { - digit = dynamic_cast( sdigits->At(index) ) ; - sprintf(tempo, "\n%6d %8f %6.5e %4d %2d :", - digit->GetId(), digit->GetAmplitude(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ; - printf("%s",tempo); - isum += digit->GetAmplitude(); + printf("\n") ; + printf("event %i", rl->GetRunLoader()->GetEventNumber()); + printf(" Number of entries in SDigits list %i", sdigits->GetEntriesFast()); + if(strstr(option,"all")||strstr(option,"EMC")){ - Int_t iprimary; - for (iprimary=0; iprimaryGetNprimary(); iprimary++) { - sprintf(tempo, "%d ",digit->GetPrimary(iprimary+1) ) ; - printf("%s",tempo); - } - } - delete [] tempo ; - printf("\n** Sum %2.3f : %10.3f GeV/c **\n ", isum, Calibrate(isum)); - } else printf("\n"); + //loop over digits + AliEMCALDigit * digit; + printf("\n Id Amplitude Time Index Nprim: Primaries list \n") ; + Int_t index = 0; + Float_t isum = 0.; + const Int_t bufferSize = 8192; + char * tempo = new char[bufferSize]; + for (index = 0 ; index < sdigits->GetEntries() ; index++) { + digit = dynamic_cast( sdigits->At(index) ) ; + if(digit){ + snprintf(tempo, bufferSize,"\n%6d %8f %6.5e %4d %2d :", + digit->GetId(), digit->GetAmplitude(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ; + printf("%s",tempo); + isum += digit->GetAmplitude(); + + Int_t iprimary; + for (iprimary=0; iprimaryGetNprimary(); iprimary++) { + snprintf(tempo,bufferSize, "%d ",digit->GetPrimary(iprimary+1) ) ; + printf("%s",tempo); + } + } //sdigit exists + else AliFatal("SDigit is NULL!"); + }//loop + delete [] tempo ; + printf("\n** Sum %2.3f : %10.3f GeV/c **\n ", isum, Calibrate(isum)); + } else printf("\n"); + } + else AliFatal("EMCALLoader is NULL!"); } //____________________________________________________________________________ @@ -497,8 +517,11 @@ void AliEMCALSDigitizer::Unload() const { // Unload Hits and SDigits from the folder AliEMCALLoader *rl = dynamic_cast(AliRunLoader::Instance()->GetDetectorLoader("EMCAL")); - rl->UnloadHits() ; - rl->UnloadSDigits() ; + if(rl){ + rl->UnloadHits() ; + rl->UnloadSDigits() ; + } + else AliFatal("EMCALLoader is NULL!"); } //____________________________________________________________________________ diff --git a/EMCAL/AliEMCALSurvey.cxx b/EMCAL/AliEMCALSurvey.cxx index 7782097a479..d27f8901305 100644 --- a/EMCAL/AliEMCALSurvey.cxx +++ b/EMCAL/AliEMCALSurvey.cxx @@ -84,24 +84,24 @@ AliEMCALSurvey::AliEMCALSurvey(const TString &txtFileName,const SurveyDataType_t //Get the geometry object and then attempt to //read survey data from a file, depending on which //method (kSurvey or kDummy) is selected. - + const AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(); if (!geom) { AliError("Cannot obtain AliEMCALGeometry instance."); return; } - + fNSuperModule = geom->GetNumberOfSuperModules(); - + if(fDataType == kSurvey) { - + AliSurveyObj *s1 = new AliSurveyObj(); s1->FillFromLocalFile(txtFileName); TObjArray* points = s1->GetData(); InitSuperModuleData(points); - + } else { - + //Use a dummy file that stores x,y,z of the center of each SM //useful for testing... std::ifstream inputFile(txtFileName.Data()); @@ -109,39 +109,48 @@ AliEMCALSurvey::AliEMCALSurvey(const TString &txtFileName,const SurveyDataType_t AliError(("Cannot open the survey file " + txtFileName).Data()); return; } + Int_t dummyInt = 0; - Double_t *xReal = new Double_t[fNSuperModule]; - Double_t *yReal = new Double_t[fNSuperModule]; - Double_t *zReal = new Double_t[fNSuperModule]; - Double_t *psiReal = new Double_t[fNSuperModule]; + Double_t *xReal = new Double_t[fNSuperModule]; + Double_t *yReal = new Double_t[fNSuperModule]; + Double_t *zReal = new Double_t[fNSuperModule]; + Double_t *psiReal = new Double_t[fNSuperModule]; Double_t *thetaReal = new Double_t[fNSuperModule]; - Double_t *phiReal = new Double_t[fNSuperModule]; - + Double_t *phiReal = new Double_t[fNSuperModule]; + //init the arrays + memset(xReal, 0,sizeof(Int_t)*fNSuperModule); + memset(yReal, 0,sizeof(Int_t)*fNSuperModule); + memset(zReal, 0,sizeof(Int_t)*fNSuperModule); + memset(psiReal, 0,sizeof(Int_t)*fNSuperModule); + memset(thetaReal, 0,sizeof(Int_t)*fNSuperModule); + memset(phiReal, 0,sizeof(Int_t)*fNSuperModule); + + for (Int_t i = 0; i < fNSuperModule; ++i) { if (!inputFile) { - AliError("Error while reading input file."); - delete [] xReal; - delete [] yReal; - delete [] zReal; - delete [] psiReal; - delete [] thetaReal; - delete [] phiReal; - return; + AliError("Error while reading input file."); + delete [] xReal; + delete [] yReal; + delete [] zReal; + delete [] psiReal; + delete [] thetaReal; + delete [] phiReal; + return; } inputFile>>dummyInt>>xReal[i]>>yReal[i]>>zReal[i]>>psiReal[i]>>thetaReal[i]>>phiReal[i]; } - + InitSuperModuleData(xReal, yReal, zReal, psiReal, thetaReal, phiReal); - + delete [] xReal; delete [] yReal; delete [] zReal; delete [] psiReal; delete [] thetaReal; delete [] phiReal; - + } //kDummy way of doing it - + } //____________________________________________________________________________ @@ -241,54 +250,54 @@ void AliEMCALSurvey::InitSuperModuleData(const TObjArray *svypts) //This method uses the data points from the EMCAL survey and CATIA program to //create the alignment matrices. Only valid for (installed) //SM, others will have null objects - + /*-------------------------------------- - The bottom edges of the strip modules - define the active area of the EMCAL, but - in software we have a box to hold them which - is longer than that. We need to convert - info about the position of the corners of the - bottom of the active area to the center of - the software box that contains the strip - modules. - - View from beam axis up to EMCAL - Ai Ci - - 0,1 0,0 1,0 1,1 - xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx - x x x x x x - x x % * x x * % x x - x x x x x x - xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx - 1,1 1,0 0,0 0,1 - <--> = added length <--> = added length - - * represents the center of the active area - % represents the center of the full box (with added length) - - View from side of topmost SM - - Ai Ci - - 0,1 0,0 1,0 1,1 - xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx - x x % * x x % * x x - xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx - 1,1 1,0 0,0 0,1 - <--> = added length <--> = added length - - * represents the center of the active area - % represents the center of the full box (with added length) - - -------------------------------------*/ - + The bottom edges of the strip modules + define the active area of the EMCAL, but + in software we have a box to hold them which + is longer than that. We need to convert + info about the position of the corners of the + bottom of the active area to the center of + the software box that contains the strip + modules. + + View from beam axis up to EMCAL + Ai Ci + + 0,1 0,0 1,0 1,1 + xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx + x x x x x x + x x % * x x * % x x + x x x x x x + xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx + 1,1 1,0 0,0 0,1 + <--> = added length <--> = added length + + * represents the center of the active area + % represents the center of the full box (with added length) + + View from side of topmost SM + + Ai Ci + + 0,1 0,0 1,0 1,1 + xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx + x x % * x x % * x x + xxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx + 1,1 1,0 0,0 0,1 + <--> = added length <--> = added length + + * represents the center of the active area + % represents the center of the full box (with added length) + + -------------------------------------*/ + AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(); //Center of supermodules Float_t *pars = geom->GetSuperModulesPars(); Double_t rpos = (geom->GetEnvelop(0) + geom->GetEnvelop(1))/2.; Double_t phi=0, phiRad=0, xpos=0, ypos=0, zpos=0; - + AliEMCALSuperModuleCoords *idealSM = new AliEMCALSuperModuleCoords[fNSuperModule]; for (Int_t smodnum = 0; smodnum < geom->GetNumberOfSuperModules(); ++smodnum) { AliEMCALSuperModuleCoords &smc = idealSM[smodnum]; @@ -311,25 +320,25 @@ void AliEMCALSurvey::InitSuperModuleData(const TObjArray *svypts) } else { smc.fZ1 = -zpos; } - + //printf("PHI OF IDEAL SM = %.2f\n",smc.fPhi); - + } - + //Real coordinates of center and rotation angles need to be computed //from the survey/CATIA points - - char substr[100]; + const Int_t buffersize = 255; + char substr[buffersize]; AliEMCALSuperModuleCoords *realSM = new AliEMCALSuperModuleCoords[fNSuperModule]; for (Int_t smodnum = 0; smodnum < geom->GetNumberOfSuperModules(); ++smodnum) { AliEMCALSuperModuleCoords &smc = realSM[smodnum]; Double_t zLength = pars[2]*2.; //length of SM in z from software Double_t halfHeight = pars[0]; //half the height of the SM in y direction - - sprintf(substr,"4096%d",smodnum); + + snprintf(substr,buffersize,"4096%d",smodnum); //retrieve components of four face points and determine average position of center //in x,y,z - + std::vector xval; std::vector yval; std::vector zval; @@ -338,22 +347,22 @@ void AliEMCALSurvey::InitSuperModuleData(const TObjArray *svypts) AliSurveyPoint* pt = (AliSurveyPoint*)svypts->At(i); TString ptname = pt->GetPointName(); if(ptname.Contains(substr)) { - //Note: order of values is 00, 01, 10, 11 - xval.push_back(pt->GetX()*100.); //convert m to cm - yval.push_back(pt->GetY()*100.); - zval.push_back(pt->GetZ()*100.); + //Note: order of values is 00, 01, 10, 11 + xval.push_back(pt->GetX()*100.); //convert m to cm + yval.push_back(pt->GetY()*100.); + zval.push_back(pt->GetZ()*100.); } } - + //compute center of active area of each SM on bottome face from survey points Double_t activeX = ((xval[0] + (xval[2] - xval[0])/2.) //x00 and x10 - +(xval[1] + (xval[3] - xval[1])/2.) ) /2.; //x01 and x11 + +(xval[1] + (xval[3] - xval[1])/2.) ) /2.; //x01 and x11 -// Double_t activeY = ((yval[0] + (yval[2] - yval[0])/2.) -// +(yval[1] + (yval[3] - yval[1])/2.) ) /2.; -// -// Double_t activeZ = ((zval[0] + (zval[2] - zval[0])/2.) -// +(zval[1] + (zval[3] - zval[1])/2.) ) /2.; + // Double_t activeY = ((yval[0] + (yval[2] - yval[0])/2.) + // +(yval[1] + (yval[3] - yval[1])/2.) ) /2.; + // + // Double_t activeZ = ((zval[0] + (zval[2] - zval[0])/2.) + // +(zval[1] + (zval[3] - zval[1])/2.) ) /2.; //printf("Bottom Center of active area of SM %s: %.2f, %.2f, %.2f\n",substr,activeX,activeY,activeZ); @@ -365,26 +374,26 @@ void AliEMCALSurvey::InitSuperModuleData(const TObjArray *svypts) //Note: this is phi wrt y axis. To get phi wrt to x, add pi/2 if(smodnum%2 == 0) { realphi = (TMath::ATan((yval[2] - yval[0])/(xval[2] - xval[0])) - +TMath::ATan((yval[3] - yval[1])/(xval[3] - xval[1])) )/2.; + +TMath::ATan((yval[3] - yval[1])/(xval[3] - xval[1])) )/2.; } else { realphi = (TMath::ATan((yval[0] - yval[2])/(xval[0] - xval[2])) - +TMath::ATan((yval[1] - yval[3])/(xval[1] - xval[3])) )/2.; + +TMath::ATan((yval[1] - yval[3])/(xval[1] - xval[3])) )/2.; } - + //NOTE: Psi angle is always zero because the two z values being //subtracted are exactly the same, but just in case that could change... //psi = angle in x-z plane Double_t realpsi = (TMath::ATan((zval[0] - zval[2])/(xval[2] - xval[0])) - +TMath::ATan((zval[1] - zval[3])/(xval[3] - xval[1])) )/2.; + +TMath::ATan((zval[1] - zval[3])/(xval[3] - xval[1])) )/2.; //theta = angle in y-z plane Double_t realtheta = TMath::Pi()/2. - - (TMath::ATan((zval[2] - zval[3])/(yval[3] - yval[2])) - +TMath::ATan((zval[0] - zval[1])/(yval[1] - yval[0])) )/2.; - + - (TMath::ATan((zval[2] - zval[3])/(yval[3] - yval[2])) + +TMath::ATan((zval[0] - zval[1])/(yval[1] - yval[0])) )/2.; + //printf("Old edge of %s 01: %.2f, %.2f, %.2f\n",substr,xval[1],yval[1],zval[1]); //printf("Old edge of %s 11: %.2f, %.2f, %.2f\n",substr,xval[3],yval[3],zval[3]); - + //Now calculate the center of the box in z with length added to the 01 //and 11 corners, corrected by the theta angle Double_t activeLength = TMath::Abs(((zval[1] - zval[0]) + (zval[3] - zval[2]))/2.); @@ -400,37 +409,37 @@ void AliEMCALSurvey::InitSuperModuleData(const TObjArray *svypts) zval[1] -= (zLength - activeLength)*cos(realtheta); zval[3] -= (zLength - activeLength)*cos(realtheta); } - + //printf("New extended edge of %s 01: %.2f, %.2f, %.2f\n",substr,xval[1],yval[1],zval[1]); //printf("New extended edge of %s 11: %.2f, %.2f, %.2f\n",substr,xval[3],yval[3],zval[3]); - + //Compute the center of the bottom of the box in x,y,z Double_t realX = activeX; Double_t realY = ((yval[0] + (yval[2] - yval[0])/2.) - +(yval[1] + (yval[3] - yval[1])/2.) ) /2.; + +(yval[1] + (yval[3] - yval[1])/2.) ) /2.; Double_t realZ = ((zval[0] + (zval[2] - zval[0])/2.) - +(zval[1] + (zval[3] - zval[1])/2.) ) /2.; - - + +(zval[1] + (zval[3] - zval[1])/2.) ) /2.; + + //printf("Bottom Center of SM %s Box: %.2f, %.2f, %.2f\n",substr,realX,realY,realZ); - + //correct the SM centers so that we have the center of the box in //x,y using the phi,theta angles realX += halfHeight*TMath::Cos(TMath::Pi()/2+realphi); realY += halfHeight*(TMath::Sin(TMath::Pi()/2+realphi) + TMath::Sin(realtheta)); realZ += halfHeight*TMath::Cos(TMath::Pi()/2-realtheta); - + //printf("Rotation angles of SM %s: %.4f, %.4f, %.4f\n",substr,realphi*TMath::RadToDeg(),realpsi*TMath::RadToDeg(),realtheta*TMath::RadToDeg()); //printf("Middle of SM %s: %.2f, %.2f, %.2f\n\n",substr,realX,realY,realZ); - + smc.fX1 = realX; smc.fY1 = realY; smc.fZ1 = realZ; - + smc.fPhi = 90. + realphi*TMath::RadToDeg(); smc.fTheta = 0. + realtheta*TMath::RadToDeg(); smc.fPsi = 0. + realpsi*TMath::RadToDeg(); - + }//loop over supermodules fSuperModuleData = new AliEMCALSuperModuleDelta[fNSuperModule]; @@ -445,7 +454,7 @@ void AliEMCALSurvey::InitSuperModuleData(const TObjArray *svypts) t.fPhi = real.fPhi - ideal.fPhi; t.fTheta = real.fTheta - ideal.fTheta; t.fPsi = real.fPsi - ideal.fPsi; - + printf("===================== SM %d =======================\n",i); printf("real x (%.2f) - ideal x (%.2f) = shift in x (%.2f)\n",real.fX1,ideal.fX1,t.fXShift); printf("real y (%.2f) - ideal y (%.2f) = shift in y (%.2f)\n",real.fY1,ideal.fY1,t.fYShift); @@ -455,7 +464,7 @@ void AliEMCALSurvey::InitSuperModuleData(const TObjArray *svypts) printf("real phi (%.2f) - ideal phi (%.2f) = shift in phi %.2f\n",real.fPhi,ideal.fPhi,t.fPhi); printf("===================================================\n"); } - + delete [] realSM; delete [] idealSM; } -- 2.43.0