]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGLF/SPECTRA/PiKaPr/TestAOD/AliAnalysisTaskSpectraBoth.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / PiKaPr / TestAOD / AliAnalysisTaskSpectraBoth.cxx
index 80cc688785da9053060e1981ca359187d0a9fd6d..af9348a0d5cb7ab376fe5d81b5befd337c144302 100644 (file)
@@ -59,7 +59,8 @@ using namespace std;
 ClassImp(AliAnalysisTaskSpectraBoth)
 
 //________________________________________________________________________
-AliAnalysisTaskSpectraBoth::AliAnalysisTaskSpectraBoth(const char *name) : AliAnalysisTaskSE(name), fAOD(0), fHistMan(0), fTrackCuts(0), fEventCuts(0),  fPID(0), fIsMC(0), fNRebin(0),fUseMinSigma(0),fCuts(0),fdotheMCLoopAfterEventCuts(0)
+AliAnalysisTaskSpectraBoth::AliAnalysisTaskSpectraBoth(const char *name) : AliAnalysisTaskSE(name), fAOD(0), fHistMan(0), fTrackCuts(0), fEventCuts(0),  fPID(0), fIsMC(0), fNRebin(0),fUseMinSigma(0),fCuts(0),fdotheMCLoopAfterEventCuts(0),fmakePIDQAhisto(1),fMotherWDPDGcode(-1)
+
 {
   // Default constructor
   
@@ -76,7 +77,7 @@ AliAnalysisTaskSpectraBoth::AliAnalysisTaskSpectraBoth(const char *name) : AliAn
 void AliAnalysisTaskSpectraBoth::UserCreateOutputObjects()
 {
   // create output objects
-  fHistMan = new AliSpectraBothHistoManager("SpectraHistos",fNRebin);
+  fHistMan = new AliSpectraBothHistoManager("SpectraHistos",fNRebin,fmakePIDQAhisto);
 
   if (!fTrackCuts) AliFatal("Track Cuts should be set in the steering macro");
   if (!fEventCuts) AliFatal("Event Cuts should be set in the steering macro");
@@ -112,8 +113,16 @@ void AliAnalysisTaskSpectraBoth::UserExec(Option_t *)
        }
        else
                AliFatal("Not processing AODs or ESDS") ;
+       if(fIsMC)
+       {               
+               if(!fEventCuts->CheckMCProcessType(MCEvent()))
+                       return ;                
+       }
+
+
        if(fdotheMCLoopAfterEventCuts)
-               if(!fEventCuts->IsSelected(fAOD,fTrackCuts))return;//event selection
+               if(!fEventCuts->IsSelected(fAOD,fTrackCuts,fIsMC,-100,fHistMan->GetEventStatHist()))
+                       return;//event selection
        TClonesArray *arrayMC = 0;
        Int_t npar=0;
        AliStack* stack=0x0;
@@ -204,7 +213,8 @@ void AliAnalysisTaskSpectraBoth::UserExec(Option_t *)
                  }
        }
        if(!fdotheMCLoopAfterEventCuts)
-               if(!fEventCuts->IsSelected(fAOD,fTrackCuts,fIsMC,mcZ))return;//event selection
+               if(!fEventCuts->IsSelected(fAOD,fTrackCuts,fIsMC,mcZ,fHistMan->GetEventStatHist()))
+                       return;//event selection
        //main loop on tracks
        Int_t ntracks=0;
        //cout<<fAOD->GetNumberOfTracks()<<endl;
@@ -244,9 +254,11 @@ void AliAnalysisTaskSpectraBoth::UserExec(Option_t *)
                else
                        continue;
                if (!fTrackCuts->IsSelected(track,kTRUE)) 
-                       continue;
+                       continue;       
+                       
                ntracks++;
-               fPID->FillQAHistos(fHistMan, track, fTrackCuts);
+               if(fmakePIDQAhisto)
+                       fPID->FillQAHistos(fHistMan, track, fTrackCuts);
                
                //calculate DCA for AOD track
                if(dca==-999.)
@@ -264,6 +276,7 @@ void AliAnalysisTaskSpectraBoth::UserExec(Option_t *)
                fHistMan->GetPtHistogram(kHistPtRec)->Fill(track->Pt(),dca);  // PT histo
                // get identity and charge
                Bool_t rec[3]={false,false,false};
