#include "AliTPCPIDResponse.h"
#include "AliInputEventHandler.h"
#include "AliAnalysisManager.h"
+#include "AliGenEventHeader.h"
+#include "AliGenCocktailEventHeader.h"
+#include "AliGenHijingEventHeader.h"
//class AliPWG0Helper;
//#include "$ALICE_ROOT/PWG0/AliPWG0Helper.h"
Float_t AliAnalysisHadEtMonteCarlo::fgSmearWidths[4] = {0.005,0.006,0.007,0.008};
AliAnalysisHadEtMonteCarlo::AliAnalysisHadEtMonteCarlo():AliAnalysisHadEt()
+ ,checkLabelForHIJING(kFALSE)
+ ,fNMCProducedMin(0)
+ ,fNMCProducedMax(0)
,fSimPiKPEt(0)
,fSimRawEtTPC(0)
,fSimRawEtITS(0)
return 0;
}
AliStack *stack = mcEvent->Stack();
+
+ if(checkLabelForHIJING) SetGeneratorMinMaxParticles(mcEvent);
fCentBin= -1;
fGoodEvent = kTRUE;//for p+p collisions if we made it this far we have a good event
if(fDataSet==20100){//If this is Pb+Pb
for (Int_t iTrack = 0; iTrack < nGoodTracks; iTrack++)
{
AliESDtrack *track = dynamic_cast<AliESDtrack*> (list->At(iTrack));
+ UInt_t label = (UInt_t)TMath::Abs(track->GetLabel());
+ if(checkLabelForHIJING && !IsHIJINGLabel(label,mcEvent,stack) ){cout<<"I am rejecting this particle because it is not HIJING"<<endl;}
+ if(checkLabelForHIJING && !IsHIJINGLabel(label,mcEvent,stack) ) continue;
if (!track)
{
Printf("ERROR: Could not get track %d", iTrack);
FillHisto2D(Form("dEdxAll%s",cutName->Data()),track->P(),dEdx,1.0);
- UInt_t label = (UInt_t)TMath::Abs(track->GetLabel());
TParticle *simPart = stack->Particle(label);
if(!simPart) {
Printf("no MC particle\n");
// Let's play with the stack!
AliStack *stack = mcEvent->Stack();
+
Int_t nPrim = stack->GetNtrack();
Float_t fSimPiKPEtPtSmeared = 0;
TParticle *part = stack->Particle(iPart);//This line is identified as a loss of memory by valgrind, however, the pointer still belongs to the stack, so it's the stack's problem
+ if(checkLabelForHIJING && !IsHIJINGLabel(iPart,mcEvent,stack) ) continue;
+
if (!part)
{
Printf("ERROR: Could not get particle %d", iPart);
}
+void AliAnalysisHadEtMonteCarlo::SetGeneratorMinMaxParticles(AliMCEvent *eventMC){
+ // In case of access only to hijing particles in cocktail
+ // get the min and max labels
+ // TODO: Check when generator is not the first one ...
+
+ fNMCProducedMin = 0;
+ fNMCProducedMax = 0;
+
+ AliGenEventHeader * eventHeader = eventMC->GenEventHeader();
+
+ AliGenCocktailEventHeader *cocktail = dynamic_cast<AliGenCocktailEventHeader *>(eventHeader);
+
+ if(!cocktail) return ;
+
+ TList *genHeaders = cocktail->GetHeaders();
+
+ Int_t nGenerators = genHeaders->GetEntries();
+ //printf("N generators %d \n", nGenerators);
+
+ for(Int_t igen = 0; igen < nGenerators; igen++)
+ {
+ AliGenEventHeader * eventHeader2 = (AliGenEventHeader*)genHeaders->At(igen) ;
+ TString name = eventHeader2->GetName();
+
+ //printf("Generator %d: Class Name %s, Name %s, title %s \n",igen, eventHeader2->ClassName(), name.Data(), eventHeader2->GetTitle());
+
+ fNMCProducedMin = fNMCProducedMax;
+ fNMCProducedMax+= eventHeader2->NProduced();
+
+ if(name.Contains("Hijing",TString::kIgnoreCase)){
+ //cout<<"Found HIJING event and set range "<<fNMCProducedMin<<"-"<<fNMCProducedMax<<endl;
+ return ;
+ }
+ }
+
+}
+AliGenEventHeader* AliAnalysisHadEtMonteCarlo::GetGenEventHeader(AliMCEvent *eventMC) const
+{
+ // Return pointer to Generated event header
+ // If requested and cocktail, search for the hijing generator
+ AliGenEventHeader * eventHeader = eventMC->GenEventHeader();
+ AliGenCocktailEventHeader *cocktail = dynamic_cast<AliGenCocktailEventHeader *>(eventHeader);
+
+ if(!cocktail) return 0x0 ;
+
+ TList *genHeaders = cocktail->GetHeaders();
+
+ Int_t nGenerators = genHeaders->GetEntries();
+ //printf("N generators %d \n", nGenerators);
+
+ for(Int_t igen = 0; igen < nGenerators; igen++)
+ {
+ AliGenEventHeader * eventHeader2 = (AliGenEventHeader*)genHeaders->At(igen) ;
+ TString name = eventHeader2->GetName();
+
+ //printf("Generator %d: Class Name %s, Name %s, title %s \n",igen, eventHeader2->ClassName(), name.Data(), eventHeader2->GetTitle());
+
+ if(name.Contains("Hijing",TString::kIgnoreCase)) return eventHeader2 ;
+ }
+
+ return 0x0;
+
+}
+Bool_t AliAnalysisHadEtMonteCarlo::IsHIJINGLabel(Int_t label,AliMCEvent *eventMC,AliStack *stack)
+{
+
+ // Find if cluster/track was generated by HIJING
+
+ AliGenHijingEventHeader* hijingHeader = dynamic_cast<AliGenHijingEventHeader *> (GetGenEventHeader(eventMC));
+
+ //printf("header %p, label %d\n",hijingHeader,label);
+
+ if(!hijingHeader || label < 0 ) return kFALSE;
+
+
+ //printf("pass a), N produced %d\n",nproduced);
+
+ if(label >= fNMCProducedMin && label < fNMCProducedMax)
+ {
+ //printf(" accept!, label is smaller than produced, N %d\n",nproduced);
+
+ return kTRUE;
+ }
+
+ if(!stack) return kFALSE;
+
+ Int_t nprimaries = stack->GetNtrack();
+
+ if(label > nprimaries) return kFALSE;
+
+ TParticle * mom = stack->Particle(label);
+
+ Int_t iMom = label;
+ Int_t iParent = mom->GetFirstMother();
+ while(iParent!=-1){
+ if(iParent >= fNMCProducedMin && iParent < fNMCProducedMax){
+ return kTRUE;
+ }
+
+ iMom = iParent;
+ mom = stack->Particle(iMom);
+ iParent = mom->GetFirstMother();
+ }
+
+ return kFALSE ;
+
+}
+
+
+
+
class AliVEvent;
class TRandom;
class AliAnalysisHadEtReconstructed;
+class AliMCEvent;
+class AliGenEventHeader;
+class AliStack;
class AliAnalysisHadEtMonteCarlo : public AliAnalysisHadEt
{
void DoTriggerChecksOnly(){kDoTriggerChecksOnly=kTRUE;}
void SetIsOfflineV0AND(Bool_t val){kIsOfflineV0AND = val;}
void SetIsOfflineMB(Bool_t val){kIsOfflineMB = val;}
+
+
+ void SetGeneratorMinMaxParticles(AliMCEvent *eventMC);
+ AliGenEventHeader* GetGenEventHeader(AliMCEvent *eventMC) const;
+ Bool_t IsHIJINGLabel(Int_t label,AliMCEvent *eventMC,AliStack *stack);
+ void CheckForHIJINGLabel(){checkLabelForHIJING = kTRUE;}
+
protected:
+ Bool_t checkLabelForHIJING;//Boolean - do we need to check this data set for HIJING labels? We don't need to do this unless there were signals embedded
+ Int_t fNMCProducedMin; // In case of cocktail, select particles in the list with label from this value
+ Int_t fNMCProducedMax; // In case of cocktail, select particles in the list with label up to this value
private:
//Declare it private to avoid compilation warning
//Float_t fSimPiKPEtSmeared[4];//simulated Et for pi,k,p smeared for each event by different momentum resolutions
static Float_t fgSmearWidths[4];//array with widths for smearing with different momentum resultions
static Int_t fgNumSmearWidths;//number of entries in the array above
- TRandom *fPtSmearer;//!a TRandom used for investigating momentum smearing
- AliAnalysisHadEtReconstructed *fHadEtReco;//!corresponding class for data reconstruction. Used to access corrections directly used here.
+ TRandom *fPtSmearer;//a TRandom used for investigating momentum smearing
+ AliAnalysisHadEtReconstructed *fHadEtReco;//corresponding class for data reconstruction. Used to access corrections directly used here.
ClassDef(AliAnalysisHadEtMonteCarlo, 1);
};