#include "AliVVertex.h"
#include "AliMultiplicity.h"
#include "AliESDtrackCuts.h"
#include "AliESDpid.h"
#include "AliAODPid.h"
#include "AliCentrality.h"
#include "AliESDUtils.h"
#include "AliRsnEvent.h"
#include "AliRsnDaughter.h"
#include "AliRsnMother.h"
#include "AliRsnPairDef.h"
#include "AliRsnDaughterDef.h"
#include "AliRsnValueEvent.h"
ClassImp(AliRsnValueEvent)
AliRsnValueEvent::AliRsnValueEvent(const char *name, EType type) :
AliRsnValue(name, AliRsnTarget::kEvent),
fType(type)
{
}
AliRsnValueEvent::AliRsnValueEvent(const AliRsnValueEvent ©) :
AliRsnValue(copy),
fType(copy.fType)
{
}
AliRsnValueEvent &AliRsnValueEvent::operator=(const AliRsnValueEvent ©)
{
AliRsnValue::operator=(copy);
if (this == ©)
return *this;
fType = copy.fType;
return (*this);
}
const char *AliRsnValueEvent::GetTypeName() const
{
switch (fType) {
case kLeadingPt: return "EventLeadingPt";
case kMult: return "EventMult";
case kMultMC: return "EventMultMC";
case kMultESDCuts: return "EventMultESDCuts";
case kMultSPD: return "EventMultSPD";
case kVz: return "EventVz";
case kCentralityV0: return "EventCentralityV0";
case kCentralityTrack: return "EventCentralityTrack";
case kCentralityCL1: return "EventCentralityCL1";
default: return "Undefined";
}
}
Bool_t AliRsnValueEvent::Eval(TObject *object)
{
if (!TargetOK(object)) return kFALSE;
if (!fEvent->GetRef()) {
AliWarning("NULL ref");
return kFALSE;
}
AliCentrality *centrality = fEvent->GetRef()->GetCentrality();
switch (fType) {
case kMult:
fComputedValue = (Double_t)fEvent->GetRef()->GetNumberOfTracks();
return (fComputedValue >= 0);
case kMultMC:
fComputedValue = -999.0;
if (fEvent->GetRefMC()) {
if (fEvent->IsESD())
fComputedValue = (Double_t)fEvent->GetRefMC()->GetNumberOfTracks();
else {
AliAODEvent *aod = (AliAODEvent *)fEvent->GetRefMC();
TClonesArray *mcArray = (TClonesArray *)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
if (mcArray) fComputedValue = (Double_t)mcArray->GetEntries();
}
}
return (fComputedValue >= 0);
case kMultESDCuts:
fComputedValue = -999.0;
if (fEvent->IsESD()) {
fComputedValue = AliESDtrackCuts::GetReferenceMultiplicity(fEvent->GetRefESD(), kTRUE);
} else {
AliWarning("Cannot compute ESD cuts multiplicity in AOD");
return kFALSE;
}
return (fComputedValue >= 0);
case kMultSPD:
fComputedValue = -999.0;
if (fEvent->IsESD()) {
const AliMultiplicity *mult = fEvent->GetRefESD()->GetMultiplicity();
Float_t nClusters[6] = {0.0,0.0,0.0,0.0,0.0,0.0};
for(Int_t ilay = 0; ilay < 6; ilay++) nClusters[ilay] = (Float_t)mult->GetNumberOfITSClusters(ilay);
fComputedValue = AliESDUtils::GetCorrSPD2(nClusters[1], fEvent->GetRef()->GetPrimaryVertex()->GetZ());
} else {
AliWarning("Cannot compute SPD multiplicity with AOD");
return kFALSE;
}
return (fComputedValue >= 0);
case kLeadingPt:
if (fEvent->GetLeadingIndex() >= 0) {
AliRsnDaughter leadingPart;
fEvent->SetLeadingParticle(leadingPart);
fComputedValue = leadingPart.GetRef()->Pt();
return kTRUE;
} else {
AliError("Not found good leading particle");
return kFALSE;
}
case kVz:
fComputedValue = fEvent->GetRef()->GetPrimaryVertex()->GetZ();
return kTRUE;
case kCentralityV0:
if (centrality) {
fComputedValue = centrality->GetCentralityPercentile("V0M");
return kTRUE;
} else {
AliError("Centrality undefined");
return kFALSE;
}
case kCentralityTrack:
if (centrality) {
fComputedValue = centrality->GetCentralityPercentile("TRK");
return kTRUE;
} else {
AliError("Centrality undefined");
return kFALSE;
}
case kCentralityCL1:
if (centrality) {
fComputedValue = centrality->GetCentralityPercentile("CL1");
return kTRUE;
} else {
AliError("Centrality undefined");
return kFALSE;
}
default:
AliError(Form("[%s] Invalid value type for this computation", GetName()));
return kFALSE;
}
}
void AliRsnValueEvent::ApplyCentralityPatchAOD049(TObject *object)
{
fComputedValue = -999.;
if (!TargetOK(object)) return;
if (fEvent->IsESD()) {
AliWarning(Form("Requested patch for AOD049 for ESD. Setting cent = %5.2f", fComputedValue));
return;
}
if (fType!=AliRsnValueEvent::kCentralityV0) {
AliWarning(Form("Requested patch forAOD049 for wrong value (not centrality from V0). Setting cent = %5.2f", fComputedValue));
return;
}
AliAODEvent *aodEvent = (AliAODEvent *)fEvent->GetRefAOD();
if (!aodEvent) {
AliWarning(Form("NULL ref to AOD event. Setting cent = %5.2f", fComputedValue));
return;
}
AliCentrality *centrality = aodEvent->GetCentrality();
if (!centrality) {
AliWarning(Form("Cannot get centrality from AOD event. Setting cent = %5.2f", fComputedValue));
return;
}
Float_t cent = (Float_t)(centrality->GetCentralityPercentile("V0M"));
if(cent>=0.0) {
Float_t v0 = 0.0;
AliAODVZERO *aodV0 = (AliAODVZERO *) aodEvent->GetVZEROData();
v0+=aodV0->GetMTotV0A();
v0+=aodV0->GetMTotV0C();
if ( (cent==0) && (v0<19500) ) {
fComputedValue = -999.;
AliDebug(3, Form("Filtering issue in centrality -> cent = %5.2f",fComputedValue));
return;
}
Float_t tkl = (Float_t)(aodEvent->GetTracklets()->GetNumberOfTracklets());
Float_t val = 1.30552 + 0.147931 * v0;
Float_t tklSigma[101] = {176.644, 156.401, 153.789, 153.015, 142.476, 137.951, 136.127, 129.852, 127.436, 124.86,
120.788, 115.611, 113.172, 110.496, 109.127, 104.421, 102.479, 99.9766, 97.5152, 94.0654,
92.4602, 89.3364, 87.1342, 83.3497, 82.6216, 81.1084, 78.0793, 76.1234, 72.9434, 72.1334,
68.0056, 68.2755, 66.0376, 62.9666, 62.4274, 59.65, 58.3776, 56.6361, 54.5184, 53.4224,
51.932, 50.8922, 48.2848, 47.912, 46.5717, 43.4114, 43.2083, 41.3065, 40.1863, 38.5255,
37.2851, 37.5396, 34.4949, 33.8366, 31.8043, 31.7412, 30.8392, 30.0274, 28.8793, 27.6398,
26.6488, 25.0183, 25.1489, 24.4185, 22.9107, 21.2002, 21.6977, 20.1242, 20.4963, 19.0235,
19.298, 17.4103, 16.868, 15.2939, 15.2939, 16.0295, 14.186, 14.186, 15.2173, 12.9504, 12.9504,
12.9504, 15.264, 12.3674, 12.3674, 12.3674, 12.3674, 12.3674, 18.3811, 13.7544, 13.7544,
13.7544, 13.7544, 13.7544, 13.7544, 13.7544, 13.7544, 13.7544, 13.7544, 13.7544, 13.7544
};
if ( TMath::Abs(tkl-val) > 6.*tklSigma[(Int_t)cent] ) {
fComputedValue = -999.;
AliDebug(3, Form("Outlier event in centrality -> cent = %5.2f",fComputedValue));
return;
}
} else {
cent = -999.;
}
fComputedValue=cent;
return;
}