Fixes to track selection for embedding in cluster task (Bastian), Do no select events...
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 5 May 2011 09:30:49 +0000 (09:30 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 5 May 2011 09:30:49 +0000 (09:30 +0000)
JETAN/AliAnalysisTaskJetBackgroundSubtract.cxx
JETAN/AliAnalysisTaskJetCluster.cxx
JETAN/AliAnalysisTaskJetCluster.h

index 8f7a183..452247d 100644 (file)
@@ -231,6 +231,14 @@ void AliAnalysisTaskJetBackgroundSubtract::UserCreateOutputObjects()
   fHistList->SetOwner();
   PostData(1, fHistList); // post data in any case once
 
+  // 
+  
+  // delta pT vs. area vs. cent vs. mult
+  const Int_t nSparseBinsDelta = 4;
+  const Int_t nBinsDelta[nSparseBinsDelta] =   {   241,  10,  10,  25}; 
+  const Double_t xminDelta[nSparseBinsDelta] = {-120.5,   0,   0,   0};
+  const Double_t xmaxDelta[nSparseBinsDelta] = { 120.5, 1.0, 100,5000};
   for(int iJB = 0;iJB<fJBArray->GetEntries();iJB++){
     TObjString *ostr = (TObjString*)fJBArray->At(iJB);
     TString oldName(ostr->GetString().Data()); 
@@ -241,8 +249,11 @@ void AliAnalysisTaskJetBackgroundSubtract::UserCreateOutputObjects()
       continue;
     }
     newName.ReplaceAll(fReplaceString1.Data(),Form(fReplaceString2.Data(),fSubtraction));
+    
     TH2F *hTmp = new TH2F(Form("h2PtInPtOut_%d",iJB),Form(";%s p_{T}; %s p_{T}",oldName.Data(),newName.Data()),200,0,200.,400,-200.,200.);
     fHistList->Add(hTmp);
+    THnSparseF *hFTmp = new THnSparseF(Form("hnDPtAreaCentMult_%d",iJB),Form("%s delta;#delta p_{T};Area;cent;mult",newName.Data()),nSparseBinsDelta,nBinsDelta,xminDelta,xmaxDelta);
+    fHistList->Add(hFTmp);
   }
 
   Bool_t oldStatus = TH1::AddDirectoryStatus();
@@ -253,13 +264,13 @@ void AliAnalysisTaskJetBackgroundSubtract::UserCreateOutputObjects()
   //    
 
  
-    fh2CentvsRho = new TH2F("fh2CentvsRho","centrality vs background density",100,0.,100.,2000,0.,200.);
-    fh2CentvsSigma = new TH2F("fh2CentvsSigma","centrality vs backgroun sigma",100,0.,100.,1000,0.,50.);
+    fh2CentvsRho = new TH2F("fh2CentvsRho","centrality vs background density", 100,0.,100.,600,0.,300.);
+    fh2CentvsSigma = new TH2F("fh2CentvsSigma","centrality vs backgroun sigma",100,0.,100.,500,0.,50.);
     fHistList->Add(fh2CentvsRho);
     fHistList->Add(fh2CentvsSigma);
 
-    fh2MultvsRho = new TH2F("fh2MultvsRho","mult vs background density",1000,0.,5000.,300,0.,300.);
-    fh2MultvsSigma = new TH2F("fh2MultvsSigma","mult vs backgroun sigma",1000,0.,5000.,500,0.,50.);
+    fh2MultvsRho = new TH2F("fh2MultvsRho","mult vs background density", 100,0.,5000.,600,0.,300.);
+    fh2MultvsSigma = new TH2F("fh2MultvsSigma","mult vs background sigma",100,0.,5000.,500,0.,50.);
     fHistList->Add(fh2MultvsRho);
     fHistList->Add(fh2MultvsSigma);
 
@@ -274,7 +285,6 @@ void AliAnalysisTaskJetBackgroundSubtract::UserCreateOutputObjects()
      fHistList->Add(fh2ShiftPhiLeading);
    }
     
-
   // =========== Switch on Sumw2 for all histos ===========
   for (Int_t i=0; i<fHistList->GetEntries(); ++i) {
     TH1 *h1 = dynamic_cast<TH1*>(fHistList->At(i));
@@ -431,30 +441,33 @@ void AliAnalysisTaskJetBackgroundSubtract::UserExec(Option_t */*option*/)
       continue;
     }
     TH2F* h2PtInOut = (TH2F*)fHistList->FindObject(Form("h2PtInPtOut_%d",iJB));
+    THnSparseF* hnDPtAreaCentMult = (THnSparseF*)fHistList->FindObject(Form("hnDPtAreaCentMult_%d",iJB));
     // loop over all jets
     Int_t nOut = 0;
       
