]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSTrackleterSPDEff.cxx
output histos instead of THnSparse
[u/mrichter/AliRoot.git] / ITS / AliITSTrackleterSPDEff.cxx
index 1c455c3ffbf11fe382fe43065f754a4a1a62e37c..83952641f5c6e8754b08b5773b52977878909b6b 100644 (file)
@@ -47,6 +47,8 @@
 #include "AliRunLoader.h"
 #include "AliITSReconstructor.h"
 #include "AliITSRecPoint.h"
+#include "AliESDEvent.h"
+#include "AliESDVertex.h"
 //____________________________________________________________________
 ClassImp(AliITSTrackleterSPDEff)
 
@@ -91,6 +93,7 @@ fPhiWindowL1(0),
 fZetaWindowL1(0),
 fOnlyOneTrackletPerC1(0),
 fUpdateOncePerEventPlaneEff(0),
+fMinContVtx(0),
 fChipUpdatedInEvent(0),
 fPlaneEffSPD(0),
 fPlaneEffBkg(0),
@@ -133,6 +136,10 @@ fhClustersInModuleLay2(0)
 {
    // default constructor
 // from AliITSMultReconstructor
+  Init();
+}
+//______________________________________________________________________
+void AliITSTrackleterSPDEff::Init() {
   SetPhiWindowL2();
   SetZetaWindowL2();
   SetOnlyOneTrackletPerC2();
@@ -206,6 +213,7 @@ fPhiWindowL1(mr.fPhiWindowL1),
 fZetaWindowL1(mr.fZetaWindowL1),
 fOnlyOneTrackletPerC1(mr.fOnlyOneTrackletPerC1),
 fUpdateOncePerEventPlaneEff(mr.fUpdateOncePerEventPlaneEff),
+fMinContVtx(mr.fMinContVtx),
 fChipUpdatedInEvent(mr.fChipUpdatedInEvent),
 fPlaneEffSPD(mr.fPlaneEffSPD),
 fPlaneEffBkg(mr.fPlaneEffBkg),
@@ -404,7 +412,7 @@ AliITSTrackleterSPDEff::Reconstruct(AliStack *pStack, TTree *tRef, Bool_t lbkg)
 
     found=FindChip(key, 0, vtx, fClustersLay2[iC2][0],fClustersLay2[iC2][1]);
     if (!found) {
-      AliWarning(Form("Reconstruct: cannot find chip prediction on inner layer for cluster %d on the outer layer",iC2)); 
+      AliDebug(1,Form("Reconstruct: cannot find chip prediction on inner layer for cluster %d on the outer layer",iC2)); 
       key=999999;
     }
     nfTraPred1+=(Int_t)found; // this for debugging purpose
@@ -448,7 +456,7 @@ AliITSTrackleterSPDEff::Reconstruct(AliStack *pStack, TTree *tRef, Bool_t lbkg)
        Int_t lab3=(Int_t)fClustersLay1[iC1][5];
        // do it always as a function of the chip number used to built the prediction
        found=FindChip(key,0,vtx,fClustersLay1[iC1][0],fClustersLay1[iC1][1],fClustersLay1[iC1][2]);
-       if (!found) {AliWarning(
+       if (!found) {AliDebug(1,
          Form("Reconstruct MC: cannot find chip on inner layer for cluster %d",iC1)); }
        else {
          if((lab1 != -2  &&  PrimaryTrackChecker(lab1,pStack) ) ||
@@ -577,7 +585,7 @@ AliITSTrackleterSPDEff::Reconstruct(AliStack *pStack, TTree *tRef, Bool_t lbkg)
 // Check that this cluster is still in the same chip (here you pass also Zvtx for better computation)
       found=FindChip(key,1,vtx,fClustersLay2[iC2WithBestDist][0],fClustersLay2[iC2WithBestDist][1],fClustersLay2[iC2WithBestDist][2]);
       if(!found){
-        AliWarning(
+        AliDebug(1,
          Form("Reconstruct: cannot find chip on outer layer for cluster %d",iC2WithBestDist));
         key=999999;
       }
@@ -656,7 +664,7 @@ AliITSTrackleterSPDEff::Reconstruct(AliStack *pStack, TTree *tRef, Bool_t lbkg)
        Int_t lab3=(Int_t)fClustersLay2[iC2][5];
        // do it always as a function of the chip number used to built the prediction
        found=FindChip(key,1,vtx,fClustersLay2[iC2][0],fClustersLay2[iC2][1],fClustersLay2[iC2][2]);
-       if (!found) {AliWarning(
+       if (!found) {AliDebug(1,
          Form("Reconstruct MC: cannot find chip on outer layer for cluster %d",iC2)); }
        else {
          if((lab1 != -2  &&  PrimaryTrackChecker(lab1,pStack) ) ||
@@ -778,7 +786,7 @@ AliITSTrackleterSPDEff::Reconstruct(AliStack *pStack, TTree *tRef, Bool_t lbkg)
 // Check that this cluster is still in the same chip (here you pass also Zvtx for better computation)
       found=FindChip(key,0,vtx,fClustersLay1[iC1WithBestDist][0],fClustersLay1[iC1WithBestDist][1],fClustersLay1[iC1WithBestDist][2]);
       if(!found){
-        AliWarning(
+        AliDebug(1,
          Form("Reconstruct: cannot find chip on inner layer for cluster %d",iC1WithBestDist));
         key=999999;
       }
@@ -835,7 +843,7 @@ AliITSTrackleterSPDEff::Reconstruct(AliStack *pStack, TTree *tRef, Bool_t lbkg)
   AliDebug(1,Form(("Eff. of method FindChip for Cluster on lay 2 = %d / %d"),nfClu2,ntClu2));
 }
 //____________________________________________________________________
-Bool_t AliITSTrackleterSPDEff::FindChip(UInt_t &key, Int_t layer,  Float_t* vtx, 
+Bool_t AliITSTrackleterSPDEff::FindChip(UInt_t &key, Int_t layer,const  Float_t* vtx, 
                                   Float_t thetaVtx, Float_t phiVtx, Float_t zVtx) {
 //
 // Input: a) layer number in the range [0,1]
@@ -856,7 +864,10 @@ Bool_t AliITSTrackleterSPDEff::FindChip(UInt_t &key, Int_t layer,  Float_t* vtx,
   Double_t zAbs,phiAbs; // those are the polar coordinate, in the Absolute ALICE Reference 
                         // of the intersection of the tracklet with the pixel layer.  
   if (TMath::Abs(zVtx)<100) zAbs=zVtx + vtx[2]; // this is fine only for the cluster, not for the track prediction
-  else zAbs=r/TMath::Tan(thetaVtx) + vtx[2]; // this is the only way to do for the tracklet prediction
+  else {
+    if(TMath::Abs(thetaVtx)<1E-6) return kFALSE;
+    zAbs=r/TMath::Tan(thetaVtx) + vtx[2]; // this is the only way to do for the tracklet prediction
+  }
   AliDebug(1,Form("FindChip: vtx[0] = %f, vtx[1] = %f, vtx[2] = %f",vtx[0],vtx[1],vtx[2]));
   Double_t vtxy[2]={vtx[0],vtx[1]};
   if (vtxy[0]*vtxy[1]+vtxy[1]*vtxy[1]>0) { // this method holds only for displaced vertices 
@@ -1005,7 +1016,7 @@ phi=TMath::ATan2(pP[1],pP[0]);
 return kTRUE;
 }
 //___________________________________________________________
-Bool_t AliITSTrackleterSPDEff::SetAngleRange02Pi(Double_t &angle) {
+Bool_t AliITSTrackleterSPDEff::SetAngleRange02Pi(Double_t &angle) const {
 //
 //  simple method to reduce all angles (in rad)
 //  in range [0,2pi[
@@ -1366,7 +1377,8 @@ void AliITSTrackleterSPDEff::PrintAscii(ostream *os)const{
     //   none.
     *os << fPhiWindowL1 <<" "<< fZetaWindowL1 << " " << fPhiWindowL2 <<" "<< fZetaWindowL2 
         << " " << fOnlyOneTrackletPerC1 << " " << fOnlyOneTrackletPerC2 
-        << " " << fUpdateOncePerEventPlaneEff << " " << fReflectClusterAroundZAxisForLayer0
+        << " " << fUpdateOncePerEventPlaneEff << " " << fMinContVtx 
+        << " " << fReflectClusterAroundZAxisForLayer0
         << " " << fReflectClusterAroundZAxisForLayer1;
     *os << " " << fMC;
     if(!fMC) {AliInfo("Writing only cuts, no MC info"); return;}
@@ -1400,7 +1412,8 @@ void AliITSTrackleterSPDEff::ReadAscii(istream *is){
     Bool_t tmp= fMC;
     *is >> fPhiWindowL1 >> fZetaWindowL1 >> fPhiWindowL2 >> fZetaWindowL2 
         >> fOnlyOneTrackletPerC1 >> fOnlyOneTrackletPerC2  
-        >> fUpdateOncePerEventPlaneEff >> fReflectClusterAroundZAxisForLayer0
+        >> fUpdateOncePerEventPlaneEff >> fMinContVtx 
+        >> fReflectClusterAroundZAxisForLayer0
         >> fReflectClusterAroundZAxisForLayer1;
     //if(!fMC) {AliInfo("Reading only cuts, no MC info available");return;}
     *is >> fMC;
@@ -1474,7 +1487,7 @@ void AliITSTrackleterSPDEff::SavePredictionMC(TString filename) const {
  }
  else {
     TFile* mcfile = TFile::Open(filename, "RECREATE");
-    TH1F* cuts = new TH1F("cuts", "list of cuts", 10, 0, 10); // TH1I containing cuts 
+    TH1F* cuts = new TH1F("cuts", "list of cuts", 11, 0, 11); // TH1I containing cuts 
     cuts->SetBinContent(1,fPhiWindowL1);
     cuts->SetBinContent(2,fZetaWindowL1);
     cuts->SetBinContent(3,fPhiWindowL2);
@@ -1482,9 +1495,10 @@ void AliITSTrackleterSPDEff::SavePredictionMC(TString filename) const {
     cuts->SetBinContent(5,fOnlyOneTrackletPerC1);
     cuts->SetBinContent(6,fOnlyOneTrackletPerC2);
     cuts->SetBinContent(7,fUpdateOncePerEventPlaneEff);
-    cuts->SetBinContent(8,fReflectClusterAroundZAxisForLayer0);
-    cuts->SetBinContent(9,fReflectClusterAroundZAxisForLayer1);
-    cuts->SetBinContent(10,fMC);
+    cuts->SetBinContent(8,fMinContVtx);
+    cuts->SetBinContent(9,fReflectClusterAroundZAxisForLayer0);
+    cuts->SetBinContent(10,fReflectClusterAroundZAxisForLayer1);
+    cuts->SetBinContent(11,fMC);
     cuts->Write();
     delete cuts;
     if(!fMC) {AliInfo("Writing only cuts, no MC info");}
@@ -1573,9 +1587,10 @@ void AliITSTrackleterSPDEff::ReadPredictionMC(TString filename) {
     fOnlyOneTrackletPerC1=(Bool_t)cuts->GetBinContent(5);
     fOnlyOneTrackletPerC2=(Bool_t)cuts->GetBinContent(6);
     fUpdateOncePerEventPlaneEff=(Bool_t)cuts->GetBinContent(7);
-    fReflectClusterAroundZAxisForLayer0=(Bool_t)cuts->GetBinContent(8);
-    fReflectClusterAroundZAxisForLayer1=(Bool_t)cuts->GetBinContent(9);
-    fMC=(Bool_t)cuts->GetBinContent(10);
+    fMinContVtx=(Int_t)cuts->GetBinContent(8);
+    fReflectClusterAroundZAxisForLayer0=(Bool_t)cuts->GetBinContent(9);
+    fReflectClusterAroundZAxisForLayer1=(Bool_t)cuts->GetBinContent(10);
+    fMC=(Bool_t)cuts->GetBinContent(11);
     if(!fMC) {AliInfo("Reading only cuts, no MC info"); if(tmp) SetMC(kFALSE); }
     else { // only if file with MC predictions 
       if(!tmp) {AliInfo("Calling SetMC() to read this file wtih MC info"); SetMC();}
@@ -1841,12 +1856,12 @@ void AliITSTrackleterSPDEff::DeleteHistos() {
 }
 //_______________________________________________________________
 Bool_t AliITSTrackleterSPDEff::IsReconstructableAt(Int_t layer,Int_t iC,Int_t ipart,
-                                                   Float_t* vtx, AliStack *stack, TTree *ref) {
+                                                   const Float_t* vtx, const AliStack *stack, TTree *ref) {
 // This (private) method can be used only for MC events, where both AliStack and the TrackReference
 // are available. 
 // It is used to asses whether a tracklet prediction is reconstructable or not at the other layer
 // Input: 
-//      - Int_t layer (either 0 or 1): layer which you want to chech if the tracklete can be 
+//      - Int_t layer (either 0 or 1): layer which you want to check if the tracklete can be 
 //                                     reconstructed at
 //      - Int_t iC : cluster index used to build the tracklet prediction 
 //                   if layer=0 ==> iC=iC2 ; elseif layer=1 ==> iC=iC1
@@ -1959,7 +1974,7 @@ if(ilayer==1) {
 return;
 }
 //____________________________________________________________________________
-Int_t AliITSTrackleterSPDEff::Clusters2Tracks(AliESDEvent *){
+Int_t AliITSTrackleterSPDEff::Clusters2Tracks(AliESDEvent *esd){
 // This method is used to find the tracklets. 
 // It is called from AliReconstruction
 // The vertex is supposed to be associated to the Tracker (i.e. to this) already
@@ -1967,6 +1982,10 @@ Int_t AliITSTrackleterSPDEff::Clusters2Tracks(AliESDEvent *){
 // In case Monte Carlo is required, the appropriate linking to Stack and TrackRef is attempted 
 //
   Int_t rc=1;
+  // apply cuts on the vertex quality
+  const AliESDVertex *vertex = esd->GetVertex();
+  if(vertex->GetNContributors()<fMinContVtx) return 0;
+  //
   AliRunLoader* runLoader = AliRunLoader::Instance();
   if (!runLoader) {
     Error("Clusters2Tracks", "no run loader found");
@@ -2116,3 +2135,16 @@ AliITSTrackleterSPDEff::SetLightBkgStudyInParallel(Bool_t b) {
     fPlaneEffBkg=0;
   }
 }
+//______________________________________________________________
+void AliITSTrackleterSPDEff::SetReflectClusterAroundZAxisForLayer(Int_t ilayer,Bool_t b){  
+//
+// method to study residual background:
+// Input b= KTRUE --> reflect the clusters 
+//      ilayer (either 0 or 1) --> which SPD layers should be reflected
+//
+    if(b) {AliInfo(Form("All clusters on layer %d will be rotated by 180 deg around z",ilayer));
+           SetLightBkgStudyInParallel(kFALSE);}
+    if(ilayer==0) fReflectClusterAroundZAxisForLayer0=b;                   // a rotation by 180degree around the Z axis  
+    else if(ilayer==1) fReflectClusterAroundZAxisForLayer1=b;              // (x->-x; y->-y) to all RecPoints on a 
+    else AliInfo("Nothing done: input argument (ilayer) either 0 or 1");   // given layer is applied. In such a way 
+  }