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