]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/macros/AddTaskCalorimeterQA.C
changed the order of call of endofcycle so that images are produced
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskCalorimeterQA.C
1 AliAnalysisTaskParticleCorrelation *AddTaskCalorimeterQA(TString data, Bool_t kUseKinematics = kFALSE, Bool_t kPrintSettings = kFALSE)
2 {
3   // Creates a PartCorr task for calorimeters performance studies, configures it and adds it to the analysis manager.
4   
5   // Get the pointer to the existing analysis manager via the static access method.
6   //==============================================================================
7   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
8   if (!mgr) {
9     ::Error("AddTaskPartCorr", "No analysis manager to connect to.");
10     return NULL;
11   }  
12   
13   // Check the analysis type using the event handlers connected to the analysis manager.
14   //==============================================================================
15   if (!mgr->GetInputEventHandler()) {
16     ::Error("AddTaskPartCorr", "This task requires an input event handler");
17     return NULL;
18   }
19    TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
20   
21    // Configure analysis
22    //===========================================================================
23   
24   //Reader
25   //For this particular analysis few things done by the reader.
26   //Nothing else needs to be set.
27   AliCaloTrackReader * reader = 0x0;
28   if(data=="AOD")      reader = new AliCaloTrackAODReader();
29   else if(data=="ESD") reader = new AliCaloTrackESDReader();
30   //reader->SetDebug(10);//10 for lots of messages
31    if(kPrintSettings) reader->Print("");
32   
33   if(kUseKinematics){
34                 if(inputDataType == "ESD"){
35                         reader->SwitchOnStack();          
36                         reader->SwitchOffAODMCParticles(); 
37                 }
38                 else if(inputDataType == "AOD"){
39                         reader->SwitchOffStack();          
40                         reader->SwitchOnAODMCParticles(); 
41                 }
42    }
43         
44    reader->SetDeltaAODFileName(""); //Do not create deltaAOD file, this analysis do not create branches.
45
46         
47   // ##### Analysis algorithm settings ####
48
49   AliFidutialCut * fidCut = new AliFidutialCut();
50   fidCut->DoCTSFidutialCut(kFALSE) ;
51   fidCut->DoEMCALFidutialCut(kTRUE) ;
52   fidCut->DoPHOSFidutialCut(kTRUE) ;
53                 
54   AliAnaCalorimeterQA *emcalQA = new AliAnaCalorimeterQA();
55   //emcalQA->SetDebug(2); //10 for lots of messages
56   emcalQA->SetCalorimeter("EMCAL");
57   if(kUseKinematics) emcalQA->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
58   else  emcalQA->SwitchOffDataMC() ;
59   emcalQA->AddToHistogramsName("EMCAL_"); //Begining of histograms name
60   emcalQA->SetFidutialCut(fidCut);
61   emcalQA->SwitchOnFidutialCut();
62   if(kPrintSettings) emcalQA->Print("");        
63   //emcalQA->GetMCAnalysisUtils()->SetDebug(10);
64         
65   AliAnaCalorimeterQA *phosQA = new AliAnaCalorimeterQA();
66   //phosQA->SetDebug(2); //10 for lots of messages
67   phosQA->SetCalorimeter("PHOS");
68   if(kUseKinematics) phosQA->SwitchOnDataMC() ;//Access MC stack and fill more histograms, AOD MC not implemented yet.
69   else  phosQA->SwitchOffDataMC() ;  
70   phosQA->AddToHistogramsName("PHOS_");//Begining of histograms name
71   phosQA->SetFidutialCut(fidCut);
72   phosQA->SwitchOnFidutialCut();
73   if(kPrintSettings)phosQA->Print("");  
74   //phosQA->GetMCAnalysisUtils()->SetDebug(10);
75
76   
77   // #### Configure Maker ####
78   AliAnaPartCorrMaker * maker = new AliAnaPartCorrMaker();
79   maker->SetReader(reader);//pointer to reader
80   maker->AddAnalysis(emcalQA,0);
81   maker->AddAnalysis(phosQA,1);
82   maker->SetAnaDebug(-1)  ;
83   maker->SwitchOnHistogramsMaker()  ;
84   maker->SwitchOnAODsMaker()  ;
85   if(kPrintSettings) maker->Print("");
86   
87   printf("======================== \n");
88   printf(" End Configuration of Calorimeter QA \n");
89   printf("======================== \n");
90   
91    // Create task
92    //===========================================================================
93   AliAnalysisTaskParticleCorrelation * task = new AliAnalysisTaskParticleCorrelation ("CalorimeterPerformance");
94   task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
95   task->SetDebugLevel(0);
96   task->SetAnalysisMaker(maker);                                
97   mgr->AddTask(task);
98   
99   AliAnalysisDataContainer *cout_pc = mgr->CreateContainer("Calo.Performance",TList::Class(),
100                                                            AliAnalysisManager::kOutputContainer, "Calo.Performance.root");
101   
102   // Create ONLY the output containers for the data produced by the task.
103   // Get and connect other common input/output containers via the manager as below
104   //==============================================================================
105   mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
106   // AOD output slot will be used in a different way in future
107   //mgr->ConnectOutput (task, 0, mgr->GetCommonOutputContainer());
108   mgr->ConnectOutput (task, 1, cout_pc);
109   
110   return task;
111 }
112
113