Added the new D0 cuts (cosThetaPointingXY and NormDecayLengthXY) (Davide, Chiara)
authordainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 7 Jun 2011 11:42:22 +0000 (11:42 +0000)
committerdainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 7 Jun 2011 11:42:22 +0000 (11:42 +0000)
PWG3/vertexingHF/AliRDHFCutsD0toKpi.cxx
PWG3/vertexingHF/ConfigVertexingHF.C
PWG3/vertexingHF/ConfigVertexingHF_highmult.C
PWG3/vertexingHF/macros/makeTFile4CutsD0toKpi.C

index 0f2a3d3..01ea6c2 100644 (file)
@@ -40,7 +40,7 @@ ClassImp(AliRDHFCutsD0toKpi)
 //--------------------------------------------------------------------------
 AliRDHFCutsD0toKpi::AliRDHFCutsD0toKpi(const char* name) : 
 AliRDHFCuts(name),
-fUseSpecialCuts(kFALSE),
+fUseSpecialCuts(kTRUE),
 fLowPt(kTRUE),
 fDefaultPID(kFALSE),
 fUseKF(kFALSE)
@@ -48,36 +48,42 @@ fUseKF(kFALSE)
   //
   // Default Constructor
   //
-  Int_t nvars=9;
+  Int_t nvars=11;
   SetNVars(nvars);
-  TString varNames[9]={"inv. mass [GeV]",   
-                      "dca [cm]",
-                      "cosThetaStar", 
-                      "pTK [GeV/c]",
-                      "pTPi [GeV/c]",
-                      "d0K [cm]",
-                      "d0Pi [cm]",
-                      "d0d0 [cm^2]",
-                      "cosThetaPoint"};
-  Bool_t isUpperCut[9]={kTRUE,
-                       kTRUE,
-                       kTRUE,
-                       kFALSE,
-                       kFALSE,
-                       kTRUE,
-                       kTRUE,
-                       kTRUE,
-                       kFALSE};
+  TString varNames[11]={"inv. mass [GeV]",   
+                       "dca [cm]",
+                       "cosThetaStar", 
+                       "pTK [GeV/c]",
+                       "pTPi [GeV/c]",
+                       "d0K [cm]",
+                       "d0Pi [cm]",
+                       "d0d0 [cm^2]",
+                       "cosThetaPoint",
+                       "|cosThetaPointXY|", 
+                       "NormDecayLenghtXY"};
+  Bool_t isUpperCut[11]={kTRUE,
+                        kTRUE,
+                        kTRUE,
+                        kFALSE,
+                        kFALSE,
+                        kTRUE,
+                        kTRUE,
+                        kTRUE,
+                        kFALSE,
+                        kFALSE, 
+                        kFALSE};
   SetVarNames(nvars,varNames,isUpperCut);
-  Bool_t forOpt[9]={kFALSE,
-                   kTRUE,
-                   kTRUE,
-                   kFALSE,
-                   kFALSE,
-                   kFALSE,
-                   kFALSE,
-                   kTRUE,
-                   kTRUE};
+  Bool_t forOpt[11]={kFALSE,
+                    kTRUE,
+                    kTRUE,
+                    kFALSE,
+                    kFALSE,
+                    kFALSE,
+                    kFALSE,
+                    kTRUE,
+                    kTRUE,
+                    kFALSE,
+                    kFALSE};
   SetVarsForOpt(4,forOpt);
   Float_t limits[2]={0,999999999.};
   SetPtBins(2,limits);
@@ -192,6 +198,16 @@ void AliRDHFCutsD0toKpi::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int
     vars[iter]=dd->CosPointingAngle();
   }
   
+  if(fVarsForOpt[9]){
+               iter++;
+               vars[iter]=TMath::Abs(dd->CosPointingAngleXY());
+       }
+  
+   if(fVarsForOpt[10]){
+               iter++;
+          vars[iter]=(dd->NormalizedDecayLengthXY()*(dd->P()/dd->Pt()));
+       }
+       
   return;
 }
 //---------------------------------------------------------------------------
