]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/JetCorrel/AliJetCorrelMaker.cxx
Recalculate distance only when requested via switch
[u/mrichter/AliRoot.git] / PWG4 / JetCorrel / AliJetCorrelMaker.cxx
CommitLineData
c97d2ae1 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15/* $Id: $ */
16
17//__________________________________________
18// Class that uses info from the AliJetCorrelSelector object to set up the
19// two-particle correlations to be run in one instance of the analysis module.
20//-- Author: Paul Constantin
21
22#include "AliJetCorrelMaker.h"
23
24using namespace std;
c97d2ae1 25
26ClassImp(AliJetCorrelMaker)
27
28AliJetCorrelMaker::AliJetCorrelMaker() :
29 fNumCorrel(0), fNumTrigg(0), fNumAssoc(0),
30 fCorrelType(NULL), fCorrelStr(NULL),
31 fTriggType(NULL), fAssocType(NULL),
32 fIdxTrigg(NULL), fIdxAssoc(NULL){
33 // (default) constructor
34}
35
36AliJetCorrelMaker::~AliJetCorrelMaker(){
37 // destructor
38 fNumCorrel = 0;
39 fNumTrigg = 0;
40 fNumAssoc = 0;
41 if(fCorrelType) delete [] fCorrelType;
42 if(fCorrelStr) delete [] fCorrelStr;
43 if(fTriggType) delete [] fTriggType;
44 if(fAssocType) delete [] fAssocType;
45 if(fIdxTrigg) delete [] fIdxTrigg;
46 if(fIdxAssoc) delete [] fIdxAssoc;
47}
48
49Bool_t AliJetCorrelMaker::Init(UInt_t s, UInt_t * const v){
50 // Main method. Returns false on initialisation error
51 fNumCorrel = s;
c97d2ae1 52 fCorrelType = new UInt_t[fNumCorrel];
53 fCorrelStr = new TString[fNumCorrel];
11ad5089 54 fTriggType = new cPartType_t[fNumCorrel];
55 fAssocType = new cPartType_t[fNumCorrel];
c97d2ae1 56 for(UInt_t k=0; k<fNumCorrel; k++){
57 fCorrelType[k] = v[k];
58 switch(fCorrelType[k]){
59 case 0:
11ad5089 60 fTriggType[k] = t_hadron; fAssocType[k] = t_hadron; fCorrelStr[k] = "DiHadron";
c97d2ae1 61 break;
62 case 1:
11ad5089 63 fTriggType[k] = t_diphoton; fAssocType[k] = t_hadron; fCorrelStr[k] = "Pi0Hadron";
c97d2ae1 64 break;
65 case 2:
11ad5089 66 fTriggType[k] = t_photon; fAssocType[k] = t_hadron; fCorrelStr[k] = "PhotHadron";
c97d2ae1 67 break;
68 case 3:
11ad5089 69 fTriggType[k] = t_dielectron; fAssocType[k] = t_hadron; fCorrelStr[k] = "Z0Hadron";
c97d2ae1 70 break;
71 case 4:
11ad5089 72 fTriggType[k] = t_jet; fAssocType[k] = t_jet; fCorrelStr[k] = "JetJet";
c97d2ae1 73 break;
74 case 5:
11ad5089 75 fTriggType[k] = t_photon; fAssocType[k] = t_jet; fCorrelStr[k] = "PhotJet";
c97d2ae1 76 break;
77 case 6:
11ad5089 78 fTriggType[k] = t_dielectron; fAssocType[k] = t_jet; fCorrelStr[k] = "Z0Jet";
c97d2ae1 79 break;
80 default:
81 std::cerr<<"AliJetCorrelMaker::Initialize - ERROR: unknown correlation type!"<<std::endl;
82 return kFALSE;
83 break;
84 }
85 } // loop over correlations
86
87 Bool_t notStored;
88 fIdxTrigg = new UInt_t[fNumCorrel];
11ad5089 89 cPartType_t *fTriggUniq = new cPartType_t[fNumCorrel];
c97d2ae1 90 for(UInt_t k=0; k<fNumCorrel; k++){
91 notStored = kTRUE;
92 for(UInt_t i=0; i<fNumTrigg; i++)
93 if(fTriggUniq[i]==fTriggType[k]) notStored = kFALSE;
94 if(notStored){fTriggUniq[fNumTrigg]=fTriggType[k]; fNumTrigg++;}
95 }
96 for(UInt_t k=0; k<fNumCorrel; k++)
97 for(UInt_t i=0; i<fNumTrigg; i++)
98 if(fTriggType[k]==fTriggUniq[i]) fIdxTrigg[k] = i;
99 delete [] fTriggUniq;
100
101 fIdxAssoc = new UInt_t[fNumCorrel];
11ad5089 102 cPartType_t *fAssocUniq = new cPartType_t[fNumCorrel];
c97d2ae1 103 for(UInt_t k=0; k<fNumCorrel; k++){
104 notStored = kTRUE;
105 for(UInt_t i=0; i<fNumAssoc; i++)
106 if(fAssocUniq[i]==fAssocType[k]) notStored = kFALSE;
107 if(notStored){fAssocUniq[fNumAssoc]=fAssocType[k]; fNumAssoc++;}
108 }
109 for(UInt_t k=0; k<fNumCorrel; k++)
110 for(UInt_t i=0; i<fNumAssoc; i++)
111 if(fAssocType[k]==fAssocUniq[i]) fIdxAssoc[k] = i;
112 delete [] fAssocUniq;
113
114 if(!Check()){
115 std::cerr<<"AliJetCorrelMaker::Initialize - array sanity check failed!"<<std::endl;
116 return kFALSE;
117 }
118
119 return kTRUE;
120}
121
7488b3de 122Bool_t AliJetCorrelMaker::Check() const {
c97d2ae1 123 // performs initialization sanity checks
124 if(fNumTrigg<1 || fNumAssoc<1) return kFALSE;
125 if(fNumTrigg>fNumCorrel || fNumAssoc>fNumCorrel) return kFALSE;
126 for(UInt_t k=0; k<fNumCorrel; k++){
127 if(fIdxTrigg[k]>=fNumTrigg) return kFALSE;
128 if(fIdxAssoc[k]>=fNumAssoc) return kFALSE;
129 }
130 return kTRUE;
131}
132
133TString AliJetCorrelMaker::Descriptor(UInt_t k) const {
134 if(k>=fNumCorrel)
135 {std::cerr<<"AliJetCorrelMaker::Descriptor overflow!"<<std::endl; return "?";}
136 return fCorrelStr[k];
137}
138
139UInt_t AliJetCorrelMaker::IdxTrigg(UInt_t k) const {
140 if(k>=fNumCorrel)
141 {std::cerr<<"AliJetCorrelMaker::IdxTrigg overflow!"<<std::endl; exit(-1);}
142 return fIdxTrigg[k];
143}
144
145UInt_t AliJetCorrelMaker::IdxAssoc(UInt_t k) const {
146 if(k>=fNumCorrel)
147 {std::cerr<<"AliJetCorrelMaker::IdxAssoc overflow!"<<std::endl; exit(-1);}
148 return fIdxAssoc[k];
149}
150
11ad5089 151cPartType_t AliJetCorrelMaker::TriggType(UInt_t k) const {
c97d2ae1 152 if(k>=fNumCorrel)
11ad5089 153 {std::cerr<<"AliJetCorrelMaker::TriggType overflow!"<<std::endl; return t_unknown;}
c97d2ae1 154 return fTriggType[k];
155}
156
11ad5089 157cPartType_t AliJetCorrelMaker::AssocType(UInt_t k) const {
c97d2ae1 158 if(k>=fNumCorrel)
11ad5089 159 {std::cerr<<"AliJetCorrelMaker::AssocType overflow!"<<std::endl; return t_unknown;}
c97d2ae1 160 return fAssocType[k];
161}
162
163Bool_t AliJetCorrelMaker::RecoTrigger(UInt_t k) const {
11ad5089 164 if(fTriggType[k]==t_diphoton || fTriggType[k]==t_dielectron)
c97d2ae1 165 return kTRUE;
166 return kFALSE;
167}
168
169Bool_t AliJetCorrelMaker::RecoTrigger() const {
170 for(UInt_t k=0; k<fNumCorrel; k++)
171 if(RecoTrigger(k)) return kTRUE;
172 return kFALSE;
173}
174
7488b3de 175void AliJetCorrelMaker::Show() const {
c97d2ae1 176 // print out whole correlation setup
177 std::cout<<"Number of Correlations:"<<fNumCorrel
178 <<" Triggers:"<<fNumTrigg<<" Associated:"<<fNumAssoc<<std::endl;
179 for(UInt_t k=0; k<fNumCorrel; k++)
180 std::cout<<"Correlation("<<k<<"):"<<fCorrelStr[k]
181 <<" TriggType="<<fTriggType[k]<<" AssocType="<<fAssocType[k]
182 <<" IdxTrigg="<<fIdxTrigg[k]<<" IdxAssoc="<<fIdxAssoc[k]<<std::endl;
183}