#include "AliStack.h"
#include "AliMCEvent.h"
#include "AliMCEventHandler.h"
+#include "AliESDInputHandler.h"
#include "AliAODEvent.h"
#include "AliAODHeader.h"
#include "AliAODMCHeader.h"
#include "AliGenHijingEventHeader.h"
#include "AliGenPythiaEventHeader.h"
#include "AliGenCocktailEventHeader.h"
+#include "AliGenEventHeaderTunedPbPb.h"
+#include "AliESDtrack.h"
+#include "AliAODTrack.h"
+#include "AliAODPid.h"
+#include "AliESDpid.h"
#include "AliLog.h"
//____________________________________________________________________
AliAnalysisTaskMCParticleFilter::AliAnalysisTaskMCParticleFilter():
-AliAnalysisTaskSE(),
+ AliAnalysisTaskSE(),
fTrackFilterMother(0x0),
+ fAODMcHeader(0x0),
+ fAODMcParticles(0x0),
fHistList(0x0)
{
// Default constructor
// Implemented Notify() to read the cross sections
// from pyxsec.root
//
- TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
+ AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+ TTree *tree = mgr->GetTree();
Double_t xsection = 0;
UInt_t ntrials = 0;
if(tree){
}
TString fileName(curfile->GetName());
- if(fileName.Contains("AliESDs.root")){
+ TString datafile = mgr->GetInputEventHandler()->GetInputFileName();
+ if (fileName.Contains(datafile)) {
+ fileName.ReplaceAll(datafile, "pyxsec.root");
+ }
+ else if(fileName.Contains("AliESDs.root")){
fileName.ReplaceAll("AliESDs.root", "pyxsec.root");
}
else if(fileName.Contains("AliAOD.root")){
}
TTree *xtree = (TTree*)fxsec->Get("Xsection");
if(!xtree){
- Printf("%s:%d tree not found in the pyxsec.root",(char*)__FILE__,__LINE__);
+ AliWarning(Form("%s:%d tree not found in the pyxsec.root",(char*)__FILE__,__LINE__));
return kTRUE;
}
xtree->SetBranchAddress("xsection",&xsection);
AliAnalysisTaskMCParticleFilter::AliAnalysisTaskMCParticleFilter(const char* name):
AliAnalysisTaskSE(name),
fTrackFilterMother(0x0),
+ fAODMcHeader(0x0),
+ fAODMcParticles(0x0),
fHistList(0x0)
{
// Default constructor
- DefineOutput(1,TList::Class());
+ DefineOutput(1, TList::Class());
}
/*
//____________________________________________________________________
AliAnalysisTaskMCParticleFilter::~AliAnalysisTaskMCParticleFilter()
{
- // if( fTrackFilterMother ) delete fTrackFilterMother;
+
+ if(fAODMcHeader){
+ delete fAODMcHeader;
+ }
+ if(fAODMcParticles){
+ fAODMcParticles->Delete();
+ delete fAODMcParticles;
+ }
}
/*
void AliAnalysisTaskMCParticleFilter::UserCreateOutputObjects()
{
// Create the output container
+
+
if (OutputTree()&&fTrackFilterMother)
OutputTree()->GetUserInfo()->Add(fTrackFilterMother);
// mcparticles
- TClonesArray *tca = new TClonesArray("AliAODMCParticle", 0);
- tca->SetName(AliAODMCParticle::StdBranchName());
- AddAODBranch("TClonesArray",&tca);
+ fAODMcParticles = new TClonesArray("AliAODMCParticle", 0);
+ fAODMcParticles->SetName(AliAODMCParticle::StdBranchName());
+ AddAODBranch("TClonesArray",&fAODMcParticles);
// MC header...
- AliAODMCHeader *mcHeader = new AliAODMCHeader();
- mcHeader->SetName(AliAODMCHeader::StdBranchName());
- AddAODBranch("AliAODMCHeader",&mcHeader);
-
-
+ fAODMcHeader = new AliAODMCHeader();
+ fAODMcHeader->SetName(AliAODMCHeader::StdBranchName());
+ AddAODBranch("AliAODMCHeader",&fAODMcHeader);
AliMCEventHandler *mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
AliAODHandler *aodH = dynamic_cast<AliAODHandler*> ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
h1Trials->GetXaxis()->SetBinLabel(1,"#sum{ntrials}");
fHistList->Add(h1Trials);
+ PostData(1,fHistList);
}
//____________________________________________________________________
void AliAnalysisTaskMCParticleFilter::UserExec(Option_t */*option*/)
{
-// Execute analysis for current event
-//
-
-// Fill AOD tracks from Kinematic stack
-
+ // Execute analysis for current event
+ //
+
+ // Fill AOD tracks from Kinematic stack
+ PostData(1,fHistList);
+
// get AliAOD Event
AliAODEvent* aod = AODEvent();
if (!aod) {
Int_t nprim = mcE->GetNumberOfPrimaries();
// TODO ADD MC VERTEX
- AliAODMCHeader *aodMCHo = (AliAODMCHeader *) aod->FindListObject("mcHeader");
// Get the proper MC Collision Geometry
AliGenEventHeader* mcEH = mcE->GenEventHeader();
- AliGenPythiaEventHeader *pyH = dynamic_cast<AliGenPythiaEventHeader*>(mcEH);
- AliGenHijingEventHeader *hiH = 0;
- AliCollisionGeometry *colG = 0;
+ AliGenPythiaEventHeader *pyH = dynamic_cast<AliGenPythiaEventHeader*>(mcEH);
+ AliGenHijingEventHeader *hiH = 0;
+ AliCollisionGeometry *colG = 0;
AliGenDPMjetEventHeader *dpmH = 0;
+ AliGenEventHeaderTunedPbPb *tunedH = 0;
+
// it can be only one save some casts
// assuming PYTHIA and HIJING are the most likely ones...
if(!pyH){
- hiH = dynamic_cast<AliGenHijingEventHeader*>(mcEH);
- if(!hiH){
- colG = dynamic_cast<AliCollisionGeometry *>(mcEH);
- if(!colG)dpmH = dynamic_cast<AliGenDPMjetEventHeader*>(mcEH);
- }
+ hiH = dynamic_cast<AliGenHijingEventHeader*>(mcEH);
+ if(!hiH){
+ dpmH = dynamic_cast<AliGenDPMjetEventHeader*>(mcEH);
+ if(!dpmH){
+ tunedH = dynamic_cast<AliGenEventHeaderTunedPbPb*>(mcEH);
+ }
+ }
}
-
+
+ if (hiH || dpmH) colG = dynamic_cast<AliCollisionGeometry*>(mcEH);
// fetch the trials on a event by event basis, not from pyxsec.root otherwise
// we will get a problem when running on proof since Notify may be called
if (ccEH) {
TList *genHeaders = ccEH->GetHeaders();
for (int imch=0; imch<genHeaders->GetEntries(); imch++) {
- if(!pyH)dynamic_cast<AliGenPythiaEventHeader*>(genHeaders->At(imch));
- if(!hiH)dynamic_cast<AliGenHijingEventHeader*>(genHeaders->At(imch));
+ if(!pyH)pyH = dynamic_cast<AliGenPythiaEventHeader*>(genHeaders->At(imch));
+ if(!hiH)hiH = dynamic_cast<AliGenHijingEventHeader*>(genHeaders->At(imch));
if(!colG)colG = dynamic_cast<AliCollisionGeometry *>(genHeaders->At(imch));
- if(!dpmH)dynamic_cast<AliGenDPMjetEventHeader*>(genHeaders->At(imch));
+ if(!dpmH)dpmH = dynamic_cast<AliGenDPMjetEventHeader*>(genHeaders->At(imch));
}
}
}
if (colG) {
- aodMCHo->SetReactionPlaneAngle(colG->ReactionPlaneAngle());
- printf("Found Collision Geometry. Got Reaction Plane %lf\n", colG->ReactionPlaneAngle());
+ fAODMcHeader->SetReactionPlaneAngle(colG->ReactionPlaneAngle());
+ AliInfo(Form("Found Collision Geometry. Got Reaction Plane %lf\n", colG->ReactionPlaneAngle()));
+ }
+ else if(tunedH) {
+ fAODMcHeader->SetReactionPlaneAngle(tunedH->GetPsi2());
+ fAODMcHeader->SetCrossSection(tunedH->GetCentrality());
}
-
-
-
- // check varibales for charm need all daughters
- static int iTaken = 0;
- static int iAll = 0;
- static int iCharm = 0;
Int_t j=0;
if (ip < nprim) {
// Select the primary event
write = kTRUE;
- } else if (part->GetUniqueID() == 4) {
+ } else if (part->GetUniqueID() == kPDecay) {
// Particles from decay
// Check that the decay chain ends at a primary particle
AliMCParticle* mother = mcpart;
Int_t imo = mcpart->GetMother();
- while((imo >= nprim) && (mother->GetUniqueID() == 4)) {
+ while((imo >= nprim) && (mother->Particle()->GetUniqueID() == kPDecay)) {
mother = (AliMCParticle*) mcE->GetTrack(imo);
imo = mother->GetMother();
}
// Select according to pseudorapidity and production point of primary ancestor
- if (imo < nprim && Select(((AliMCParticle*) mcE->GetTrack(imo))->Particle(), rv, zv))write = kTRUE;
- } else if (part->GetUniqueID() == 5) {
+ if (imo < nprim)write = kTRUE;
+ // if(!Select(((AliMCParticle*) mcE->GetTrack(imo))->Particle(), rv, zv))write = kFALSE; // selection on eta and phi of the mother
+ } else if (part->GetUniqueID() == kPPair) {
// Now look for pair production
Int_t imo = mcpart->GetMother();
if (imo < nprim) {
// Check if the gamma comes from the decay chain of a primary particle
AliMCParticle* mother = (AliMCParticle*) mcE->GetTrack(imo);
imo = mother->GetMother();
- while((imo >= nprim) && (mother->GetUniqueID() == 4)) {
+ while((imo >= nprim) && (mother->Particle()->GetUniqueID() == kPDecay)) {
mother = (AliMCParticle*) mcE->GetTrack(imo);
imo = mother->GetMother();
}
write = kTRUE;
}
}
- /*
- else if (part->GetUniqueID() == 13){
- // Evaporation
- // Check that we end at a primary particle
- TParticle* mother = part;
- Int_t imo = part->GetFirstMother();
- while((imo >= nprim) && ((mother->GetUniqueID() == 4 ) || ( mother->GetUniqueID() == 13))) {
- mother = mcE->Stack()->Particle(imo);
- imo = mother->GetFirstMother();
- }
- // Select according to pseudorapidity and production point
- if (imo < nprim && Select(mother, rv, zv))
- write = kTRUE;
- }
- */
+
if (write) {
if(mcH)mcH->SelectParticle(ip);
- j++;
-
- // debug info to check fro charm daugthers
- if((TMath::Abs(part->GetPdgCode()))==411){
- iCharm++;
- Int_t d0 = mcpart->GetFirstDaughter();
- Int_t d1 = mcpart->GetLastDaughter();
- if(d0>0&&d1>0){
- for(int id = d0;id <= d1;id++){
- iAll++;
- if(mcH->IsParticleSelected(id))iTaken++;
+ j++;
+ }
+ }
+
+ /*
+
+ // check varibales for charm need all daughters
+ static int iTaken = 0;
+ static int iAll = 0;
+ static int iCharm = 0;
+
+ for (Int_t ip = 0; ip < np; ip++){
+ AliMCParticle* mcpart = (AliMCParticle*) mcE->GetTrack(ip);
+ TParticle* part = mcpart->Particle();
+ // debug info to check fro charm daugthers
+ if((TMath::Abs(part->GetPdgCode()))==411){
+ iCharm++;
+ Int_t d0 = part->GetFirstDaughter();
+ Int_t d1 = part->GetLastDaughter();
+ if(d0>0&&d1>0){
+ for(int id = d0;id <= d1;id++){
+ iAll++;
+ if(mcH->IsParticleSelected(id)){
+ iTaken++;
+ Printf("> %d/%d Taken",id,nprim);
+ PrintMCParticle( (AliMCParticle*)mcE->GetTrack(id),id);
+ }
+ else{
+ Printf("> %d/%d NOT Taken",id,nprim);
+ PrintMCParticle( (AliMCParticle*)mcE->GetTrack(id),id);
}
}
- }// if charm
- }
+ }
+ }// if charm
+ AliInfo(Form("Taken daughters %d/%d of %d charm",iTaken,iAll,iCharm));
}
+ */
- AliInfo(Form("Taken daughters %d/%d of %d charm",iTaken,iAll,iCharm));
aodH->StoreMCParticles();
- PostData(1,fHistList);
return;
}
}
+void AliAnalysisTaskMCParticleFilter::PrintMCParticle(const AliMCParticle *mcp,Int_t np){
+
+ const TParticle *p = mcp->Particle();
+ Printf("Nr.%d --- Status %d ---- Mother1 %d Mother2 %d Daughter1 %d Daughte\
+r2 %d ",
+ np,p->GetStatusCode(),p->GetMother(0),p->GetMother(1),p->GetDaughter \
+ (0),p->GetDaughter(1));
+ Printf("Eta %3.3f Phi %3.3f ",p->Eta(),p->Phi());
+ p->Print();
+ Printf("---------------------------------------");
+}