AliPhysics  master (3d17d9d)
AliEmcalTriggerSelection.cxx
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (C) 2017, Copyright Holders of the ALICE Collaboration *
3  * All rights reserved. *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions are met: *
7  * * Redistributions of source code must retain the above copyright *
8  * notice, this list of conditions and the following disclaimer. *
9  * * Redistributions in binary form must reproduce the above copyright *
10  * notice, this list of conditions and the following disclaimer in the *
11  * documentation and/or other materials provided with the distribution. *
12  * * Neither the name of the <organization> nor the *
13  * names of its contributors may be used to endorse or promote products *
14  * derived from this software without specific prior written permission. *
15  * *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND *
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
19  * DISCLAIMED. IN NO EVENT SHALL ALICE COLLABORATION BE LIABLE FOR ANY *
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
26  ************************************************************************************/
27 #include <vector>
28 #include <iostream>
29 #include <TClonesArray.h>
30 
31 #include "AliEMCALTriggerPatchInfo.h"
35 #include "AliLog.h"
36 
40 
41 namespace PWG{
42 namespace EMCAL{
43 
44 AliEmcalTriggerSelection::AliEmcalTriggerSelection() :
45  TNamed(),
46  fSelectionCuts(nullptr),
47  fTriggerAlias(nullptr)
48 {
49 }
50 
52  TNamed(name, ""),
53  fSelectionCuts(cuts),
54  fTriggerAlias(alias)
55 {
56 }
57 
58 AliEmcalTriggerDecision* AliEmcalTriggerSelection::MakeDecison(const TClonesArray * const inputPatches) const {
59  AliDebugStream(1) << "Trigger selection " << GetName() << ": Make decision" << std::endl;
60  AliEmcalTriggerDecision *result = new AliEmcalTriggerDecision(GetName());
61  TIter patchIter(inputPatches);
62  AliEMCALTriggerPatchInfo *patch(NULL);
63  std::vector<AliEMCALTriggerPatchInfo *> selectedPatches;
64  AliDebugStream(1) << "Number of input patches: " << inputPatches->GetEntries() << std::endl;
65  while((patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(patchIter()))){
66  if(fSelectionCuts->IsSelected(patch)){
67  selectedPatches.push_back(patch);
68  }
69  }
70  AliDebugStream(1) << "Number of patches fulfilling the trigger condition: " << selectedPatches.size() << std::endl;
71  // Find the main patch
72  AliEMCALTriggerPatchInfo *mainPatch(NULL), *testpatch(NULL);
73  for(std::vector<AliEMCALTriggerPatchInfo *>::iterator it = selectedPatches.begin(); it != selectedPatches.end(); ++it){
74  testpatch = *it;
75  if(!mainPatch) mainPatch = testpatch;
76  else if(fSelectionCuts->CompareTriggerPatches(testpatch, mainPatch) > 0) mainPatch = testpatch;
77  result->AddAcceptedPatch(testpatch);
78  }
79  if(mainPatch) result->SetMainPatch(mainPatch);
82  return result;
83 }
84 
85 void AliEmcalTriggerSelection::PrintStream(std::ostream &stream) const {
86  stream << " Name of the trigger class: " << GetName() << std::endl;
87  if(fTriggerAlias) stream << fTriggerAlias;
88  stream << *fSelectionCuts << std::endl;
89 }
90 
91 }
92 }
93 
94 std::ostream &operator<<(std::ostream &stream, const PWG::EMCAL::AliEmcalTriggerSelection &sel) {
95  sel.PrintStream(stream);
96  return stream;
97 }
Class for the selection of trigger patches in the EMCAL triggered event selection.
Object performing offline EMCAL trigger selection.
const AliEmcalTriggerSelectionCuts * fSelectionCuts
Cuts used for the trigger patch selection.
Container for trigger decision.
void PrintStream(std::ostream &stream) const
Helper function for the stream operator.
void SetTriggerAlias(const AliEmcalTriggerAlias *alias)
Set trigger alias (names of trigger classes corresponding to the trigger condintion) ...
void SetSelectionCuts(const AliEmcalTriggerSelectionCuts *const cuts)
Set the selection cuts used in the trigger selection.
Namespace for EMCAL framework classes and task.
Bool_t IsSelected(const AliEMCALTriggerPatchInfo *const patch) const
Apply selection of the given trigger patch according to the selections described in the object...
void AddAcceptedPatch(AliEMCALTriggerPatchInfo *const acceptedPatch)
friend std::ostream & operator<<(std::ostream &stream, const AliEmcalTriggerSelection &sel)
Output stream operator.
void SetMainPatch(const AliEMCALTriggerPatchInfo *const mainpatch)
Set the main (highest-energetic) trigger patch.
Namespace for PWG framework classes.
AliEmcalTriggerDecision * MakeDecison(const TClonesArray *const reconstructedPatches) const
Int_t CompareTriggerPatches(const AliEMCALTriggerPatchInfo *first, const AliEMCALTriggerPatchInfo *second) const
Compare two patches according to the energy measure specified in the cut object.
const AliEmcalTriggerAlias * fTriggerAlias
Trigger alias for the trigger selection.
Class for trigger aliases.