+    Double_t deltaPt[4];
+    deltaPt[2] = cent;
+    deltaPt[3] = mult;
 
     for(int i = 0;i < jarray->GetEntriesFast();i++){
       AliAODJet *jet = (AliAODJet*)jarray->At(i);
       AliAODJet tmpNewJet(*jet);
       Bool_t bAdd = false;
-     
+      Float_t ptSub = 0;
+
 
       if(fSubtraction==kArea){ 
        Double_t background = rho * jet->EffectiveAreaCharged();
-       Float_t ptSub = jet->Pt() - background; 
+       ptSub = jet->Pt() - background; 
        if(fDebug>2){
          Printf("%s:%d Jet %d %3.3f %3.3f",(char*)__FILE__,__LINE__,i,jet->Pt(),ptSub);
        }
        if(ptSub<0){
          // optionally rescale it and keep??
          bAdd = false; // RescaleJetMomentum(&tmpNewJet,0.1);
-         if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),ptSub);
        }
        else{
          bAdd = RescaleJetMomentum(&tmpNewJet,ptSub);
-         if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),ptSub);
        }
        // add background estimates to the new jet object
        // allows to recover old p_T and rho...
@@ -462,35 +475,30 @@ void AliAnalysisTaskJetBackgroundSubtract::UserExec(Option_t */*option*/)
       }// kAREA
       else if(fSubtraction==kRhoRecalc){
        Double_t background = rho * jet->EffectiveAreaCharged();
-       Float_t ptSub = jet->Pt() - background; 
+       ptSub = jet->Pt() - background; 
         if(fDebug>2){
          Printf("%s:%d Jet %d %3.3f %3.3f %3.3f %3.3f",(char*)__FILE__,__LINE__,i,jet->Pt(),ptSub,background,rho);}
        if(ptSub<0){
          // optionally rescale it and keep??
          bAdd = false;// RescaleJetMomentum(&tmpNewJet,0.1);
-         if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),ptSub);
        }
        else{
          bAdd = RescaleJetMomentum(&tmpNewJet,ptSub);
-         if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),ptSub);
        }
        // add background estimates to the new jet object
        // allows to recover old p_T and rho...
        tmpNewJet.SetBgEnergy(background,0);
-
       }//kRhoRecalc
        else if(fSubtraction==kRhoRC){
        Double_t background = rho * jet->EffectiveAreaCharged();
-       Float_t ptSub = jet->Pt() - background; 
+       ptSub = jet->Pt() - background; 
        if(fDebug>2){   Printf("%s:%d Jet %d %3.3f %3.3f %3.3f %3.3f",(char*)__FILE__,__LINE__,i,jet->Pt(),ptSub,background,rho);}
        if(ptSub<0){
          // optionally rescale it and keep??
          bAdd = false; // RescaleJetMomentum(&tmpNewJet,0.1);
-         if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),ptSub);
        }
        else{
          bAdd = RescaleJetMomentum(&tmpNewJet,ptSub);
-         if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),ptSub);
        }
        // add background estimates to the new jet object
        // allows to recover old p_T and rho...
@@ -499,14 +507,11 @@ void AliAnalysisTaskJetBackgroundSubtract::UserExec(Option_t */*option*/)
        }//kRhoRC
 
        else if(fSubtraction==k4Area&&jet->VectorAreaCharged()){
-
-        
         backgroundv.SetPxPyPzE(rho*(jet->VectorAreaCharged())->Px(),rho*(jet->VectorAreaCharged())->Py(),rho*(jet->VectorAreaCharged())->Pz(),rho*(jet->VectorAreaCharged())->E());
+        ptSub = jet->Pt()-backgroundv.Pt();
         if((backgroundv.E()>jet->E())&&(backgroundv.Pt()>jet->Pt())){
-       
-          // optionally rescale it and keep??
+                  // optionally rescale it and keep??
           bAdd = false; // RescaleJetMomentum(&tmpNewJet,0.1);
-          if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),jet->Pt()-backgroundv.Pt());
         }
         else{
           bAdd = RescaleJet4vector(&tmpNewJet,backgroundv);
@@ -526,7 +531,6 @@ void AliAnalysisTaskJetBackgroundSubtract::UserExec(Option_t */*option*/)
         AliAODJet *newJet = new ((*jarrayOut)[nOut++]) AliAODJet(tmpNewJet);
        // what about track references, clear for now...
        if(fSubtraction==k4Area){
-         if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),jet->Pt()-newJet->Pt());
          fh2ShiftEta->Fill(jet->Eta(),newJet->Eta());
          fh2ShiftPhi->Fill(jet->Phi(),newJet->Phi());
          if(i==0){fh2ShiftEtaLeading->Fill(jet->Eta(),newJet->Eta());
@@ -540,6 +544,12 @@ void AliAnalysisTaskJetBackgroundSubtract::UserExec(Option_t */*option*/)
          if(vp)newJet->AddTrack(vp);
        }
       }
