Fix coverity defects
authorsma <sma@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 May 2011 09:42:05 +0000 (09:42 +0000)
committersma <sma@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 May 2011 09:42:05 +0000 (09:42 +0000)
Separate cut steps for TRD and TOF
Add centrality information for TRD PID QA histograms

PWG3/hfe/AliHFEcuts.cxx
PWG3/hfe/AliHFEcuts.h
PWG3/hfe/AliHFEextraCuts.cxx
PWG3/hfe/AliHFEextraCuts.h
PWG3/hfe/AliHFEmcQA.cxx
PWG3/hfe/AliHFEmcQA.h
PWG3/hfe/AliHFEtrdPIDqaV1.cxx

index 941c732..63ee2d2 100644 (file)
@@ -83,6 +83,7 @@ const Char_t * AliHFEcuts::fgkRecoCutName[AliHFEcuts::kNcutStepsRecTrack] = {
   "RecKineITSTPC",
   "Primary",
   "HFEITS",
+  "HFETOF",
   "HFETRD"
 };
 
@@ -123,6 +124,8 @@ AliHFEcuts::AliHFEcuts():
   fTOFMISMATCHStep(kFALSE),
   fUseMixedVertex(kTRUE),
   fIsIPSigmacut(kFALSE),
+  fFractionOfSharedTPCClusters(-1.0),
+  fMaxImpactParameterRpar(kFALSE),
   fHistQA(0x0),
   fCutList(0x0),
   fDebugLevel(0)
@@ -151,6 +154,8 @@ AliHFEcuts::AliHFEcuts(const Char_t *name, const Char_t *title):
   fTOFMISMATCHStep(kFALSE),
   fUseMixedVertex(kTRUE),
   fIsIPSigmacut(kFALSE),
+  fFractionOfSharedTPCClusters(-1.0),
+  fMaxImpactParameterRpar(kFALSE),
   fHistQA(0x0),
   fCutList(0x0),
   fDebugLevel(0)
@@ -183,6 +188,8 @@ AliHFEcuts::AliHFEcuts(const AliHFEcuts &c):
   fTOFMISMATCHStep(kFALSE),
   fUseMixedVertex(kTRUE),
   fIsIPSigmacut(kFALSE),
+  fFractionOfSharedTPCClusters(-1.0),
+  fMaxImpactParameterRpar(kFALSE),
   fHistQA(0x0),
   fCutList(0x0),
   fDebugLevel(0)
