]>
Commit | Line | Data |
---|---|---|
106c7c4e | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | #include <TChain.h> | |
19 | #include <TFile.h> | |
20 | ||
21 | #include "AliTender.h" | |
22 | #include "AliTenderSupply.h" | |
23 | #include "AliAnalysisManager.h" | |
24 | #include "AliCDBManager.h" | |
25 | #include "AliESDEvent.h" | |
26 | #include "AliESDInputHandler.h" | |
27 | #include "AliLog.h" | |
28 | ||
29 | ||
30 | ClassImp(AliTender) | |
31 | ||
32 | //______________________________________________________________________________ | |
33 | AliTender::AliTender(): | |
102f6f85 | 34 | AliAnalysisTaskSE(), |
106c7c4e | 35 | fRun(0), |
36 | fRunChanged(kFALSE), | |
37 | fCDBkey(0), | |
38 | fDefaultStorage(), | |
39 | fCDB(NULL), | |
40 | fESDhandler(NULL), | |
41 | fESD(NULL), | |
7604d16b | 42 | fSupplies(NULL), |
43 | fCDBSettings(NULL) | |
106c7c4e | 44 | { |
45 | // Dummy constructor | |
46 | } | |
47 | ||
48 | //______________________________________________________________________________ | |
49 | AliTender::AliTender(const char* name): | |
102f6f85 | 50 | AliAnalysisTaskSE(name), |
106c7c4e | 51 | fRun(0), |
52 | fRunChanged(kFALSE), | |
53 | fCDBkey(0), | |
54 | fDefaultStorage(), | |
55 | fCDB(NULL), | |
56 | fESDhandler(NULL), | |
57 | fESD(NULL), | |
7604d16b | 58 | fSupplies(NULL), |
59 | fCDBSettings(NULL) | |
106c7c4e | 60 | { |
61 | // Default constructor | |
102f6f85 | 62 | DefineOutput(1, AliESDEvent::Class()); |
106c7c4e | 63 | } |
64 | ||
65 | //______________________________________________________________________________ | |
66 | AliTender::~AliTender() | |
67 | { | |
68 | // Destructor | |
f91aec70 | 69 | if (fSupplies) { |
70 | fSupplies->Delete(); | |
71 | delete fSupplies; | |
72 | } | |
106c7c4e | 73 | } |
74 | ||
f91aec70 | 75 | //______________________________________________________________________________ |
76 | void AliTender::AddSupply(AliTenderSupply *supply) | |
77 | { | |
78 | // Addition of supplies. | |
79 | if (!fSupplies) fSupplies = new TObjArray(); | |
af71a55f | 80 | if (fSupplies->FindObject(supply)) { |
81 | Error("AddSupply", "Tender supply %s already connected.", supply->GetName()); | |
82 | return; | |
83 | } | |
f91aec70 | 84 | fSupplies->Add(supply); |
af71a55f | 85 | supply->SetTender(this); |
f91aec70 | 86 | } |
87 | ||
106c7c4e | 88 | //______________________________________________________________________________ |
102f6f85 | 89 | void AliTender::ConnectInputData(Option_t* option) |
106c7c4e | 90 | { |
91 | // Connect the input data, create CDB manager. | |
92 | if (fDebug > 1) Printf("AliTender::ConnectInputData()\n"); | |
0e373bac | 93 | |
94 | if (!fESDhandler) { | |
95 | AliAnalysisTaskSE::ConnectInputData(option); | |
96 | fESDhandler = dynamic_cast<AliESDInputHandler *>(fInputHandler); | |
97 | } | |
98 | ||
106c7c4e | 99 | if (fESDhandler) { |
100 | fESD = fESDhandler->GetEvent(); | |
101 | } else { | |
102 | AliFatal("No ESD input event handler connected") ; | |
103 | } | |
104 | // Create CDB manager | |
105 | if (!fDefaultStorage.Length()) AliFatal("Default CDB storage not set."); | |
106 | fCDB = AliCDBManager::Instance(); | |
107 | // SetDefault storage. Specific storages must be set by AliTenderSupply::Init() | |
108 | fCDB->SetDefaultStorage(fDefaultStorage); | |
109 | fRun = fESD->GetRunNumber(); | |
106c7c4e | 110 | // Unlock CDB |
111 | fCDBkey = fCDB->SetLock(kFALSE, fCDBkey); | |
14ac93a1 | 112 | fCDB->SetRun(fRun); |
106c7c4e | 113 | TIter next(fSupplies); |
114 | AliTenderSupply *supply; | |
115 | while ((supply=(AliTenderSupply*)next())) supply->Init(); | |
116 | // Lock CDB | |
117 | fCDBkey = fCDB->SetLock(kTRUE, fCDBkey); | |
118 | } | |
119 | ||
120 | //______________________________________________________________________________ | |
102f6f85 | 121 | void AliTender::UserCreateOutputObjects() |
106c7c4e | 122 | { |
123 | // Nothing for the moment, but we may need ESD event replication here. | |
124 | if (fDebug > 1) Printf("AliTender::CreateOutputObjects()\n"); | |
3c4c9c84 | 125 | fESDhandler = dynamic_cast<AliESDInputHandler *>(fInputHandler); |
aaf2d706 | 126 | if (fESDhandler && TObject::TestBit(kCheckEventSelection)) { |
127 | fESDhandler->SetUserCallSelectionMask(kTRUE); | |
128 | Info("UserCreateOutputObjects","The TENDER will check the event selection. Make sure you add the tender as FIRST wagon!"); | |
129 | } | |
106c7c4e | 130 | } |
131 | ||
132 | //______________________________________________________________________________ | |
0e373bac | 133 | void AliTender::UserExec(Option_t* option) |
106c7c4e | 134 | { |
135 | // | |
136 | // Execute all supplied analysis of one event. Notify run change via RunChanged(). | |
137 | if (fDebug > 1) { | |
e8b839ab | 138 | Long64_t entry = fESDhandler->GetReadEntry(); |
106c7c4e | 139 | Printf("AliTender::Exec() %s ==> processing event %lld\n", fESDhandler->GetTree()->GetCurrentFile()->GetName(),entry); |
140 | } | |
141 | fESD = fESDhandler->GetEvent(); | |
142 | ||
143 | // Call the user analysis | |
144 | // Unlock CDB | |
145 | fCDBkey = fCDB->SetLock(kFALSE, fCDBkey); | |
146 | // Intercept when the run number changed | |
147 | if (fRun != fESD->GetRunNumber()) { | |
148 | fRunChanged = kTRUE; | |
149 | fRun = fESD->GetRunNumber(); | |
150 | fCDB->SetRun(fRun); | |
151 | } | |
152 | TIter next(fSupplies); | |
153 | AliTenderSupply *supply; | |
154 | while ((supply=(AliTenderSupply*)next())) supply->ProcessEvent(); | |
155 | fRunChanged = kFALSE; | |
af7afbf3 | 156 | |
157 | if (TObject::TestBit(kCheckEventSelection)) fESDhandler->CheckSelectionMask(); | |
158 | ||
106c7c4e | 159 | // Lock CDB |
160 | fCDBkey = fCDB->SetLock(kTRUE, fCDBkey); | |
0e373bac | 161 | |
162 | TString opt = option; | |
163 | if (!opt.Contains("NoPost")) PostData(1, fESD); | |
106c7c4e | 164 | } |
9aaca412 | 165 | |
166 | //______________________________________________________________________________ | |
167 | void AliTender::SetDefaultCDBStorage(const char *dbString) | |
168 | { | |
169 | // Set default CDB storage | |
170 | fDefaultStorage = dbString; | |
171 | } |