<commit_before>#ifndef LMEECutLib_slehner
#define LMEECutLib_slehner

class LMEECutLib {
    
  
private:
      
    
public:
  
  LMEECutLib() {  
  ::Info("LMEECutLib","CREATE NEW LMEECUTLIB slehner");
    pidFilterCuts = new AliDielectronPID("PIDCuts1","PIDCuts1");
    fUsedVars= new TBits(AliDielectronVarManager::kNMaxValues);
    
  }
  static AliDielectronPID* GetPIDCutsAna();
  AliDielectronCutGroup* GetTrackCuts(int trsel=0, int pidsel=0, Int_t MVACut=0, Bool_t useAODFilterCuts, TString TMVAweight="TMVAClassification_BDTG.weights_094.xml");
  AliDielectronEventCuts* GetEventCuts(Double_t centMin, Double_t centMax);
  void SetEtaCorrection( Int_t det, Bool_t isMC, Int_t corrXdim, Int_t corrYdim, Int_t corrZdim, int sel);
  static AliDielectronPID* pidFilterCuts;
  static TBits *fUsedVars;               // used variables
  TH1 *fPostPIDCntrdCorr;   // post pid correction object for electron sigma centroids in TPC
};

void LMEECutLib::SetEtaCorrection(Int_t det, Bool_t isMC, Int_t corrXdim, Int_t corrYdim, Int_t corrZdim, int sel) {
//For usage with TreeMaker
//For efficiency task postcalibration is set in AddTask_slehner_ElectronEfficiency.C
  TString detstr;
  TString type;
  switch(det) {
    case 1: {detstr="its";break;}
    case 2: {detstr="tpc";break;}
    case 3: {detstr="tof";break;}
    } 
  switch(isMC) {
    case {kTRUE: type="mc";break;}
    case {kFALSE: type="data";break;}
    }
    
  ::Info("LMEECutLib::SetCorrection",(TString("Starting Correction for ")+detstr).Data());
  TString path="alien:///alice/cern.ch/user/s/selehner/recal/";
  TString fName= "recalib_"+type+"_"+detstr+"_nsigmaele.root";
  
  TFile* corrfile;
  corrfile= TFile::Open(fName.Data());
  if(!corrfile){
    gSystem->Exec(TString::Format("alien_cp %s .",path.Data()));
    corrfile = TFile::Open(fName.Data());
    if(!corrfile) ::Error("LMEECutLib::SetEtaCorrection",(TString("Cannot get correction from Alien: ")+path+fName).Data());
    else  ::Info("LMEECutLib::SetEtaCorrection",(TString("Copy correction from Alien: ")+path+fName).Data());
  }    
    
  TH3D* mean = dynamic_cast<TH3D*>(corrfile->Get("sum_mean_correction"));
  TH3D* width= dynamic_cast<TH3D*>(corrfile->Get("sum_width_correction"));
  
  // AliDielectron::SetCentroidCorrFunction
  UInt_t valType[20] = {0};
  valType[0]=corrXdim;     valType[1]=corrYdim;     valType[2]=corrZdim;
  AliDielectronHistos::StoreVariables(mean, valType);
  // clone temporare histogram, otherwise it will not be streamed to file!
  TString key = Form("cntrd%d%d%d",corrXdim,corrYdim,corrZdim);
  fPostPIDCntrdCorr = (TH1*)mean->Clone(key.Data());
  // check for corrections and add their variables to the fill map
  if(fPostPIDCntrdCorr)  {
    printf("POST %s on %s PID CORRECTION added for centroids:  ",detstr.Data(),type.Data());
    switch(fPostPIDCntrdCorr->GetDimension()) {
    case 3: printf(" %s, ",fPostPIDCntrdCorr->GetZaxis()->GetName());
    case 2: printf(" %s, ",fPostPIDCntrdCorr->GetYaxis()->GetName());
    case 1: printf(" %s ",fPostPIDCntrdCorr->GetXaxis()->GetName());
    }
    printf("\n");
    fUsedVars->SetBitNumber(corrXdim, kTRUE);
    fUsedVars->SetBitNumber(corrYdim, kTRUE);
    fUsedVars->SetBitNumber(corrZdim, kTRUE);
  }
  
  if(fPostPIDCntrdCorr)  {   
    switch(det) {
      case 1: {AliDielectronPID::SetCentroidCorrFunctionITS(fPostPIDCntrdCorr); break;}
      case 2: {AliDielectronPID::SetCentroidCorrFunction(fPostPIDCntrdCorr); break;}
      case 3: {AliDielectronPID::SetCentroidCorrFunctionTOF(fPostPIDCntrdCorr); break;}
    } 
  }
  
  
  // AliDielectron::SetWidthCorrFunction
  {
  UInt_t valType[20] = {0};
  valType[0]=corrXdim;     valType[1]=corrYdim;     valType[2]=corrZdim;
  AliDielectronHistos::StoreVariables(width, valType);
  // clone temporare histogram, otherwise it will not be streamed to file!
  TString key = Form("wdth%d%d%d",corrXdim,corrYdim,corrZdim);
  fPostPIDWdthCorr = (TH1*)width->Clone(key.Data());
  // check for corrections and add their variables to the fill map
  if(fPostPIDWdthCorr)  {
    printf("POST %s on %s PID CORRECTION added for widths:  ",detstr.Data(),type.Data());
    switch(fPostPIDWdthCorr->GetDimension()) {
    case 3: {printf(" %s, ",fPostPIDWdthCorr->GetZaxis()->GetName());break;}
    case 2: {printf(" %s, ",fPostPIDWdthCorr->GetYaxis()->GetName());break;}
    case 1: {printf(" %s ",fPostPIDWdthCorr->GetXaxis()->GetName());break;}
    }
    printf("\n");
    fUsedVars->SetBitNumber(corrXdim, kTRUE);
    fUsedVars->SetBitNumber(corrYdim, kTRUE);
    fUsedVars->SetBitNumber(corrZdim, kTRUE);
        }
    }
  
  if(fPostPIDWdthCorr){
    switch(det) {
      case 1: {AliDielectronPID::SetWidthCorrFunctionITS(fPostPIDCntrdCorr); break;}
      case 2: {AliDielectronPID::SetWidthCorrFunction(fPostPIDCntrdCorr); break;}
      case 3: {AliDielectronPID::SetWidthCorrFunctionTOF(fPostPIDCntrdCorr);  break;}
  }
  if(sel==1){
        if(mean)   ::Info("LMEECutLib::SetEtaCorrection","Mean Correction Histo loaded, entries: %f",mean->GetEntries());
        else {
        ::Info("LMEECutLib::SetEtaCorrection","Mean Correction Histo not loaded! entries: %f",mean->GetEntries());
        return 0;
        }
      return *mean;
  }
  else{
        if(width)   ::Info("LMEECutLib::SetEtaCorrection","Width Correction Histo loaded, entries: %f",width->GetEntries());<commit_msg>remove brackets that caused error<commit_after>#ifndef LMEECutLib_slehner
#define LMEECutLib_slehner

class LMEECutLib {
    
  
private:
      
    
public:
  
  LMEECutLib() {  
  ::Info("LMEECutLib","CREATE NEW LMEECUTLIB slehner");
    pidFilterCuts = new AliDielectronPID("PIDCuts1","PIDCuts1");
    fUsedVars= new TBits(AliDielectronVarManager::kNMaxValues);
    
  }
  static AliDielectronPID* GetPIDCutsAna();
  AliDielectronCutGroup* GetTrackCuts(int trsel=0, int pidsel=0, Int_t MVACut=0, Bool_t useAODFilterCuts, TString TMVAweight="TMVAClassification_BDTG.weights_094.xml");
  AliDielectronEventCuts* GetEventCuts(Double_t centMin, Double_t centMax);
  void SetEtaCorrection( Int_t det, Bool_t isMC, Int_t corrXdim, Int_t corrYdim, Int_t corrZdim, int sel);
  static AliDielectronPID* pidFilterCuts;
  static TBits *fUsedVars;               // used variables
  TH1 *fPostPIDCntrdCorr;   // post pid correction object for electron sigma centroids in TPC
};

void LMEECutLib::SetEtaCorrection(Int_t det, Bool_t isMC, Int_t corrXdim, Int_t corrYdim, Int_t corrZdim, int sel) {
//For usage with TreeMaker
//For efficiency task postcalibration is set in AddTask_slehner_ElectronEfficiency.C
  TString detstr;
  TString type;
  switch(det) {
    case 1: detstr="its";break;
    case 2: detstr="tpc";break;
    case 3: detstr="tof";break;
    } 
  switch(isMC) {
    case kTRUE: type="mc";break;
    case kFALSE: type="data";break;
    }
    
  ::Info("LMEECutLib::SetCorrection",(TString("Starting Correction for ")+detstr).Data());
  TString path="alien:///alice/cern.ch/user/s/selehner/recal/";
  TString fName= "recalib_"+type+"_"+detstr+"_nsigmaele.root";
  
  TFile* corrfile;
  corrfile= TFile::Open(fName.Data());
  if(!corrfile){
    gSystem->Exec(TString::Format("alien_cp %s .",path.Data()));
    corrfile = TFile::Open(fName.Data());
    if(!corrfile) ::Error("LMEECutLib::SetEtaCorrection",(TString("Cannot get correction from Alien: ")+path+fName).Data());
    else  ::Info("LMEECutLib::SetEtaCorrection",(TString("Copy correction from Alien: ")+path+fName).Data());
  }    
    
  TH3D* mean = dynamic_cast<TH3D*>(corrfile->Get("sum_mean_correction"));
  TH3D* width= dynamic_cast<TH3D*>(corrfile->Get("sum_width_correction"));
  
  // AliDielectron::SetCentroidCorrFunction
  UInt_t valType[20] = {0};
  valType[0]=corrXdim;     valType[1]=corrYdim;     valType[2]=corrZdim;
  AliDielectronHistos::StoreVariables(mean, valType);
  // clone temporare histogram, otherwise it will not be streamed to file!
  TString key = Form("cntrd%d%d%d",corrXdim,corrYdim,corrZdim);
  fPostPIDCntrdCorr = (TH1*)mean->Clone(key.Data());
  // check for corrections and add their variables to the fill map
  if(fPostPIDCntrdCorr)  {
    printf("POST %s on %s PID CORRECTION added for centroids:  ",detstr.Data(),type.Data());
    switch(fPostPIDCntrdCorr->GetDimension()) {
    case 3: printf(" %s, ",fPostPIDCntrdCorr->GetZaxis()->GetName());
    case 2: printf(" %s, ",fPostPIDCntrdCorr->GetYaxis()->GetName());
    case 1: printf(" %s ",fPostPIDCntrdCorr->GetXaxis()->GetName());
    }
    printf("\n");
    fUsedVars->SetBitNumber(corrXdim, kTRUE);
    fUsedVars->SetBitNumber(corrYdim, kTRUE);
    fUsedVars->SetBitNumber(corrZdim, kTRUE);
  }
  
  if(fPostPIDCntrdCorr)  {   
    switch(det) {
      case 1: AliDielectronPID::SetCentroidCorrFunctionITS(fPostPIDCntrdCorr); break;
      case 2: AliDielectronPID::SetCentroidCorrFunction(fPostPIDCntrdCorr); break;
      case 3: AliDielectronPID::SetCentroidCorrFunctionTOF(fPostPIDCntrdCorr); break;
    } 
  }
  
  
  // AliDielectron::SetWidthCorrFunction
  {
  UInt_t valType[20] = {0};
  valType[0]=corrXdim;     valType[1]=corrYdim;     valType[2]=corrZdim;
  AliDielectronHistos::StoreVariables(width, valType);
  // clone temporare histogram, otherwise it will not be streamed to file!
  TString key = Form("wdth%d%d%d",corrXdim,corrYdim,corrZdim);
  fPostPIDWdthCorr = (TH1*)width->Clone(key.Data());
  // check for corrections and add their variables to the fill map
  if(fPostPIDWdthCorr)  {
    printf("POST %s on %s PID CORRECTION added for widths:  ",detstr.Data(),type.Data());
    switch(fPostPIDWdthCorr->GetDimension()) {
    case 3: printf(" %s, ",fPostPIDWdthCorr->GetZaxis()->GetName());break;
    case 2: printf(" %s, ",fPostPIDWdthCorr->GetYaxis()->GetName());break;
    case 1: printf(" %s ",fPostPIDWdthCorr->GetXaxis()->GetName());break;
    }
    printf("\n");
    fUsedVars->SetBitNumber(corrXdim, kTRUE);
    fUsedVars->SetBitNumber(corrYdim, kTRUE);
    fUsedVars->SetBitNumber(corrZdim, kTRUE);
        }
    }
  
  if(fPostPIDWdthCorr){
    switch(det) {
      case 1: AliDielectronPID::SetWidthCorrFunctionITS(fPostPIDCntrdCorr); break;
      case 2: AliDielectronPID::SetWidthCorrFunction(fPostPIDCntrdCorr); break;
      case 3: AliDielectronPID::SetWidthCorrFunctionTOF(fPostPIDCntrdCorr);  break;
  }
  if(sel==1){
        if(mean)   ::Info("LMEECutLib::SetEtaCorrection","Mean Correction Histo loaded, entries: %f",mean->GetEntries());
        else {
        ::Info("LMEECutLib::SetEtaCorrection","Mean Correction Histo not loaded! entries: %f",mean->GetEntries());
        return 0;
        }
      return *mean;
  }
  else{
        if(width)   ::Info("LMEECutLib::SetEtaCorrection","Width Correction Histo loaded, entries: %f",width->GetEntries());
{'fraction_non_alphanumeric': 0.1446999439147504, 'fraction_numerical': 0.008225836604972891, 'mean_word_length': 4.724451578384163, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2883116', 'n_tokens_mistral': 4187, 'n_tokens_neox': 3998, 'n_words': 707}