+               Bool_t sel[3]={false,false,false};
                Int_t idRec  = fPID->GetParticleSpecie(fHistMan,track, fTrackCuts,rec);
                for(int irec=kSpPion;irec<kNSpecies;irec++)
                {
@@ -287,9 +300,13 @@ void AliAnalysisTaskSpectraBoth::UserExec(Option_t *)
                        if(idRec != kSpUndefined && fTrackCuts->CheckYCut ((BothParticleSpecies_t)idRec))
                        {
                                fHistMan->GetHistogram2D(kHistPtRecSigma,idRec,charge)->Fill(track->Pt(),dca);
-                               fTrackCuts->GetHistoDCAzQA()->Fill(idRec,track->Pt(),dcaz);
-                               fTrackCuts->GetHistoNclustersQA()->Fill(idRec,track->Pt(),ncls);
-                               fTrackCuts->GetHistochi2perNDFQA()->Fill(idRec,track->Pt(),chi2perndf);
+                               if(fTrackCuts->GetMakeQAhisto())
+                               { 
+                                       fTrackCuts->GetHistoDCAzQA()->Fill(idRec,track->Pt(),dcaz);
+                                       fTrackCuts->GetHistoNclustersQA()->Fill(idRec,track->Pt(),ncls);
+                                       fTrackCuts->GetHistochi2perNDFQA()->Fill(idRec,track->Pt(),chi2perndf);
+                               }
+                               sel[idRec]=true;
                        }
                        //can't put a continue because we still have to fill allcharged primaries, done later
                
@@ -301,6 +318,7 @@ void AliAnalysisTaskSpectraBoth::UserExec(Option_t *)
                                Bool_t isSecondaryWeak     = kFALSE; 
                                Int_t idGen     =kSpUndefined;
                                Int_t pdgcode=0;
+                               Int_t motherpdg=-1;
                                if (ifAODEvent==AliSpectraBothTrackCuts::kAODobject)
                                {
                                        AliAODMCParticle *partMC = (AliAODMCParticle*) arrayMC->At(TMath::Abs(track->GetLabel()));
@@ -315,7 +333,7 @@ void AliAnalysisTaskSpectraBoth::UserExec(Option_t *)
                                        isSecondaryMaterial      = partMC->IsSecondaryFromMaterial();
                                        //cout<<"AOD tagging "<<isPrimary<<" "<<isSecondaryWeak<<isSecondaryMaterial<<" "<<partMC->GetMCProcessCode()<<endl;
 
-                                       if(!isPrimary&&!isSecondaryWeak&&!isSecondaryMaterial) 
+                                       if(!isPrimary&&!isSecondaryWeak&&!isSecondaryMaterial)//old tagging for old AODs 
                                        {
                                                AliError("old tagging");
                                                Int_t mfl=-999,codemoth=-999;
@@ -336,7 +354,16 @@ void AliAnalysisTaskSpectraBoth::UserExec(Option_t *)
                                                        isSecondaryMaterial = kTRUE;
                                        }
                                        //cout<<"AOD 2 tagging "<<isPrimary<<" "<<isSecondaryWeak<<isSecondaryMaterial<<" "<<partMC->GetMCProcessCode()<<endl;
-
+                                       if(isSecondaryWeak)
+                                       {       
+                                               Int_t indexMoth=partMC->GetMother(); // FIXME ignore fakes? TO BE CHECKED, on ESD is GetFirstMother()
+                                               if(indexMoth>=0)
+                                               {
+                                                       AliAODMCParticle* moth = (AliAODMCParticle*) arrayMC->At(indexMoth);
+                                                       if(moth)
+                                                               motherpdg=TMath::Abs(moth->GetPdgCode());
+                                               }
+                                       }
 
                                        idGen     = fPID->GetParticleSpecie(partMC);
                                        pdgcode=partMC->GetPdgCode(); 
@@ -354,6 +381,16 @@ void AliAnalysisTaskSpectraBoth::UserExec(Option_t *)
                                        isSecondaryMaterial      = stack->IsSecondaryFromMaterial(TMath::Abs(track->GetLabel()));
                                        //cout<<"ESD tagging "<<isPrimary<<" "<<isSecondaryWeak<<isSecondaryMaterial<<endl;
                                        
+                                       if(isSecondaryWeak)     
+                                       {
+
+                                               TParticle* moth=stack->Particle(TMath::Abs(partMC->GetFirstMother()));
+                                               if(moth)
+                                                        motherpdg = TMath::Abs(moth->GetPdgCode());
+
+                                       }
+                                       
+
                                        idGen     = fPID->GetParticleSpecie(partMC);
                                        pdgcode=partMC->GetPdgCode(); 
                                }
@@ -374,7 +411,7 @@ void AliAnalysisTaskSpectraBoth::UserExec(Option_t *)
                                 if(!fTrackCuts->CheckYCut ((BothParticleSpecies_t)idRec)) continue;
                  
                  // Get true ID
-                 
+                                       
                  
                                 if (idRec == idGen) fHistMan->GetHistogram2D(kHistPtRecTrue,  idGen, charge)->Fill(track->Pt(),dca); 
                  
@@ -407,13 +444,30 @@ void AliAnalysisTaskSpectraBoth::UserExec(Option_t *)
                                 ///..... END FIXME
                  
                                // Fill secondaries
-                               if(isSecondaryWeak    )  
-                                       fHistMan->GetHistogram2D(kHistPtRecSigmaSecondaryWeakDecay, idRec, charge)->Fill(track->Pt(),dca);
+                               if(isSecondaryWeak)
+                               {  
+                                       if(fMotherWDPDGcode>0)
+                                       {
+                                               if(motherpdg==fMotherWDPDGcode)
+                                                       fHistMan->GetHistogram2D(kHistPtRecSigmaSecondaryWeakDecay, idRec, charge)->Fill(track->Pt(),dca);
+                                       }       
+                                       else    
+                                               fHistMan->GetHistogram2D(kHistPtRecSigmaSecondaryWeakDecay, idRec, charge)->Fill(track->Pt(),dca);
+                               }
                                if(isSecondaryMaterial)  
                                        fHistMan->GetHistogram2D(kHistPtRecSigmaSecondaryMaterial , idRec, charge)->Fill(track->Pt(),dca);
                  
                        }//end if(arrayMC)
                }
+               if(sel[0]&&sel[1]&&sel[2])//pi+k+p
+                       fHistMan->GetPtHistogram("hHistDoubleCounts")->Fill(track->Pt(),0);
+               else if(sel[0]&&sel[1]) //pi+k
+                       fHistMan->GetPtHistogram("hHistDoubleCounts")->Fill(track->Pt(),1);
+               else if(sel[0]&&sel[2]) //pi+k
+                       fHistMan->GetPtHistogram("hHistDoubleCounts")->Fill(track->Pt(),2);
+               else if(sel[1]&&sel[2]) //p+k
+                       fHistMan->GetPtHistogram("hHistDoubleCounts")->Fill(track->Pt(),3);
+
        
        
        } // end loop on tracks