@@ -225,6 +232,8 @@ void AliHFEcuts::Copy(TObject &c) const {
   target.fTOFMISMATCHStep = fTOFMISMATCHStep;
   target.fUseMixedVertex = fUseMixedVertex;
   target.fIsIPSigmacut = fIsIPSigmacut;
+  target.fFractionOfSharedTPCClusters = fFractionOfSharedTPCClusters;
+  target.fMaxImpactParameterRpar = fMaxImpactParameterRpar;
   target.fDebugLevel = 0;
 
   memcpy(target.fProdVtx, fProdVtx, sizeof(Double_t) * 4);
@@ -299,6 +308,7 @@ void AliHFEcuts::Initialize(AliCFManager *cfm){
   SetRecKineITSTPCCutList();
   SetRecPrimaryCutList();
   SetHFElectronITSCuts();
+  SetHFElectronTOFCuts();
   SetHFElectronTRDCuts();
   SetHFElectronDcaCuts();
 
@@ -326,6 +336,7 @@ void AliHFEcuts::Initialize(AliCFManager *cfm){
   cfm->SetParticleCutsList(kStepRecKineITSTPC + kMCOffset, dynamic_cast<TObjArray *>(fCutList->FindObject("fPartRecKineITSTPCCuts")));
   cfm->SetParticleCutsList(kStepRecPrim + kMCOffset, dynamic_cast<TObjArray *>(fCutList->FindObject("fPartPrimCuts")));
   cfm->SetParticleCutsList(kStepHFEcutsITS + kMCOffset, dynamic_cast<TObjArray *>(fCutList->FindObject("fPartHFECutsITS")));
+  cfm->SetParticleCutsList(kStepHFEcutsTOF+ kMCOffset, dynamic_cast<TObjArray *>(fCutList->FindObject("fPartHFECutsTOF")));
   cfm->SetParticleCutsList(kStepHFEcutsTRD + kMCOffset, dynamic_cast<TObjArray *>(fCutList->FindObject("fPartHFECutsTRD")));
   cfm->SetParticleCutsList(kStepHFEcutsDca + kRecOffset + kMCOffset, dynamic_cast<TObjArray *>(fCutList->FindObject("fPartHFECutsDca")));
 
@@ -351,6 +362,7 @@ void AliHFEcuts::Initialize(){
   SetRecKineITSTPCCutList();
   SetRecPrimaryCutList();
   SetHFElectronITSCuts();
+  SetHFElectronTOFCuts();
   SetHFElectronTRDCuts();
   SetHFElectronDcaCuts();
 
@@ -503,6 +515,7 @@ void AliHFEcuts::SetRecKineITSTPCCutList(){
   // Set the cut in the TPC number of clusters
   hfecuts->SetMinNClustersTPC(fMinClustersTPC, fTPCclusterDef);
   hfecuts->SetClusterRatioTPC(fMinClusterRatioTPC, fTPCratioDef);
+  if(fFractionOfSharedTPCClusters > 0.0) hfecuts->SetFractionOfTPCSharedClusters(fFractionOfSharedTPCClusters); 
   
   AliCFTrackKineCuts *kineCuts = new AliCFTrackKineCuts((Char_t *)"fCutsKineRec", (Char_t *)"REC Kine Cuts");
   kineCuts->SetPtRange(fPtRange[0], fPtRange[1]);
@@ -545,9 +558,15 @@ void AliHFEcuts::SetRecPrimaryCutList(){
   primaryCut->SetAcceptKinkDaughters(kFALSE);
   if(IsQAOn()) primaryCut->SetQAOn(fHistQA);
   
+  AliHFEextraCuts *hfecuts = new AliHFEextraCuts("fCutsPrimaryCutsextra","Extra cuts from the HFE group");
+  hfecuts->SetMaxImpactParameterRpar(fMaxImpactParameterRpar);
+
   TObjArray *primCuts = new TObjArray;
   primCuts->SetName("fPartPrimCuts");
   primCuts->AddLast(primaryCut);
+  if(fMaxImpactParameterRpar){
+    primCuts->AddLast(hfecuts);
+  }
   fCutList->AddLast(primCuts);
 }
 
@@ -573,19 +592,35 @@ void AliHFEcuts::SetHFElectronITSCuts(){
 }
 
 //__________________________________________________________________
-void AliHFEcuts::SetHFElectronTRDCuts(){
+void AliHFEcuts::SetHFElectronTOFCuts(){
   //
   // Special Cuts introduced by the HFElectron Group: TRD
   //
   AliDebug(2, "Called\n");
-  AliHFEextraCuts *hfecuts = new AliHFEextraCuts("fCutsHFElectronGroupTRD","Extra cuts from the HFE group");
-  if(fMinTrackletsTRD > 0.) hfecuts->SetMinTrackletsTRD(fMinTrackletsTRD);
+  AliHFEextraCuts *hfecuts = new AliHFEextraCuts("fCutsHFElectronGroupTOF","Extra cuts from the HFE group on TOF PID");
   if(fTOFPIDStep) hfecuts->SetTOFPID(kTRUE);
   if(fTOFMISMATCHStep) hfecuts->SetTOFMISMATCH(kTRUE);
   if(IsQAOn()) hfecuts->SetQAOn(fHistQA);
   hfecuts->SetDebugLevel(fDebugLevel);
   
   TObjArray *hfeCuts = new TObjArray;
+  hfeCuts->SetName("fPartHFECutsTOF");
+  hfeCuts->AddLast(hfecuts);
+  fCutList->AddLast(hfeCuts);
+}
+
+//__________________________________________________________________
+void AliHFEcuts::SetHFElectronTRDCuts(){
+  //
+  // Special Cuts introduced by the HFElectron Group: TRD
+  //
+  AliDebug(2, "Called\n");
+  AliHFEextraCuts *hfecuts = new AliHFEextraCuts("fCutsHFElectronGroupTRD","Extra cuts from the HFE group on TRD PID");
+  if(fMinTrackletsTRD > 0.) hfecuts->SetMinTrackletsTRD(fMinTrackletsTRD);
+  if(IsQAOn()) hfecuts->SetQAOn(fHistQA);
+  hfecuts->SetDebugLevel(fDebugLevel);
+  
+  TObjArray *hfeCuts = new TObjArray;
   hfeCuts->SetName("fPartHFECutsTRD");
   hfeCuts->AddLast(hfecuts);
   fCutList->AddLast(hfeCuts);
index 95c98f4..7864cf1 100644 (file)
@@ -42,8 +42,9 @@ class AliHFEcuts : public TNamed{
       kStepRecKineITSTPC = 1,
       kStepRecPrim = 2,
       kStepHFEcutsITS = 3,
-      kStepHFEcutsTRD = 4,
-      kNcutStepsRecTrack = 5
+      kStepHFEcutsTOF = 4,
+      kStepHFEcutsTRD = 5,
+      kNcutStepsRecTrack = 6
     } RecoCutStep_t;
     typedef enum{
       kStepHFEcutsDca = 0, 
@@ -145,6 +146,8 @@ class AliHFEcuts : public TNamed{
     void SetTOFPIDStep(Bool_t tofPidStep) {fTOFPIDStep = tofPidStep;};
     void SetTOFMISMATCHStep(Bool_t tofMismatchStep) {fTOFMISMATCHStep = tofMismatchStep;};
     void SetUseMixedVertex(Bool_t useMixedVertex) {fUseMixedVertex = useMixedVertex;};    
+    void SetFractionOfSharedTPCClusters( Bool_t fractionOfSharedTPCClusters) {fFractionOfSharedTPCClusters = fractionOfSharedTPCClusters;};
+    void SetMaxImpactParameterRpar(Bool_t maxImpactParameterRpar) { fMaxImpactParameterRpar = maxImpactParameterRpar; };
     
     inline void CreateStandardCuts();
     
@@ -179,6 +182,7 @@ class AliHFEcuts : public TNamed{
     void SetRecKineITSTPCCutList();
     void SetRecPrimaryCutList();
     void SetHFElectronITSCuts();
+    void SetHFElectronTOFCuts();
     void SetHFElectronTRDCuts();
     void SetHFElectronDcaCuts();
     void SetEventCutList(Int_t istep);
@@ -210,6 +214,9 @@ class AliHFEcuts : public TNamed{
     Bool_t   fUseMixedVertex;         // Use primary vertex from track only as before
     Float_t  fIPCutParams[4];         // Parameters of impact parameter cut parametrization
     Bool_t   fIsIPSigmacut;           // if abs IP cut or IP sigma cut 
+    Double_t fFractionOfSharedTPCClusters; // Fraction of shared TPC clusters
+    Bool_t   fMaxImpactParameterRpar;      // Max impact parameter
+
 
     
     TList *fHistQA;                        //! QA Histograms
index ff0e697..8dc68e0 100644 (file)
@@ -61,6 +61,8 @@ AliHFEextraCuts::AliHFEextraCuts(const Char_t *name, const Char_t *title):
   fTOFmismatch(kFALSE),
   fTPCclusterDef(0),
   fTPCclusterRatioDef(0),
+  fMaxImpactParameterRpar(kFALSE),
+  fFractionOfTPCSharedClusters(-1.0),
   fCheck(kFALSE),
   fQAlist(0x0) ,
   fDebugLevel(0)
@@ -86,6 +88,8 @@ AliHFEextraCuts::AliHFEextraCuts(const AliHFEextraCuts &c):
   fTOFmismatch(c.fTOFmismatch),
   fTPCclusterDef(c.fTPCclusterDef),
   fTPCclusterRatioDef(c.fTPCclusterRatioDef),
+  fMaxImpactParameterRpar(c.fMaxImpactParameterRpar),
+  fFractionOfTPCSharedClusters(c.fFractionOfTPCSharedClusters),
   fCheck(c.fCheck),
   fQAlist(0x0),
   fDebugLevel(0)
@@ -119,6 +123,8 @@ AliHFEextraCuts &AliHFEextraCuts::operator=(const AliHFEextraCuts &c){
     fPixelITS = c.fPixelITS;
     fTPCclusterDef = c.fTPCclusterDef;
     fTPCclusterRatioDef = c.fTPCclusterRatioDef;
+    fMaxImpactParameterRpar = c.fMaxImpactParameterRpar;
+    fFractionOfTPCSharedClusters = c.fFractionOfTPCSharedClusters;
     fTOFpid = c.fTOFpid;
     fTOFmismatch = c.fTOFmismatch;
     fCheck = c.fCheck;
@@ -188,6 +194,9 @@ Bool_t AliHFEextraCuts::CheckRecCuts(AliVTrack *track){
   Float_t impactR, impactZ;
   Double_t hfeimpactR, hfeimpactnsigmaR;
   Double_t hfeimpactRcut, hfeimpactnsigmaRcut;
+  Double_t maximpactRcut; 
+  Bool_t passimpactRcut = kTRUE;
+  Bool_t passsharedTPCcut = kTRUE;
   Bool_t tofstep = kTRUE;
   Bool_t tofmismatchstep = kTRUE;
   GetImpactParameters(track, impactR, impactZ);
@@ -196,8 +205,12 @@ Bool_t AliHFEextraCuts::CheckRecCuts(AliVTrack *track){
     GetHFEImpactParameterCuts(track, hfeimpactRcut, hfeimpactnsigmaRcut);
     GetHFEImpactParameters(track, hfeimpactR, hfeimpactnsigmaR);
   }
+  if(fMaxImpactParameterRpar) {
+    GetMaxImpactParameterCutR(track,maximpactRcut);
+  }
   UInt_t nclsTPC = GetTPCncls(track);
   // printf("Check TPC findable clusters: %d, found Clusters: %d\n", track->GetTPCNclsF(), track->GetTPCNcls());
+  Float_t fractionSharedClustersTPC = GetTPCsharedClustersRatio(track);
   Double_t ratioTPC = GetTPCclusterRatio(track);
   UChar_t trdTracklets;
   trdTracklets = GetTRDnTrackletsPID(track);
@@ -206,6 +219,9 @@ Bool_t AliHFEextraCuts::CheckRecCuts(AliVTrack *track){
   Int_t status2 = GetITSstatus(track, 1);
   Bool_t statusL0 = CheckITSstatus(status1);
   Bool_t statusL1 = CheckITSstatus(status2);
+  if(fFractionOfTPCSharedClusters > 0.0) {
+    if(TMath::Abs(fractionSharedClustersTPC) >= fFractionOfTPCSharedClusters) passsharedTPCcut = kFALSE;    
+  }
   if(TESTBIT(fRequirements, kMinImpactParamR)){
     // cut on min. Impact Parameter in Radial direction
     if(TMath::Abs(impactR) >= fImpactParamCut[0]) SETBIT(survivedCut, kMinImpactParamR);
@@ -218,6 +234,9 @@ Bool_t AliHFEextraCuts::CheckRecCuts(AliVTrack *track){
     // cut on max. Impact Parameter in Radial direction
     if(TMath::Abs(impactR) <= fImpactParamCut[2]) SETBIT(survivedCut, kMaxImpactParamR);
   }
+  if(fMaxImpactParameterRpar) {
+    if(TMath::Abs(impactR) >= maximpactRcut) passimpactRcut = kFALSE;
+  }
   if(TESTBIT(fRequirements, kMaxImpactParamZ)){
     // cut on max. Impact Parameter in Z direction
     if(TMath::Abs(impactZ) <= fImpactParamCut[3]) SETBIT(survivedCut, kMaxImpactParamZ);
@@ -302,7 +321,7 @@ Bool_t AliHFEextraCuts::CheckRecCuts(AliVTrack *track){
   }
 
 
-  if(fRequirements == survivedCut && tofstep && tofmismatchstep){
+  if(fRequirements == survivedCut && tofstep && tofmismatchstep && passimpactRcut && passsharedTPCcut){
     //
     // Track selected
     //
@@ -544,6 +563,26 @@ UInt_t AliHFEextraCuts::GetTPCncls(AliVTrack *track){
 }
 
 //______________________________________________________
+Float_t AliHFEextraCuts::GetTPCsharedClustersRatio(AliVTrack *track){
+  //
+  // Get fraction of shared TPC clusters
+  //
+  Float_t fracClustersTPCShared = 0.0; 
+  TString type = track->IsA()->GetName();
+  if(!type.CompareTo("AliESDtrack")){
+    AliESDtrack *esdtrack = dynamic_cast<AliESDtrack *>(track);
+    if(esdtrack){ // coverity
+      Float_t nClustersTPC = esdtrack->GetTPCclusters(0);
+      Int_t nClustersTPCShared = esdtrack->GetTPCnclsS();
+      if (nClustersTPC!=0) {
+       fracClustersTPCShared = Float_t(nClustersTPCShared)/Float_t(nClustersTPC);
+      }
+    }
+  }
+  return fracClustersTPCShared;
+}
+
+//______________________________________________________
 Double_t AliHFEextraCuts::GetTPCclusterRatio(AliVTrack *track){
   //
   // Get Ratio of found / findable clusters for different definitions
@@ -657,3 +696,20 @@ void AliHFEextraCuts::GetHFEImpactParameterCuts(AliVTrack *track, Double_t &hfei
     hfeimpactnsigmaRcut = fIPcutParam[3];                                  // sigma cut
   }
 }
+//______________________________________________________
+void AliHFEextraCuts::GetMaxImpactParameterCutR(AliVTrack *track, Double_t &maximpactRcut){
+       //
+       // Get max impact parameter cut r (pt dependent)
+       //
+  
+  TString type = track->IsA()->GetName();
+  if(!type.CompareTo("AliESDtrack")){
+    AliESDtrack *esdtrack = dynamic_cast<AliESDtrack *>(track);
+    if(!esdtrack) return;
+    Double_t pt = esdtrack->Pt();      
+    if(pt > 0.15) {
+      maximpactRcut = 0.0182 + 0.035/TMath::Power(pt,1.01);  // abs R cut
+    }
+    else maximpactRcut = 9999999999.0;
+  }
+}
index d86fd19..c556026 100644 (file)
@@ -70,6 +70,8 @@ class AliHFEextraCuts : public AliCFCutBase{
     inline void SetMinNClustersTPC(Int_t minclusters, ETPCclusterDef_t def);
     void SetTOFPID(Bool_t tofPid) { fTOFpid = tofPid;}
     void SetTOFMISMATCH(Bool_t tofMismatch) { fTOFmismatch = tofMismatch;}
+    void SetMaxImpactParameterRpar(Bool_t maxImpactParameterRpar) {fMaxImpactParameterRpar = maxImpactParameterRpar;}
+    void SetFractionOfTPCSharedClusters(Double_t fractionOfTPCSharedClusters) {fFractionOfTPCSharedClusters = fractionOfTPCSharedClusters;}
 
     void SetCheckITSstatus(Bool_t check) { fCheck = check; };
     Bool_t GetCheckITSstatus() const { return fCheck; };
@@ -95,6 +97,8 @@ class AliHFEextraCuts : public AliCFCutBase{
     void GetImpactParameters(AliVTrack *track, Float_t &radial, Float_t &z);
     void GetHFEImpactParameters(AliVTrack *track, Double_t &dcaxy, Double_t &dcansigmaxy);
     void GetHFEImpactParameterCuts(AliVTrack *track, Double_t &hfeimpactRcut, Double_t &hfeimpactnsigmaRcut);
+    void GetMaxImpactParameterCutR(AliVTrack *track, Double_t &maximpactRcut);
+    Float_t GetTPCsharedClustersRatio(AliVTrack *track);
 
   private:
     typedef enum{
@@ -130,6 +134,8 @@ class AliHFEextraCuts : public AliCFCutBase{
     Bool_t  fTOFmismatch;             // TOF mismatch
     UChar_t fTPCclusterDef;           // TPC cluster definition Bitmap
     UChar_t fTPCclusterRatioDef;      // TPC cluster ratio definition Bitmap
+    Bool_t  fMaxImpactParameterRpar;  // Parametrized max impact parameter cut
+    Double_t  fFractionOfTPCSharedClusters; // Cut on fraction of shared clusters
 
     Bool_t  fCheck;                     // check
     TList *fQAlist;                    //! Directory for QA histograms
index 8aa8b7e..a0ff479 100644 (file)
@@ -66,6 +66,8 @@ AliHFEmcQA::AliHFEmcQA() :
   for(Int_t mom = 0; mom < 2; mom++){
     fIsHeavy[mom] = 0;
   }
+  memset(fElecBackgroundFactor, 0, sizeof(Double_t) * kElecBgSpecies * kBgPtBins);
+  memset(fBinLimit, 0, sizeof(Double_t) * (kBgPtBins+1));
 }
 
 //_______________________________________________________________________________________________
@@ -89,6 +91,8 @@ AliHFEmcQA::AliHFEmcQA(const AliHFEmcQA&p):
   for(Int_t mom = 0; mom < 2; mom++){
     fIsHeavy[mom] = 0;
   }
+  memset(fElecBackgroundFactor, 0, sizeof(Double_t) * kElecBgSpecies * kBgPtBins);
+  memset(fBinLimit, 0, sizeof(Double_t) * (kBgPtBins+1));
 }
 
 //_______________________________________________________________________________________________
@@ -117,6 +121,23 @@ void AliHFEmcQA::PostAnalyze() const
         //
 }
 
+//_______________________________________________________________________________________________
+void AliHFEmcQA::SetBackgroundWeightFactor(Double_t *elecBackgroundFactor, Double_t *binLimit)
+{
+   memcpy(fElecBackgroundFactor,elecBackgroundFactor,sizeof(Double_t) * kElecBgSpecies * kBgPtBins);
+   memcpy(fBinLimit,binLimit,sizeof(Double_t) * (kBgPtBins+1));
+/*
+   for(Int_t j=0;j < 6;j++){
+     for(Int_t i=0;i < 44;i++){ 
+       fElecBackgroundFactor[j][i] = elecBackgroundFactor[j][i]; 
+     }
+   }
+   for(Int_t i=0;i < 45;i++){
+     fBinLimit[i]=binLimit[i];
+   }
+   */
+}
+
 //__________________________________________
 void AliHFEmcQA::CreatDefaultHistograms(TList * const qaList)
 {      
@@ -138,15 +159,6 @@ void AliHFEmcQA::CreatDefaultHistograms(TList * const qaList)
   CreateHistograms(AliHFEmcQA::kCharm,2,"mcqa_unitY_");         // create histograms for charm 
   CreateHistograms(AliHFEmcQA::kBeauty,2,"mcqa_unitY_");        // create histograms for beauty
   CreateHistograms(AliHFEmcQA::kOthers,2,"mcqa_unitY_");        // create histograms for beauty
-  CreateHistograms(AliHFEmcQA::kCharm,3,"mcqa_reccut_");        // create histograms for charm 
-  CreateHistograms(AliHFEmcQA::kBeauty,3,"mcqa_reccut_");       // create histograms for beauty
-  CreateHistograms(AliHFEmcQA::kOthers,3,"mcqa_reccut_");       // create histograms for beauty
-  CreateHistograms(AliHFEmcQA::kCharm,4,"mcqa_recpidcut_");     // create histograms for charm 
-  CreateHistograms(AliHFEmcQA::kBeauty,4,"mcqa_recpidcut_");    // create histograms for beauty
-  CreateHistograms(AliHFEmcQA::kOthers,4,"mcqa_recpidcut_");    // create histograms for beauty
-  CreateHistograms(AliHFEmcQA::kCharm,5,"mcqa_secvtxcut_");     // create histograms for charm 
-  CreateHistograms(AliHFEmcQA::kBeauty,5,"mcqa_secvtxcut_");    // create histograms for beauty
-  CreateHistograms(AliHFEmcQA::kOthers,5,"mcqa_secvtxcut_");    // create histograms for beauty
  
 // check D spectra
   TString kDspecies[9];
@@ -168,12 +180,12 @@ void AliHFEmcQA::CreatDefaultHistograms(TList * const qaList)
   binEdges[0] =  AliHFEtools::MakeLogarithmicBinning(iBin[0], kPtbound[0], kPtbound[1]);
 
   // bin size is chosen to consider ALICE D measurement
-  Double_t xbins[13]={0,0.5,1.0,2.0,3.0,4.0,5.0,6.0,8.0,12,16,20,50};
+  Double_t xbins[15]={0,0.5,1.0,2.0,3.0,4.0,5.0,6.0,8.0,12,16,20,30,40,50};
   Double_t ybins[10]={-7.5,-1.0,-0.9,-0.8,-0.5,0.5,0.8,0.9,1.0,7.5};
   TString hname;
   for (Int_t iDmeson=0; iDmeson<9; iDmeson++){
      hname = "Dmeson"+kDspecies[iDmeson];
-     fhD[iDmeson] = new TH2F(hname,hname+";p_{T} (GeV/c)",12,xbins,9,ybins);
+     fhD[iDmeson] = new TH2F(hname,hname+";p_{T} (GeV/c)",14,xbins,9,ybins);
      hname = "DmesonLogbin"+kDspecies[iDmeson];
      fhDLogbin[iDmeson] = new TH1F(hname,hname+";p_{T} (GeV/c)",iBin[0],binEdges[0]);
      if(fQAhistos) fQAhistos->Add(fhD[iDmeson]);
@@ -250,8 +262,8 @@ void AliHFEmcQA::CreateHistograms(const Int_t kquark, Int_t icut, TString hnopt)
   binEdges[0] =  AliHFEtools::MakeLogarithmicBinning(iBin[0], kPtbound[0], kPtbound[1]);
 
 
-  Double_t xcorrbin[201];
-  for (int icorrbin = 0; icorrbin< 201; icorrbin++){
+  Double_t xcorrbin[501];
+  for (int icorrbin = 0; icorrbin< 501; icorrbin++){
     xcorrbin[icorrbin]=icorrbin*0.1;
   }
 
@@ -295,16 +307,16 @@ void AliHFEmcQA::CreateHistograms(const Int_t kquark, Int_t icut, TString hnopt)
   hname = hnopt+"ePtRatio_"+kqTypeLabel[kQuark];
   fHistComm[iq][icut].fePtRatio = new TH2F(hname,hname+";p_{T} (GeV/c);momentum fraction",200,0,20,100,0,1);
   hname = hnopt+"PtCorr_"+kqTypeLabel[kQuark];
-  fHistComm[iq][icut].fPtCorr = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",200,xcorrbin,44,binEdges[0]);
+  fHistComm[iq][icut].fPtCorr = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",500,xcorrbin,44,binEdges[0]);
   //fHistComm[iq][icut].fPtCorr = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",200,0,20,200,0,20);
   hname = hnopt+"PtCorrDp_"+kqTypeLabel[kQuark];
-  fHistComm[iq][icut].fPtCorrDp= new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",200,xcorrbin,44,binEdges[0]);
+  fHistComm[iq][icut].fPtCorrDp= new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",500,xcorrbin,44,binEdges[0]);
   //fHistComm[iq][icut].fPtCorrDp= new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",200,0,20,200,0,20);
   hname = hnopt+"PtCorrD0_"+kqTypeLabel[kQuark];
-  fHistComm[iq][icut].fPtCorrD0 = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",200,xcorrbin,44,binEdges[0]);
+  fHistComm[iq][icut].fPtCorrD0 = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",500,xcorrbin,44,binEdges[0]);
   //fHistComm[iq][icut].fPtCorrD0 = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",200,0,20,200,0,20);
   hname = hnopt+"PtCorrDrest_"+kqTypeLabel[kQuark];
-  fHistComm[iq][icut].fPtCorrDrest = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",200,xcorrbin,44,binEdges[0]);
+  fHistComm[iq][icut].fPtCorrDrest = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",500,xcorrbin,44,binEdges[0]);
   //fHistComm[iq][icut].fPtCorrDrest = new TH2F(hname,hname+";D p_{T} (GeV/c);e p_{T} (GeV/c)",200,0,20,200,0,20);
   hname = hnopt+"DePtRatio_"+kqTypeLabel[kQuark];
   fHistComm[iq][icut].fDePtRatio = new TH2F(hname,hname+";p_{T} (GeV/c);momentum fraction",100,0,20,100,0,1);
@@ -344,6 +356,7 @@ void AliHFEmcQA::Init()
 
 }
 
+//__________________________________________
 void AliHFEmcQA::GetMesonKine() 
 {
   //
@@ -372,7 +385,7 @@ void AliHFEmcQA::GetMesonKine()
           if(!((id2-id1)==2)) continue;
           for(int idx=id1; idx<=id2; idx++){
             if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
-            mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt);
+            if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
             if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
              fMCQACollection->Fill("piondaughters",mctrackd->Pt());
           }
@@ -388,7 +401,7 @@ void AliHFEmcQA::GetMesonKine()
           if(!((id2-id1)==2||(id2-id1)==3)) continue;
           for(int idx=id1; idx<=id2; idx++){
             if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
-            mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt);
+            if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
             if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
              fMCQACollection->Fill("etadaughters",mctrackd->Pt());
           }
@@ -404,7 +417,7 @@ void AliHFEmcQA::GetMesonKine()
           if(!((id2-id1)==1||(id2-id1)==2)) continue;
           for(int idx=id1; idx<=id2; idx++){
             if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
-            mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt);
+            if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
             if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
              fMCQACollection->Fill("omegadaughters",mctrackd->Pt());
           }
@@ -420,7 +433,7 @@ void AliHFEmcQA::GetMesonKine()
           if(!((id2-id1)==1)) continue;
           for(int idx=id1; idx<=id2; idx++){
             if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
-            mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt);
+            if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
             if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
              fMCQACollection->Fill("phidaughters",mctrackd->Pt());
           }
@@ -436,7 +449,7 @@ void AliHFEmcQA::GetMesonKine()
           if(!((id2-id1)==2||(id2-id1)==3)) continue;
           for(int idx=id1; idx<=id2; idx++){
             if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
-            mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt);
+            if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
             if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
              fMCQACollection->Fill("etapdaughters",mctrackd->Pt());
           }
@@ -452,7 +465,7 @@ void AliHFEmcQA::GetMesonKine()
           if(!((id2-id1)==1)) continue;
           for(int idx=id1; idx<=id2; idx++){
             if(!(mctrackdaugt = fMCEvent->GetTrack(idx))) continue;
-            mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt);
+            if(!(mctrackd = dynamic_cast<AliMCParticle *>(mctrackdaugt))) continue;
             if(abs(mctrackd->PdgCode()) == 11 && TMath::Abs(mctrackd->Eta())<0.8)
              fMCQACollection->Fill("rhodaughters",mctrackd->Pt());
           }
@@ -1421,6 +1434,58 @@ Int_t AliHFEmcQA::GetElecSource(TParticle * const mcpart)
 }
 
 //__________________________________________
+Double_t AliHFEmcQA::GetWeightFactor(AliMCParticle *mctrack){
+  //
+  // Get weighting factor for the realistic background estimation
+  //
+  AliMCParticle *mctrackmother = NULL;  
+  Double_t weightElecBg = 0.;
+  Double_t mesonPt = 0.;
+  Double_t bgcategory = 0.;
+  Int_t mArr = -1;  
+  Int_t mesonID = GetElecSource(mctrack->Particle());
+  if(mesonID==kGammaPi0 || mesonID==kPi0) mArr=0;                //pion
+  else if(mesonID==kGammaEta || mesonID==kEta) mArr=1;           //eta
+  else if(mesonID==kGammaOmega || mesonID==kOmega) mArr=2;       //omega
+  else if(mesonID==kGammaPhi || mesonID==kPhi) mArr=3;           //phi
+  else if(mesonID==kGammaEtaPrime || mesonID==kEtaPrime) mArr=4; //etaprime
+  else if(mesonID==kGammaRho0 || mesonID==kRho0) mArr=5;         //rho
+
+  if(!(mArr<0)){
+     if(mesonID>=kGammaPi0) {  // conversion electron, be careful with the enum odering 
+        Int_t glabel=TMath::Abs(mctrack->GetMother()); // gamma label
+        if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
+          glabel=TMath::Abs(mctrackmother->GetMother()); // gamma's mother's label
+          if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
+            mesonPt = mctrackmother->Pt(); //meson pt
+            bgcategory = 1.;
+          } 
+        }
+     }
+     else{ // nonHFE except for the conversion electron
+        Int_t glabel=TMath::Abs(mctrack->GetMother()); 
+        if((mctrackmother = dynamic_cast<AliMCParticle *>(fMCEvent->GetTrack(glabel)))){
+          mesonPt=mctrackmother->Pt(); //meson pt
+          bgcategory = -1.;
+        }
+     }
+     weightElecBg=fElecBackgroundFactor[mArr][kBgPtBins-1];                         
+     for(int ii=0; ii<kBgPtBins; ii++){              
+        if( (mesonPt > fBinLimit[ii]) && (mesonPt < fBinLimit[ii+1])){
+          weightElecBg = fElecBackgroundFactor[mArr][ii];
+        }
+     }
+     /*for(int jj=0; jj<6; jj++){              
+       for(int ii=0; ii<kBgPtBins; ii++){              
+        printf("species= %d   ptbin= %d  wfactor= %lf\n",jj,ii,fElecBackgroundFactor[jj][ii]);
+       }
+     }*/
+  }
+
+  return bgcategory*weightElecBg;
+}
+
+//__________________________________________
 void AliHFEmcQA::AliHists::FillList(TList *l) const {
   //
   // Fill Histos into a list for output
index 1a4e5fa..df989d8 100644 (file)
@@ -37,6 +37,7 @@ class TParticle;
 class TString;
 class AliMCEvent;
 class AliGenEventHeader;
+class AliMCParticle;
 class AliAODMCParticle;
 class AliHFEcollection;
 
@@ -50,6 +51,11 @@ class AliHFEmcQA: public TObject {
     enum ProcessType {
       kPairCreationFromq,  kPairCreationFromg,  kFlavourExitation,  kGluonSplitting, kInitialPartonShower, kLightQuarkShower
     };
+    enum{
+      kBgPtBins = 44,
+      kElecBgSpecies = 6
+    };
+
 
     AliHFEmcQA();
     AliHFEmcQA(const AliHFEmcQA &p); // copy constructor
@@ -69,12 +75,16 @@ class AliHFEmcQA: public TObject {
     void GetQuarkKine(TParticle *part, Int_t iTrack, const Int_t kquark); // get heavy quark kinematics distribution
     void GetHadronKine(TParticle *part, const Int_t kquark); // get heavy hadron kinematics distribution
     void GetDecayedKine(TParticle *part, const Int_t kquark, const Int_t kdecayed, Int_t icut); // get decay electron kinematics distribution
-               void GetDecayedKine(AliAODMCParticle *mcpart, const Int_t kquark, Int_t kdecayed, Int_t icut); // get decay electron kinematics for AOD 
+    void GetDecayedKine(AliAODMCParticle *mcpart, const Int_t kquark, Int_t kdecayed, Int_t icut); // get decay electron kinematics for AOD 
     void GetMesonKine(); // get meson and its decay electron pt spectra
     void EndOfEventAna(const Int_t kquark); // run analysis which should be done at the end of the event loop
-               Int_t GetSource(const TParticle * const mcpart); // return source id 
-               Int_t GetElecSource(TParticle * const mcpart); // return electron source id 
-               Int_t GetSource(const AliAODMCParticle * const mcpart); // return electron source id for AOD
+    Int_t GetSource(const TParticle * const mcpart); // return source id 
+    Int_t GetElecSource(TParticle * const mcpart); // return electron source id 
+    Int_t GetSource(const AliAODMCParticle * const mcpart); // return electron source id for AOD
+    Double_t GetWeightFactor(AliMCParticle *mctrack); // return weighting factor for electron's mother meson
+
+    void SetBackgroundWeightFactor(Double_t *elecBackgroundFactor, Double_t *binLimit);
+//    void SetBackgroundWeightFactor(Double_t const elecBackgroundFactor[6][44], Double_t const binLimit[45]) {fElecBackgroundFactor=elecBackgroundFactor; fBinLimit=binLimit;} 
 
   protected:
     void IdentifyMother(Int_t motherlabel, Int_t &motherpdg, Int_t &grandmotherlabel); // 
@@ -181,6 +191,9 @@ class AliHFEmcQA: public TObject {
     Int_t fNparents; // number of heavy hadrons to be considered
     Int_t fParentSelect[2][7]; // heavy hadron species
 
+    Double_t fElecBackgroundFactor[6][44];     // Electron background factors
+    Double_t fBinLimit[45];      // Electron background bins
+
   ClassDef(AliHFEmcQA,1);
 };
 
index 4b6add2..49185c8 100644 (file)
@@ -231,15 +231,15 @@ void AliHFEtrdPIDqaV1::ProcessTrack(const AliHFEpidObject *track, AliHFEdetPIDqa
   container[3] = step;
   fHistos->Fill("hTPCsigma", container);
 
-  container[2] = trdpid ? trdpid->GetElectronLikelihood(track->GetRecTrack(), anatype) : 0;
+  container[2] = trdpid->GetElectronLikelihood(track->GetRecTrack(), anatype);
   fHistos->Fill("hTRDlikelihood", container);
 
   if(track->IsESDanalysis()){
-    container[2] = trdpid ? trdpid->GetTRDSignalV1(dynamic_cast<const AliESDtrack *>(track->GetRecTrack())) : 0;
+    container[2] = trdpid->GetTRDSignalV1(dynamic_cast<const AliESDtrack *>(track->GetRecTrack()));
     fHistos->Fill("hTRDtruncatedMean", container);
   }
   for(UInt_t ily = 0; ily < 6; ily++){
-    container[2] = trdpid ? trdpid->GetChargeLayer(track->GetRecTrack(), ily, anatype) : 0;
+    container[2] = trdpid->GetChargeLayer(track->GetRecTrack(), ily, anatype);
     fHistos->Fill("hTRDcharge", container);
   }
 }