8011fdf4f5f44bb65f307e0b98e08733b0e98558
[u/mrichter/AliRoot.git] / ANALYSIS / TenderSupplies / AddTaskTender.C
1 AliAnalysisTask *AddTaskTender(Bool_t useV0=kFALSE, 
2                                Bool_t useTPC=kTRUE,
3                                Bool_t useTOF=kTRUE,
4                                Bool_t useTRD=kTRUE,
5                                Bool_t usePID=kTRUE,
6                                Bool_t useVTX=kTRUE,
7                                Bool_t useT0=kTRUE,
8                                Bool_t useEmc=kFALSE)
9 {
10   if (!(useV0 | useTPC | useTOF | useTRD | usePID | useVTX | useEmc)) {
11      ::Error("AddTaskTender", "No supply added to tender, so tender not created");
12      return 0;
13   }   
14   //get the current analysis manager
15   Bool_t checkEvtSelection = useV0;
16   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
17   if (!mgr) {
18     ::Error("AddTaskTender", "No analysis manager found.");
19     return 0;
20   }
21   // currently don't accept AOD input
22   if (!mgr->GetInputEventHandler()->InheritsFrom(AliESDInputHandler::Class())) {
23     ::Error("AddTask_tender_Tender","The analysis tender only works with ESD input!");
24     return 0;
25   }
26   
27   //========= Add tender to the ANALYSIS manager and set default storage =====
28   AliTender *tender=new AliTender("AnalysisTender");
29   tender->SetCheckEventSelection(checkEvtSelection);
30   tender->SetDefaultCDBStorage("raw://");
31   mgr->AddTask(tender);
32   if (checkEvtSelection) {
33     if (mgr->GetTasks()->First() != (TObject*)tender ) {
34       TString firstName(mgr->GetTasks()->First()->GetName());
35       Bool_t isSecond=(mgr->GetTasks()->At(1) == (TObject*)tender);
36       if (! (firstName=="PIDResponseTask" && isSecond )){
37         Fatal("AddTaskTender","When setting the tender to check the event selection, it has to be the first wagon, or the first after the PID Response!");
38         return NULL;
39       }
40     }
41   }
42   
43   //========= Attach VZERO supply ======
44
45   if (useV0) {
46      AliVZEROTenderSupply *vzeroSupply=new AliVZEROTenderSupply("VZEROtender");
47      vzeroSupply->SetDebug(kFALSE);
48      tender->AddSupply(vzeroSupply);
49   }   
50
51  
52   //========= Attach TPC supply ======
53   if (useTPC) {
54      AliTPCTenderSupply *tpcSupply=new AliTPCTenderSupply("TPCtender");
55      tpcSupply->SetDebugLevel(2);
56      //tpcSupply->SetMip(50.);
57      tender->AddSupply(tpcSupply);
58   }   
59
60   //========= Attach T0 supply ======
61   if (useT0) {
62     AliT0TenderSupply *t0Tender = new AliT0TenderSupply("T0tender");
63     t0Tender ->SetPass4LHC11aCorrection(kTRUE);
64     tender->AddSupply(t0Tender);
65   }   
66
67   //========= Attach TOF supply ======
68   if (useTOF) {
69     AliTOFTenderSupply *tofTender = new AliTOFTenderSupply("TOFtender");
70     tender->AddSupply(tofTender);
71  }   
72
73   //========= Attach TRD supply ======
74   if (useTRD) {
75     AliTRDTenderSupply *trdSupply=new AliTRDTenderSupply("TRDtender");
76     trdSupply->SetLoadReferencesFromCDB();
77     // Mask Bad chambers
78     trdSupply->AddBadChamber(265);      // low drift
79     trdSupply->AddBadChamber(50);
80     trdSupply->AddBadChamber(524);      // low drift
81     trdSupply->AddBadChamber(32);       // intermediate gain
82     trdSupply->AddBadChamber(15);
83     trdSupply->AddBadChamber(231);      // low gain
84     trdSupply->AddBadChamber(273);      // intermediate gain
85     trdSupply->AddBadChamber(532);
86     trdSupply->AddBadChamber(5);        // low drift
87     trdSupply->AddBadChamber(227);
88     trdSupply->AddBadChamber(287);      // low drift
89     trdSupply->AddBadChamber(212);      // intermediate gain
90     trdSupply->AddBadChamber(228);      // low gain
91     trdSupply->AddBadChamber(52);       // low gain
92     trdSupply->AddBadChamber(169);      // low drift
93     trdSupply->AddBadChamber(236);      // low drift
94
95     trdSupply->SetPIDmethod(AliTRDTenderSupply::k1DLQpid);
96     trdSupply->SetNormalizationFactor(1./7.603);
97     tender->AddSupply(trdSupply);
98   }  
99
100   //========= Attach PID supply ======
101   if (usePID) {
102     tender->AddSupply(new AliPIDTenderSupply("PIDtender"));
103   }  
104
105   //========= Attach Primary Vertex supply ======
106   if (useVTX) {
107     tender->AddSupply(new AliVtxTenderSupply("PriVtxtender"));
108   }  
109
110   //========= Attach EMCAL supply ======
111   if (useEmc) {
112     AliEMCALTenderSupply *emcSupply = new AliEMCALTenderSupply("EmcTender");
113     emcSupply->SetDefaults();
114     tender->AddSupply(emcSupply);
115   }  
116
117   //================================================
118   //              data containers
119   //================================================
120
121     //            define output containers, please use 'username'_'somename'
122   AliAnalysisDataContainer *coutput1 =
123       mgr->CreateContainer("tender_event", AliESDEvent::Class(),
124                            AliAnalysisManager::kExchangeContainer,"default_tender");
125  
126   //           connect containers
127   mgr->ConnectInput  (tender,  0, mgr->GetCommonInputContainer() );
128   mgr->ConnectOutput (tender,  1, coutput1);
129  
130   return tender;
131 }