11 #include <AliAnalysisTaskSE.h>
12 #include <TParameter.h>
15 #include "AliVVertex.h"
16 #include <AliVEvent.h>
17 #include <AliAODEvent.h>
18 #include <AliVVertex.h>
19 #include <AliVertex.h>
20 #include <AliVMultiplicity.h>
21 #include <AliMultiplicity.h>
22 #include <AliAnalysisManager.h>
23 #include <AliVEventHandler.h>
24 #include <AliESDInputHandlerRP.h>
25 #include <AliITSMultRecBg.h>
26 #include <AliCDBManager.h>
27 #include <AliCDBEntry.h>
28 #include <AliCDBPath.h>
30 #include <AliGeomManager.h>
31 #include <AliAODHandler.h>
32 #include <TGeoManager.h>
33 #include <TGeoGlobalMagField.h>
39 class AliMultiplicity;
40 class AliVMultiplicity;
41 class AliAnalysisDataContainer;
42 class AliITSMultRecBg;
45 class AliMultSelection;
48 class TGeoGlobalMagField;
212 return "alien://Folder=/alice/data/2010/OCDB";
276 const AliVVertex*
FindIP(AliVEvent* event,
330 AliMultiplicity* mult,
369 fDThetaWindow(0.025),
371 fPhiOverlapCut(0.005),
372 fZEtaOverlapCut(0.05),
385 fDThetaWindow(0.025),
387 fPhiOverlapCut(0.005),
388 fZEtaOverlapCut(0.05),
400 fScaleDTheta(other.fScaleDTheta),
401 fMaxDelta(other.fMaxDelta),
402 fDPhiShift(other.fDPhiShift),
403 fDThetaWindow(other.fDThetaWindow),
404 fDPhiWindow(other.fDPhiWindow),
405 fPhiOverlapCut(other.fPhiOverlapCut),
406 fZEtaOverlapCut(other.fZEtaOverlapCut),
408 fFilterStrange(other.fFilterStrange),
416 AliError(
"No analysis manager to connect to.");
420 dynamic_cast<AliAODHandler*
>(mgr->GetOutputEventHandler());
422 AliError(
"No AOD output handler!");
430 mgr->ConnectInput(
this, 0, mgr->GetCommonInputContainer());
437 Printf(
"%s: %s", ClassName(), GetName());
438 Printf(
" %22s: %d",
"Scale by sin^2(theta)",
fScaleDTheta);
439 Printf(
" %22s: %f",
"Delta phi shift",
fDPhiShift);
440 Printf(
" %22s: %f",
"max Delta",
fMaxDelta);
442 Printf(
" %22s: %f",
"Delta phi window",
fDPhiWindow);
445 Printf(
" %22s: %s",
"Filter strange",
466 AliWarning(
"Failed to initialize task on worker, making zombie");
474 AliInfo(
"Now initialising CDB");
477 AliError(
"No manager defined!");
482 const char* cdbNames[] = {
"CDBconnect",
"cdb", 0 };
483 const char** ptr = cdbNames;
486 if (cdbConnect && cdbConnect->IsA()->InheritsFrom(
"AliTaskCDBconnect")) {
487 AliInfoF(
"CDB-connect task (%s: %s) present, do nothing",
488 cdbConnect->ClassName(), *ptr);
494 AliInfo(
"Get the CDB manager");
495 AliCDBManager* cdbMgr = AliCDBManager::Instance();
497 AliError(
"Failed to get instance of CDB manager");
502 AliWarningF(
"Using reference CDB storage \"%s\" and run \"%d\"",
503 refUrl.Data(), refRun);
508 cdbMgr->SetDefaultStorage(refUrl);
510 AliInfo(
"Get Geometry entry");
511 AliCDBEntry* cdbEnt = cdbMgr->Get(
"GRP/Geometry/Data", refRun);
513 AliErrorF(
"No geometry found from %d", refRun);
517 AliInfo(
"Set Geometry");
518 AliGeomManager::SetGeometry(static_cast<TGeoManager*>(cdbEnt->GetObject()));
520 AliInfo(
"Misalign geometry");
521 if (!AliGeomManager::ApplyAlignObjsToGeom(
"ITS",refRun,-1,-1)) {
522 AliErrorF(
"Failed to misalign geometry from %d", refRun);
535 dynamic_cast<AliAODHandler*
>(am->GetOutputEventHandler());
537 AliWarning(
"No AOD output handler set in analysis manager");
540 ah->AddBranch(
"TClonesArray", &obj);
567 AliWarning(
"Tracklets container not initialized, init must have failed!");
581 if (!event)
return false;
585 const AliVVertex* ip =
FindIP(event);
587 if (fDebug > 0) AliInfoF(
"Cluster tree: %p, ip: %p", clusters, ip);
588 if (!ip)
return false;
591 if (fDebug > 1) AliInfoF(
"After geo check: %d", ret);
592 if (ret && !
HasField(event)) ret =
false;
593 if (fDebug > 1) AliInfoF(
"After field check: %d", ret);
596 if (fDebug > 1) AliInfoF(
"After reconstruction: %d", ret);
603 if (fDebug > 1) AliInfoF(
"Return value: %d", ret);
610 if (!AliGeomManager::GetGeometry()) {
611 AliError(
"No geometry loaded, needed for reconstruction");
612 AliError(
"Add the AliTaskCDBconnect to the train");
620 if (!TGeoGlobalMagField::Instance()->GetField() &&
621 !event->InitMagneticField()) {
622 AliWarning(
"Failed to initialize magnetic field");
631 AliVEvent*
event = InputEvent();
632 if (fDebug > 0 && !event) AliWarning(
"No event");
640 AliVEventHandler* inh = mgr->GetInputEventHandler();
641 if (!inh->IsA()->InheritsFrom(AliESDInputHandlerRP::Class())) {
643 AliWarningF(
"Clusters not available via input handler of class: %s",
647 AliESDInputHandlerRP* rph =
static_cast<AliESDInputHandlerRP*
>(inh);
648 TTree* tree = rph->GetTreeR(
"ITS");
650 AliWarning(
"Tree of clusters (rec.points) not found");
661 const AliVVertex* ip =
event->GetPrimaryVertex();
662 if (ip->GetNContributors() <= 0) {
664 AliWarning(
"Not enough contributors for IP");
668 if (ip->IsFromVertexerZ()) {
671 ip->GetCovarianceMatrix(covar);
672 Double_t sigmaZ = TMath::Sqrt(covar[5]);
673 if (sigmaZ >= maxZError) {
675 AliWarningF(
"IPz resolution = %f >= %f", sigmaZ, maxZError);
680 if (ip->IsA()->InheritsFrom(AliVertex::Class())) {
681 const AliVertex* ipv =
static_cast<const AliVertex*
>(ip);
683 if (ipv->GetDispersion() >= maxDispersion) {
685 AliWarningF(
"IP dispersion = %f >= %f",
686 ipv->GetDispersion(), maxDispersion);
695 if (ip->GetZ() < fIPzAxis.GetXmin() || ip->GetZ() > fIPzAxis.GetXmax()) {
696 AliWarningF(
"IPz = %fcm out of range [%f,%f]cm",
697 ip->GetZ(), fIPzAxis.GetXmin(), fIPzAxis.GetXmax());
711 dynamic_cast<AliAODHandler*
>(am->GetOutputEventHandler());
712 if (!ah)
return false;
713 ah->SetFillAOD(kTRUE);
714 if (fDebug > 0) AliInfo(
"Storing event");
727 AliInfoF(
"Reconstructing from cluster tree %p with (%4.2f,%4.2f,%7.4f",
728 clusters, ipv[0], ipv[1], ipv[2]);
732 AliITSMultRecBg reco;
733 reco.SetCreateClustersCopy (
true);
743 reco.SetHistOn (
false);
747 reco.Run(clusters, ipv);
753 AliWarning(
"Process tracklets (normal) failed");
759 reco.SetRecType(AliITSMultRecBg::kBgInj);
760 reco.Run(clusters, ipv);
764 AliWarning(
"Process tracklets (injection) failed");
767 if (fDebug > 1) AliInfo(
"Returning true");
773 AliVMultiplicity* vmult)
780 AliMultiplicity* mult =
static_cast<AliMultiplicity*
>(vmult);
781 Int_t nTracklets = mult->GetNumberOfTracklets();
782 for (
Int_t trackletNo = 0; trackletNo < nTracklets; trackletNo++) {
798 AliMultiplicity* mult,
803 Double_t dTheta = mult->GetDeltaTheta(no);
804 Double_t dPhi = mult->GetDeltaPhi (no);
805 Double_t delta = mult->CalcDist (no);
822 #include <AliStack.h>
823 #include <AliMCEvent.h>
824 #include <AliGenEventHeader.h>
825 #include <TParticle.h>
826 #include <TParticlePDG.h>
827 #include <TDatabasePDG.h>
828 #include <AliITSgeomTGeo.h>
945 return "alien://Folder=/alice/simulation/2008/v4-15-Release/Residual";
976 AliMultiplicity* mult,
1043 #define ADDP(P,M,L,Q) \
1044 db->AddParticle("p" #P, "p" #P,M,false,L,Q,"Baryon",P); \
1045 db->AddAntiParticle("p" #P "_bar", -P)
1053 TDatabasePDG* db = TDatabasePDG::Instance();
1054 db->GetParticle(2212);
1055 db->AddParticle(
"deut",
"deut",1.876560,
false,0.000000,3,
"Baryon",1000010020);
1056 db->AddAntiParticle(
"deut_bar",-1000010020);
1057 db->AddParticle(
"trit",
"trit",2.816700,
false,0.000000,3,
"Baryon",1000010030);
1058 db->AddAntiParticle(
"trit_bar",-1000010030);
1059 db->AddParticle(
"alph",
"alph",3.755000,
false,0.000000,6,
"Baryon",1000020040);
1060 db->AddAntiParticle(
"alph_bar",-1000020040);
1061 ADDP(32224, 1.524000,0.145000,6);
1062 ADDP(12224, 1.816000,0.350000,6);
1063 ADDP(12222, 2.108000,0.350000,6);
1064 ADDP(12212, 1.525720,0.145000,3);
1065 ADDP(2124, 1.819440,0.150000,3);
1066 ADDP(32214, 2.113160,0.150000,3);
1067 ADDP(32212, 2.406880,0.145000,3);
1068 ADDP(12214, 2.700600,0.300000,3);
1069 ADDP(22124, 2.994320,0.150000,3);
1070 ADDP(12122, 3.288040,0.300000,3);
1071 ADDP(13222, 1.575200,0.080000,3);
1072 ADDP(23222, 1.768100,0.100000,3);
1073 ADDP(13226, 1.961000,0.170000,3);
1074 ADDP(12112, 1.524430,0.350000,0);
1075 ADDP(1214, 1.816860,0.150000,0);
1076 ADDP(32114, 2.109290,0.150000,0);
1077 ADDP(32112, 2.401720,0.145000,0);
1078 ADDP(12114, 2.694150,0.300000,0);
1079 ADDP(21214, 2.986579,0.150000,0);
1080 ADDP(11212, 3.279010,0.300000,0);
1081 ADDP(13122, 1.761000,0.040000,0);
1082 ADDP(3124, 1.950500,0.016000,0);
1083 ADDP(23122, 2.140000,0.090000,0);
1084 ADDP(13212, 2.329500,0.080000,0);
1085 ADDP(23212, 2.519000,0.100000,0);
1086 ADDP(43122, 2.708500,0.145000,0);
1087 ADDP(13216, 2.898000,0.170000,0);
1088 ADDP(31114, 1.524000,0.145000,-3);
1089 ADDP(11114, 1.816000,0.350000,-3);
1090 ADDP(11112, 2.108000,0.350000,-3);
1091 ADDP(13112, 1.577600,0.080000,-3);
1092 ADDP(23112, 1.767700,0.100000,-3);
1093 ADDP(13116, 1.957800,0.170000,-3);
1094 ADDP(9900110,0.000000,0.000000,0);
1095 ADDP(9900210,0.000000,0.000000,0);
1096 ADDP(9900220,0.000000,0.000000,0);
1097 ADDP(9900330,0.000000,0.000000,0);
1098 ADDP(9900440,0.000000,0.000000,0);
1099 ADDP(9902210,0.000000,0.000000,0);
1100 ADDP(9902110,0.000000,0.000000,0);
1101 ADDP(88, 0.000000,0.000000,0);
1102 ADDP(90, 0.000000,0.000000,0);
1103 ADDP(990, 0.000000,0.000000,0);
1104 ADDP(99999, 0.000000,0.000000,0);
1110 const Double_t k0s = 1.52233299626516083e+00;
1111 const Double_t kpm = (1.43744204476109627e+00*
1112 9.82150320171071400e-01);
1113 const Double_t lam = 2.75002089647900005e+00;
1114 const Double_t sig = 2.75002089647899961e+00;
1115 const Double_t xi = 3.24109605656453548e+00;
1119 switch (TMath::Abs(pdg)) {
1120 case 310:
return k0s;
1121 case 321:
return kpm;
1122 case 3122:
return lam;
1123 case 3212:
return sig;
1124 case 3322:
return xi;
1131 if (weight <= 1)
return true;
1133 return (
gRandom->Uniform() >= chance);
1141 if (fDebug > 0) AliInfo(
"Returning original cluster tree");
1145 TDirectory* savDir = gDirectory;
1148 copy->SetAutoFlush(0);
1155 AliInfoF(
"Returning reduced cluster tree %p (original %p)", copy, t);
1163 TClonesArray* in =
new TClonesArray(
"AliITSRecPoint");
1164 TClonesArray* out =
new TClonesArray(
"AliITSRecPoint");
1166 copy->Branch(
"ITSRecPoints", &out);
1167 t->SetBranchAddress(
"ITSRecPoints", &in);
1171 Int_t min1 = AliITSgeomTGeo::GetModuleIndex(1,1,1);
1172 Int_t max1 = AliITSgeomTGeo::GetModuleIndex(2,1,1);
1173 Int_t min2 = AliITSgeomTGeo::GetModuleIndex(2,1,1);
1174 Int_t max2 = AliITSgeomTGeo::GetModuleIndex(3,1,1);
1179 for (
Int_t i = 0; i < max2; i++) {
1188 Int_t inN = in->GetEntries();
1189 for (
Int_t j = 0; j < inN; j++) {
1190 AliITSRecPoint* inCl =
static_cast<AliITSRecPoint*
>(in->At(j));
1191 if (!inCl)
continue;
1195 for (
Int_t k = 0; k < 3; k++) {
1196 Int_t label = inCl->GetLabel(k);
1197 if (label <= 0)
continue;
1201 if (!parent)
continue;
1203 weight *=
GetWeight(parent->GetPdgCode());
1205 Printf(
"Cluster from %+5d: %7.5f", parent->GetPdgCode(), weight);
1212 if (!KeepIt(weight))
continue;
1215 new ((*out)[outN++]) AliITSRecPoint(*inCl);
1222 Printf(
"Kept %d out of %d clusters from strange primaries (%4.1f%%)",
1223 nKept, nTotal, 100.*loss);
1233 TClonesArray* in =
new TClonesArray(
"AliITSRecPoint");
1234 TClonesArray* out =
new TClonesArray(
"AliITSRecPoint");
1236 copy->Branch(
"ITSRecPoints", &out);
1237 t->SetBranchAddress(
"ITSRecPoints", &in);
1242 AliStack* stack = MCEvent()->Stack();
1243 Int_t nTracks = stack->GetNtrack();
1244 TBits kept(nTracks);
1245 TBits seen(nTracks);
1246 kept.ResetAllBits(
true);
1247 seen.ResetAllBits(
false);
1248 for (
Int_t trackNo = nTracks; trackNo--; ) {
1251 if (parent < 0)
continue;
1253 if (seen.TestBitNumber(parent))
continue;
1254 seen.SetBitNumber(parent,
true);
1257 TParticle* par = stack->Particle(parent);
1262 keep = KeepIt(weight);
1266 Printf(
"Primary parent %6d from a %6d %6s (%f)",
1267 parent, par->GetPdgCode(), keep ?
"kept" :
"marked", weight);
1268 kept.SetBitNumber(parent, keep);
1269 par->SetWeight(keep ? 1 : weight);
1274 if (fDebug > 0 && nTotal > 0) {
1276 Printf(
"Kept %d out of %d strange primaries (%4.1f%%)",
1277 nKept, nTotal, 100.*loss);
1283 Int_t min1 = AliITSgeomTGeo::GetModuleIndex(1,1,1);
1284 Int_t max1 = AliITSgeomTGeo::GetModuleIndex(2,1,1);
1285 Int_t min2 = AliITSgeomTGeo::GetModuleIndex(2,1,1);
1286 Int_t max2 = AliITSgeomTGeo::GetModuleIndex(3,1,1);
1290 for (
Int_t i = 0; i < max2; i++) {
1299 Int_t inN = in->GetEntries();
1301 for (
Int_t j = 0; j < inN; j++) {
1302 AliITSRecPoint* inCl =
static_cast<AliITSRecPoint*
>(in->At(j));
1303 if (!inCl)
continue;
1307 for (
Int_t k = 0; k < 3; k++) {
1308 Int_t label = inCl->GetLabel(k);
1309 if (label <= 0)
continue;
1313 if (parent < 0)
continue;
1315 if (!kept.TestBitNumber(parent)) toRemove =
true;
1317 Printf(
"Cluster %6d from parent %6d (%7.5f) of type %6d %s",
1319 stack->Particle(parent)->GetPdgCode(),
1320 stack->Particle(parent)->GetWeight(),
1321 toRemove ?
"removed" :
"kept");
1327 if (toRemove)
continue;
1328 new ((*out)[outN++]) AliITSRecPoint(*inCl);
1335 Printf(
"Wrote out %6d out of %6d clusters (%4.1f%%)",
1336 outT, inT, (inT > 0 ? 100*
float(inT-outT)/inT : 100));
1364 if (fDebug > 0) AliInfo(
"Processing generated particles");
1365 AliStack* stack = MCEvent()->Stack();
1366 Int_t nTracks = stack->GetNtrack();
1367 for (
Int_t trackNo = nTracks; trackNo--; ) {
1368 if (!stack->IsPhysicalPrimary(trackNo)) {
1374 TParticle* particle = stack->Particle(trackNo);
1376 AliWarningF(
"No particle found for track # %d", trackNo);
1379 TParticlePDG* pdg = particle->GetPDG();
1381 AliWarningF(
"Unknown PDG code: %d", particle->GetPdgCode());
1390 Double_t theta = particle->Theta();
1392 if (theta < 1e-6 || TMath::Abs(theta-TMath::Pi()) < 1e-6) {
1394 AliWarningF(
"Track # %6d is beam-like (%f)", trackNo,
1395 TMath::RadToDeg()*theta);
1398 Double_t eta = -TMath::Log(TMath::ATan(theta/2));
1401 if (TMath::Abs(eta) > 3)
continue;
1415 if (pdg && pdg->Charge() == 0) mc->
SetNeutral();
1417 if (fDebug > 2) AliInfo(
"Returning true from generated");
1431 AliMultiplicity* mult,
1436 if (!normal)
return tracklet;
1439 Int_t label0 = mult->GetLabel(no, 0);
1440 Int_t label1 = mult->GetLabel(no, 1);
1446 if (label0 != label1) {
1461 Int_t clus0 =
Int_t(ftrack[AliITSMultReconstructor::kClID1]);
1462 Int_t clus1 =
Int_t(ftrack[AliITSMultReconstructor::kClID2]);
1465 AliITSMultReconstructor::kClMC0);
1467 AliITSMultReconstructor::kClMC0);
1470 for (
Int_t i = 0; i < 3; i++)
1474 for (
Int_t i = 0; i < 3; i++) {
1477 if (flbl > nextafter(INT_MAX, 0) || flbl < nextafter(INT_MIN, 0))
1489 if (!MCEvent()->Stack()->IsPhysicalPrimary(label0))
1498 AliStack* stack = MCEvent()->Stack();
1499 Int_t nTracks = stack->GetNtrack();
1500 TParticle* particle = stack->Particle(label);
1501 if (!particle)
return -1;
1502 Int_t ret = particle->GetFirstMother();
1503 if (ret > nTracks)
return -1;
1516 while (i < fill.GetSize()-1 && lbl >= 1) {
1534 while (i < fill.GetSize()-1 && lbl >= 1) {
1537 for (
Int_t j = 0; j < fill.GetSize(); j++) {
1538 if (fill[j] == lbl)
return j;
1555 if (parent < 0)
return 0;
1556 return MCEvent()->Stack()->Particle(parent);
1561 AliStack* stack = MCEvent()->Stack();
1562 Int_t nTracks = stack->GetNtrack();
1563 Int_t trackNo = label;
1564 if (trackNo > nTracks || trackNo <= 0)
return 0;
1565 TParticle* particle = stack->Particle(label);
1566 while (!stack->IsPhysicalPrimary(trackNo)) {
1567 trackNo = particle->GetFirstMother();
1569 if (trackNo < 0)
return 0;
1571 particle = stack->Particle(trackNo);
1580 ::Error(
"Create",
"No analysis manager to connect to.");
1584 dynamic_cast<AliAODHandler*
>(mgr->GetOutputEventHandler());
1586 ::Error(
"Create",
"No AOD output handler!");
1589 Bool_t mc = mgr->GetMCtruthEventHandler() != 0;
void SetPhiOverlapCut(Double_t x=0.005)
Bool_t ProcessGenerated()
void UserExec(Option_t *)
Double_t GetWeight(Int_t averageoption, Double_t pt, TH1D *hRaa, Double_t raaSystLow, Double_t raaSystHigh, Double_t ppSystRawYieldCutVar, Double_t ppSystRawYieldCutVarPid, Double_t ABSystRawYieldCutVar, Double_t ABSystRawYieldCutVarPid)
virtual const char * GetCDBReferenceURL() const
Int_t FindPrimaryParentID(Int_t label) const
virtual AliAODTracklet * MakeTracklet(Bool_t normal)
virtual Bool_t WorkerInit()
Int_t FindParent(Int_t label) const
void SetParentPdg(Short_t pdg, Bool_t second=false)
AliTrackletAODTask & operator=(const AliTrackletAODTask &other)
AliTrackletAODMCTask(const char *name)
void SetDPhiWindow(Double_t x=0.06)
void SetDPhiShift(Double_t x=0.0045)
virtual void CleanClusters(TTree *&t)
ClassDef(AliTrackletAODTask, 1)
virtual Bool_t ProcessEvent()
TString kData
Declare data MC or deltaAOD.
virtual TTree * FilterClusters(TTree *t)
TParticle * FindPrimaryParent(Int_t label) const
virtual const char * TrackletClassName() const
static AliTrackletAODTask * Create()
Int_t CommonParent(Int_t label, const TArrayI &fill) const
virtual AliAODTracklet * ProcessTracklet(Bool_t normal, AliMultiplicity *mult, Int_t no)
void SetZEtaOverlapCut(Double_t x=0.05)
Bool_t ProcessTracklets(Bool_t normal, AliVMultiplicity *mult)
TParameter< double > * fStrangeLoss
virtual Bool_t ProcessEvent()
virtual Int_t GetCDBReferenceRun() const
void SetParentPt(Real_t pt, Bool_t second=false)
void UserCreateOutputObjects()
virtual AliAODTracklet * MakeTracklet(Bool_t normal)
void SetScaleDTheta(Bool_t x=false)
void SetDThetaWindow(Double_t x=0.025)
const AliVVertex * FindIP(AliVEvent *event, Double_t maxDispersion=0.04, Double_t maxZError=0.25)
virtual void CleanClusters(TTree *&t)
Bool_t HasField(AliVEvent *event)
TClonesArray * fTracklets
void SetMaxDelta(Double_t x=25)
virtual AliAODTracklet * ProcessTracklet(Bool_t normal, AliMultiplicity *mult, Int_t no)
virtual TTree * FilterClusters(TTree *t)
ClassDef(AliTrackletAODMCTask, 1)
void Print(Option_t *) const
virtual void FilterClustersRandom(TTree *t, TTree *copy)
virtual const char * GetCDBReferenceURL() const
AliTrackletAODMCTask(const AliTrackletAODMCTask &other)
virtual void SetFilterStrange(Int_t mode)
Bool_t Reconstruct(TTree *clusters, const AliVVertex *ip)
AliTrackletAODMCTask & operator=(const AliTrackletAODMCTask &other)
virtual void FilterClustersTrack(TTree *t, TTree *copy)
Int_t FindParents(Int_t label, TArrayI &fill, Int_t offset) const
virtual const char * TrackletClassName() const
void Terminate(Option_t *)