- Reshuffling of the particle codes in AliPID. Now the light nuclei are between the
[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                                Bool_t usePtFix=kFALSE)
10 {
11   if (!(useV0 | useTPC | useTOF | useTRD | usePID | useVTX | | useT0 | useEmc | usePtFix)) {
12      ::Error("AddTaskTender", "No supply added to tender, so tender not created");
13      return 0;
14   }   
15   //get the current analysis manager
16   Bool_t checkEvtSelection = useV0;
17   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
18   if (!mgr) {
19     ::Error("AddTaskTender", "No analysis manager found.");
20     return 0;
21   }
22   // currently don't accept AOD input
23   if (!mgr->GetInputEventHandler()->InheritsFrom(AliESDInputHandler::Class())) {
24     ::Error("AddTask_tender_Tender","The analysis tender only works with ESD input!");
25     return 0;
26   }
27   
28   //========= Add tender to the ANALYSIS manager and set default storage =====
29   AliTender *tender=new AliTender("AnalysisTender");
30   tender->SetCheckEventSelection(checkEvtSelection);
31   tender->SetDefaultCDBStorage("raw://");
32   mgr->AddTask(tender);
33   
34   Bool_t cachePID=kFALSE;
35
36   //check that that tender is the first task after the pid response
37   TString firstName(mgr->GetTasks()->First()->GetName());
38   Bool_t isSecond=(mgr->GetTasks()->At(1) == (TObject*)tender);
39
40   if (! (firstName=="PIDResponseTask" && isSecond )){
41     Fatal("AddTaskTender","When using the tender the first task needs to be the PIDResponse and the tender the second task!!!");
42     return NULL;
43   }
44   
45   AliAnalysisTaskPIDResponse *pidResp=(AliAnalysisTaskPIDResponse*)mgr->GetTasks()->First();
46   if (pidResp->GetCachePID()){
47     usePID=kTRUE;
48     pidResp->SetCachePID(kFALSE);
49     cachePID=kTRUE;
50   }
51   
52   //========= Attach VZERO supply ======
53
54   if (useV0) {
55      AliVZEROTenderSupply *vzeroSupply=new AliVZEROTenderSupply("VZEROtender");
56      vzeroSupply->SetDebug(kFALSE);
57      tender->AddSupply(vzeroSupply);
58   }   
59
60  
61   //========= Attach TPC supply ======
62   if (useTPC) {
63      AliTPCTenderSupply *tpcSupply=new AliTPCTenderSupply("TPCtender");
64      tpcSupply->SetDebugLevel(2);
65      //tpcSupply->SetMip(50.);
66      tender->AddSupply(tpcSupply);
67   }   
68
69   //========= Attach track 1/pt correction supply ======
70   if (usePtFix) {
71      AliTrackFixTenderSupply *trfixSupply=new AliTrackFixTenderSupply("PTInvFix");
72      //trfixSupply->SetDebugLevel(2);
73      tender->AddSupply(trfixSupply);
74   }   
75
76   //========= Attach T0 supply ======
77   if (useT0) {
78     AliT0TenderSupply *t0Tender = new AliT0TenderSupply("T0tender");
79     t0Tender ->SetPass4LHC11aCorrection(kTRUE);
80     tender->AddSupply(t0Tender);
81   }   
82
83   //========= Attach TOF supply ======
84   if (useTOF) {
85     AliTOFTenderSupply *tofTender = new AliTOFTenderSupply("TOFtender");
86     tender->AddSupply(tofTender);
87  }   
88
89   //========= Attach TRD supply ======
90   if (useTRD) {
91     AliTRDTenderSupply *trdSupply=new AliTRDTenderSupply("TRDtender");
92     trdSupply->SetLoadReferencesFromCDB();
93     // Mask Bad chambers
94     trdSupply->AddBadChamber(265);      // low drift
95     trdSupply->AddBadChamber(50);
96     trdSupply->AddBadChamber(524);      // low drift
97     trdSupply->AddBadChamber(32);       // intermediate gain
98     trdSupply->AddBadChamber(15);
99     trdSupply->AddBadChamber(231);      // low gain
100     trdSupply->AddBadChamber(273);      // intermediate gain
101     trdSupply->AddBadChamber(532);
102     trdSupply->AddBadChamber(5);        // low drift
103     trdSupply->AddBadChamber(227);
104     trdSupply->AddBadChamber(287);      // low drift
105     trdSupply->AddBadChamber(212);      // intermediate gain
106     trdSupply->AddBadChamber(228);      // low gain
107     trdSupply->AddBadChamber(52);       // low gain
108     trdSupply->AddBadChamber(169);      // low drift
109     trdSupply->AddBadChamber(236);      // low drift
110
111     trdSupply->SetPIDmethod(AliTRDTenderSupply::k1DLQpid);
112     trdSupply->SetNormalizationFactor(1./7.603);
113     tender->AddSupply(trdSupply);
114   }  
115
116   //========= Attach Primary Vertex supply ======
117   if (useVTX) {
118     tender->AddSupply(new AliVtxTenderSupply("PriVtxtender"));
119   }  
120
121   //========= Attach EMCAL supply ======
122   if (useEmc) {
123     AliEMCALTenderSupply *emcSupply = new AliEMCALTenderSupply("EmcTender");
124     emcSupply->SetDefaults();
125     tender->AddSupply(emcSupply);
126   }  
127
128   //========= Attach PID supply ======
129   if (usePID) {
130     AliPIDTenderSupply *pidSupply=new AliPIDTenderSupply("PIDtender");
131     pidSupply->SetCachePID(cachePID);
132     tender->AddSupply(pidSupply);
133   }
134
135   //================================================
136   //              data containers
137   //================================================
138
139     //            define output containers, please use 'username'_'somename'
140   AliAnalysisDataContainer *coutput1 =
141       mgr->CreateContainer("tender_event", AliESDEvent::Class(),
142                            AliAnalysisManager::kExchangeContainer,"default_tender");
143  
144   //           connect containers
145   mgr->ConnectInput  (tender,  0, mgr->GetCommonInputContainer() );
146   mgr->ConnectOutput (tender,  1, coutput1);
147  
148   return tender;
149 }