peak finder code from Per Thomas/Yale
[u/mrichter/AliRoot.git] / PWG4 / JetTasks / AliAnalysisTaskJetServices.cxx
index 3754cfc..83dc75c 100644 (file)
@@ -70,7 +70,6 @@ AliAnalysisTaskJetServices::AliAnalysisTaskJetServices(): AliAnalysisTaskSE(),
   fAvgTrials(1),
   fZVtxCut(8.),
   fRealData(kFALSE),
-  fPhysicsSelection(0),
   fh1Xsec(0x0),
   fh1Trials(0x0),
   fh1PtHard(0x0),
@@ -92,7 +91,6 @@ AliAnalysisTaskJetServices::AliAnalysisTaskJetServices(const char* name):
   fAvgTrials(1),
   fZVtxCut(8.),
   fRealData(kFALSE),
-  fPhysicsSelection(0),
   fh1Xsec(0x0),
   fh1Trials(0x0),
   fh1PtHard(0x0),
@@ -157,13 +155,6 @@ void AliAnalysisTaskJetServices::UserCreateOutputObjects()
 
   Bool_t oldStatus = TH1::AddDirectoryStatus();
   TH1::AddDirectory(kFALSE);
-
-  if(!fPhysicsSelection)
-    fPhysicsSelection = new AliPhysicsSelection();
-  fPhysicsSelection->SetName("AliPhysicsSelection_outputlist"); // to prevent conflict with object that is automatically streamed back
-  //AliLog::SetClassDebugLevel("AliPhysicsSelection", AliLog::kDebug);
-  fHistList->Add(fPhysicsSelection);
-
   fh1Xsec = new TProfile("fh1Xsec","xsec from pyxsec.root",1,0,1);
   fh1Xsec->GetXaxis()->SetBinLabel(1,"<#sigma>");
   fHistList->Add(fh1Xsec);
@@ -349,29 +340,30 @@ void AliAnalysisTaskJetServices::UserExec(Option_t */*option*/)
     if(esd){
       const AliESDVertex *vtxESD = esd->GetPrimaryVertex();
       //      Printf(">> ESDvtx %s %s",vtxESD->GetName(),vtxESD->GetTitle());vtxESD->Print();
-      Bool_t cand = true;
-      if(fRealData)cand = fPhysicsSelection->IsCollisionCandidate(esd);
-      if(cand) fh2ESDTriggerCount->Fill(it,kSelectedALICE); 
+      Bool_t cand = fInputHandler->IsEventSelected();
+      if(cand){
+       fh2ESDTriggerCount->Fill(it,kSelectedALICE); 
+       fh2ESDTriggerCount->Fill(it,kSelected);
+       AliAnalysisHelperJetTasks::Selected(kTRUE,kTRUE);// select this event
+      }
       if(vtxESD->GetNContributors()>0){
        if(esdTrig)fh2ESDTriggerCount->Fill(it,kTriggeredSPDVertex);
        Float_t zvtx = vtxESD->GetZ();
        Float_t yvtx = vtxESD->GetY();
        Float_t xvtx = vtxESD->GetX();
+       Float_t r2   = yvtx*yvtx+xvtx*xvtx;  
        fh2ESDTriggerVtx->Fill(it,zvtx);
-       if(TMath::Abs(zvtx)<fZVtxCut&&esdTrig&&TMath::Abs(xvtx)<0.5&&TMath::Abs(yvtx)<0.5){
+       if(TMath::Abs(zvtx)<fZVtxCut&&esdTrig&&r2<1){
          fh2ESDTriggerCount->Fill(it,kTriggeredVertexIn);
-         // here we select based on ESD info...
-         if(esdTrig&&(it==AliAnalysisHelperJetTasks::kMB1)){
+         if(cand){
+           fh2ESDTriggerCount->Fill(it,kSelectedALICEVertexIn);
            fh2ESDTriggerCount->Fill(it,kSelected);
            AliAnalysisHelperJetTasks::Selected(kTRUE,kTRUE);// select this event
          }
+         // here we select based on ESD info...
        }
-
-
       }
-
     }
-
   }
 
 
@@ -416,44 +408,4 @@ void AliAnalysisTaskJetServices::Terminate(Option_t */*option*/)
 {
   // Terminate analysis
   //
-
-  TDirectory* owd = gDirectory;
-
-  if (fDebug > 1) printf("AnalysisJetServices: Terminate() \n");
-
-  fHistList = dynamic_cast<TList*> (GetOutputData(1));
-  if (!fHistList)
-    Printf("ERROR: fHistList not available");
-
-
-
-  AliAnalysisDataContainer *cont = GetOutputSlot(1)->GetContainer();
-  TString filename = cont->GetFileName();
-  TFile *f = NULL;
-  // Check first if the file is already opened
-  f = (TFile*)gROOT->GetListOfFiles()->FindObject(filename);
-  if (f) {
-    // Cd to file
-    f->cd();
-    // Check for a folder request
-    TString dir = cont->GetFolderName(); 
-    if (!dir.IsNull()) {
-      if (!f->GetDirectory(dir)) f->mkdir(dir);
-      f->cd(dir);
-    }
-  }
-
-  if (fHistList)
-  {
-    fPhysicsSelection = dynamic_cast<AliPhysicsSelection*> (fHistList->FindObject("AliPhysicsSelection_outputlist"));
-  }
-
-  if (fPhysicsSelection)
-    {
-      fPhysicsSelection->SaveHistograms("physics_selection");
-      fPhysicsSelection->Print();
-    }
-
-  owd->cd();
-
 }