TClonesArray &caloClusters = *(AODEvent()->GetCaloClusters());
Int_t jClusters=0;
- for (Int_t iClust=0; iClust<nCaloClus; ++iClust) {
-
- AliVCluster * cluster = event->GetCaloCluster(iClust);
-
- //Check which calorimeter information we want to keep.
-
- if(fCaloFilter!=kBoth){
- if (fCaloFilter==kPHOS && cluster->IsEMCAL()) continue ;
- else if(fCaloFilter==kEMCAL && cluster->IsPHOS()) continue ;
- }
-
- //--------------------------------------------------------------
- //If EMCAL, and requested, correct energy, position ...
- if(cluster->IsEMCAL() && fCorrect){
+ //Do Corrections in EMCAL
+ //If EMCAL, and requested, correct energy, position ...
+ //Need to do this in a separate loop before filling the ESDs because of the track matching recalculations
+ if(fCorrect && (fCaloFilter==kEMCAL || fCaloFilter==kBoth) ) {
+ //Cluster Loop
+ for (Int_t iClust=0; iClust<nCaloClus; ++iClust) {
+
+ AliVCluster * cluster = event->GetCaloCluster(iClust);
+ if(cluster->IsPHOS()) continue ;
+
Float_t position[]={0,0,0};
if(DebugLevel() > 2)
printf("Check cluster %d for bad channels and close to border\n",cluster->GetID());
if(fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo,cluster->GetCellsAbsId(), cluster->GetNCells())) continue;
-// if(!fEMCALRecoUtils->CheckCellFiducialRegion(fEMCALGeo, cluster, event->GetEMCALCells())) {
-// printf("Finally reject\n");
-// continue;
-// }
+ // if(!fEMCALRecoUtils->CheckCellFiducialRegion(fEMCALGeo, cluster, event->GetEMCALCells())) {
+ // printf("Finally reject\n");
+ // continue;
+ // }
if(DebugLevel() > 2)
{
printf("Filter, before : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",iClust,cluster->E(),
cluster->GetPosition(position);
printf("Filter, before : i %d, x %f, y %f, z %f\n",cluster->GetID(), position[0], position[1], position[2]);
}
-
+
if(fEMCALRecoUtils->IsRecalibrationOn()) {
fEMCALRecoUtils->RecalibrateClusterEnergy(fEMCALGeo, cluster, event->GetEMCALCells());
fEMCALRecoUtils->RecalculateClusterShowerShapeParameters(fEMCALGeo, event->GetEMCALCells(),cluster);
fEMCALRecoUtils->RecalculateClusterPID(cluster);
-
}
cluster->SetE(fEMCALRecoUtils->CorrectClusterEnergyLinearity(cluster));
fEMCALRecoUtils->RecalculateClusterPosition(fEMCALGeo, event->GetEMCALCells(),cluster);
-
+
if(DebugLevel() > 2)
{
printf("Filter, after : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",cluster->GetID(),cluster->E(),
printf("Filter, after : i %d, x %f, y %f, z %f\n",cluster->GetID(), position[0], position[1], position[2]);
}
+ }
+ //Recalculate track-matching
+ fEMCALRecoUtils->FindMatches(event);
+
+ } // corrections in EMCAL
+
+ //Now loop on clusters to fill AODs
+ for (Int_t iClust=0; iClust<nCaloClus; ++iClust) {
+
+ AliVCluster * cluster = event->GetCaloCluster(iClust);
+
+ //Check which calorimeter information we want to keep.
+
+ if(fCaloFilter!=kBoth){
+ if (fCaloFilter==kPHOS && cluster->IsEMCAL()) continue ;
+ else if(fCaloFilter==kEMCAL && cluster->IsPHOS()) continue ;
+ }
+
+ //Temporary trick, FIXME
+ Float_t dR = cluster->GetTrackDx();
+ Float_t dZ = cluster->GetTrackDz();
+ if(DebugLevel() > 2)
+ printf("Original residuals : dZ %f, dR %f\n ",dZ, dR);
+ //--------------------------------------------------------------
+ //If EMCAL and corrections done, get the new matching parameters, do not copy noisy clusters
+ if(cluster->IsEMCAL() && fCorrect){
+ if(DebugLevel() > 2)
+ printf("Check cluster %d for bad channels and close to border\n",cluster->GetID());
+ if(fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo,cluster->GetCellsAbsId(), cluster->GetNCells())) continue;
+ // if(!fEMCALRecoUtils->CheckCellFiducialRegion(fEMCALGeo, cluster, event->GetEMCALCells())) {
+ // printf("Finally reject\n");
+ // continue;
+ // }
+
+ fEMCALRecoUtils->GetMatchedResiduals(cluster->GetID(),dR,dZ);
+ if(DebugLevel() > 2)
+ printf("Corrected Residuals : dZ %f, dR %f\n ",dZ, dR);
+
}
//--------------------------------------------------------------
//Now fill AODs
+
Int_t id = cluster->GetID();
Float_t energy = cluster->E();
cluster->GetPosition(posF);
NULL,
cluster->GetType());
+ caloCluster->SetChi2(dZ);//Temporary trick, FIXME
caloCluster->SetCaloCluster(cluster->GetDistanceToBadChannel(),
cluster->GetDispersion(),
cluster->GetM20(), cluster->GetM02(),
- cluster->GetEmcCpvDistance(),
+ dR, //Temporary trick, FIXME
cluster->GetNExMax(),cluster->GetTOF()) ;
caloCluster->SetPIDFromESD(cluster->GetPID());
if(DebugLevel() > 2)
{
- printf("Filter, aod : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",caloCluster->GetID(),caloCluster->E(),
+ printf("Filter, aod : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",caloCluster->GetID(),caloCluster->E(),
caloCluster->GetDispersion(),caloCluster->GetM02(),caloCluster->GetM20());
caloCluster->GetPosition(posF);
- printf("Filter, aod : i %d, x %f, y %f, z %f\n",caloCluster->GetID(), posF[0], posF[1], posF[2]);
+ printf("Filter, aod : i %d, x %f, y %f, z %f\n",caloCluster->GetID(), posF[0], posF[1], posF[2]);
}
//Matched tracks, just to know if there was any match, the track pointer is useless.
+ //Temporary trick, FIXME
if(bESD){
- TArrayI* matchedT = ((AliESDCaloCluster*)cluster)->GetTracksMatched();
- if (InputEvent()->GetNumberOfTracks() > 0 && matchedT && cluster->GetTrackMatchedIndex() >= 0) {
- for (Int_t im = 0; im < matchedT->GetSize(); im++) {
- Int_t iESDtrack = matchedT->At(im);;
- if ((AliVTrack*)InputEvent()->GetTrack(iESDtrack) != 0) {
- caloCluster->AddTrackMatched((AliVTrack*)InputEvent()->GetTrack(iESDtrack));
- }
- }
- }// There is at least a match with a track
+ if(TMath::Abs(dR) < 990 && TMath::Abs(dZ) < 990) { //Default value in PHOS 999, in EMCAL 1024, why?
+ if(DebugLevel() > 2)
+ printf("*** Cluster Track-Matched *** dR %f, dZ %f\n",caloCluster->GetEmcCpvDistance(),caloCluster->Chi2());
+ caloCluster->AddTrackMatched(0x0);
+ }// fill the array with one entry to signal a possible match
+ //TArrayI* matchedT = ((AliESDCaloCluster*)cluster)->GetTracksMatched();
+ //if (InputEvent()->GetNumberOfTracks() > 0 && matchedT && cluster->GetTrackMatchedIndex() >= 0) {
+ // for (Int_t im = 0; im < matchedT->GetSize(); im++) {
+ // Int_t iESDtrack = matchedT->At(im);;
+ // if ((AliVTrack*)InputEvent()->GetTrack(iESDtrack) != 0) {
+ // caloCluster->AddTrackMatched((AliVTrack*)InputEvent()->GetTrack(iESDtrack));
+ // }
+ // }
+ //}// There is at least a match with a track
}
}
caloClusters.Expand(jClusters); // resize TObjArray to 'remove' slots for pseudo clusters