e1d15751fa0cf7d58849996b49907eb9816a2d4c
[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   if (checkEvtSelection) {
34     if (mgr->GetTasks()->First() != (TObject*)tender ) {
35       TString firstName(mgr->GetTasks()->First()->GetName());
36       Bool_t isSecond=(mgr->GetTasks()->At(1) == (TObject*)tender);
37       if (! (firstName=="PIDResponseTask" && isSecond )){
38         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!");
39         return NULL;
40       }
41     }
42   }
43   
44   //========= Attach VZERO supply ======
45
46   if (useV0) {
47      AliVZEROTenderSupply *vzeroSupply=new AliVZEROTenderSupply("VZEROtender");
48      vzeroSupply->SetDebug(kFALSE);
49      tender->AddSupply(vzeroSupply);
50   }   
51
52  
53   //========= Attach TPC supply ======
54   if (useTPC) {
55      AliTPCTenderSupply *tpcSupply=new AliTPCTenderSupply("TPCtender");
56      tpcSupply->SetDebugLevel(2);
57      //tpcSupply->SetMip(50.);
58      tender->AddSupply(tpcSupply);
59   }   
60
61   //========= Attach track 1/pt correction supply ======
62   if (usePtFix) {
63      AliTrackFixTenderSupply *trfixSupply=new AliTrackFixTenderSupply("PTInvFix");
64      //trfixSupply->SetDebugLevel(2);
65      tender->AddSupply(trfixSupply);
66   }   
67
68   //========= Attach T0 supply ======
69   if (useT0) {
70     AliT0TenderSupply *t0Tender = new AliT0TenderSupply("T0tender");
71     t0Tender ->SetPass4LHC11aCorrection(kTRUE);
72     tender->AddSupply(t0Tender);
73   }   
74
75   //========= Attach TOF supply ======
76   if (useTOF) {
77     AliTOFTenderSupply *tofTender = new AliTOFTenderSupply("TOFtender");
78     tender->AddSupply(tofTender);
79  }   
80
81   //========= Attach TRD supply ======
82   if (useTRD) {
83     AliTRDTenderSupply *trdSupply=new AliTRDTenderSupply("TRDtender");
84     trdSupply->SetLoadReferencesFromCDB();
85     // Mask Bad chambers
86     trdSupply->AddBadChamber(265);      // low drift
87     trdSupply->AddBadChamber(50);
88     trdSupply->AddBadChamber(524);      // low drift
89     trdSupply->AddBadChamber(32);       // intermediate gain
90     trdSupply->AddBadChamber(15);
91     trdSupply->AddBadChamber(231);      // low gain
92     trdSupply->AddBadChamber(273);      // intermediate gain
93     trdSupply->AddBadChamber(532);
94     trdSupply->AddBadChamber(5);        // low drift
95     trdSupply->AddBadChamber(227);
96     trdSupply->AddBadChamber(287);      // low drift
97     trdSupply->AddBadChamber(212);      // intermediate gain
98     trdSupply->AddBadChamber(228);      // low gain
99     trdSupply->AddBadChamber(52);       // low gain
100     trdSupply->AddBadChamber(169);      // low drift
101     trdSupply->AddBadChamber(236);      // low drift
102
103     trdSupply->SetPIDmethod(AliTRDTenderSupply::k1DLQpid);
104     trdSupply->SetNormalizationFactor(1./7.603);
105     tender->AddSupply(trdSupply);
106   }  
107
108   //========= Attach PID supply ======
109   if (usePID) {
110     tender->AddSupply(new AliPIDTenderSupply("PIDtender"));
111   }  
112
113   //========= Attach Primary Vertex supply ======
114   if (useVTX) {
115     tender->AddSupply(new AliVtxTenderSupply("PriVtxtender"));
116   }  
117
118   //========= Attach EMCAL supply ======
119   if (useEmc) {
120     AliEMCALTenderSupply *emcSupply = new AliEMCALTenderSupply("EmcTender");
121     emcSupply->SetDefaults();
122     tender->AddSupply(emcSupply);
123   }  
124
125   //================================================
126   //              data containers
127   //================================================
128
129     //            define output containers, please use 'username'_'somename'
130   AliAnalysisDataContainer *coutput1 =
131       mgr->CreateContainer("tender_event", AliESDEvent::Class(),
132                            AliAnalysisManager::kExchangeContainer,"default_tender");
133  
134   //           connect containers
135   mgr->ConnectInput  (tender,  0, mgr->GetCommonInputContainer() );
136   mgr->ConnectOutput (tender,  1, coutput1);
137  
138   return tender;
139 }