]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding AliTPCComparisonPID class
authormarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 2 Nov 2009 11:45:24 +0000 (11:45 +0000)
committermarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 2 Nov 2009 11:45:24 +0000 (11:45 +0000)
(Marian)

PWG1/AliTPCComparisonPID.cxx [new file with mode: 0644]
PWG1/AliTPCComparisonPID.h [new file with mode: 0644]
PWG1/PWG1LinkDef.h

diff --git a/PWG1/AliTPCComparisonPID.cxx b/PWG1/AliTPCComparisonPID.cxx
new file mode 100644 (file)
index 0000000..249d71a
--- /dev/null
@@ -0,0 +1,354 @@
+//
+//
+// 
+
+//
+// ROOT includes
+#include <TChain.h>
+#include <TMath.h>
+#include <TVectorD.h>
+#include <TSystem.h>
+#include <TFile.h>
+#include <TParticle.h>
+
+// ALIROOT includes
+#include <TTreeStream.h>
+#include <AliAnalysisManager.h>
+#include <AliESDInputHandler.h>
+#include "AliStack.h"
+#include "AliMCEvent.h"
+#include "AliMCEventHandler.h"
+#include "AliMathBase.h"
+
+#include <AliESD.h>
+#include "AliExternalTrackParam.h"
+#include "AliTracker.h"
+#include "AliTPCseed.h"
+//
+#include "AliTPCComparisonPID.h"
+//
+#include <THnSparse.h>
+
+//
+
+// STL includes
+#include <iostream>
+
+using namespace std;
+
+ClassImp(AliTPCComparisonPID)
+
+//________________________________________________________________________
+AliTPCComparisonPID::AliTPCComparisonPID() : 
+  AliAnalysisTask(), 
+  fMCinfo(0),     //! MC event handler
+  fESD(0),
+  fTPCsignal(0),
+  fTPCsignalNorm(0),
+  fDebugStreamer(0),
+  fStreamLevel(0),
+  fDebugLevel(0),
+  fDebugOutputPath()
+{
+  //
+  // Default constructor (should not be used)
+  //
+}
+
+AliTPCComparisonPID::AliTPCComparisonPID(const AliTPCComparisonPID& info) : 
+  AliAnalysisTask(info), 
+  fMCinfo(info.fMCinfo),     //! MC event handler
+  fESD(info.fESD),        //!
+  fTPCsignal(0),
+  fTPCsignalNorm(0),
+  //
+  fDebugStreamer(0),
+  fStreamLevel(0),
+  fDebugLevel(),
+  fDebugOutputPath()
+{
+  //
+  // Dummy Copy  constructor - no copy constructor for THnSparse 
+  //
+}
+
+
+
+//________________________________________________________________________
+AliTPCComparisonPID::AliTPCComparisonPID(const char *name) : 
+  AliAnalysisTask(name, "AliTPCComparisonPID"), 
+  fMCinfo(0),     //! MC event handler
+  fESD(0),
+  fTPCsignal(0),
+  fTPCsignalNorm(0),
+  fDebugStreamer(0),
+  fStreamLevel(0),
+  fDebugLevel(0),
+  fDebugOutputPath()
+{
+  //
+  // Normal constructor
+  //
+  // Input slot #0 works with a TChain
+  DefineInput(0, TChain::Class());
+  // Output slot #0 writes into a TList
+  DefineOutput(0, AliTPCComparisonPID::Class());
+  //
+  //make histos
+  Init(); 
+}
+
+void AliTPCComparisonPID::Init(){
+  //
+  // Init dEdx histogram
+  // Dimensions
+  // 0 - particle specie as defined in the AliPID - negatives+5 <0,9>
+  // 1 - momenta - at the entrance of the TPC
+  // 2 - tan lambda- fP[3]
+  // 3 - betagamma
+  // 4 - measurement - dEdx or dEdx/BB
+  //
+  Double_t xmin[5],  xmax[5];
+  Int_t    nbins[5];
+  // pid
+  nbins[0]=10;
+  xmin[0]=0; xmax[0]=10;
+  // momenta
+  nbins[1]=30;
+  xmin[1]=0.1; xmax[1]=3;
+  //P3
+  nbins[2]=20;
+  xmin[2]=-1.5; xmax[2]=1.5;
+  //
+  // log (betagamma)
+  //
+  nbins[3]=50;
+  xmin[3]=0.1; xmax[3]=100;
+  //
+  // 
+  nbins[4]=400;
+  xmin[4]=20; xmax[4]=400;
+  fTPCsignal = new THnSparseF("TPC signal","TPC signal",5,nbins,xmin,xmax);
+  nbins[4]=100;
+  xmin[4]=25; xmax[4]=75;
+  fTPCsignal = new THnSparseF("TPC signal Norm","TPC signal Norm",5,nbins,xmin,xmax);
+  //
+}
+
+
+
+
+
+AliTPCComparisonPID::~AliTPCComparisonPID(){
+  //
+  //
+  //
+  if (fDebugLevel>0)  printf("AliTPCComparisonPID::~AliTPCComparisonPID\n");
+  if (fDebugStreamer) delete fDebugStreamer;
+  fDebugStreamer=0;
+  delete fTPCsignal;
+  delete fTPCsignalNorm;
+}
+
+
+//________________________________________________________________________
+void AliTPCComparisonPID::ConnectInputData(Option_t *) 
+{
+  //
+  // Connect the input data
+  //
+  if(fDebugLevel>3)
+    cout << "AnalysisTaskTPCCluster::ConnectInputData()" << endl;
+
+  TTree* tree=dynamic_cast<TTree*>(GetInputData(0));
+  if (!tree) {
+    //Printf("ERROR: Could not read chain from input slot 0");
+  }
+  else {
+    AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+    if (!esdH) {
+      //Printf("ERROR: Could not get ESDInputHandler");
+    }
+    else {
+      fESD = esdH->GetEvent();
+      //Printf("*** CONNECTED NEW EVENT ****");
+    }  
+  }
+  AliMCEventHandler* mcinfo = (AliMCEventHandler*) (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());  
+  mcinfo->SetReadTR(kTRUE);
+  
+  fMCinfo = mcinfo->MCEvent();
+
+
+}
+
+
+
+
+
+
+//________________________________________________________________________
+void AliTPCComparisonPID::CreateOutputObjects() 
+{
+  //
+  // Connect the output objects
+  //
+  if(fDebugLevel>3)
+    cout << "AnalysisTaskTPCCluster::CreateOutputObjects()" << endl;
+
+}
+
+
+//________________________________________________________________________
+void AliTPCComparisonPID::Exec(Option_t *) {
+  //
+  // Execute analysis for current event 
+  //
+
+  if(fDebugLevel>3)
+    cout << "AliTPCComparisonPID::Exec()" << endl;
+    
+
+  // If MC has been connected   
+
+  if (!fMCinfo){
+    cout << "Not MC info\n" << endl;
+  }else{
+    ProcessMCInfo();
+    //mcinfo->Print();
+    //DumpInfo();
+  }
+  //
+  PostData(0, this);
+}      
+
+
+
+
+//________________________________________________________________________
+void AliTPCComparisonPID::Terminate(Option_t *) {
+    //
+    // Terminate loop
+    //
+  if(fDebugLevel>3)
+    printf("AliTPCComparisonPID: Terminate() \n");  
+  //
+  if (fDebugLevel>0) printf("AliMCtrackingTestTask::Terminate\n");
+  if (fDebugStreamer) delete fDebugStreamer;
+  fDebugStreamer = 0;
+  return;
+}
+
+
+
+TTreeSRedirector *AliTPCComparisonPID::GetDebugStreamer(){
+  //
+  // Get Debug streamer
+  // In case debug streamer not yet initialized and StreamLevel>0 create new one
+  //
+  if (fStreamLevel==0) return 0;
+  if (fDebugStreamer) return fDebugStreamer;
+  TString dsName;
+  dsName=GetName();
+  dsName+="Debug.root";
+  dsName.ReplaceAll(" ","");
+  fDebugStreamer = new TTreeSRedirector(dsName.Data());
+  return fDebugStreamer;
+}
+
+
+
+
+void  AliTPCComparisonPID::ProcessMCInfo(){
+  //
+  //
+  //
+  //
+  Int_t npart   = fMCinfo->GetNumberOfTracks();
+  Int_t ntracks = fESD->GetNumberOfTracks(); 
+  if (npart<=0) return;
+  if (ntracks<=0) return;
+  //
+  //
+  TParticle * particle= new TParticle;
+  TClonesArray * trefs = new TClonesArray("AliTrackReference");
+  
+  for (Int_t itrack=0;itrack<ntracks;itrack++){
+    AliESDtrack *track = fESD->GetTrack(itrack);
+    const AliExternalTrackParam *in=track->GetInnerParam();
+    if (!in) continue;
+    Int_t ipart = TMath::Abs(track->GetLabel());
+    //
+    Int_t status = fMCinfo->GetParticleAndTR(ipart, particle, trefs);
+    if (status<0) continue;
+    if (!particle) continue;
+    if (!trefs) continue;
+    //
+    //
+    Double_t mom = in->GetP();
+    Double_t dedx=track->GetTPCsignal();
+    Double_t mass = particle->GetMass();
+    Double_t bg  =mom/mass;
+    Double_t betheBloch = AliMathBase::BetheBlochAleph(bg);
+    //
+    // Fill histos
+    //
+    Double_t x[5];
+    //PID
+    Int_t pdg = particle->GetPdgCode();
+    for (Int_t iType=0;iType<5;iType++) {
+      if (AliPID::ParticleCode(iType)==TMath::Abs(pdg)){
+       x[0]=iType;
+       if (pdg<0) x[0]+=5;
+      }
+    }
+    x[1]= mom;
+    x[2]= track->GetTgl();
+    x[3]= TMath::Log(bg);
+    x[4]= dedx;
+    fTPCsignal->Fill(x);
+    x[4]=dedx/betheBloch;
+    fTPCsignalNorm->Fill(x);    
+  }
+}
+
+
+
+
+void AliTPCComparisonPID::FinishTaskOutput()
+{
+  //
+  // According description in AliAnalisysTask this method is call
+  // on the slaves before sending data
+  //
+  Terminate("slave");
+  gSystem->Exec("pwd");
+  RegisterDebugOutput();
+
+}
+
+
+void AliTPCComparisonPID::RegisterDebugOutput(){
+  //
+  //
+  //
+  //
+  // store  - copy debug output to the destination position
+  // currently ONLY for local copy
+  TString dsName;
+  dsName=GetName();
+  dsName+="Debug.root";
+  dsName.ReplaceAll(" ","");
+  TString dsName2=fDebugOutputPath.Data();
+  gSystem->MakeDirectory(dsName2.Data());
+  dsName2+=gSystem->HostName();
+  gSystem->MakeDirectory(dsName2.Data());
+  dsName2+="/";
+  dsName2+=gSystem->BaseName(gSystem->pwd());
+  dsName2+="/";
+  gSystem->MakeDirectory(dsName2.Data());
+  dsName2+=dsName;
+  AliInfo(Form("copy %s\t%s\n",dsName.Data(),dsName2.Data()));
+  printf("copy %s\t%s\n",dsName.Data(),dsName2.Data());
+  TFile::Cp(dsName.Data(),dsName2.Data());
+}
diff --git a/PWG1/AliTPCComparisonPID.h b/PWG1/AliTPCComparisonPID.h
new file mode 100644 (file)
index 0000000..9df34b7
--- /dev/null
@@ -0,0 +1,72 @@
+#ifndef ALITPCOMPARISONPID_H
+#define ALITPCOMPARISONPID_H
+
+// ROOT includes
+#include <TList.h>
+#include <TH1.h>
+#include <TH2.h>
+
+// AliRoot includes
+#include <AliAnalysisTask.h>
+#include <AliESDEvent.h>
+#include <AliESDfriend.h>
+#include <AliESDtrack.h>
+#include <AliESDfriendTrack.h>
+#include <AliTPCseed.h>
+#include <TString.h>
+class AliGenInfoMaker;
+class TTreeSRedirector;
+class AliMCEventHadnler;
+class TParticle;
+class AliMCInfo;
+class AliESDRecInfo;
+class AliESDEvent;
+class AliMCEvent;
+class THnSparse;
+
+class AliTPCComparisonPID : public AliAnalysisTask {
+public:
+  AliTPCComparisonPID();
+  AliTPCComparisonPID(const char *name);
+  AliTPCComparisonPID(const AliTPCComparisonPID& info);
+  virtual ~AliTPCComparisonPID();  
+  virtual void   ConnectInputData(Option_t *);
+  virtual void   CreateOutputObjects();
+  virtual void   Exec(Option_t *option);
+  virtual void   Terminate(Option_t *);
+  virtual void   FinishTaskOutput();
+  void           SetDebugOuputhPath(const char * name){fDebugOutputPath=name;}
+  void           Init();
+  //
+  void           ProcessMCInfo();
+  //
+  THnSparse * GetTPCsignal(){return fTPCsignal;}
+  THnSparse * GetTPCsignalNorm(){return fTPCsignalNorm;}
+  //
+  // debug streamer part
+  //
+  TTreeSRedirector *GetDebugStreamer();
+  void       SetStreamLevel(Int_t streamLevel){fStreamLevel=streamLevel;}
+  void       SetDebugLevel(Int_t level) {fDebugLevel = level;}
+  Int_t      GetStreamLevel() const {return fStreamLevel;}
+  Int_t      GetDebugLevel() const {return fDebugLevel;}
+  //
+protected:
+  void RegisterDebugOutput();
+  AliTPCComparisonPID& operator=(const AliTPCComparisonPID& /*info*/) { return *this;}
+  AliMCEvent  * fMCinfo;          //! MC event handler
+  AliESDEvent * fESD;             //! current esd event
+  //
+  //
+  //
+  THnSparse * fTPCsignal;         //raw tpc signal - dEdx
+  THnSparse * fTPCsignalNorm;     //normalized TPC signal
+  //
+  TTreeSRedirector *fDebugStreamer;     //! debug streamer
+  Int_t  fStreamLevel;                  //  debug stream level 
+  Int_t  fDebugLevel;                   //  debug level
+  TString      fDebugOutputPath; // debug output path
+  ClassDef(AliTPCComparisonPID, 1); // Analysis task base class for tracks
+};
+
+#endif
index d9db0ea66e13ce7097d8af1b30c7f3695d1339ef..0ac305fb63ac284b3ac120ff05a13726b6966779 100644 (file)
@@ -6,13 +6,13 @@
 
 #pragma link C++ class AliAnaFwdDetsQA+;
 #pragma link C++ class AliAnalysisTaskVtXY+;
-#pragma link C++ class AliComparisonSelector+;
 #pragma link C++ class AliESDresolParams+;
 #pragma link C++ class AliESDresolMakerFast+;
 
 #pragma link C++ class AliTreeDraw+;
 //
 #pragma link C++ class AliTPCdigitRow+;
+#pragma link C++ class AliTPCComparisonPID+;
 #pragma link C++ class AliMCInfo+;
 #pragma link C++ class AliGenV0Info+;
 #pragma link C++ class AliGenKinkInfo+;