1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
22 #include "AliJetCorrelMaker.h"
26 ClassImp(AliJetCorrelMaker)
28 AliJetCorrelMaker::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
36 AliJetCorrelMaker::~AliJetCorrelMaker(){
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;
49 Bool_t AliJetCorrelMaker::Init(UInt_t s, UInt_t * const v){
50 // Main method. Returns false on initialisation error
53 std::cerr<<"AliJetCorrelMaker::Initialize - ERROR: non-pozitive fNumCorrel"
54 <<fNumCorrel<<std::endl;
57 if(fNumCorrel>kMAXNUMCORREL){
58 std::cerr<<"AliJetCorrelMaker::Initialize - ERROR: increase kMAXNUMCORREL above "
59 <<fNumCorrel<<std::endl;
62 fCorrelType = new UInt_t[fNumCorrel];
63 fCorrelStr = new TString[fNumCorrel];
64 fTriggType = new PartType_t[fNumCorrel];
65 fAssocType = new PartType_t[fNumCorrel];
66 for(UInt_t k=0; k<fNumCorrel; k++){
67 fCorrelType[k] = v[k];
68 switch(fCorrelType[k]){
70 fTriggType[k] = hadron; fAssocType[k] = hadron; fCorrelStr[k] = "DiHadron";
73 fTriggType[k] = diphoton; fAssocType[k] = hadron; fCorrelStr[k] = "Pi0Hadron";
76 fTriggType[k] = photon; fAssocType[k] = hadron; fCorrelStr[k] = "PhotHadron";
79 fTriggType[k] = dielectron; fAssocType[k] = hadron; fCorrelStr[k] = "Z0Hadron";
82 fTriggType[k] = jet; fAssocType[k] = jet; fCorrelStr[k] = "JetJet";
85 fTriggType[k] = photon; fAssocType[k] = jet; fCorrelStr[k] = "PhotJet";
88 fTriggType[k] = dielectron; fAssocType[k] = jet; fCorrelStr[k] = "Z0Jet";
91 std::cerr<<"AliJetCorrelMaker::Initialize - ERROR: unknown correlation type!"<<std::endl;
95 } // loop over correlations
98 fIdxTrigg = new UInt_t[fNumCorrel];
99 PartType_t *fTriggUniq = new PartType_t[fNumCorrel];
100 for(UInt_t k=0; k<fNumCorrel; k++){
102 for(UInt_t i=0; i<fNumTrigg; i++)
103 if(fTriggUniq[i]==fTriggType[k]) notStored = kFALSE;
104 if(notStored){fTriggUniq[fNumTrigg]=fTriggType[k]; fNumTrigg++;}
106 for(UInt_t k=0; k<fNumCorrel; k++)
107 for(UInt_t i=0; i<fNumTrigg; i++)
108 if(fTriggType[k]==fTriggUniq[i]) fIdxTrigg[k] = i;
109 delete [] fTriggUniq;
111 fIdxAssoc = new UInt_t[fNumCorrel];
112 PartType_t *fAssocUniq = new PartType_t[fNumCorrel];
113 for(UInt_t k=0; k<fNumCorrel; k++){
115 for(UInt_t i=0; i<fNumAssoc; i++)
116 if(fAssocUniq[i]==fAssocType[k]) notStored = kFALSE;
117 if(notStored){fAssocUniq[fNumAssoc]=fAssocType[k]; fNumAssoc++;}
119 for(UInt_t k=0; k<fNumCorrel; k++)
120 for(UInt_t i=0; i<fNumAssoc; i++)
121 if(fAssocType[k]==fAssocUniq[i]) fIdxAssoc[k] = i;
122 delete [] fAssocUniq;
125 std::cerr<<"AliJetCorrelMaker::Initialize - array sanity check failed!"<<std::endl;
132 Bool_t AliJetCorrelMaker::Check() const {
133 // performs initialization sanity checks
134 if(fNumTrigg<1 || fNumAssoc<1) return kFALSE;
135 if(fNumTrigg>fNumCorrel || fNumAssoc>fNumCorrel) return kFALSE;
136 for(UInt_t k=0; k<fNumCorrel; k++){
137 if(fIdxTrigg[k]>=fNumTrigg) return kFALSE;
138 if(fIdxAssoc[k]>=fNumAssoc) return kFALSE;
143 TString AliJetCorrelMaker::Descriptor(UInt_t k) const {
145 {std::cerr<<"AliJetCorrelMaker::Descriptor overflow!"<<std::endl; return "?";}
146 return fCorrelStr[k];
149 UInt_t AliJetCorrelMaker::IdxTrigg(UInt_t k) const {
151 {std::cerr<<"AliJetCorrelMaker::IdxTrigg overflow!"<<std::endl; exit(-1);}
155 UInt_t AliJetCorrelMaker::IdxAssoc(UInt_t k) const {
157 {std::cerr<<"AliJetCorrelMaker::IdxAssoc overflow!"<<std::endl; exit(-1);}
161 PartType_t AliJetCorrelMaker::TriggType(UInt_t k) const {
163 {std::cerr<<"AliJetCorrelMaker::TriggType overflow!"<<std::endl; return unknown;}
164 return fTriggType[k];
167 PartType_t AliJetCorrelMaker::AssocType(UInt_t k) const {
169 {std::cerr<<"AliJetCorrelMaker::AssocType overflow!"<<std::endl; return unknown;}
170 return fAssocType[k];
173 Bool_t AliJetCorrelMaker::RecoTrigger(UInt_t k) const {
174 if(fTriggType[k]==diphoton || fTriggType[k]==dielectron)
179 Bool_t AliJetCorrelMaker::RecoTrigger() const {
180 for(UInt_t k=0; k<fNumCorrel; k++)
181 if(RecoTrigger(k)) return kTRUE;
185 void AliJetCorrelMaker::Show() const {
186 // print out whole correlation setup
187 std::cout<<"Number of Correlations:"<<fNumCorrel
188 <<" Triggers:"<<fNumTrigg<<" Associated:"<<fNumAssoc<<std::endl;
189 for(UInt_t k=0; k<fNumCorrel; k++)
190 std::cout<<"Correlation("<<k<<"):"<<fCorrelStr[k]
191 <<" TriggType="<<fTriggType[k]<<" AssocType="<<fAssocType[k]
192 <<" IdxTrigg="<<fIdxTrigg[k]<<" IdxAssoc="<<fIdxAssoc[k]<<std::endl;