+      if(h2PtInOut)h2PtInOut->Fill(jet->Pt(),ptSub);
+      if(hnDPtAreaCentMult){
+       deltaPt[0] = ptSub;
+       deltaPt[1] = jet->EffectiveAreaCharged();
+       hnDPtAreaCentMult->Fill(deltaPt);
+      }
     }
     if(jarrayOut)jarrayOut->Sort();
    }
index 5831287..469f8a8 100644 (file)
@@ -90,8 +90,8 @@ AliAnalysisTaskJetCluster::AliAnalysisTaskJetCluster(): AliAnalysisTaskSE(),
   fRef(new TRefArray),
   fUseAODTrackInput(kFALSE),
   fUseAODMCInput(kFALSE),
-  fUseGlobalSelection(kFALSE),
   fUseBackgroundCalc(kFALSE),
+  fEventSelection(kFALSE),                                                     
   fFilterMask(0),
   fTrackTypeRec(kTrackUndef),
   fTrackTypeGen(kTrackUndef),  
@@ -105,6 +105,8 @@ AliAnalysisTaskJetCluster::AliAnalysisTaskJetCluster(): AliAnalysisTaskSE(),
   fTrackPtCut(0.),                                                     
   fJetOutputMinPt(0.150),
   fJetTriggerPtCut(0),
+  fVtxZCut(8),
+  fVtxR2Cut(1),
   fCentCutUp(0),
   fCentCutLo(0),
   fNonStdBranch(""),
@@ -199,8 +201,8 @@ AliAnalysisTaskJetCluster::AliAnalysisTaskJetCluster(const char* name):
   fRef(new TRefArray),
   fUseAODTrackInput(kFALSE),
   fUseAODMCInput(kFALSE),
-  fUseGlobalSelection(kFALSE),
   fUseBackgroundCalc(kFALSE),
+  fEventSelection(kFALSE),                                                     
   fFilterMask(0),
   fTrackTypeRec(kTrackUndef),
   fTrackTypeGen(kTrackUndef),
@@ -214,6 +216,8 @@ AliAnalysisTaskJetCluster::AliAnalysisTaskJetCluster(const char* name):
   fTrackPtCut(0.),                                                     
   fJetOutputMinPt(0.150),
   fJetTriggerPtCut(0),
+  fVtxZCut(8),
+  fVtxR2Cut(1),
   fCentCutUp(0),
   fCentCutLo(0),
   fNonStdBranch(""),
@@ -636,15 +640,6 @@ void AliAnalysisTaskJetCluster::Init()
 void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
 {
 
-  if(fUseGlobalSelection){
-    // no selection by the service task, we continue
-    if (fDebug > 1)Printf("Not selected %s:%d",(char*)__FILE__,__LINE__);
-    PostData(1, fHistList);
-    return;
-  }
-
-
-
   // handle and reset the output jet branch 
 
   if(fTCAJetsOut)fTCAJetsOut->Delete();
@@ -704,24 +699,28 @@ void AliAnalysisTaskJetCluster::UserExec(Option_t */*option*/)
       fh1ZPhySel->Fill(zVtx);
     }
 
