Next version of the analysis task used for extraction of centrality trigger thr.
[u/mrichter/AliRoot.git] / PWG1 / VZERO / runAnaTrigProof.C
1 // 2010
2 // .x runAnaTrigProof.C(0,"/alice/data","LHC10h_000138396_hlt_clustering",28,kFALSE,"CMBACS2")
3 // 2011
4 // .x runAnaTrigProof.C(0,"/alice/data","LHC11h_000166532_p1_HLT",28,kTRUE,"CPBI")
5
6 void runAnaTrigProof(Int_t mode = 0, const char *folder = "/alice/data",
7                      const char *dataset = "LHC10h_000138396_hlt_clustering",
8                      Int_t workers=28,
9                      Bool_t customOADB = kFALSE,
10                      const char *minBias = "CPBI",
11                      Int_t firstFile = 0, Int_t lastFile = -1)
12 {
13   gSystem->Load("libANALYSIS");
14   gSystem->Load("libANALYSISalice");
15   gSystem->Load("libOADB");
16   gSystem->AddIncludePath("-I$ALICE_ROOT/include ");
17
18   if (mode==0) {
19     // Connect to Proof
20     gEnv->SetValue("XSec.GSI.DelegProxy","2");
21     Char_t *alienuser = gSystem->Getenv("alien_API_USER");
22     cout<<"==> Your AliEn username is: "<<alienuser<<endl;
23
24     TProof *p = TProof::Open(alienuser!=0 ? Form("%s@alice-caf.cern.ch",
25                                                  alienuser) : "alice-caf.cern.ch",
26                              workers>0 ? Form("workers=%d",workers) : "");
27
28     //  gProof->GetManager()->SetROOTVersion("VO_ALICE@ROOT::v5-28-00f");
29     gProof->EnablePackage("VO_ALICE@AliRoot::v5-02-09-AN");
30   }
31
32   // Create the analysis manager
33   AliAnalysisManager *mgr = new AliAnalysisManager("AliAnaFwdDet");
34
35   AliESDInputHandler* esdH = new AliESDInputHandler();
36   esdH->SetInactiveBranches("FMD AliRawDataErrorLogs CaloClusters Cascades EMCALCells EMCALTrigger ESDfriend.fTracks Kinks MuonTracks TrdTracks");
37   //  esdH->SetReadFriends(kTRUE);
38   esdH->SetReadFriends(kFALSE);
39   mgr->SetInputEventHandler(esdH);
40
41   // physics and centrality selection
42   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
43   AliPhysicsSelectionTask *physicsSelectionTask = AddTaskPhysicsSelection(kFALSE);
44   AliOADBTriggerAnalysis * oadbTrigAnalysis = new
45     AliOADBTriggerAnalysis("CustomTA");
46   oadbTrigAnalysis->SetZDCCorrParameters(-0.823, -0.653, 4*0.58, 4*0.5);
47   physicsSelectionTask->GetPhysicsSelection()->SetCustomOADBObjects(0,0,oadbTrigAnalysis);
48   if (customOADB) {
49
50     // OADB default trigger selection from trunk Revision: 52599 taken from the PbPb configuration in the macro: 
51     // BrowseAndFillPhysicsSelectionOADB (as suggested by Michele). To be removed with the new revision.
52   AliOADBPhysicsSelection * oadbDefaultPbPb = new AliOADBPhysicsSelection("oadbDefaultPbPb");
53   
54   Int_t triggerCount = 0;
55   oadbDefaultPbPb->AddCollisionTriggerClass   ( AliVEvent::kMB,"+CPBI1-B-NOPF-ALLNOTRD,CPBI2_B1-B-NOPF-ALLNOTRD,CPBI2_B1-B-PF-ALLNOTRD","B",triggerCount);
56   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kMB,"+CPBI1-AC-NOPF-ALLNOTRD,CPBI2_B1-AC-NOPF-ALLNOTRD","AC",triggerCount);
57   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kMB,"+CPBI1-E-NOPF-ALLNOTRD,CPBI2_B1-E-NOPF-ALLNOTRD","E",triggerCount);
58   oadbDefaultPbPb->SetHardwareTrigger         ( triggerCount,"V0A && V0C");
59   oadbDefaultPbPb->SetOfflineTrigger          ( triggerCount,"V0A && V0C && !V0ABG && !V0CBG && !TPCLaserWarmUp");
60
61   triggerCount++;
62   oadbDefaultPbPb->AddCollisionTriggerClass   ( AliVEvent::kCentral,"+CVHN-B-NOPF-ALLNOTRD,CVHN-B-NOPF-CENTNOTRD,CVHN-B-PF-ALLNOTRD,CVHN-B-PF-CENTNOTRD","B",triggerCount);
63   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kCentral,"+CVHN-AC-NOPF-ALLNOTRD,CVHN-AC-NOPF-CENTNOTRD","AC",triggerCount);
64   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kCentral,"+CVHN-E-NOPF-ALLNOTRD,CVHN-E-NOPF-CENTNOTRD","E",triggerCount);
65   oadbDefaultPbPb->SetHardwareTrigger         ( triggerCount,"V0A && V0C && Central");
66   oadbDefaultPbPb->SetOfflineTrigger          ( triggerCount,"V0A && V0C && !V0ABG && !V0CBG && !TPCLaserWarmUp");
67
68   triggerCount++;
69   // semicentral includes central ones (and might have different downscaling)
70   oadbDefaultPbPb->AddCollisionTriggerClass   ( AliVEvent::kSemiCentral,"+CVHN-B-NOPF-ALLNOTRD,CVHN-B-NOPF-CENTNOTRD,CVHN-B-PF-ALLNOTRD,CVHN-B-PF-CENTNOTRD,CVLN-B-NOPF-ALLNOTRD,CVLN-B-PF-ALLNOTRD","B",triggerCount);
71   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kSemiCentral,"+CVHN-AC-NOPF-ALLNOTRD,CVHN-AC-NOPF-CENTNOTRD,CVLN-AC-NOPF-ALLNOTRD","AC",triggerCount);
72   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kSemiCentral,"+CVHN-E-NOPF-ALLNOTRD,CVHN-E-NOPF-CENTNOTRD,CVLN-E-NOPF-ALLNOTRD","E",triggerCount);
73   oadbDefaultPbPb->SetHardwareTrigger         ( triggerCount,"V0A && V0C && SemiCentral && !Central");
74   oadbDefaultPbPb->SetOfflineTrigger          ( triggerCount,"V0A && V0C && !V0ABG && !V0CBG && !TPCLaserWarmUp");
75
76   triggerCount++;
77   oadbDefaultPbPb->AddCollisionTriggerClass   ( AliVEvent::kEMCEJE,"+CPBI2EJE-B-NOPF-CENTNOTRD","B",triggerCount);
78   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kEMCEJE,"+CPBI2EJE-AC-NOPF-CENTNOTRD","AC",triggerCount);
79   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kEMCEJE,"+CPBI2EJE-E-NOPF-CENTNOTRD","E",triggerCount);
80   oadbDefaultPbPb->SetHardwareTrigger         ( triggerCount,"V0A && V0C");
81   // TODO EMC offline check missing, https://savannah.cern.ch/bugs/index.php?87104
82   oadbDefaultPbPb->SetOfflineTrigger          ( triggerCount,"V0A && V0C && !V0ABG && !V0CBG && !TPCLaserWarmUp");
83   
84   triggerCount++;
85   oadbDefaultPbPb->AddCollisionTriggerClass   ( AliVEvent::kEMCEGA,"+CPBI2EGA-B-NOPF-CENTNOTRD","B",triggerCount);
86   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kEMCEGA,"+CPBI2EGA-AC-NOPF-CENTNOTRD","AC",triggerCount);
87   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kEMCEGA,"+CPBI2EGA-E-NOPF-CENTNOTRD","E",triggerCount);
88   oadbDefaultPbPb->SetHardwareTrigger         ( triggerCount,"V0A && V0C");
89   // TODO EMC offline check missing, https://savannah.cern.ch/bugs/index.php?87104
90   oadbDefaultPbPb->SetOfflineTrigger          ( triggerCount,"V0A && V0C && !V0ABG && !V0CBG && !TPCLaserWarmUp");
91   
92   triggerCount++;
93   oadbDefaultPbPb->AddCollisionTriggerClass   ( AliVEvent::kMUSPB,"+CPBI1MSL-B-NOPF-MUON","B",  triggerCount);
94   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kMUSPB,"+CPBI1MSL-ACE-NOPF-MUON","ACE",triggerCount);
95   oadbDefaultPbPb->SetHardwareTrigger         ( triggerCount,"V0A && V0C");                                         
96   oadbDefaultPbPb->SetOfflineTrigger          ( triggerCount,"V0A && V0C && !V0ABG && !V0CBG && !TPCLaserWarmUp");
97
98   triggerCount++;
99   oadbDefaultPbPb->AddCollisionTriggerClass   ( AliVEvent::kMUSHPB,"+CPBI1MSH-B-NOPF-MUON","B",  triggerCount);
100   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kMUSHPB,"+CPBI1MSH-ACE-NOPF-MUON","ACE",triggerCount);
101   oadbDefaultPbPb->SetHardwareTrigger         ( triggerCount,"V0A && V0C");                                         
102   oadbDefaultPbPb->SetOfflineTrigger          ( triggerCount,"V0A && V0C && !V0ABG && !V0CBG && !TPCLaserWarmUp");
103     
104   triggerCount++;
105   oadbDefaultPbPb->AddCollisionTriggerClass   ( AliVEvent::kMuonUnlikePB,"+CPBI1MUL-B-NOPF-MUON","B",  triggerCount);
106   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kMuonUnlikePB,"+CPBI1MUL-AC-NOPF-MUON","AC",triggerCount);
107   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kMuonUnlikePB,"+CPBI1MUL-E-NOPF-MUON","E",  triggerCount);
108   oadbDefaultPbPb->SetHardwareTrigger         ( triggerCount,"V0A && V0C");                                         
109   oadbDefaultPbPb->SetOfflineTrigger          ( triggerCount,"V0A && V0C && !V0ABG && !V0CBG && !TPCLaserWarmUp");
110
111   triggerCount++;
112   oadbDefaultPbPb->AddCollisionTriggerClass   ( AliVEvent::kMuonLikePB,"+CPBI1MLL-B-NOPF-MUON","B",  triggerCount);
113   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kMuonLikePB,"+CPBI1MLL-AC-NOPF-MUON","AC",triggerCount);
114   oadbDefaultPbPb->AddBGTriggerClass          ( AliVEvent::kMuonLikePB,"+CPBI1MLL-E-NOPF-MUON","E",  triggerCount);
115   oadbDefaultPbPb->SetHardwareTrigger         ( triggerCount,"V0A && V0C");                                         
116   oadbDefaultPbPb->SetOfflineTrigger          ( triggerCount,"V0A && V0C && !V0ABG && !V0CBG && !TPCLaserWarmUp");
117
118   physicsSelectionTask->GetPhysicsSelection()->SetCustomOADBObjects(oadbDefaultPbPb,0,0); 
119   }
120
121   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
122   AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
123
124   // Create task
125   if (mode==0) {
126     gProof->Load(Form("%s/AliAnaVZEROTrigger.cxx++g",
127                       gSystem->pwd()));
128   }
129   else {
130     gROOT->LoadMacro(Form("%s/AliAnaVZEROTrigger.cxx++g",
131                           gSystem->pwd()));
132   }
133   AliAnaVZEROTrigger *task = new AliAnaVZEROTrigger("AliAnaVZEROTrigger");
134   task->SetMBTrigName(minBias);
135   task->Setup("trigger.txt");
136   
137   // Add task
138   mgr->AddTask(task);
139
140   // Create containers for input/output
141   AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
142   AliAnalysisDataContainer *coutput = 
143     mgr->CreateContainer("coutput", TList::Class(), 
144     AliAnalysisManager::kOutputContainer, Form("VZERO.Trigger.%s.root",dataset));
145
146   // Connect input/output
147   mgr->ConnectInput(task, 0, cinput);
148   mgr->ConnectOutput(task, 1, coutput);
149
150
151   // Enable debug printouts
152   mgr->SetDebugLevel(3);
153
154   if (!mgr->InitAnalysis())
155     return;
156
157   mgr->PrintStatus();
158
159   if (mode==0)
160     mgr->StartAnalysis("proof", Form("%s/%s",folder,dataset));
161   else {
162     TGrid::Connect("alien://");
163     TChain *chain = new TChain("esdTree");
164     TGridResult *res = gGrid->Query(folder,"AliESDs.root");
165     Int_t nFiles = res->GetEntries();
166     if (lastFile < 0) lastFile = nFiles - 1;
167     for(Int_t iFile = firstFile; iFile <= lastFile; ++iFile) {
168       TString filename = res->GetKey(iFile, "turl");
169       if(filename == "") continue;
170       chain->AddFile(filename.Data());
171     }
172     mgr->StartAnalysis("local", chain);
173   }
174 }
175