AliPhysics  608b256 (608b256)
AliConversionCutHandler.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 <iostream>
28 #include <TString.h>
30 
32 fValidCuts(true),
33 fNCuts(0),
34 fNMaxCuts(nMax),
35 fEventCutArray(new TString[fNMaxCuts]),
36 fPhotonCutArray(new TString[fNMaxCuts]),
37 fMesonCutArray(new TString[fNMaxCuts]),
38 fClusterCutArray(new TString[fNMaxCuts])
39 {
40  for(Int_t i=0; i<fNMaxCuts; i++) {
41  fEventCutArray[i] = "";
42  fPhotonCutArray[i] = "";
43  fMesonCutArray[i] = "";
44  fClusterCutArray[i] = "";
45  }
46 }
47 
50 fNCuts(ref.fNCuts),
51 fNMaxCuts(ref.fNMaxCuts),
56 {
57  for(Int_t i=0; i<fNMaxCuts; i++) {
58  fEventCutArray[i] = ref.fEventCutArray[i];
59  fPhotonCutArray[i] = ref.fPhotonCutArray[i];
60  fMesonCutArray[i] = ref.fMesonCutArray[i];
62  }
63 }
64 
66  if(this != &ref){
67  delete[] fEventCutArray;
68  delete[] fPhotonCutArray;
69  delete[] fMesonCutArray;
70  delete[] fClusterCutArray;
71 
72  fValidCuts = ref.fValidCuts;
73  fNCuts = ref.fNCuts;
74  fNMaxCuts = ref.fNMaxCuts;
79  for(Int_t i=0; i<fNMaxCuts; i++) {
80  for(Int_t i=0; i<fNMaxCuts; i++) {
81  fEventCutArray[i] = ref.fEventCutArray[i];
82  fPhotonCutArray[i] = ref.fPhotonCutArray[i];
83  fMesonCutArray[i] = ref.fMesonCutArray[i];
85  }
86  }
87  }
88  return *this;
89 }
90 
92  delete[] fEventCutArray;
93  delete[] fPhotonCutArray;
94  delete[] fMesonCutArray;
95  delete[] fClusterCutArray;
96 }
97 
98 void AliConversionCutHandler::AddCut(TString eventCut, TString photonCut, TString mesonCut){
99  if(fNCuts>=fNMaxCuts) {
100  std::cout << "ERROR in CutHandlerConv: Exceeded maximum number of cuts!" << std::endl;
101  fValidCuts = false;
102  return;
103  }
104  if(eventCut.Length()!=8 || photonCut.Length()!=26 || mesonCut.Length()!=16 ) { // Markus: These numbers should in principle be handled by the cut classes themselves
105  std::cout << "ERROR in CutHandlerConv: Incorrect length of cut string!" << std::endl;
106  fValidCuts = false;
107  return;
108  }
109  fEventCutArray[fNCuts]=eventCut;
110  fPhotonCutArray[fNCuts]=photonCut;
111  fMesonCutArray[fNCuts]=mesonCut;
113  fNCuts++;
114  return;
115 }
116 
117 void AliConversionCutHandler::AddCut(TString eventCut, TString photonCut, TString mesonCut, TString clusterCut){
118  if(fNCuts>=fNMaxCuts) {
119  std::cout << "ERROR in CutHandlerConv: Exceeded maximum number of cuts!" << std::endl;
120  fValidCuts = false;
121  return;
122  }
123  if( eventCut.Length()!=8 || photonCut.Length()!=26 || mesonCut.Length()!=16 || clusterCut.Length()!=19 ){
124  std::cout << "ERROR in CutHandlerConv: Incorrect length of cut string!" << std::endl;
125  fValidCuts = false; return;
126  }
127  fEventCutArray[fNCuts]=eventCut;
128  fPhotonCutArray[fNCuts]=photonCut;
129  fMesonCutArray[fNCuts]=mesonCut;
130  fClusterCutArray[fNCuts]=clusterCut;
131  fNCuts++;
132  return;
133 }
134 
136  if(fValidCuts&&i<fNMaxCuts&&i>=0)
137  return fEventCutArray[i];
138  else{
139  std::cout << "ERROR in CutHandlerConv: GetEventCut wrong index i" << std::endl;
140  return "";
141  }
142 }
143 
145  if(fValidCuts&&i<fNMaxCuts&&i>=0)
146  return fPhotonCutArray[i];
147  else {
148  std::cout << "ERROR in CutHandlerConv: GetPhotonCut wrong index i" << std::endl;
149  return "";
150  }
151 }
152 
154  if(fValidCuts&&i<fNMaxCuts&&i>=0)
155  return fMesonCutArray[i];
156  else {
157  std::cout << "ERROR in CutHandlerConv: GetMesonCut wrong index i" << std::endl;
158  return "";
159  }
160 }
161 
163  if(fValidCuts&&i<fNMaxCuts&&i>=0)
164  return fClusterCutArray[i];
165  else {
166  std::cout << "ERROR in CutHandlerConv: GetClusterCut wrong index i" << std::endl;
167  return "";
168  }
169 }
TString * fPhotonCutArray
Array of photon cuts.
TString * fEventCutArray
Array of event cuts.
TString * fClusterCutArray
Array of calo cluster cuts.
TString GetPhotonCut(Int_t i) const
int Int_t
Definition: External.C:63
void AddCut(TString eventCut, TString photonCut, TString mesonCut)
Int_t fNCuts
Number of cuts handled so far.
TString GetMesonCut(Int_t i) const
TString * fMesonCutArray
Array of meson cuts.
AliConversionCutHandler & operator=(const AliConversionCutHandler &ref)
TString GetClusterCut(Int_t i) const
TString GetEventCut(Int_t i) const
Int_t fNMaxCuts
Max. number of cuts that can be handled.
Bool_t fValidCuts
Test if all cuts are valid.