X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EMCAL%2FAliEMCALReconstructor.cxx;h=526a5680eaa46310f8ac80133408c635946e2215;hb=9519e3e3eab8deea511b84c15f82ee14d0b15130;hp=5da4a598f14130283f44b06dc3578a34529f8d23;hpb=408710530b2a466829df74b21081e361ea54a8a7;p=u%2Fmrichter%2FAliRoot.git diff --git a/EMCAL/AliEMCALReconstructor.cxx b/EMCAL/AliEMCALReconstructor.cxx index 5da4a598f14..526a5680eaa 100644 --- a/EMCAL/AliEMCALReconstructor.cxx +++ b/EMCAL/AliEMCALReconstructor.cxx @@ -37,6 +37,8 @@ #include "AliEMCALReconstructor.h" #include "AliCodeTimer.h" +#include "AliCaloCalibPedestal.h" +#include "AliEMCALCalibData.h" #include "AliESDEvent.h" #include "AliESDCaloCluster.h" #include "AliESDCaloCells.h" @@ -45,6 +47,7 @@ #include "AliEMCALRawUtils.h" #include "AliEMCALDigit.h" #include "AliEMCALClusterizerv1.h" +#include "AliEMCALClusterizerNxN.h" #include "AliEMCALRecPoint.h" #include "AliEMCALPID.h" #include "AliEMCALTrigger.h" @@ -59,18 +62,24 @@ #include "AliRun.h" #include "AliEMCALTriggerData.h" #include "AliEMCALTriggerElectronics.h" -#include "AliVZEROLoader.h" +#include "AliEMCALTriggerDCSConfigDB.h" +#include "AliEMCALTriggerDCSConfig.h" +#include "AliEMCALTriggerData.h" +#include "AliEMCALTriggerRawDigit.h" +#include "AliEMCALTriggerPatch.h" +#include "AliEMCALTriggerTypes.h" ClassImp(AliEMCALReconstructor) -const AliEMCALRecParam* AliEMCALReconstructor::fgkRecParam = 0; // EMCAL rec. parameters -AliEMCALRawUtils* AliEMCALReconstructor::fgRawUtils = 0; // EMCAL raw utilities class -AliEMCALClusterizer* AliEMCALReconstructor::fgClusterizer = 0; // EMCAL clusterizer class -TClonesArray* AliEMCALReconstructor::fgDigitsArr = 0; // shoud read just once at event +const AliEMCALRecParam* AliEMCALReconstructor::fgkRecParam = 0; // EMCAL rec. parameters +AliEMCALRawUtils* AliEMCALReconstructor::fgRawUtils = 0; // EMCAL raw utilities class +AliEMCALClusterizer* AliEMCALReconstructor::fgClusterizer = 0; // EMCAL clusterizer class +TClonesArray* AliEMCALReconstructor::fgDigitsArr = 0; // list of digits, to be used multiple times +TObjArray* AliEMCALReconstructor::fgClustersArr = 0; // list of clusters, to be used multiple times AliEMCALTriggerElectronics* AliEMCALReconstructor::fgTriggerProcessor = 0x0; //____________________________________________________________________________ AliEMCALReconstructor::AliEMCALReconstructor() - : fDebug(kFALSE), fList(0), fGeom(0),fCalibData(0),fPedestalData(0) + : fDebug(kFALSE), fList(0), fGeom(0),fCalibData(0),fPedestalData(0),fTriggerData(0x0) { // ctor @@ -79,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()); } @@ -100,32 +112,56 @@ AliEMCALReconstructor::AliEMCALReconstructor() //Get calibration parameters if(!fPedestalData) { - AliCDBEntry *entry = (AliCDBEntry*) - AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals"); - if (entry) fPedestalData = (AliCaloCalibPedestal*) entry->GetObject(); + AliCDBEntry *entry = (AliCDBEntry*) + AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals"); + if (entry) fPedestalData = (AliCaloCalibPedestal*) entry->GetObject(); } - - if(!fPedestalData) - AliFatal("Dead map not found in CDB!"); - - - //Init the clusterizer with geometry and calibration pointers, avoid doing it twice. - fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData,fPedestalData); - + + if(!fPedestalData) + AliFatal("Dead map not found in CDB!"); + if(!fGeom) AliFatal(Form("Could not get geometry!")); - fgTriggerProcessor = new AliEMCALTriggerElectronics(); + AliEMCALTriggerDCSConfigDB* dcsConfigDB = AliEMCALTriggerDCSConfigDB::Instance(); + + const AliEMCALTriggerDCSConfig* dcsConfig = dcsConfigDB->GetTriggerDCSConfig(); + + if (!dcsConfig) AliFatal("No Trigger DCS Configuration from OCDB!"); + fgTriggerProcessor = new AliEMCALTriggerElectronics( dcsConfig ); + + fTriggerData = new AliEMCALTriggerData(); + + //Init temporary list of digits + fgDigitsArr = new TClonesArray("AliEMCALDigit",1000); + fgClustersArr = new TObjArray(1000); + } //____________________________________________________________________________ AliEMCALReconstructor::~AliEMCALReconstructor() { // dtor - delete fGeom; - delete fgRawUtils; - delete fgClusterizer; - delete fgTriggerProcessor; + if(fGeom) delete fGeom; + + //No need to delete, recovered from OCDB + //if(fCalibData) delete fCalibData; + //if(fPedestalData) delete fPedestalData; + + if(fgDigitsArr){ + fgDigitsArr->Clear("C"); + delete fgDigitsArr; + } + + if(fgClustersArr){ + fgClustersArr->Clear(); + delete fgClustersArr; + } + + if(fgRawUtils) delete fgRawUtils; + if(fgClusterizer) delete fgClusterizer; + if(fgTriggerProcessor) delete fgTriggerProcessor; + AliCodeTimer::Instance()->Print(); } @@ -136,6 +172,52 @@ AliEMCALReconstructor::~AliEMCALReconstructor() // fList = AliEMCALHistoUtilities::GetTriggersListOfHists(kTRUE); // } +//____________________________________________________________________________ +void AliEMCALReconstructor::InitClusterizer() const +{ + //Init the clusterizer with geometry and calibration pointers, avoid doing it twice. + Int_t clusterizerType = -1; + Int_t eventType = -1; + if(GetRecParam()) { + clusterizerType = GetRecParam()->GetClusterizerFlag(); + eventType = GetRecParam()->GetEventSpecie(); + } + else{ + AliCDBEntry *entry = (AliCDBEntry*) + AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam"); + //Get The reco param for the default event specie + if (entry) { + AliEMCALRecParam *recParam = (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(0); + if(recParam) clusterizerType = recParam->GetClusterizerFlag(); + } + } + + //Check if clusterizer previously set corresponds to what is needed for this event type + if(fgClusterizer){ + if(eventType!=AliRecoParam::kCalib){ + //printf("ReCreate clusterizer? Clusterizer set <%d>, Clusterizer in use <%s>\n", + // clusterizerType, fgClusterizer->Version()); + + if (clusterizerType == AliEMCALRecParam::kClusterizerv1 && !strcmp(fgClusterizer->Version(),"clu-v1")) return; + + else if(clusterizerType == AliEMCALRecParam::kClusterizerNxN && !strcmp(fgClusterizer->Version(),"clu-NxN")) return; + + //Need to create new clusterizer, the one set previously is not the correct one + delete fgClusterizer; + } + else return; + } + + if (clusterizerType == AliEMCALRecParam::kClusterizerv1) + { + fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData,fPedestalData); + } + else + { + fgClusterizer = new AliEMCALClusterizerNxN(fGeom, fCalibData,fPedestalData); + } +} + //____________________________________________________________________________ void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const { @@ -148,64 +230,30 @@ void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) AliCodeTimerAuto("",0) ReadDigitsArrayFromTree(digitsTree); + + InitClusterizer(); + fgClusterizer->InitParameters(); fgClusterizer->SetOutput(clustersTree); - - AliEMCALTriggerData* trgData = new AliEMCALTriggerData(); - - Int_t bufferSize = 32000; - - if (TBranch* triggerBranch = clustersTree->GetBranch("EMTRG")) - triggerBranch->SetAddress(&trgData); - else - clustersTree->Branch("EMTRG","AliEMCALTriggerData",&trgData,bufferSize); - - AliVZEROLoader* vzeroLoader = dynamic_cast(AliRunLoader::Instance()->GetDetectorLoader("VZERO")); - TTree* treeV0 = 0x0; - - if (vzeroLoader) - { - vzeroLoader->LoadDigits("READ"); - treeV0 = vzeroLoader->TreeD(); - } + //Skip clusterization of LED events + if (GetRecParam()->GetEventSpecie()!=AliRecoParam::kCalib){ + + if(fgDigitsArr && fgDigitsArr->GetEntries()) { - TClonesArray *trgDigits = new TClonesArray("AliEMCALRawDigit",1000); - TBranch *branchdig = digitsTree->GetBranch("EMTRG"); - if (!branchdig) - { - AliError("Can't get the branch with the EMCAL trigger digits !"); - return; - } - - branchdig->SetAddress(&trgDigits); - branchdig->GetEntry(0); - - fgTriggerProcessor->Digits2Trigger(trgDigits, treeV0, trgData); - - trgDigits->Delete(); - - if(fgDigitsArr && fgDigitsArr->GetEntries()) { - - fgClusterizer->SetInput(digitsTree); + fgClusterizer->SetInput(digitsTree); - if(Debug()) - fgClusterizer->Digits2Clusters("deb all") ; - else - fgClusterizer->Digits2Clusters(""); + if(Debug()) + fgClusterizer->Digits2Clusters("deb all") ; + else + fgClusterizer->Digits2Clusters(""); - fgClusterizer->Clear(); - - } - - if (vzeroLoader) - { - vzeroLoader->UnloadDigits(); - } + fgClusterizer->Clear(); + }//digits array exists and has somethind + }//not a LED event + clustersTree->Fill(); - - delete trgData; } //____________________________________________________________________________ @@ -218,31 +266,42 @@ void AliEMCALReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digits rawReader->Reset() ; - TClonesArray *digitsArr = new TClonesArray("AliEMCALDigit",200); - TClonesArray *digitsTrg = new TClonesArray("AliEMCALRawDigit", 200); + fTriggerData->SetMode(1); + + if(fgDigitsArr) fgDigitsArr->Clear("C"); + + TClonesArray *digitsTrg = new TClonesArray("AliEMCALTriggerRawDigit", 32 * 96); Int_t bufsize = 32000; - digitsTree->Branch("EMCAL", &digitsArr, bufsize); + digitsTree->Branch("EMCAL", &fgDigitsArr, bufsize); digitsTree->Branch("EMTRG", &digitsTrg, bufsize); - - //must be done here because, in constructor, option is not yet known - fgRawUtils->SetOption(GetOption()); - - fgRawUtils->SetRawFormatHighLowGainFactor(GetRecParam()->GetHighLowGainFactor()); - fgRawUtils->SetRawFormatOrder(GetRecParam()->GetOrderParameter()); - fgRawUtils->SetRawFormatTau(GetRecParam()->GetTau()); - fgRawUtils->SetNoiseThreshold(GetRecParam()->GetNoiseThreshold()); - fgRawUtils->SetNPedSamples(GetRecParam()->GetNPedSamples()); - fgRawUtils->SetRemoveBadChannels(GetRecParam()->GetRemoveBadChannels()); - fgRawUtils->SetFittingAlgorithm(GetRecParam()->GetFittingAlgorithm()); - fgRawUtils->SetFALTROUsage(GetRecParam()->UseFALTRO()); - fgRawUtils->Raw2Digits(rawReader,digitsArr,fPedestalData,digitsTrg); - + //Skip calibration events do the rest + Bool_t doFit = kTRUE; + if ( !(GetRecParam()->FitLEDEvents()) && GetRecParam()->GetEventSpecie()==AliRecoParam::kCalib) doFit = kFALSE; + if (doFit){ + //must be done here because, in constructor, option is not yet known + fgRawUtils->SetOption(GetOption()); + + fgRawUtils->SetRawFormatHighLowGainFactor(GetRecParam()->GetHighLowGainFactor()); + fgRawUtils->SetRawFormatOrder(GetRecParam()->GetOrderParameter()); + fgRawUtils->SetRawFormatTau(GetRecParam()->GetTau()); + fgRawUtils->SetNoiseThreshold(GetRecParam()->GetNoiseThreshold()); + fgRawUtils->SetNPedSamples(GetRecParam()->GetNPedSamples()); + fgRawUtils->SetRemoveBadChannels(GetRecParam()->GetRemoveBadChannels()); + fgRawUtils->SetFittingAlgorithm(GetRecParam()->GetFittingAlgorithm()); + fgRawUtils->SetFALTROUsage(GetRecParam()->UseFALTRO()); + fgRawUtils->SetTimeMin(GetRecParam()->GetTimeMin()); + fgRawUtils->SetTimeMax(GetRecParam()->GetTimeMax()); + + fgRawUtils->Raw2Digits(rawReader,fgDigitsArr,fPedestalData,digitsTrg,fTriggerData); + }//skip calibration event + else{ + AliDebug(1," Calibration Event, skip!"); + } + digitsTree->Fill(); - digitsArr->Delete(); digitsTrg->Delete(); - delete digitsArr; delete digitsTrg; } @@ -255,115 +314,116 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, // Called by AliReconstruct after Reconstruct() and global tracking and vertexing // and V0 // Works on the current event - // printf(" ## AliEMCALReconstructor::FillESD() is started ### \n "); + // printf(" ## AliEMCALReconstructor::FillESD() is started ### \n "); //return; - //###################################################### - //#########Calculate trigger and set trigger info########### - //###################################################### - // Obsolete, to be changed with new trigger emulator when consensus is achieved about what is stored in ESDs. - AliEMCALTrigger tr; - // tr.SetPatchSize(1); // create 4x4 patches - tr.SetSimulation(kFALSE); // Reconstruction mode - tr.SetDigitsList(fgDigitsArr); - // Get VZERO total multiplicity for jet trigger simulation - // The simulation of jey trigger will be incorrect if no VZERO data - // at ESD - AliESDVZERO* vZero = esd->GetVZEROData(); - if(vZero) { - tr.SetVZER0Multiplicity(vZero->GetMTotV0A() + vZero->GetMTotV0C()); - } - // - tr.Trigger(); - - Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude(); - Float_t maxAmpnxn = tr.GetnxnMaxAmplitude(); - Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ; - Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ; - - Int_t iSM2x2 = tr.Get2x2SuperModule(); - Int_t iSMnxn = tr.GetnxnSuperModule(); - Int_t iModulePhi2x2 = tr.Get2x2ModulePhi(); - Int_t iModulePhinxn = tr.GetnxnModulePhi(); - Int_t iModuleEta2x2 = tr.Get2x2ModuleEta(); - Int_t iModuleEtanxn = tr.GetnxnModuleEta(); - - AliDebug(2, Form("Trigger 2x2 max amp %f, out amp %f, SM %d, iphi %d ieta %d", maxAmp2x2, ampOutOfPatch2x2, iSM2x2,iModulePhi2x2, iModuleEta2x2)); - AliDebug(2, Form("Trigger 4x4 max amp %f , out amp %f, SM %d, iphi %d, ieta %d", maxAmpnxn, ampOutOfPatchnxn, iSMnxn,iModulePhinxn, iModuleEtanxn)); - - TVector3 pos2x2(-1,-1,-1); - TVector3 posnxn(-1,-1,-1); - - Int_t iAbsId2x2 = fGeom->GetAbsCellIdFromCellIndexes( iSM2x2, iModulePhi2x2, iModuleEta2x2) ; // should be changed to Module - Int_t iAbsIdnxn = fGeom->GetAbsCellIdFromCellIndexes( iSMnxn, iModulePhinxn, iModuleEtanxn) ; - fGeom->GetGlobal(iAbsId2x2, pos2x2); - fGeom->GetGlobal(iAbsIdnxn, posnxn); - //printf(" iAbsId2x2 %i iAbsIdnxn %i \n", iAbsId2x2, iAbsIdnxn); + //######################################## + // Trigger + //######################################## + + Int_t v0M[2] = {0, 0}; + + AliESDVZERO* esdV0 = esd->GetVZEROData(); + + if (esdV0) + { + for (Int_t i = 0; i < 32; i++) + { + v0M[0] += (Int_t)esdV0->GetAdcV0C(i); + v0M[1] += (Int_t)esdV0->GetAdcV0A(i); + } + } + else + { + AliWarning("Cannot retrieve V0 ESD! Run w/ null V0 charges"); + } + + TClonesArray *trgDigits = new TClonesArray("AliEMCALTriggerRawDigit",1000); + + TBranch *branchtrg = digitsTree->GetBranch("EMTRG"); + + if (!branchtrg) + { + AliError("Can't get the branch with the EMCAL trigger digits!"); + return; + } + + branchtrg->SetAddress(&trgDigits); + branchtrg->GetEntry(0); - TArrayF triggerPosition(6); - triggerPosition[0] = pos2x2(0) ; - triggerPosition[1] = pos2x2(1) ; - triggerPosition[2] = pos2x2(2) ; - triggerPosition[3] = posnxn(0) ; - triggerPosition[4] = posnxn(1) ; - triggerPosition[5] = posnxn(2) ; - //printf(" triggerPosition "); - //for(int i=0; i<6; i++) printf(" %i %f : ", i, triggerPosition[i]); - - TArrayF triggerAmplitudes(4); - triggerAmplitudes[0] = maxAmp2x2 ; - triggerAmplitudes[1] = ampOutOfPatch2x2 ; - triggerAmplitudes[2] = maxAmpnxn ; - triggerAmplitudes[3] = ampOutOfPatchnxn ; - //printf("\n triggerAmplitudes "); - //for(int i=0; i<4; i++) printf(" %i %f : ", i, triggerAmplitudes[i]); - //printf("\n"); - //tr.Print(""); - // - // Trigger jet staff - // - if(tr.GetNJetThreshold()>0) { - // Jet phi/eta - Int_t n0 = triggerPosition.GetSize(); - const TH2F *hpatch = tr.GetJetMatrixE(); - triggerPosition.Set(n0 + 2); - for(Int_t i=0; i<2; i++) triggerPosition[n0+i] = hpatch->GetMean(i+1); - // Add jet ampitudes - n0 = triggerAmplitudes.GetSize(); - triggerAmplitudes.Set(n0 + tr.GetNJetThreshold()); - Double_t *ampJet = tr.GetL1JetThresholds(); - for(Int_t i=0; iAddEMCALTriggerPosition(triggerPosition); - esd->AddEMCALTriggerAmplitudes(triggerAmplitudes); - // Fill trigger hists - // AliEMCALHistoUtilities::FillTriggersListOfHists(fList,&triggerPosition,&triggerAmplitudes); + // Note: fgTriggerProcessor reset done at the end of this method + fgTriggerProcessor->Digits2Trigger(trgDigits, v0M, fTriggerData); + // Fill ESD + AliESDCaloTrigger* trgESD = esd->GetCaloTrigger("EMCAL"); + + if (trgESD) + { + trgESD->Allocate(trgDigits->GetEntriesFast()); + + for (Int_t i = 0; i < trgDigits->GetEntriesFast(); i++) + { + AliEMCALTriggerRawDigit* rdig = (AliEMCALTriggerRawDigit*)trgDigits->At(i); + + Int_t px, py; + if (fGeom->GetPositionInEMCALFromAbsFastORIndex(rdig->GetId(), px, py)) + { + Int_t a = -1, t = -1, times[10]; + + rdig->GetMaximum(a, t); + rdig->GetL0Times(times); + + trgESD->Add(px, py, a, t, times, rdig->GetNL0Times(), rdig->GetL1TimeSum()); + } + } + + trgESD->SetL1Threshold(0, fTriggerData->GetL1GammaThreshold()); + + trgESD->SetL1Threshold(1, fTriggerData->GetL1JetThreshold() ); + + for (Int_t i = 0; i < kTriggerTypeEnd; i++) + { + for (Int_t j = 0; j < 2; j++) + { + TClonesArray* patches = fTriggerData->GetPatches((TriggerType_t)i, j); + + TIter NextPatch(patches); + while (AliEMCALTriggerPatch* p = (AliEMCALTriggerPatch*)NextPatch()) + { + TVector2 pos; p->Position(pos); + trgESD->SetTriggerBits((Int_t) pos.X(), (Int_t) pos.Y(), i, j); + } + } + } + } + + // Resetting + fTriggerData->Reset(); + //######################################## //##############Fill CaloCells############### //######################################## + ReadDigitsArrayFromTree(digitsTree); - TClonesArray *digits = new TClonesArray("AliEMCALDigit",1000); - TBranch *branchdig = digitsTree->GetBranch("EMCAL"); - if (!branchdig) { - AliError("can't get the branch with the EMCAL digits !"); - return; - } - branchdig->SetAddress(&digits); - digitsTree->GetEvent(0); - Int_t nDigits = digits->GetEntries(), idignew = 0 ; +// TClonesArray *digits = new TClonesArray("AliEMCALDigit",1000); +// TBranch *branchdig = digitsTree->GetBranch("EMCAL"); +// if (!branchdig) { +// AliError("can't get the branch with the EMCAL digits !"); +// return; +// } +// branchdig->SetAddress(&digits); +// digitsTree->GetEvent(0); + Int_t nDigits = fgDigitsArr->GetEntries(), idignew = 0 ; AliDebug(1,Form("%d digits",nDigits)); AliESDCaloCells &emcCells = *(esd->GetEMCALCells()); emcCells.CreateContainer(nDigits); - emcCells.SetType(AliESDCaloCells::kEMCALCell); + emcCells.SetType(AliVCaloCells::kEMCALCell); Float_t energy = 0; for (Int_t idig = 0 ; idig < nDigits ; idig++) { - const AliEMCALDigit * dig = (const AliEMCALDigit*)digits->At(idig); - if(dig->GetAmp() > 0 ){ - energy = (static_cast (fgClusterizer))->Calibrate(dig->GetAmp(),dig->GetId()); + const AliEMCALDigit * dig = (const AliEMCALDigit*)fgDigitsArr->At(idig); + if(dig->GetAmplitude() > 0 ){ + energy = fgClusterizer->Calibrate(dig->GetAmplitude(),dig->GetTime(),dig->GetId()); //TimeR or Time? if(energy > 0){ //Digits tagged as bad (dead, hot, not alive) are set to 0 in calibrate, remove them emcCells.SetCell(idignew,dig->GetId(),energy, dig->GetTime()); idignew++; @@ -376,12 +436,15 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, //------------------------------------------------------------ //-----------------CLUSTERS----------------------------- //------------------------------------------------------------ - TObjArray *clusters = new TObjArray(100); + clustersTree->SetBranchStatus("*",0); //disable all branches + clustersTree->SetBranchStatus("EMCALECARP",1); //Enable only the branch we need + if(fgClustersArr) fgClustersArr->Clear(); TBranch *branch = clustersTree->GetBranch("EMCALECARP"); - branch->SetAddress(&clusters); - clustersTree->GetEvent(0); + branch->SetAddress(&fgClustersArr); + branch->GetEntry(0); + //clustersTree->GetEvent(0); - Int_t nClusters = clusters->GetEntries(), nClustersNew=0; + Int_t nClusters = fgClustersArr->GetEntries(), nClustersNew=0; AliDebug(1,Form("%d clusters",nClusters)); //###################################################### @@ -407,8 +470,8 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, //##############Fill CaloClusters############# //######################################## for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) { - const AliEMCALRecPoint * clust = (const AliEMCALRecPoint*)clusters->At(iClust); - //if(clust->GetClusterType()== AliESDCaloCluster::kEMCALClusterv1) nRP++; else nPC++; + const AliEMCALRecPoint * clust = (const AliEMCALRecPoint*)fgClustersArr->At(iClust); + //if(clust->GetClusterType()== AliVCluster::kEMCALClusterv1) nRP++; else nPC++; if (Debug()) clust->Print(); // Get information from EMCAL reconstruction points Float_t xyz[3]; @@ -430,11 +493,11 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, for (Int_t iCell=0; iCell 0) { absIdList[newCellMult] = (UShort_t)(digitInts[iCell]); - //Uncomment when unfolding is done - //if(emcCells.GetCellAmplitude(digitInts[iCell])>0) - //fracList[newCellMult] = amplFloat[iCell]/(emcCells.GetCellAmplitude(digitInts[iCell])*calibration);//get cell calibration value - //else - fracList[newCellMult] = 0; + //Calculate Fraction + if(emcCells.GetCellAmplitude(digitInts[iCell])>0 && GetRecParam()->GetUnfold()) + fracList[newCellMult] = amplFloat[iCell]/(emcCells.GetCellAmplitude(digitInts[iCell]));//get cell calibration value + else + fracList[newCellMult] = 0; newCellMult++; } } @@ -449,25 +512,25 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, Int_t *parentList = clust->GetParents(parentMult); // fills the ESDCaloCluster AliESDCaloCluster * ec = new AliESDCaloCluster() ; - ec->SetClusterType(AliESDCaloCluster::kEMCALClusterv1); + ec->SetType(AliVCluster::kEMCALClusterv1); ec->SetPosition(xyz); ec->SetE(clust->GetEnergy()); - //Distance to the nearest bad crystal - ec->SetDistanceToBadChannel(clust->GetDistanceToBadTower()); + //Distance to the nearest bad crystal + ec->SetDistanceToBadChannel(clust->GetDistanceToBadTower()); ec->SetNCells(newCellMult); //Change type of list from short to ushort UShort_t *newAbsIdList = new UShort_t[newCellMult]; - Double_t *newFracList = new Double_t[newCellMult]; + Double_t *newFracList = new Double_t[newCellMult]; for(Int_t i = 0; i < newCellMult ; i++) { newAbsIdList[i]=absIdList[i]; - newFracList[i]=fracList[i]; + newFracList[i] =fracList[i]; } ec->SetCellsAbsId(newAbsIdList); ec->SetCellsAmplitudeFraction(newFracList); - ec->SetClusterDisp(clust->GetDispersion()); - ec->SetClusterChi2(-1); //not yet implemented + ec->SetDispersion(clust->GetDispersion()); + ec->SetChi2(-1); //not yet implemented ec->SetM02(elipAxis[0]*elipAxis[0]) ; ec->SetM20(elipAxis[1]*elipAxis[1]) ; ec->SetTOF(clust->GetTime()) ; //time-of-fligh @@ -495,10 +558,7 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, pid->SetReconstructor(kTRUE); pid->RunPID(esd); delete pid; - - delete digits; - delete clusters; - + //Store EMCAL misalignment matrixes FillMisalMatrixes(esd) ; @@ -520,11 +580,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); @@ -549,8 +610,8 @@ void AliEMCALReconstructor::ReadDigitsArrayFromTree(TTree *digitsTree) const // See AliEMCALClusterizer::SetInput(TTree *digitsTree); if(fgDigitsArr) { // Clear previous digits - fgDigitsArr->Delete(); - delete fgDigitsArr; + fgDigitsArr->Clear("C"); + //delete fgDigitsArr; } // Read the digits from the input tree TBranch *branch = digitsTree->GetBranch("EMCAL");