@@ -291,6 +307,12 @@ Int_t AliRDHFCutsD0toKpi::IsSelected(TObject* obj,Int_t selectionLevel,AliAODEve
       if(!okD0 && !okD0bar)   {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
     
       if(d->CosPointingAngle() < fCutsRD[GetGlobalIndex(8,ptbin)])  {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
+
+      
+      if(TMath::Abs(d->CosPointingAngleXY()) < fCutsRD[GetGlobalIndex(9,ptbin)])  {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
+       
+      Double_t normalDecayLengXY=(d->NormalizedDecayLengthXY()*(d->P()/d->Pt()));
+      if (normalDecayLengXY < fCutsRD[GetGlobalIndex(10, ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
       
       if (returnvalueCuts!=0) {
        if (okD0) returnvalueCuts=1; //cuts passed as D0
@@ -1037,8 +1059,7 @@ Int_t AliRDHFCutsD0toKpi::IsSelectedSpecialCuts(AliAODRecoDecayHF *d) const
   }
   if(d->DecayLength2()<decLengthCut*decLengthCut)  return 0; //decLengthCut not passed
   if(d->NormalizedDecayLength2()<normDecLengthCut*normDecLengthCut)  return 0; //decLengthCut not passed
-    
-
+       
   return returnvalue;
 }
 
@@ -1084,8 +1105,8 @@ void AliRDHFCutsD0toKpi::SetUseKF(Bool_t useKF)
                    kFALSE,
                    kTRUE,
                    kTRUE,
-                    kFALSE,
-                    kFALSE};
+                   kFALSE,
+                   kFALSE};
     SetVarsForOpt(4,forOpt);
   }
   return;
@@ -1123,7 +1144,7 @@ void AliRDHFCutsD0toKpi::SetStandardCutsPP2010() {
   
   const Int_t nptbins =13;
   const Double_t ptmax = 9999.;
-  const Int_t nvars=9;
+  const Int_t nvars=11;
   Float_t ptbins[nptbins+1];
   ptbins[0]=0.;
   ptbins[1]=0.5;       
@@ -1143,19 +1164,19 @@ void AliRDHFCutsD0toKpi::SetStandardCutsPP2010() {
   SetGlobalIndex(nvars,nptbins);
   SetPtBins(nptbins+1,ptbins);
   
-  Float_t cutsMatrixD0toKpiStand[nptbins][nvars]={{0.400,300.*1E-4,0.8,0.3,0.3,1000.*1E-4,1000.*1E-4,-35000.*1E-8,0.73},/* pt<0.5*/
-                                                 {0.400,300.*1E-4,0.8,0.3,0.3,1000.*1E-4,1000.*1E-4,-35000.*1E-8,0.73},/* 0.5<pt<1*/
-                                                 {0.400,200.*1E-4,0.8,0.4,0.4,1000.*1E-4,1000.*1E-4,-25000.*1E-8,0.75},/* 1<pt<2 */
-                                                 {0.400,200.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-15000.*1E-8,0.8},/* 2<pt<3 */
-                                                 {0.400,200.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-8000.*1E-8,0.85},/* 3<pt<4 */
-                                                 {0.400,200.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-8000.*1E-8,0.85},/* 4<pt<5 */
-                                                 {0.400,150.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-8000.*1E-8,0.85},/* 5<pt<6 */
-                                                 {0.400,150.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-8000.*1E-8,0.85},/* 6<pt<8 */
-                                                 {0.400,150.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-5000.*1E-8,0.85},/* 8<pt<12 */
-                                                 {0.400,150.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-0.*1E-8,0.85},/* 12<pt<16 */
-                                                 {0.400,150.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,0.*1E-8,0.85},/* 16<pt<20 */
-                                                 {0.400,150.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,0.*1E-8,0.85},/* 20<pt<24 */
-                                                 {0.400,150.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,0.*1E-8,0.85}};/* pt>24 */
+  Float_t cutsMatrixD0toKpiStand[nptbins][nvars]={{0.400,300.*1E-4,0.8,0.3,0.3,1000.*1E-4,1000.*1E-4,-35000.*1E-8,0.73,0.,0.},/* pt<0.5*/
+                                                 {0.400,300.*1E-4,0.8,0.3,0.3,1000.*1E-4,1000.*1E-4,-35000.*1E-8,0.73,0.,0.},/* 0.5<pt<1*/
+                                                 {0.400,200.*1E-4,0.8,0.4,0.4,1000.*1E-4,1000.*1E-4,-25000.*1E-8,0.75,0.,0.},/* 1<pt<2 */
+                                                 {0.400,200.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-15000.*1E-8,0.8,0.,0.},/* 2<pt<3 */
+                                                 {0.400,200.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-8000.*1E-8,0.85,0.,0.},/* 3<pt<4 */
+                                                 {0.400,200.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-8000.*1E-8,0.85,0.,0.},/* 4<pt<5 */
+                                                 {0.400,150.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-8000.*1E-8,0.85,0.,0.},/* 5<pt<6 */
+                                                 {0.400,150.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-8000.*1E-8,0.85,0.,0.},/* 6<pt<8 */
+                                                 {0.400,150.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-5000.*1E-8,0.85,0.,0.},/* 8<pt<12 */
+                                                 {0.400,150.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-0.*1E-8,0.85,0.,0.},/* 12<pt<16 */
+                                                 {0.400,150.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,0.*1E-8,0.85,0.,0.},/* 16<pt<20 */
+                                                 {0.400,150.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,0.*1E-8,0.85,0.,0.},/* 20<pt<24 */
+                                                 {0.400,150.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,0.*1E-8,0.85,0.,0.}};/* pt>24 */
   
   
   //CREATE TRANSPOSE MATRIX...REVERSE INDICES as required by AliRDHFCuts
@@ -1251,7 +1272,7 @@ void AliRDHFCutsD0toKpi::SetStandardCutsPbPb2010() {
   // CANDIDATE CUTS  
   const Int_t nptbins =13;
   const Double_t ptmax = 9999.;
-  const Int_t nvars=9;
+  const Int_t nvars=11;
   Float_t ptbins[nptbins+1];
   ptbins[0]=0.;
   ptbins[1]=0.5;       
@@ -1272,19 +1293,19 @@ void AliRDHFCutsD0toKpi::SetStandardCutsPbPb2010() {
   SetPtBins(nptbins+1,ptbins);
   SetMinPtCandidate(2.);
 
-  Float_t cutsMatrixD0toKpiStand[nptbins][nvars]={{0.400,400.*1E-4,0.8,0.3,0.3,1000.*1E-4,1000.*1E-4,-50000.*1E-8,0.85},/* pt<0.5*/
-                                                 {0.400,400.*1E-4,0.8,0.3,0.3,1000.*1E-4,1000.*1E-4,-50000.*1E-8,0.85},/* 0.5<pt<1*/
-                                                 {0.400,400.*1E-4,0.8,0.4,0.4,1000.*1E-4,1000.*1E-4,-43000.*1E-8,0.85},/* 1<pt<2 */
-                                                 {0.400,250.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-40000.*1E-8,0.95},/* 2<pt<3 */
-                                                 {0.400,250.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-36000.*1E-8,0.95},/* 3<pt<4 */
-                                                 {0.400,250.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-27000.*1E-8,0.95},/* 4<pt<5 */
-                                                 {0.400,250.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-21000.*1E-8,0.92},/* 5<pt<6 */
-                                                 {0.400,270.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-14000.*1E-8,0.88},/* 6<pt<8 */
-                                                 {0.400,300.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-5000.*1E-8,0.85},/* 8<pt<12 */
-                                                 {0.400,350.*1E-4,1.0,0.7,0.7,1000.*1E-4,1000.*1E-4,-1000.*1E-8,0.83},/* 12<pt<16 */
-                                                 {0.400,400.*1E-4,1.0,0.7,0.7,1000.*1E-4,1000.*1E-4,-1000.*1E-8,0.82},/* 16<pt<20 */
-                                                 {0.400,400.*1E-4,1.0,0.7,0.7,1000.*1E-4,1000.*1E-4,-1000.*1E-8,0.81},/* 20<pt<24 */
-                                                 {0.400,400.*1E-4,1.0,0.7,0.7,1000.*1E-4,1000.*1E-4,-1000.*1E-8,0.8}};/* pt>24 */
+  Float_t cutsMatrixD0toKpiStand[nptbins][nvars]={{0.400,400.*1E-4,0.8,0.3,0.3,1000.*1E-4,1000.*1E-4,-50000.*1E-8,0.85,0.,5.},/* pt<0.5*/
+                                                 {0.400,400.*1E-4,0.8,0.3,0.3,1000.*1E-4,1000.*1E-4,-50000.*1E-8,0.85,0.,5.},/* 0.5<pt<1*/
+                                                 {0.400,400.*1E-4,0.8,0.4,0.4,1000.*1E-4,1000.*1E-4,-43000.*1E-8,0.85,0.,5.},/* 1<pt<2 */
+                                                 {0.400,250.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-40000.*1E-8,0.95,0.998,5.},/* 2<pt<3 */
+                                                 {0.400,250.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-36000.*1E-8,0.95,0.998,5.},/* 3<pt<4 */
+                                                 {0.400,250.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-27000.*1E-8,0.95,0.998,5.},/* 4<pt<5 */
+                                                 {0.400,250.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-21000.*1E-8,0.92,0.998,5.},/* 5<pt<6 */
+                                                 {0.400,270.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-14000.*1E-8,0.88,0.998,5.},/* 6<pt<8 */
+                                                 {0.400,300.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-5000.*1E-8,0.85,0.998,5.},/* 8<pt<12 */
+                                                 {0.400,350.*1E-4,1.0,0.7,0.7,1000.*1E-4,1000.*1E-4,-1000.*1E-8,0.83,0.998,5.},/* 12<pt<16 */
+                                                 {0.400,400.*1E-4,1.0,0.7,0.7,1000.*1E-4,1000.*1E-4,-1000.*1E-8,0.82,0.998,5.},/* 16<pt<20 */
+                                                 {0.400,400.*1E-4,1.0,0.7,0.7,1000.*1E-4,1000.*1E-4,-1000.*1E-8,0.81,0.998,5.},/* 20<pt<24 */
+                                                 {0.400,400.*1E-4,1.0,0.7,0.7,1000.*1E-4,1000.*1E-4,-1000.*1E-8,0.8,0.998,5.}};/* pt>24 */
   
   
   //CREATE TRANSPOSE MATRIX...REVERSE INDICES as required by AliRDHFCuts
index 3ccd950..bf32be1 100644 (file)
@@ -42,8 +42,8 @@ AliAnalysisVertexingHF* ConfigVertexingHF() {
   AliRDHFCutsD0toKpi *cutsD0toKpi = new AliRDHFCutsD0toKpi("CutsD0toKpi");
   cutsD0toKpi->SetMaxVtxZ(1.e6);
   cutsD0toKpi->SetTriggerClass("");
-  Float_t cutsArrayD0toKpi[9]={0.3,999999.,1.1,0.,0.,999999.,999999.,999999.,0.};
-  cutsD0toKpi->SetCuts(9,cutsArrayD0toKpi);
+  Float_t cutsArrayD0toKpi[11]={0.3,999999.,1.1,0.,0.,999999.,999999.,999999.,0.,-1,0.};
+  cutsD0toKpi->SetCuts(11,cutsArrayD0toKpi);
   cutsD0toKpi->AddTrackCuts(esdTrackCuts);
   vHF->SetCutsD0toKpi(cutsD0toKpi);
   AliRDHFCutsJpsitoee *cutsJpsitoee = new AliRDHFCutsJpsitoee("CutsJpsitoee");
index 7582b44..6fde864 100644 (file)
@@ -52,9 +52,9 @@ AliAnalysisVertexingHF* ConfigVertexingHF() {
   cutsD0toKpi->SetUsePID(kFALSE);
   cutsD0toKpi->SetMaxVtxZ(1.e6);
   cutsD0toKpi->SetTriggerClass("");
-  Float_t cutsArrayD0toKpi[9]={0.2,999999.,1.1,0.,0.,999999.,999999.,0.,0.5};
+  Float_t cutsArrayD0toKpi[11]={0.2,999999.,1.1,0.,0.,999999.,999999.,0.,0.5,-1,0.};
   cutsD0toKpi->SetPtBins(nptbins,ptlimits);
-  cutsD0toKpi->SetCuts(9,cutsArrayD0toKpi);
+  cutsD0toKpi->SetCuts(11,cutsArrayD0toKpi);
   cutsD0toKpi->AddTrackCuts(esdTrackCuts);
   vHF->SetCutsD0toKpi(cutsD0toKpi);
   AliRDHFCutsJpsitoee *cutsJpsitoee = new AliRDHFCutsJpsitoee("CutsJpsitoee");
index 31f3ca3..579df8d 100644 (file)
@@ -40,7 +40,7 @@ void makeInputAliAnalysisTaskSED0Mass(){
 
   RDHFD0toKpi->AddTrackCuts(esdTrackCuts);
 
-  const Int_t nvars=9;
+  const Int_t nvars=11;
 
   const Int_t nptbins=13;
   Float_t* ptbins;
@@ -80,9 +80,11 @@ void makeInputAliAnalysisTaskSED0Mass(){
     //     printf("    |d0pi| [cm]  < %f\n",fD0toKpiCuts[6]);
     //     printf("    d0d0  [cm^2] < %f\n",fD0toKpiCuts[7]);
     //     printf("    cosThetaPoint    > %f\n",fD0toKpiCuts[8]);
+    //     printf("    |cosThetaPointXY| < %f\n",fD0toKpiCuts[9]);
+    //     printf("    NormDecayLenghtXY    > %f\n",fD0toKpiCuts[10]);
 
 
-  Double_t arrcuts[9]={0.3,0.03,0.8,0.8,0.8,0.1,0.1,-0.0004,0.9};
+  Double_t arrcuts[11]={0.3,0.03,0.8,0.8,0.8,0.1,0.1,-0.0004,0.9,0.998,5.}; //put the last 2 values at 0. for pp
 
   //setting my cut values
   //0-0.5 GeV
@@ -97,6 +99,7 @@ void makeInputAliAnalysisTaskSED0Mass(){
 
   //2-3 GeV
   arrcuts[7]=-0.00026;
+  arrcuts[9]=0.998;
   for(Int_t ic=0;ic<nvars;ic++) rdcutsvalmine[ic][3]=arrcuts[ic];
 
   //3-4 GeV
@@ -174,7 +177,7 @@ void makeInputAliAnalysisTaskSED0Mass(){
   RDHFD0toKpi->SetUseCentrality(AliRDHFCuts::kCentV0M); //kCentOff,kCentV0M,kCentTRK,kCentTKL,kCentCL1,kCentInvalid
 
   //temporary
-  RDHFD0toKpi->SetFixRefs();
+  //RDHFD0toKpi->SetFixRefs();
 
   cout<<"This is the odject I'm going to save:"<<endl;
   RDHFD0toKpi->PrintAll();
@@ -185,7 +188,7 @@ void makeInputAliAnalysisTaskSED0Mass(){
   fout->Close();
 
 }
-
 //macro to make a .root file (for significance maximization) which contains an AliRDHFCutsD0toKpi with loose set of cuts  and TParameter with the tighest value of these cuts
 
 void makeInputAliAnalysisTaskSESignificanceMaximization(){
@@ -209,9 +212,9 @@ void makeInputAliAnalysisTaskSESignificanceMaximization(){
   
   RDHFD0toKpi->AddTrackCuts(esdTrackCuts);
 
-  const Int_t nvars=9;
+  const Int_t nvars=11;
 
-  const Int_t nptbins=13; //change this when adding pt bins!
+  const Int_t nptbins=14; //change this when adding pt bins!
   Float_t ptbins[nptbins+1];
   ptbins[0]=0.;
   ptbins[1]=0.5;
@@ -222,11 +225,12 @@ void makeInputAliAnalysisTaskSESignificanceMaximization(){
   ptbins[6]=5.;
   ptbins[7]=6.;
   ptbins[8]=8.;
-  ptbins[9]=12.;
-  ptbins[10]=16.;
-  ptbins[11]=20.;
-  ptbins[12]=24.;
-  ptbins[13]=9999.;
+  ptbins[9]=10.;
+  ptbins[10]=12.;
+  ptbins[11]=16.;
+  ptbins[12]=20.;
+  ptbins[13]=24.;
+  ptbins[14]=9999.;
 
   RDHFD0toKpi->SetPtBins(nptbins+1,ptbins);
 
@@ -247,21 +251,24 @@ void makeInputAliAnalysisTaskSESignificanceMaximization(){
     //     printf("    |d0pi| [cm]  < %f\n",fD0toKpiCuts[6]);
     //     printf("    d0d0  [cm^2] < %f\n",fD0toKpiCuts[7]);
     //     printf("    cosThetaPoint    > %f\n",fD0toKpiCuts[8]);
-
-
-  Float_t cutsMatrixD0toKpiStand[nptbins][nvars]={{0.3,400.*1E-4,0.8,0.8,0.8,1000.*1E-4,1000.*1E-4,-0.00005,0.7},/* 0<pt<0.5 */
-                                                 {0.3,400.*1E-4,0.8,0.8,0.8,1000.*1E-4,1000.*1E-4,-0.00005,0.7},/* 0.5<pt<1 */
-                                                 {0.3,400.*1E-4,0.8,0.8,0.8,1000.*1E-4,1000.*1E-4,-0.00005,0.7},/* 1<pt<2 */
-                                                 {0.3,400.*1E-4,0.8,0.8,0.8,1000.*1E-4,1000.*1E-4,-0.00005,0.7},/* 2<pt<3 */
-                                                 {0.3,400.*1E-4,0.8,0.8,0.8,1000.*1E-4,1000.*1E-4,0.00005,0.6},/* 3<pt<4 */
-                                                 {0.3,400.*1E-4,0.8,0.8,0.8,1000.*1E-4,1000.*1E-4,0.00005,0.6},/* 4<pt<5 */ 
-                                                 {0.3,400.*1E-4,0.8,0.8,0.8,1000.*1E-4,1000.*1E-4,0.00005,0.6}, /*5<pt<6*/
-                                                 {0.3,400.*1E-4,1.,0.8,0.8,1000.*1E-4,1000.*1E-4,0.00005,0.6}, /*6<pt<8*/
-                                                 {0.3,400.*1E-4,1.,0.8,0.8,1000.*1E-4,1000.*1E-4,0.00005,0.6}, /*8<pt<12*/
-                                                 {0.3,400.*1E-4,1.,0.8,0.8,1000.*1E-4,1000.*1E-4,0.00005,0.6}, /*12<pt<16*/
-                                                 {0.3,400.*1E-4,1.,0.8,0.8,1000.*1E-4,1000.*1E-4,0.00005,0.6}, /*16<pt<20*/
-                                                 {0.3,400.*1E-4,1.,0.8,0.8,1000.*1E-4,1000.*1E-4,0.00005,0.6}, /*20<pt<24*/
-                                                 {0.3,400.*1E-4,1.,0.8,0.8,1000.*1E-4,1000.*1E-4,0.00005,0.6}}; /*pt>24*/
+    //     printf("    |cosThetaPointXY| < %f\n",fD0toKpiCuts[9]);
+    //     printf("    NormDecayLenghtXY    > %f\n",fD0toKpiCuts[10]);
+
+
+    Float_t cutsMatrixD0toKpiStand[nptbins][nvars]={{0.400,400.*1E-4,0.8,0.3,0.3,1000.*1E-4,1000.*1E-4,-40000.*1E-8,0.75,0.,2.},/* pt<0.5*/
+                                                 {0.400,400.*1E-4,0.8,0.3,0.3,1000.*1E-4,1000.*1E-4,-40000.*1E-8,0.75,0.,2.},/* 0.5<pt<1*/
+                                                 {0.400,400.*1E-4,0.8,0.4,0.4,1000.*1E-4,1000.*1E-4,-33000.*1E-8,0.75,0.,2.},/* 1<pt<2 */
+                                                 {0.400,250.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-30000.*1E-8,0.85,0.994,2.},/* 2<pt<3 */
+                                                 {0.400,250.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-26000.*1E-8,0.85,0.994,2.},/* 3<pt<4 */
+                                                 {0.400,250.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-15000.*1E-8,0.85,0.994,2.},/* 4<pt<5 */
+                                                 {0.400,250.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-11000.*1E-8,0.82,0.994,2.},/* 5<pt<6 */
+                                                 {0.400,270.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-10000.*1E-8,0.78,0.994,2.},/* 6<pt<8 */
+                                                 {0.400,300.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-1000.*1E-8,0.7,0.994,2.},/* 8<pt<10 */
+                                                 {0.400,300.*1E-4,0.8,0.7,0.7,1000.*1E-4,1000.*1E-4,-1000.*1E-8,0.7,0.994,2.},/* 10<pt<12 */
+                                                 {0.400,350.*1E-4,1.0,0.7,0.7,1000.*1E-4,1000.*1E-4,-500.*1E-8,0.7,0.994,2.},/* 12<pt<16 */
+                                                 {0.400,400.*1E-4,1.0,0.7,0.7,1000.*1E-4,1000.*1E-4,-500.*1E-8,0.7,0.994,2.},/* 16<pt<20 */
+                                                 {0.400,400.*1E-4,1.0,0.7,0.7,1000.*1E-4,1000.*1E-4,-500.*1E-8,0.7,0.994,2.},/* 20<pt<24 */
+                                                 {0.400,400.*1E-4,1.0,0.7,0.7,1000.*1E-4,1000.*1E-4,-500.*1E-8,0.7,0.994,2.}};/* pt>24 */
 
   //CREATE TRANSPOSE MATRIX...REVERSE INDICES as required by AliRDHFCuts
   Float_t **cutsMatrixTransposeStand=new Float_t*[nvars];
@@ -274,37 +281,32 @@ void makeInputAliAnalysisTaskSESignificanceMaximization(){
   RDHFD0toKpi->SetCuts(nvars,nptbins,cutsMatrixTransposeStand);
 
 
-  Int_t nvarsforopt=RDHFD0toKpi->GetNVarsForOpt();
-  Int_t dim=2; //set this!!
+  Bool_t stdvaropt=kFALSE;
+  Int_t dim=4; //set this!!
   Bool_t *boolforopt;
   boolforopt=new Bool_t[nvars];
-  if(dim>nvarsforopt){
-    cout<<"Number of variables for optimization has probably changed, check and edit accordingly"<<endl;
-    return;
-  } else {
-    if(dim==nvarsforopt){
-      boolforopt=RDHFD0toKpi->GetVarsForOpt();
-    }else{
-      TString *names;
-      names=new TString[nvars];
-      TString answer="";
-      Int_t checktrue=0;
-      names=RDHFD0toKpi->GetVarNames();
-      for(Int_t i=0;i<nvars;i++){
-       cout<<names[i]<<" for opt? (y/n)"<<endl;
-       cin>>answer;
-       if(answer=="y") {
-         boolforopt[i]=kTRUE;
-         checktrue++;
-       }
-       else boolforopt[i]=kFALSE;
-      }
-      if (checktrue!=dim) {
-       cout<<"Error! You set "<<checktrue<<" kTRUE instead of "<<dim<<endl;
-       return;
+  if(stdvaropt){
+    boolforopt=RDHFD0toKpi->GetVarsForOpt();
+  }else{
+    TString *names;
+    names=new TString[nvars];
+    TString answer="";
+    Int_t checktrue=0;
+    names=RDHFD0toKpi->GetVarNames();
+    for(Int_t i=0;i<nvars;i++){
+      cout<<names[i]<<" for opt? (y/n)"<<endl;
+      cin>>answer;
+      if(answer=="y") {
+       boolforopt[i]=kTRUE;
+       checktrue++;
       }
-      RDHFD0toKpi->SetVarsForOpt(dim,boolforopt);
+      else boolforopt[i]=kFALSE;
     }
+    if (checktrue!=dim) {
+      cout<<"Error! You set "<<checktrue<<" kTRUE instead of "<<dim<<endl;
+      return;
+    }
+    RDHFD0toKpi->SetVarsForOpt(dim,boolforopt);
   }
 
 
@@ -313,78 +315,95 @@ void makeInputAliAnalysisTaskSESignificanceMaximization(){
   //costhetastar
   //d0d0 <-this 
   //costhetapoint <-this 
-
+  //cosThetaPointXY <-this 
+  //NormDecayLength <-this 
   
   //number of steps for each variable is set in the AddTask arguments (default=8)
   //set this!!
-  // tighterval[0][0]=0.01;
-  // tighterval[0][0]=100e-4;
-  // tighterval[1][0]=-0.0006;
-  // tighterval[2][0]=1.;
+  //0-0.5
   tighterval[0][0]=-0.00065;
   tighterval[1][0]=1.;
+  tighterval[2][0]=0.4;
+  tighterval[3][0]=6.;
 
-  // tighterval[0][1]=0.01;
-  // tighterval[0][1]=100e-4;
-  // tighterval[1][1]=-0.0007; //try with tighter in this bin
-  // tighterval[2][1]=1.;
+  //0.5-1.
   tighterval[0][1]=-0.00065;
   tighterval[1][1]=1.;
+  tighterval[2][1]=0.4;
+  tighterval[3][1]=6.;
 
- // tighterval[0][2]=0.01;
-  // tighterval[0][2]=100e-4;
-  // tighterval[1][2]=-0.0006;
-  // tighterval[2][2]=1.;
+  //1-2
   tighterval[0][2]=-0.00065;
   tighterval[1][2]=1.;
+  tighterval[2][2]=0.4;
+  tighterval[3][2]=6.;
  
-  // tighterval[0][3]=0.01;
-  // tighterval[0][3]=100e-4;
-  // tighterval[1][3]=-0.0006;
-  // tighterval[2][3]=0.95;
-  tighterval[0][3]=-0.00065;
+  //2-3
+  tighterval[0][3]=-0.0006;
   tighterval[1][3]=1.;
+  tighterval[2][3]=1.;
+  tighterval[3][3]=6.;
 
-  // tighterval[0][4]=0.01;
-  // tighterval[0][4]=100e-4;
-  // tighterval[1][4]=-0.0006;
-  // tighterval[2][4]=0.95;
-  tighterval[0][4]=-0.00027;
+  //3-4
+  tighterval[0][4]=-0.00046;
   tighterval[1][4]=1.;
+  tighterval[2][4]=1.;
+  tighterval[3][4]=6.;
  
-  // tighterval[0][5]=0.01;
-  //  tighterval[0][5]=100e-4;
-  tighterval[0][5]=-0.00027;
+  //4-5
+  tighterval[0][5]=-0.00045;
   tighterval[1][5]=1.;
+  tighterval[2][5]=1.;
+  tighterval[3][5]=6.;
  
-  // tighterval[0][6]=0.01;
-  //  tighterval[0][6]=100e-4;
-  tighterval[0][6]=-0.00027;
+  //5-6
+  tighterval[0][6]=-0.00031;
   tighterval[1][6]=1.;
-
-  // tighterval[0][6]=0.01;
-  //tighterval[0][7]=100e-4;
-  tighterval[0][7]=-0.00027;
-  tighterval[1][7]=1.;
-
-  // tighterval[0][6]=0.01;
-  //tighterval[0][8]=100e-4;
-  tighterval[0][8]=-0.00027;
-  tighterval[1][8]=1.;
-
-  // tighterval[0][6]=0.01;
-  //tighterval[0][9]=100e-4;
-  tighterval[0][9]=-0.00027;
-  tighterval[1][9]=1.;
+  tighterval[2][6]=1.;
+  tighterval[3][6]=6.;
+
+  //6-8
+  tighterval[0][7]=-0.00021;
+  tighterval[1][7]=0.98;
+  tighterval[2][7]=1.;
+  tighterval[3][7]=6.;
+
+  //8-10
+  tighterval[0][8]=-0.0001;
+  tighterval[1][8]=0.98;
+  tighterval[2][8]=1.;
+  tighterval[3][8]=6.;
+
+  //10-12
+  tighterval[0][9]=-0.0001;
+  tighterval[1][9]=0.9;
+  tighterval[2][9]=1.;
+  tighterval[3][9]=6.;
  
-  tighterval[0][10]=-0.00027;
-  tighterval[1][10]=1.;
-
-  tighterval[0][11]=-0.00027;
-  tighterval[1][11]=1.;
+  //12-16
+  tighterval[0][10]=-0.00005;
+  tighterval[1][10]=0.9;
+  tighterval[2][10]=1.;
+  tighterval[3][10]=6.;
+
+  //16-20
+  tighterval[0][11]=-0.00005;
+  tighterval[1][11]=0.9;
+  tighterval[2][11]=1.;
+  tighterval[3][11]=6.;
+
+  //20-24
+  tighterval[0][12]=-0.00005;
+  tighterval[1][12]=0.9;
+  tighterval[2][12]=1.;
+  tighterval[3][12]=6.;
+
+  //>24
+  tighterval[0][13]=-0.00005;
+  tighterval[1][13]=0.9;
+  tighterval[2][13]=1.;
+  tighterval[3][13]=6.;
 
-  tighterval[0][12]=-0.00027;
-  tighterval[1][12]=1.;
 
   TString name=""; 
   Int_t arrdim=dim*nptbins;