6 #include <AliAODEvent.h> 7 #include <AliVCaloCells.h> 8 #include <AliAODCaloCells.h> 9 #include <AliESDCaloCells.h> 28 fExternalCellsBranchName(
"emcalCells"),
29 fCreatedCellsBranchName(
"emcalCellsCombined"),
30 fVerifyCombinedCells(true),
31 fInitializedCombinedCells(false),
35 AliDebug(3, Form(
"%s", __PRETTY_FUNCTION__));
58 AliDebug(3, Form(
"%s", __PRETTY_FUNCTION__));
81 AliDebug(3, Form(
"%s", __PRETTY_FUNCTION__));
117 AliDebugStream(2) <<
"Added combined calo cells \"" <<
fCombinedCells->GetName() <<
"\" with " <<
fCombinedCells->GetNumberOfCells() <<
" cells to the input event" << std::endl;
129 AliDebug(3, Form(
"%s", __PRETTY_FUNCTION__));
153 AliFatal(
"Could not retrieve external event!");
158 if (!externalCells) {
159 AliFatal(TString::Format(
"Could not retrieve cells \"%s\" from external event!",
fExternalCellsBranchName.c_str()));
189 Bool_t getCellResult = kFALSE;
191 AliDebugStream(3) <<
"Adding caloCells \"" << inputCells->GetName() <<
"\" of type \"" << inputCells->GetType() <<
"\" with " << inputCells->GetNumberOfCells() <<
" cells to the combined cells" << std::endl;
194 for (
unsigned int i = 0; i < static_cast<unsigned int>(inputCells->GetNumberOfCells()); i++)
196 getCellResult = inputCells->GetCell(i, cellNumber, amplitude, time, mcLabel, eFrac);
197 if (!getCellResult) {
198 AliWarning(TString::Format(
"Could not get cell %i from cell collection %s", i, inputCells->GetName()));
202 cellHighGain = inputCells->GetHighGain(i);
205 fCombinedCells->SetCell(i + indexOffset, cellNumber, amplitude, time, mcLabel, eFrac, cellHighGain);
223 Bool_t getCellResult = kFALSE;
226 Double_t amplitudeCombined, timeCombined, eFracCombined;
227 Int_t mcLabelCombined;
228 Bool_t cellHighGainCombined;
229 Bool_t getCellResultCombined = kFALSE;
231 unsigned int combinedCellsIndex = 0;
232 for (
auto caloCells : inputCaloCells)
234 AliDebugStream(2) <<
"Verifying cells from cell collection " << caloCells->GetName() <<
"\n";
235 for (
unsigned int i = 0; i < static_cast<unsigned int>(caloCells->GetNumberOfCells()); i++)
238 getCellResult = caloCells->GetCell(i, cellNumber, amplitude, time, mcLabel, eFrac);
239 if (!getCellResult) {
240 AliWarning(TString::Format(
"Could not get cell %i from cell collection %s", i, caloCells->GetName()));
243 cellHighGain = caloCells->GetHighGain(i);
245 getCellResultCombined =
fCombinedCells->GetCell(combinedCellsIndex, cellNumberCombined, amplitudeCombined, timeCombined, mcLabelCombined, eFracCombined);
246 if (!getCellResultCombined) {
247 AliWarning(TString::Format(
"Could not get cell %i from combined cell collection %s", combinedCellsIndex,
fCombinedCells->GetName()));
250 cellHighGainCombined =
fCombinedCells->GetHighGain(combinedCellsIndex);
252 if (cellNumberCombined != cellNumber ||
253 amplitudeCombined != amplitude ||
254 timeCombined != time ||
255 mcLabelCombined != mcLabel ||
256 eFracCombined != eFrac ||
257 cellHighGainCombined != cellHighGain)
259 std::stringstream errorMessage;
260 errorMessage << std::boolalpha;
261 errorMessage <<
"Cell mistmatch at index " << i <<
" of cell collection " << caloCells->GetName() <<
", combined cells " << combinedCellsIndex <<
" of combined cell collection " <<
fCombinedCells->GetName() <<
"\n";
262 errorMessage <<
"Input cell: cell number: " << cellNumber <<
", amplitude: " << amplitude <<
", time: " << time <<
", mcLabel: " << mcLabel <<
", eFrac: " << eFrac <<
", cellHighGain: " << cellHighGain <<
"\n";
263 errorMessage <<
"Combined cell: cell number: " << cellNumberCombined <<
", amplitude: " << amplitudeCombined <<
", time: " << timeCombined <<
", mcLabel: " << mcLabelCombined <<
", eFrac: " << eFracCombined <<
", cellHighGain: " << cellHighGainCombined <<
"\n";
264 AliFatal(errorMessage.str().c_str());
267 combinedCellsIndex++;
271 AliDebugStream(1) <<
"Input cells were successfully combined into the combined cells.\n";
282 if (!(event->FindListObject(obj->GetName()))) {
283 event->AddObject(obj);
287 AliFatal(Form(
"Container with name %s already present. Aborting", obj->GetName()));
Bool_t fEsdMode
flag for ESD
static RegisterCorrectionComponent< AliEmcalCorrectionCellCombineCollections > reg
void AddCellsToCombinedCellObject(AliVCaloCells *inputCells, int indexOffset)
std::string fCreatedCellsBranchName
Name of the cell branch which will be created for the combined cells.
Declaration of class AliAnalysisTaskEmcalEmbeddingHelper.
virtual void UserCreateOutputObjects()
AliVEvent * GetExternalEvent() const
Retrieve the embedded event from the embedding helper.
AliVEvent * InputEvent() const
virtual ~AliEmcalCorrectionCellCombineCollections()
AliVCaloCells * fCaloCells
! Pointer to CaloCells
void UserCreateOutputObjects()
AliEmcalCorrectionCellCombineCollections()
Combines two cell collections into one collection.
std::string fExternalCellsBranchName
Name of the cell branch which will be copied from the external event for the combined cells...
Base class for correction components in the EMCal correction framework.
Implementation of task to embed external events.
void CreateCombinedCells()
void VerifyCombinedCells(std::vector< AliVCaloCells * > inputCaloCells)
void SetupCombinedCells()
bool fVerifyCombinedCells
True if the task should confirm that the combined cells properly copied the input cells...
void AddObjectToEvent(TObject *obj, AliVEvent *event, Bool_t attempt=kFALSE)
virtual Bool_t Initialize()
AliEmcalCorrectionEventManager fEventManager
Minimal task which inherits from AliAnalysisTaskSE and manages access to the event.
bool fInitializedCombinedCells
! True if the combined cells object has been initialized
static std::string DetermineUseDefaultName(InputObject_t objType)
AliVCaloCells * fCombinedCells
! Cells combined from the input and external events.
bool GetProperty(std::string propertyName, T &property, bool requiredProperty=true, std::string correctionName="")
Retrieve property.
static const AliAnalysisTaskEmcalEmbeddingHelper * GetInstance()