1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
21 #include "AliTender.h"
22 #include "AliTenderSupply.h"
23 #include "AliAnalysisManager.h"
24 #include "AliCDBManager.h"
25 #include "AliESDEvent.h"
26 #include "AliESDInputHandler.h"
32 //______________________________________________________________________________
33 AliTender::AliTender():
48 //______________________________________________________________________________
49 AliTender::AliTender(const char* name):
50 AliAnalysisTaskSE(name),
61 // Default constructor
62 DefineOutput(1, AliESDEvent::Class());
65 //______________________________________________________________________________
66 AliTender::~AliTender()
75 //______________________________________________________________________________
76 void AliTender::AddSupply(AliTenderSupply *supply)
78 // Addition of supplies.
79 if (!fSupplies) fSupplies = new TObjArray();
80 if (fSupplies->FindObject(supply)) {
81 Error("AddSupply", "Tender supply %s already connected.", supply->GetName());
84 fSupplies->Add(supply);
85 supply->SetTender(this);
88 //______________________________________________________________________________
89 void AliTender::ConnectInputData(Option_t* option)
91 // Connect the input data, create CDB manager.
92 if (fDebug > 1) Printf("AliTender::ConnectInputData()\n");
95 AliAnalysisTaskSE::ConnectInputData(option);
96 fESDhandler = dynamic_cast<AliESDInputHandler *>(fInputHandler);
100 fESD = fESDhandler->GetEvent();
102 AliFatal("No ESD input event handler connected") ;
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 Int_t run = AliAnalysisManager::GetAnalysisManager()->GetRunFromPath();
111 fCDBkey = fCDB->SetLock(kFALSE, fCDBkey);
113 AliWarning("AliTaskCDBconnect: Could not set run from path");
117 printf("AliTender: #### Setting run to: %d\n", fRun);
120 TIter next(fSupplies);
121 AliTenderSupply *supply;
122 while ((supply=(AliTenderSupply*)next())) supply->Init();
124 fCDBkey = fCDB->SetLock(kTRUE, fCDBkey);
127 //______________________________________________________________________________
128 void AliTender::UserCreateOutputObjects()
130 // Nothing for the moment, but we may need ESD event replication here.
131 if (fDebug > 1) Printf("AliTender::CreateOutputObjects()\n");
132 fESDhandler = dynamic_cast<AliESDInputHandler *>(fInputHandler);
133 if (fESDhandler && TObject::TestBit(kCheckEventSelection)) {
134 fESDhandler->SetUserCallSelectionMask(kTRUE);
135 Info("UserCreateOutputObjects","The TENDER will check the event selection. Make sure you add the tender as FIRST wagon!");
139 //______________________________________________________________________________
140 void AliTender::UserExec(Option_t* option)
143 // Execute all supplied analysis of one event. Notify run change via RunChanged().
145 Long64_t entry = fESDhandler->GetReadEntry();
146 Printf("AliTender::Exec() %s ==> processing event %lld\n", fESDhandler->GetTree()->GetCurrentFile()->GetName(),entry);
148 fESD = fESDhandler->GetEvent();
150 // Call the user analysis
152 fCDBkey = fCDB->SetLock(kFALSE, fCDBkey);
153 // Intercept when the run number changed
154 if (fRun != fESD->GetRunNumber()) {
156 fRun = fESD->GetRunNumber();
159 TIter next(fSupplies);
160 AliTenderSupply *supply;
161 while ((supply=(AliTenderSupply*)next())) supply->ProcessEvent();
162 fRunChanged = kFALSE;
164 if (TObject::TestBit(kCheckEventSelection)) fESDhandler->CheckSelectionMask();
167 fCDBkey = fCDB->SetLock(kTRUE, fCDBkey);
169 TString opt = option;
170 if (!opt.Contains("NoPost")) PostData(1, fESD);
173 //______________________________________________________________________________
174 void AliTender::SetDefaultCDBStorage(const char *dbString)
176 // Set default CDB storage
177 fDefaultStorage = dbString;