]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
wagon for photon isolation spectra analysis with CaloTrackCorr frame
authorgconesab <gustavo.conesa.balbastre@cern.ch>
Fri, 11 Apr 2014 13:28:37 +0000 (15:28 +0200)
committergconesab <gustavo.conesa.balbastre@cern.ch>
Fri, 11 Apr 2014 13:29:16 +0000 (15:29 +0200)
PWGGA/CaloTrackCorrelations/macros/AddTaskIsoPhoton.C [new file with mode: 0644]

diff --git a/PWGGA/CaloTrackCorrelations/macros/AddTaskIsoPhoton.C b/PWGGA/CaloTrackCorrelations/macros/AddTaskIsoPhoton.C
new file mode 100644 (file)
index 0000000..5171936
--- /dev/null
@@ -0,0 +1,740 @@
+// Configuration macro for analysis of isolated photon spectra
+// Author : Gustavo Conesa;  Marie Germain.
+
+TString kAnaIsoPhotonName = "";
+AliAnalysisTaskCaloTrackCorrelation *AddTaskIsoPhoton(const Float_t  cone          = 0.4,
+                                                      const Float_t  pth           = 5.,
+                                                      const Bool_t   timecut       = kFALSE,
+                                                      const TString  calorimeter   = "EMCAL",
+                                                      const Bool_t   simu          = kFALSE,
+                                                      const Bool_t   exotic        = kTRUE,
+                                                      const Bool_t   nonlin        = kFALSE,
+                                                      const TString  trigger       = "EMC7",
+                                                      const Bool_t   tm            = kTRUE,
+                                                      const Int_t    minCen        = -1,
+                                                      const Int_t    maxCen        = -1,
+                                                      const Bool_t   qaan          = kFALSE,
+                                                      const Int_t    debug         = -1,
+                                                      const Bool_t   print         = kFALSE
+                                                      )
+{
+  // Creates a CaloTrackCorr task, configures it and adds it to the analysis manager.
+  
+  printf("AddTaskIsoPhoton() - Settings: cone %2.2f, pth %2.2f, timeCut On %d, calorimeter %s, simu %d, exotic %d, non lin %d, trigger %s, TM %d, qa %d, debug %d, centrality %d-%d\n",
+                                         cone,    pth,    timecut   ,    calorimeter.Data(),simu, exotic,    nonlin,     trigger.Data(), tm,    qaan,   debug, minCen, maxCen );
+  
+  // Get the pointer to the existing analysis manager via the static access method.
+  
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) 
+  {
+    ::Error("AddTask", "No analysis manager to connect to.");
+    return NULL;
+  }  
+  
+  // Check the analysis type using the event handlers connected to the analysis manager.
+  
+  if (!mgr->GetInputEventHandler()) 
+  {
+    ::Error("AddTask", "This task requires an input event handler");
+    return NULL;
+  }
+
+  Bool_t useKinematics = kFALSE;
+  useKinematics = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE;
+
+  // Name for containers
+  
+  kAnaIsoPhotonName = Form("%s_Trig%s_TM%d_R%1.1f_Pt%1.1f",calorimeter.Data(), trigger.Data(),tm,cone,pth);
+
+  if(maxCen>=0) kAnaIsoPhotonName+=Form("Cen%d_%d",minCen,maxCen);
+    
+  printf("<<<< NAME: %s >>>>>\n",kAnaIsoPhotonName.Data());
+  
+  // #### Configure analysis ####
+    
+  AliAnaCaloTrackCorrMaker * maker = new AliAnaCaloTrackCorrMaker();
+  
+  //maker->SetScaleFactor(scaleFactor); // for MC, negative (not scaled) by default
+  
+  // General frame setting and configuration
+  maker->SetReader   (ConfigureReader   (mgr->GetInputEventHandler()->GetDataType(),useKinematics,simu,
+                                         calorimeter,nonlin, timecut,minCen, maxCen, debug,print));
+  maker->SetCaloUtils(ConfigureCaloUtils(nonlin,exotic,simu,timecut,debug,print));
+  
+  // Analysis tasks setting and configuration
+  Int_t n = 0;//Analysis number, order is important
+
+  // Isolation settings
+  Int_t partInCone = AliIsolationCut::kNeutralAndCharged; // kOnlyCharged;
+  //  Int_t thresType  = AliIsolationCut::kPtThresIC;//  AliIsolationCut::kSumPtFracIC ; 
+  Int_t thresType  = AliIsolationCut::kSumPtIC ; 
+  
+  // Photon analysis
+  
+  maker->AddAnalysis(ConfigurePhotonAnalysis(calorimeter,tm,simu,debug,print), n++); // Photon cluster selection
+  
+  // Photon analysis
+  maker->AddAnalysis(ConfigureIsolationAnalysis(calorimeter,"Photon", partInCone,thresType,cone, pth,tm,kFALSE,simu,debug,print), n++); // Photon isolation
+
+  if(qaan)  maker->AddAnalysis(ConfigureQAAnalysis(calorimeter,simu,debug,print),n++);
+  
+  maker->SetAnaDebug(debug)  ;
+  maker->SwitchOnHistogramsMaker()  ;
+  maker->SwitchOnAODsMaker()  ;
+  
+  if(print) maker->Print("");
+  
+  maker->SwitchOffDataControlHistograms();
+  
+  printf("<< End Configuration of %d analysis for calorimeter %s >>\n",n, calorimeter.Data());
+  // Create task
+  
+  AliAnalysisTaskCaloTrackCorrelation * task = new AliAnalysisTaskCaloTrackCorrelation (Form("CaloTrackCorr%s",kAnaIsoPhotonName.Data()));
+  task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
+  task->SetDebugLevel(debug);
+  task->SetBranches("ESD:AliESDRun.,AliESDHeader"); 
+  task->SetAnalysisMaker(maker);
+  mgr->AddTask(task);
+  
+  //Create containers
+  
+  TString outputfile = AliAnalysisManager::GetCommonFileName();
+  
+  AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer(kAnaIsoPhotonName, TList::Class(), 
+                                                             AliAnalysisManager::kOutputContainer, 
+                                                             Form("%s",outputfile.Data()));
+       
+  AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("Param_%s",kAnaIsoPhotonName.Data()), TList::Class(), 
+                                                             AliAnalysisManager::kParamContainer, 
+                                                             "AnalysisParameters.root");
+  
+  // Create ONLY the output containers for the data produced by the task.
+  // Get and connect other common input/output containers via the manager as below
+  //==============================================================================
+  mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
+  // AOD output slot will be used in a different way in future
+  mgr->ConnectOutput (task, 1, cout_pc);
+  mgr->ConnectOutput (task, 2, cout_cuts);
+
+  // Set the trigger selection
+  UInt_t mask =  SetTriggerMaskFromName(trigger);
+  task->SelectCollisionCandidates(mask);
+  
+  return task;
+}
+
+//____________________________________
+AliCaloTrackReader * ConfigureReader(TString inputDataType = "AOD", Bool_t useKinematics = kFALSE, Bool_t simu = kFALSE,
+                                     TString calorimeter = "EMCAL", Bool_t nonlin = kTRUE, Bool_t timecut = kFALSE,
+                                     Float_t minCen = -1, Float_t maxCen = -1,
+                                     Int_t debug = -1, Bool_t print = kFALSE)
+{
+  // Init reader settings: event selection, basic cluster track cuts, etc
+  
+  if(simu)
+  {
+    if (!useKinematics && inputDataType=="AOD") useKinematics = kTRUE; //AOD primary should be available ...
+  }
+  
+  cout<<"********* ACCESS KINE? "<<useKinematics<< endl;
+
+  AliCaloTrackReader * reader = 0;
+  if     (inputDataType=="AOD") reader = new AliCaloTrackAODReader();
+  else if(inputDataType=="ESD") reader = new AliCaloTrackESDReader();
+  else  printf("AliCaloTrackReader::ConfigureReader() - Data not known inputData=%s\n",inputDataType.Data());
+  
+  reader->SetDebug(debug);//10 for lots of messages
+  
+  reader->SwitchOffTriggerPatchMatching();
+  reader->SwitchOffBadTriggerEventsRemoval();
+  
+  reader->SwitchOffWriteDeltaAOD()  ;
+  
+  // MC settings
+  if(useKinematics)
+  {
+    if(inputDataType == "ESD")
+    {
+      reader->SwitchOnStack();          
+      reader->SwitchOffAODMCParticles(); 
+    }
+    else if(inputDataType == "AOD")
+    {
+      reader->SwitchOffStack();          
+      reader->SwitchOnAODMCParticles(); 
+    }
+  }  
+  
+  //------------------------
+  // Detector input filling
+  //------------------------
+  
+  //Min cluster/track E
+  reader->SetEMCALEMin(0.3); 
+  reader->SetEMCALEMax(1000); 
+  reader->SetPHOSEMin(0.3);
+  reader->SetPHOSEMax(1000);
+  reader->SetCTSPtMin(0.2);
+  reader->SetCTSPtMax(1000);
+
+  // Time cuts
+  if(simu)
+  {
+    reader->SwitchOffUseTrackTimeCut();
+    reader->SwitchOffUseParametrizedTimeCut();
+    reader->SwitchOffUseEMCALTimeCut();
+    reader->SetEMCALTimeCut(-1e10,1e10); // Open time cut
+  }
+  else
+  {
+    reader->SwitchOffUseParametrizedTimeCut();
+
+    if(timecut)
+    {
+      printf("Set time cut \n");
+      reader->SwitchOnUseEMCALTimeCut();
+      //Absolute window
+      reader->SetEMCALTimeCut(-30.,30.); // default is -25ns-20ns
+    }
+    else
+    {
+      printf("Off time cuts time cut \n");
+      reader->SwitchOffUseEMCALTimeCut();
+      //Absolute window
+      reader->SetEMCALTimeCut(-1.e6,1.e6);
+    }
+  }
+  
+  reader->SwitchOffFiducialCut();
+  reader->GetFiducialCut()->SetSimpleCTSFiducialCut(0.8, 0, 360) ;
+
+  // Tracks
+  reader->SwitchOnCTS();
+
+  reader->SwitchOffRecalculateVertexBC();
+  reader->SwitchOffVertexBCEventSelection();
+  
+  reader->SwitchOffUseTrackTimeCut();
+  reader->SetTrackTimeCut(0,50);
+  
+  reader->SwitchOffUseTrackDCACut();
+  //reader->SetTrackDCACut(0,0.0105);
+  //reader->SetTrackDCACut(1,0.035);
+  //reader->SetTrackDCACut(2,1.1);
+  
+  if(inputDataType=="ESD")
+  {
+    gROOT->LoadMacro("$ALICE_ROOT/PWGJE/macros/CreateTrackCutsPWGJE.C");
+    //AliESDtrackCuts * esdTrackCuts = CreateTrackCutsPWGJE(10041004);
+    //reader->SetTrackCuts(esdTrackCuts);
+    //reader->SwitchOnConstrainTrackToVertex();
+    
+//    if(kYears>2010)
+    {
+      //Hybrids 2011
+      AliESDtrackCuts * esdTrackCuts  = CreateTrackCutsPWGJE(10001008);
+      reader->SetTrackCuts(esdTrackCuts);
+      AliESDtrackCuts * esdTrackCuts2 = CreateTrackCutsPWGJE(10011008);
+      reader->SetTrackComplementaryCuts(esdTrackCuts2);
+    }
+//    else
+//    {
+//      //Hybrids 2010
+//      AliESDtrackCuts * esdTrackCuts  = CreateTrackCutsPWGJE(10001006);
+//      reader->SetTrackCuts(esdTrackCuts);
+//      AliESDtrackCuts * esdTrackCuts2 = CreateTrackCutsPWGJE(10041006);
+//      reader->SetTrackComplementaryCuts(esdTrackCuts2);
+//    }
+  }
+  else if(inputDataType=="AOD")
+  {
+    //reader->SetTrackFilterMask(128);           // Filter bit, not mask, use if off hybrid
+    reader->SwitchOnAODHybridTrackSelection(); // Check that the AODs have Hybrids!!!!
+    reader->SetTrackStatus(AliVTrack::kITSrefit);
+    //reader->SwitchOnTrackHitSPDSelection();    // Check that the track has at least a hit on the SPD, not much sense to use for hybrid or TPC only tracks
+  }
+  
+  // Calorimeter
+  
+  reader->SwitchOffClusterRecalculation();
+  
+  
+  // CAREFUL
+  if(!nonlin) reader->SwitchOffClusterELinearityCorrection();
+  else        reader->SwitchOnClusterELinearityCorrection();
+  
+  if(calorimeter == "EMCAL") {
+    reader->SwitchOnEMCALCells();
+    reader->SwitchOnEMCAL();
+  }
+  if(calorimeter == "PHOS") { // Should be on if QA is activated with correlation on
+    reader->SwitchOffPHOSCells();
+    reader->SwitchOffPHOS();
+  }
+  
+  //-----------------
+  // Event selection
+  //-----------------
+  
+  //if(!kUseKinematics) reader->SetFiredTriggerClassName("CEMC7EGA-B-NOPF-CENTNOTRD"); // L1 Gamma
+  
+  // reader->RejectFastClusterEvents() ;
+  
+  reader->SwitchOnEventTriggerAtSE();
+  
+  reader->SetZvertexCut(10.);               // Open cut
+  reader->SwitchOnPrimaryVertexSelection(); // and besides primary vertex
+  reader->SwitchOnRejectNoTrackEvents();
+  reader->SwitchOffPileUpEventRejection();   // remove pileup
+  reader->SwitchOffV0ANDSelection() ;        // and besides v0 AND
+
+  if(maxCen > 0 )
+  {
+    // Centrality
+    reader->SetCentralityClass("V0M");
+    reader->SetCentralityOpt(100);  // 10 (c= 0-10, 10-20 ...), 20  (c= 0-5, 5-10 ...) or 100 (c= 1, 2, 3 ..)
+    reader->SetCentralityBin(minCen,maxCen); // Accept all events, if not select range
+    
+    // Event plane (only used in Maker and mixing for AliAnaPi0/AliAnaHadronCorrelation for the moment)
+    reader->SetEventPlaneMethod("V0");
+  }
+  
+  if(print) reader->Print("");
+  
+  return reader;
+    
+}
+
+//_______________________________________
+AliCalorimeterUtils* ConfigureCaloUtils(Bool_t nonlin = kTRUE, Bool_t exotic = kTRUE ,Bool_t simu = kFALSE, Bool_t timecut = kFALSE, Int_t debug = -1, Bool_t print = kFALSE)
+{
+  
+  AliCalorimeterUtils *cu = new AliCalorimeterUtils;
+  cu->SetDebug(debug);
+  
+  // Remove clusters close to borders, at least max energy cell is 1 cell away 
+  cu->SetNumberOfCellsFromEMCALBorder(1);
+  cu->SetNumberOfCellsFromPHOSBorder(2);
+  
+  cu->SwitchOffRecalculateClusterTrackMatching();
+  
+  cu->SwitchOffBadChannelsRemoval() ;
+  
+  //EMCAL settings
+
+  if(simu)
+    cu->SwitchOnLoadOwnEMCALGeometryMatrices();
+  
+  AliEMCALRecoUtils * recou = cu->GetEMCALRecoUtils();
+  
+  cu->SwitchOffRecalibration();
+  cu->SwitchOffRunDepCorrection();
+  
+  gROOT->LoadMacro("$ALICE_ROOT/PWGGA/EMCALTasks/macros/ConfigureEMCALRecoUtils.C");
+  ConfigureEMCALRecoUtils(recou,
+                          simu,
+                          exotic,
+                          nonlin,
+                          kFALSE, // e calib
+                          kFALSE, // bad map
+                          kFALSE); // time calib
+  if(timecut) recou->SetExoticCellDiffTimeCut(50.);
+
+  
+  if( nonlin)
+  { 
+    printf("ConfigureCaloUtils() - Apply non linearity to EMCAL\n");
+    cu->SwitchOnCorrectClusterLinearity();
+  }
+    
+  printf("ConfigureCaloUtils() - EMCAL Recalibration ON? %d %d\n",recou->IsRecalibrationOn(), cu->IsRecalibrationOn());
+  printf("ConfigureCaloUtils() - EMCAL BadMap        ON? %d %d\n",recou->IsBadChannelsRemovalSwitchedOn(), cu->IsBadChannelsRemovalSwitchedOn());
+  
+    
+  // PHOS 
+  cu->SwitchOffLoadOwnPHOSGeometryMatrices();
+    
+  if(print) cu->Print("");
+  
+  return cu;
+  
+}
+
+//_____________________________________
+AliAnaPhoton* ConfigurePhotonAnalysis(TString calorimeter = "EMCAL", Bool_t tm = kFALSE, Bool_t simu = kFALSE, Int_t debug = -1, Bool_t print = kFALSE)
+{
+  
+  AliAnaPhoton *ana = new AliAnaPhoton();
+  ana->SetDebug(debug); //10 for lots of messages
+  
+  // cluster selection cuts
+  
+  ana->SwitchOffFiducialCut();
+
+  ana->SetCalorimeter(calorimeter);
+  
+  if(calorimeter == "PHOS")
+  {
+    ana->SetNCellCut(2);// At least 3 cells
+    ana->SetMinPt(0.3);
+    ana->SetMinDistanceToBadChannel(2, 4, 5);
+    ana->SetTimeCut(-1e10,1e10); // open cut
+  }
+  else 
+  {//EMCAL
+    ana->SetNCellCut(1);// At least 2 cells
+    ana->SetMinEnergy(0.3); // avoid mip peak at E = 260 MeV
+    ana->SetMaxEnergy(1000); 
+    //    ana->SetTimeCut(-1e10,1e10); // open cut, usual time window of [425-825] ns if time recalibration is off 
+    // restrict to less than 100 ns when time calibration is on 
+    ana->SetMinDistanceToBadChannel(2, 4, 6); 
+    
+    // NLM cut, used in all, exclude clusters with more than 2 maxima
+    // Not needed if M02 cut is already strong or clusterizer V2
+    ana->SetNLMCut(1, 2) ;
+  }
+  
+  if(tm)
+  {
+    ana->SwitchOnTrackMatchRejection() ;
+    ana->SwitchOffTMHistoFill() ;
+  }
+  else
+  {
+    ana->SwitchOffTrackMatchRejection() ;
+    ana->SwitchOnTMHistoFill() ;
+  }
+  
+  //PID cuts (shower shape)
+  ana->SwitchOnCaloPID(); // do PID selection, unless specified in GetCaloPID, selection not based on bayesian
+  AliCaloPID* caloPID = ana->GetCaloPID();
+  //Not used in bayesian
+  
+  //EMCAL
+  caloPID->SetEMCALLambda0CutMax(10.);
+  caloPID->SetEMCALLambda0CutMin(0.10);
+  
+  caloPID->SetEMCALDEtaCut(0.025);
+  caloPID->SetEMCALDPhiCut(0.030);
+
+  ana->SwitchOnFillShowerShapeHistograms();  // Filled before photon shower shape selection
+  if(!simu) ana->SwitchOnFillPileUpHistograms();
+
+  // Input / output delta AOD settings
+  
+  ana->SetOutputAODName(Form("Photon%s",kAnaIsoPhotonName.Data()));
+  ana->SetOutputAODClassName("AliAODPWG4ParticleCorrelation");
+  
+  //Set Histograms name tag, bins and ranges
+  
+  ana->AddToHistogramsName(Form("AnaPhoton_TM%d_",tm));
+  SetHistoRangeAndNBins(ana->GetHistogramRanges(), calorimeter); // see method below
+  
+  // Number of particle type MC histograms
+  ana->FillNOriginHistograms(20);
+  ana->FillNPrimaryHistograms(20);
+  
+  ConfigureMC(ana,simu);
+  
+  if(print) ana->Print("");
+  
+  return ana;
+  
+}
+
+//____________________________________________________________________________________________________
+AliAnaParticleIsolation* ConfigureIsolationAnalysis(TString calorimeter = "EMCAL", TString particle="Photon",
+                                                    Int_t  partInCone = AliIsolationCut::kOnlyCharged,
+                                                    Int_t  thresType  = AliIsolationCut::kSumPtFracIC,
+                                                    Float_t cone = 0.3,
+                                                    Float_t pth  = 0.3,
+                                                    Bool_t tm = kFALSE,
+                                                    Bool_t multi = kFALSE, Bool_t simu = kFALSE,
+                                                    Int_t debug = -1, Bool_t print = kFALSE)
+{
+  
+  AliAnaParticleIsolation *ana = new AliAnaParticleIsolation();
+  ana->SetDebug(debug);
+  
+  ana->SwitchOnFiducialCut();
+  //Avoid borders of EMCal
+  if(calorimeter=="EMCAL")
+    ana->GetFiducialCut()->SetSimpleEMCALFiducialCut(0.6, 86, 174) ;
+  
+  ana->SetMinPt(5);
+  
+  // Input / output delta AOD settings
+  
+  ana->SetInputAODName(Form("%s%s",particle.Data(),kAnaIsoPhotonName.Data()));
+  ana->SetAODObjArrayName(Form("IC%s_%s",particle.Data(),kAnaIsoPhotonName.Data())); 
+  
+  ana->SetCalorimeter(calorimeter);
+  
+  if(!tm)  ana->SwitchOnTMHistoFill();
+  else     ana->SwitchOffTMHistoFill();
+  //   ana->SwitchOnTMHistoFill();
+  // ana->SwitchOffSSHistoFill();
+  // if(!kSimulation) ana->SwitchOnFillPileUpHistograms();
+   ana->SwitchOnSSHistoFill();
+  if(!simu) ana->SwitchOnFillPileUpHistograms();
+
+  //Do settings for main isolation cut class
+  AliIsolationCut * ic =  ana->GetIsolationCut();      
+  ic->SetDebug(debug);
+  
+  printf("\t *** Set: R = %2.2f, Threshold %2.2f, Method %d, Neutral/Charged option %d ***\n",cone,pth,thresType,partInCone);
+  
+  ic->SetPtThreshold(pth);
+  ic->SetConeSize(cone);
+  
+  ic->SetPtFraction(0.1);
+  //  ic->SetSumPtThreshold(1.0) ;
+  ic->SetPtThreshold(pth);
+  ic->SetSumPtThreshold(pth);
+  ic->SetParticleTypeInCone(partInCone);
+  ic->SetICMethod(thresType);
+  
+  //Do or not do isolation with previously produced AODs.
+  //No effect if use of SwitchOnSeveralIsolation()
+  ana->SwitchOffReIsolation();
+  
+  //Multiple IC
+  if(multi) 
+  {
+    ic->SetConeSize(1.);    // Take all for first iteration
+    ic->SetPtThreshold(100);// Take all for first iteration
+    ana->SwitchOnSeveralIsolation() ;
+    ana->SetAODObjArrayName(Form("MultiIC%sTM%d",particle.Data(),tm));
+     
+    ana->SetNCones(4);
+    ana->SetNPtThresFrac(4);
+    ana->SetConeSizes(0,0.3);       ana->SetConeSizes(1,0.4);
+    ana->SetConeSizes(2,0.5);       ana->SetConeSizes(3,0.6);
+    ana->SetPtThresholds(0, 0.5);   ana->SetPtThresholds(1, 1);     ana->SetPtThresholds(2, 2);
+    ana->SetPtFractions (0, 0.05) ; ana->SetPtFractions (1, 0.1);   ana->SetPtFractions (2, 0.2) ;  ana->SetPtFractions (3, 0.3) ;
+    ana->SetSumPtThresholds(0, 1) ; ana->SetSumPtThresholds(1, 3) ; ana->SetSumPtThresholds(2, 5);  ana->SetSumPtThresholds(3, 7)  ;
+    
+    ana->SwitchOffTMHistoFill();
+    ana->SwitchOffSSHistoFill();
+  }
+  else      
+    ana->SwitchOffSeveralIsolation() ;
+  
+  AliCaloPID* caloPID = ana->GetCaloPID();
+  caloPID->SetEMCALDEtaCut(0.02);
+  caloPID->SetEMCALDPhiCut(0.030);
+  
+  //Set Histograms name tag, bins and ranges
+  
+  if(!multi)ana->AddToHistogramsName(Form("AnaIsol%s_TM%d_",particle.Data(),tm));
+  else      ana->AddToHistogramsName(Form("AnaMultiIsol%s_TM%d_",particle.Data(),tm));
+
+  SetHistoRangeAndNBins(ana->GetHistogramRanges(),calorimeter); // see method below
+  
+  ana->SetHistoPtInConeRangeAndNBins(0, 50 , 250);
+  ana->SetHistoPtSumRangeAndNBins   (0, 100, 250);
+  
+  if(particle=="Hadron"  || particle.Contains("CTS"))
+  {
+    ana->GetHistogramRanges()->SetHistoPhiRangeAndNBins(0, TMath::TwoPi(), 200) ;
+    ana->GetHistogramRanges()->SetHistoEtaRangeAndNBins(-1.5, 1.5, 300) ;
+  }
+  
+  ConfigureMC(ana,simu);
+  
+  if(print) ic ->Print("");
+  if(print) ana->Print("");
+  
+  return ana;
+  
+}
+
+
+//________________________________________
+AliAnaCalorimeterQA* ConfigureQAAnalysis(TString calorimeter = "EMCAL", Bool_t simu = kFALSE, Int_t debug = -1, Bool_t print = kFALSE)
+{
+  
+  AliAnaCalorimeterQA *ana = new AliAnaCalorimeterQA();
+  ana->SetDebug(debug); //10 for lots of messages
+  ana->SetCalorimeter(calorimeter);
+  
+  ana->SetTimeCut(-1e10,1e10); // Open time cut
+  ana->SwitchOffCorrelation();
+  
+  // Study exotic clusters PHOS and EMCAL
+  ana->SwitchOffStudyBadClusters() ;
+  
+  
+  ana->SwitchOffFiducialCut();
+  ana->SwitchOffFillAllTH3Histogram();
+  ana->SwitchOffFillAllPositionHistogram();
+  ana->SwitchOffFillAllPositionHistogram2();
+  ana->SwitchOffStudyBadClusters();
+  ana->SwitchOffStudyClustersAsymmetry();
+  ana->SwitchOffStudyWeight();
+  ana->SwitchOnFillAllTrackMatchingHistogram();
+  ana->SwitchOnFillAllCellTimeHisto() ;
+
+  if(calorimeter=="EMCAL")
+  {
+    ana->SetNumberOfModules(10);
+  }
+  else 
+  {//PHOS
+    ana->SetNumberOfModules(3); 
+  }
+  
+  ana->AddToHistogramsName("QA_"); //Begining of histograms name
+  SetHistoRangeAndNBins(ana->GetHistogramRanges(),calorimeter); // see method below
+  
+  ConfigureMC(ana,simu);
+  
+  if(print) ana->Print("");
+  
+  return ana;
+  
+}
+
+//________________________________________________________
+void ConfigureMC(AliAnaCaloTrackCorrBaseClass* ana, Bool_t simu = kFALSE)
+{
+  if(simu) ana->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
+  else     ana->SwitchOffDataMC() ;
+
+  //Set here generator name, default pythia
+  //ana->GetMCAnalysisUtils()->SetMCGenerator("");
+}  
+
+//________________________________________________________
+void SetHistoRangeAndNBins (AliHistogramRanges* histoRanges, TString calorimeter = "EMCAL")
+{
+  // Set common bins for all analysis and MC histograms filling
+    
+  histoRanges->SetHistoPtRangeAndNBins(0, 100, 200) ; // Energy and pt histograms
+  
+  if(calorimeter=="EMCAL")
+  {
+    
+    histoRanges->SetHistoPhiRangeAndNBins(78*TMath::DegToRad(), 182*TMath::DegToRad(), 108) ;
+    histoRanges->SetHistoXRangeAndNBins(-600,90,200); // QA
+    histoRanges->SetHistoYRangeAndNBins(100,450,100); // QA
+
+    histoRanges->SetHistoEtaRangeAndNBins(-0.72, 0.72, 144) ;
+  }
+  else
+  {
+    histoRanges->SetHistoPhiRangeAndNBins(260*TMath::DegToRad(), 320*TMath::DegToRad(), 60) ;
+    histoRanges->SetHistoEtaRangeAndNBins(-0.13, 0.13, 130) ;
+  }
+  
+  histoRanges->SetHistoShowerShapeRangeAndNBins(-0.1, 4.9, 500);
+  
+  // Invariant mass histoRangeslysis
+  histoRanges->SetHistoMassRangeAndNBins(0., 1., 200) ;
+  histoRanges->SetHistoAsymmetryRangeAndNBins(0., 1. , 100) ;
+  
+  // check if time calibration is on
+  histoRanges->SetHistoTimeRangeAndNBins(-1000.,1000,1000);
+  histoRanges->SetHistoDiffTimeRangeAndNBins(-200, 200, 800);
+  
+  // track-cluster residuals
+  histoRanges->SetHistoTrackResidualEtaRangeAndNBins(-0.15,0.15,300);
+  histoRanges->SetHistoTrackResidualPhiRangeAndNBins(-0.15,0.15,300);
+  histoRanges->SetHistodRRangeAndNBins(0.,0.15,150);//QA
+
+  // QA, electron, charged
+  histoRanges->SetHistoPOverERangeAndNBins(0,  2.5 ,500);
+  histoRanges->SetHistodEdxRangeAndNBins  (0.,250.0,500);
+  
+  // QA
+  histoRanges->SetHistoFinePtRangeAndNBins(0, 10, 200) ; // bining for fhAmpId
+  histoRanges->SetHistoRatioRangeAndNBins(0.,2.,100);
+  histoRanges->SetHistoVertexDistRangeAndNBins(0.,500.,500);
+  histoRanges->SetHistoNClusterCellRangeAndNBins(0,50,50);
+  histoRanges->SetHistoZRangeAndNBins(-400,400,200);
+  histoRanges->SetHistoRRangeAndNBins(400,450,25);
+  histoRanges->SetHistoV0SignalRangeAndNBins(0,5000,500);
+  histoRanges->SetHistoV0MultiplicityRangeAndNBins(0,5000,500);
+  histoRanges->SetHistoTrackMultiplicityRangeAndNBins(0,5000,500);
+  
+}
+
+//_____________________________
+UInt_t SetTriggerMaskFromName(TString trigger)
+{
+  if(trigger=="EMC7")
+  {
+    printf("CaloTrackCorr trigger EMC7\n");
+    return AliVEvent::kEMC7;
+  }
+  else if (trigger=="INT7")
+  {
+    printf("CaloTrackCorr trigger INT7\n");
+    return AliVEvent::kINT7;
+  }
+  else if(trigger=="EMC1")
+  {
+    printf("CaloTrackCorr trigger EMC1\n");
+    return AliVEvent::kEMC1;
+  }
+  else if(trigger=="MB")
+  {
+    printf("CaloTrackCorr trigger MB\n");
+    return AliVEvent::kMB;
+  }  
+  else if(trigger=="PHOS")
+  {
+    printf("CaloTrackCorr trigger PHOS\n");
+    return AliVEvent::kPHI7;
+  }  
+  else if(trigger=="PHOSPb")
+  {
+    printf("CaloTrackCorr trigger PHOSPb\n");
+    return AliVEvent::kPHOSPb;
+  }
+  else if(trigger=="AnyINT")
+  {
+    printf("CaloTrackCorr trigger AnyINT\n");
+    return AliVEvent::kAnyINT;
+  }  
+  else if(trigger=="INT")
+  {
+    printf("CaloTrackCorr trigger AnyINT\n");
+    return AliVEvent::kAny;
+  }
+  else if(trigger=="EMCEGA")
+  {
+    printf("CaloTrackCorr trigger EMC Gamma\n");
+    return AliVEvent::kEMCEGA;
+  } 
+  else if(trigger=="EMCEJE")
+  {
+    printf("CaloTrackCorr trigger EMC Jet\n");
+    return AliVEvent::kEMCEJE;
+  }
+  else if(trigger=="Central")
+  {
+    printf("CaloTrackCorr trigger Central\n");
+    return (AliVEvent::kCentral  | AliVEvent::kMB);
+  }
+  else if(trigger=="CentralEGA")
+  {
+    printf("CaloTrackCorr trigger Central+EMCEGA\n");
+    return (AliVEvent::kCentral | AliVEvent::kEMCEGA);
+  }
+  else if(trigger=="SemiCentral")
+  {
+    printf("CaloTrackCorr trigger SemiCentral\n");
+    return (AliVEvent::kSemiCentral | AliVEvent::kMB);
+  }
+  else if(trigger=="SemiOrCentral")
+  {
+    printf("CaloTrackCorr trigger SemiCentral Or Central\n");
+    return (AliVEvent::kSemiCentral | AliVEvent::kCentral  | AliVEvent::kMB);
+  }
+}
+