-
-    if(vtxAOD->GetNContributors()>2&&!vtxTitle.Contains("TPCVertex")){
+    if(fEventSelection){
+      if(vtxAOD->GetNContributors()>2&&!vtxTitle.Contains("TPCVertex")){
        Float_t yvtx = vtxAOD->GetY();
        Float_t xvtx = vtxAOD->GetX();
        Float_t r2   = yvtx*yvtx+xvtx*xvtx;  
-       if(TMath::Abs(zVtx)<8.&&r2<1.){ // apply vertex cut later on
+       if(TMath::Abs(zVtx)<fVtxZCut&&r2<fVtxR2Cut){ // apply vertex cut later on
          if(physicsSelection){
            selectEvent = true;
          }
        }
-    }
-    if(fCentCutUp>0){
-      if(cent<fCentCutLo||cent>fCentCutUp){
-       selectEvent = false;
       }
+      if(fCentCutUp>0){
+       if(cent<fCentCutLo||cent>fCentCutUp){
+         selectEvent = false;
+       }
+      }
+    }else{
+      selectEvent = true;
     }
-
   }
+  
+
   if(!selectEvent){
     PostData(1, fHistList);
     return;
@@ -1388,6 +1387,8 @@ Int_t  AliAnalysisTaskJetCluster::GetListOfTracks(TList *list,Int_t type){
 
        AliAODTrack *trackAOD = dynamic_cast<AliAODTrack*> (track);
        if(!trackAOD)continue;
+        if((fFilterMask>0)&&!(trackAOD->TestFilterBit(fFilterMask))) continue;
+        if(TMath::Abs(trackAOD->Eta())>fTrackEtaWindow) continue;
        if(trackAOD->Pt()<fTrackPtCut) continue;
        list->Add(trackAOD);
        iCount++;
index c9b49a2..98eafd5 100644 (file)
@@ -51,9 +51,9 @@ class AliAnalysisTaskJetCluster : public AliAnalysisTaskSE
 
     
 
-    virtual void SetUseGlobalSelection(Bool_t b){fUseGlobalSelection = b;}
     virtual void SetAODTrackInput(Bool_t b){fUseAODTrackInput = b;}
     virtual void SetAODMCInput(Bool_t b){fUseAODMCInput = b;}
+    virtual void SetEventSelection(Bool_t b){fEventSelection = b;}
     virtual void SetRecEtaWindow(Float_t f){fRecEtaWindow = f;}
     virtual void SetTrackEtaWindow(Float_t f){fTrackEtaWindow = f;}
     virtual void SetTrackTypeGen(Int_t i){fTrackTypeGen = i;}
@@ -62,6 +62,7 @@ class AliAnalysisTaskJetCluster : public AliAnalysisTaskSE
     virtual void SetCentralityCut(Float_t xLo,Float_t xUp){fCentCutLo = xLo; fCentCutUp = xUp;}
     virtual void SetFilterMask(UInt_t i){fFilterMask = i;}
     virtual void SetJetTriggerPtCut(Float_t x){fJetTriggerPtCut = x;}    
+    virtual void SetVtxCuts(Float_t z,Float_t r = 1){fVtxZCut = z; fVtxR2Cut = r *r;}    
     virtual void SetBackgroundBranch(const char* c){fBackgroundBranch = c;}
     virtual const char* GetBackgroundBranch(){return fBackgroundBranch.Data();}    
     virtual void SetNSkipLeadingRan(Int_t x){fNSkipLeadingRan = x;}
@@ -118,8 +119,8 @@ class AliAnalysisTaskJetCluster : public AliAnalysisTaskSE
     TRefArray       *fRef;               // ! trefarray for track references within the jet
     Bool_t        fUseAODTrackInput;      // take track from input AOD not from ouptu AOD
     Bool_t        fUseAODMCInput;         // take MC from input AOD not from ouptu AOD
-    Bool_t        fUseGlobalSelection;    // Limit the eta of the generated jets
     Bool_t        fUseBackgroundCalc;     // switches on background calculations
+    Bool_t        fEventSelection;        // use the event selection of this task, otherwise analyse all
     UInt_t        fFilterMask;            // filter bit for slecected tracks
     Int_t         fTrackTypeRec;          // type of tracks used for FF 
     Int_t         fTrackTypeGen;          // type of tracks used for FF 
@@ -128,11 +129,13 @@ class AliAnalysisTaskJetCluster : public AliAnalysisTaskSE
     Int_t         fNRandomCones;          // number of generated random cones
     Float_t       fAvgTrials;             // Average nimber of trials
     Float_t       fExternalWeight;        // external weight
-    Float_t       fTrackEtaWindow;          // eta window used for corraltion plots between rec and gen 
+    Float_t       fTrackEtaWindow;        // eta window used for corraltion plots between rec and gen 
     Float_t       fRecEtaWindow;          // eta window used for corraltion plots between rec and gen 
     Float_t       fTrackPtCut;            // minimum track pt to be accepted
     Float_t       fJetOutputMinPt;        // minimum p_t for jets to be written out
     Float_t       fJetTriggerPtCut;       // minimum jwt pT for AOD to be written
+    Float_t       fVtxZCut;               // zvtx cut
+    Float_t       fVtxR2Cut;              // R vtx cut (squared) 
     Float_t       fCentCutUp;             // upper limit on centrality
     Float_t       fCentCutLo;             // lower limit on centrality
     // output configurartion
@@ -230,7 +233,7 @@ class AliAnalysisTaskJetCluster : public AliAnalysisTaskSE
     TList *fHistList; //!leading tracks to be skipped in the randomized event Output list
    
 
-    ClassDef(AliAnalysisTaskJetCluster, 16) 
+    ClassDef(AliAnalysisTaskJetCluster, 17) 
 };
  
 #endif