AliPhysics  ff07904 (ff07904)
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(NULL)
47 {
48 }
49 
51  TNamed(name, ""),
52  fSelectionCuts(cuts)
53 {
54 }
55 
56 AliEmcalTriggerDecision* AliEmcalTriggerSelection::MakeDecison(const TClonesArray * const inputPatches) const {
57  AliDebugStream(1) << "Trigger selection " << GetName() << ": Make decision" << std::endl;
58  AliEmcalTriggerDecision *result = new AliEmcalTriggerDecision(GetName());
59  TIter patchIter(inputPatches);
60  AliEMCALTriggerPatchInfo *patch(NULL);
61  std::vector<AliEMCALTriggerPatchInfo *> selectedPatches;
62  AliDebugStream(1) << "Number of input patches: " << inputPatches->GetEntries() << std::endl;
63  while((patch = dynamic_cast<AliEMCALTriggerPatchInfo *>(patchIter()))){
64  if(fSelectionCuts->IsSelected(patch)){
65  selectedPatches.push_back(patch);
66  }
67  }
68  AliDebugStream(1) << "Number of patches fulfilling the trigger condition: " << selectedPatches.size() << std::endl;
69  // Find the main patch
70  AliEMCALTriggerPatchInfo *mainPatch(NULL), *testpatch(NULL);
71  for(std::vector<AliEMCALTriggerPatchInfo *>::iterator it = selectedPatches.begin(); it != selectedPatches.end(); ++it){
72  testpatch = *it;
73  if(!mainPatch) mainPatch = testpatch;
74  else if(fSelectionCuts->CompareTriggerPatches(testpatch, mainPatch) > 0) mainPatch = testpatch;
75  result->AddAcceptedPatch(testpatch);
76  }
77  if(mainPatch) result->SetMainPatch(mainPatch);
79  return result;
80 }
81 
82 void AliEmcalTriggerSelection::PrintStream(std::ostream &stream) const {
83  stream << " Name of the trigger class: " << GetName() << std::endl;
84  stream << *fSelectionCuts << std::endl;
85 }
86 
87 }
88 }
89 
90 std::ostream &operator<<(std::ostream &stream, const PWG::EMCAL::AliEmcalTriggerSelection &sel) {
91  sel.PrintStream(stream);
92  return stream;
93 }
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 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.