]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGGA/GammaConv/AliAODConversionPhoton.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliAODConversionPhoton.cxx
CommitLineData
fd94f234 1#include "AliAODMCParticle.h"
2#include "AliAODMCHeader.h"
2eedd4ed 3#include "AliAODConversionPhoton.h"
4#include "AliKFConversionPhoton.h"
5
6using namespace std;
7
8ClassImp(AliAODConversionPhoton)
9
10AliAODConversionPhoton::AliAODConversionPhoton() :
11AliAODConversionParticle(),
4803eb1f 12AliConversionPhotonBase(),
13fDCArPrimVtx(0),
fd94f234 14fDCAzPrimVtx(0),
15fCaloPhoton(0),
d53bf4ac 16fCaloClusterRef(-1),
fd94f234 17fNCaloPhotonMCLabels(0),
cc579963 18fNCaloPhotonMotherMCLabels(0),
fd94f234 19fCaloPhotonMCFlags(0)
2eedd4ed 20{
fd94f234 21 // initialize calo photon MC labels
cc579963 22 for (Int_t i =0; i<20; i++){
fd94f234 23 fCaloPhotonMCLabels[i]=-1;
24 }
cc579963 25 for (Int_t i =0; i<20; i++){
26 fCaloPhotonMotherMCLabels[i]=-1;
27 }
3b77b2d1 28 //Standard constructor
2eedd4ed 29}
30
31AliAODConversionPhoton::AliAODConversionPhoton(AliKFConversionPhoton *kfphoton) :
3b77b2d1 32AliAODConversionParticle(kfphoton),
4803eb1f 33AliConversionPhotonBase(*((AliConversionPhotonBase*)kfphoton)),
34fDCArPrimVtx(0),
fd94f234 35fDCAzPrimVtx(0),
36fCaloPhoton(0),
d53bf4ac 37fCaloClusterRef(-1),
fd94f234 38fNCaloPhotonMCLabels(0),
cc579963 39fNCaloPhotonMotherMCLabels(0),
fd94f234 40fCaloPhotonMCFlags(0)
2eedd4ed 41{
92efd725 42 //Constructor from kfphoton
43
44 // puts the mass to zero and store dilepton mass
ae947965 45 SetMass(kfphoton->M());
fd94f234 46
47 //SetE(P());
48
49 // initialize calo photon MC labels
cc579963 50 for (Int_t i =0; i<20; i++){
fd94f234 51 fCaloPhotonMCLabels[i]=-1;
52 }
cc579963 53 for (Int_t i =0; i<20; i++){
54 fCaloPhotonMotherMCLabels[i]=-1;
55 }
fd94f234 56
2eedd4ed 57}
58
92efd725 59AliAODConversionPhoton::AliAODConversionPhoton(TLorentzVector *vec) :
60AliAODConversionParticle(vec),
4803eb1f 61AliConversionPhotonBase(),
62fDCArPrimVtx(0),
fd94f234 63fDCAzPrimVtx(0),
64fCaloPhoton(0),
d53bf4ac 65fCaloClusterRef(-1),
fd94f234 66fNCaloPhotonMCLabels(0),
cc579963 67fNCaloPhotonMotherMCLabels(0),
fd94f234 68fCaloPhotonMCFlags(0)
92efd725 69{
70 //Constructor from TLorentzVector
fd94f234 71
72 // initialize calo photon MC labels
cc579963 73 for (Int_t i =0; i<20; i++){
fd94f234 74 fCaloPhotonMCLabels[i]=-1;
75 }
cc579963 76 for (Int_t i =0; i<20; i++){
77 fCaloPhotonMotherMCLabels[i]=-1;
78 }
92efd725 79}
80
81
82
2eedd4ed 83AliAODConversionPhoton::AliAODConversionPhoton(const AliAODConversionPhoton & original) :
84AliAODConversionParticle(original),
4803eb1f 85AliConversionPhotonBase(original),
86fDCArPrimVtx(original.fDCArPrimVtx),
fd94f234 87fDCAzPrimVtx(original.fDCAzPrimVtx),
88fCaloPhoton(original.fCaloPhoton),
d53bf4ac 89fCaloClusterRef(original.fCaloClusterRef),
fd94f234 90fNCaloPhotonMCLabels(original.fNCaloPhotonMCLabels),
cc579963 91fNCaloPhotonMotherMCLabels(original.fNCaloPhotonMotherMCLabels),
fd94f234 92fCaloPhotonMCFlags(original.fCaloPhotonMCFlags)
2eedd4ed 93{
fd94f234 94 //Copy constructor
95
96 // initialize calo photon MC labels
cc579963 97 for (Int_t i =0; i<20; i++){
fd94f234 98 fCaloPhotonMCLabels[i]=original.fCaloPhotonMCLabels[i];
99 }
cc579963 100 for (Int_t i =0; i<20; i++){
101 fCaloPhotonMotherMCLabels[i]=original.fCaloPhotonMotherMCLabels[i];
102 }
2eedd4ed 103}
104
3b77b2d1 105AliAODConversionPhoton::~AliAODConversionPhoton()
106{
107 // empty standard destructor
2eedd4ed 108}
109
110AliAODConversionPhoton & AliAODConversionPhoton::operator = (const AliAODConversionPhoton & /*source*/)
111{
112 // assignment operator
113 return *this;
114}
4803eb1f 115
116///________________________________________________________________________
117void AliAODConversionPhoton::CalculateDistanceOfClossetApproachToPrimVtx(const AliVVertex* primVertex ){
118
119 Double_t primCo[3] = {primVertex->GetX(),primVertex->GetY(),primVertex->GetZ()};
120
121 Double_t absoluteP = TMath::Sqrt(TMath::Power(GetPx(),2) + TMath::Power(GetPy(),2) + TMath::Power(GetPz(),2));
122 Double_t p[3] = {GetPx()/absoluteP,GetPy()/absoluteP,GetPz()/absoluteP};
123 Double_t CP[3];
124
125 CP[0] = fConversionPoint[0] - primCo[0];
126 CP[1] = fConversionPoint[1] - primCo[1];
127 CP[2] = fConversionPoint[2] - primCo[2];
128
129 Double_t Lambda = - (CP[0]*p[0]+CP[1]*p[1]+CP[2]*p[2])/(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
130
131 Double_t S[3];
132 S[0] = fConversionPoint[0] + p[0]*Lambda;
133 S[1] = fConversionPoint[1] + p[1]*Lambda;
134 S[2] = fConversionPoint[2] + p[2]*Lambda;
135
136 fDCArPrimVtx = TMath::Sqrt( TMath::Power(primCo[0]-S[0],2) + TMath::Power(primCo[1]-S[1],2));
137 fDCAzPrimVtx = primCo[2]-S[2];
138
139 return;
140}
141
fd94f234 142
143void AliAODConversionPhoton::SetCaloPhotonMCFlags(AliStack *MCStack){
144
145 Bool_t isPhoton = kFALSE; // largest contribution to cluster is photon
146 Bool_t isElectron = kFALSE; // largest contribution to cluster is electron
147 Bool_t isConversion = kFALSE; // largest contribution to cluster is converted electron
148 Bool_t isConversionFullyContained = kFALSE; // largest contribution to cluster is converted electron, second electron has been found in same cluster
cc579963 149 Bool_t isMerged = kFALSE; // cluster contains more than one particle from the same decay
fd94f234 150 Bool_t isMergedPartConv = kFALSE; // cluster contains more than one particle from the same decay and at least one of the particles came from a conversion
cc579963 151 Bool_t isDalitz = kFALSE; // this cluster was created by a particle stemming from a dalitz decay
152 Bool_t isDalitzMerged = kFALSE; // this cluster was created by a particle stemming from a dalitz decay and more than one particle of the dalitz decay is contained in the cluster
fd94f234 153 Bool_t isPhotonWithElecMother = kFALSE; // this cluster is from a photon with an electron as mother
154 Bool_t isShower = kFALSE; // this cluster contains as a largest contribution a particle from a shower or radiative process
cc579963 155 Bool_t isSubLeadingEM = kFALSE; // cluster contains at least one electron or photon from a pi0, eta or eta_prime in subleading contribution
fd94f234 156
157 TParticle* Photon;
158 if (fNCaloPhotonMCLabels==0) return;
159 Photon = MCStack->Particle(GetCaloPhotonMCLabel(0));
160
161 if(Photon == NULL){
162 return;
163 }
164
fd94f234 165 Int_t particleMotherLabel = Photon->GetMother(0);
166 Int_t particleGrandMotherLabel = -1;
167 Int_t particleMotherPDG = -1;
168 Int_t particleGrandMotherPDG = -1;
169 Int_t particleMotherNDaugthers = 0;
170 Int_t particleGrandMotherNDaugthers = 0;
171 if (particleMotherLabel > -1){
172 particleMotherNDaugthers = MCStack->Particle(Photon->GetMother(0))->GetNDaughters();
173 particleGrandMotherLabel = MCStack->Particle(Photon->GetMother(0))->GetMother(0);
174 particleMotherPDG = MCStack->Particle(Photon->GetMother(0))->GetPdgCode();
175 if (particleGrandMotherLabel > -1){
176 particleGrandMotherPDG = MCStack->Particle(MCStack->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode();
177 particleGrandMotherNDaugthers = MCStack->Particle(MCStack->Particle(Photon->GetMother(0))->GetMother(0))->GetNDaughters();
178 }
179 }
cc579963 180
181 //determine mother/grandmother of leading particle and if it is pion/eta/eta_prime: fill array fCaloPhotonMotherMCLabels at position 0
182 if (particleMotherLabel > -1){
183 if( abs(particleMotherPDG) == 111 || abs(particleMotherPDG) == 221 || abs(particleMotherPDG) == 331 ){
184 fCaloPhotonMotherMCLabels[0] = particleMotherLabel;
185 fNCaloPhotonMotherMCLabels++;
186 }
187 else if (particleGrandMotherLabel > -1){
188 if ( abs(particleMotherPDG) == 22 && (abs(particleGrandMotherPDG) == 111 || abs(particleGrandMotherPDG) == 221 || abs(particleGrandMotherPDG) == 331) ){
189 fCaloPhotonMotherMCLabels[0] = particleGrandMotherLabel;
190 fNCaloPhotonMotherMCLabels++;
191 }
192 }
193 }
194
195 // Check whether the first contribution was photon
196 if(abs(MCStack->Particle(GetCaloPhotonMCLabel(0))->GetPdgCode()) == 22){
fd94f234 197 isPhoton=kTRUE;
198 // did it decay via the dalitz channel
199 if (particleMotherLabel > -1 && particleMotherNDaugthers == 3) isDalitz = kTRUE;
cc579963 200 // Test whether particle stems from a shower or radiation
fd94f234 201 if (abs(particleMotherPDG) == 11){ // check whether photon stems from electron
202 isPhotonWithElecMother = kTRUE;
203 if (particleGrandMotherLabel > -1){ // test whether first particle has a grandmother
204 if (abs(particleGrandMotherPDG) == 22 ) isShower = kTRUE; // check whether grandmother is a photon (meaning this is most likely a shower)
205 }
206 }
207 }
cc579963 208 // Check whether the first contribution was electron
fd94f234 209 if( abs(MCStack->Particle(GetCaloPhotonMCLabel(0))->GetPdgCode()) == 11 ){
cc579963 210 isElectron=kTRUE;
fd94f234 211 if (particleMotherLabel > -1) {
212 // was it a conversion
213 if (abs(particleMotherPDG) == 22) isConversion = kTRUE;
214 // did it decay via the dalitz channel
215 if (particleGrandMotherLabel > -1 && particleGrandMotherNDaugthers == 3 ) isDalitz = kTRUE;
216 }
217 if (particleGrandMotherLabel > -1){ // check whether electron has a grandmother
cc579963 218 if (abs(particleGrandMotherPDG) == 11 || abs(particleGrandMotherPDG) == 22){ // test whether electron has photon or electron as grandmother (meaning will most likely be a shower)
fd94f234 219 isShower = kTRUE;
220 }
221 }
222 }
cc579963 223
224
225 // check whether there were other contributions to the cluster
fd94f234 226 if (fNCaloPhotonMCLabels>1){
cc579963 227 TParticle* dummyPart =NULL;
228 for (Int_t i = 1; i< fNCaloPhotonMCLabels; i++){
229 if (i > 19) continue; // abort if more than 20 entries to the cluster have been checked (more are not stored in these objects)
230 dummyPart = MCStack->Particle(GetCaloPhotonMCLabel(i));
231 Int_t dummyPartMotherLabel = dummyPart->GetMother(0);
232 Int_t dummyPartGrandMotherLabel = -1;
233 Int_t dummyPartMotherPDG = -1;
234 Int_t dummyPartGrandMotherPDG = -1;
235 // check whether this particle has a mother & obtain the pdg code
236 if (dummyPartMotherLabel > -1){
237 dummyPartGrandMotherLabel = MCStack->Particle(dummyPart->GetMother(0))->GetMother(0);
238 dummyPartMotherPDG = MCStack->Particle(dummyPart->GetMother(0))->GetPdgCode();
239 // check whether this particle has a grandmother & obtain its pdg code
240 if (dummyPartGrandMotherLabel > -1){
241 dummyPartGrandMotherPDG = MCStack->Particle(MCStack->Particle(dummyPart->GetMother(0))->GetMother(0))->GetPdgCode();
fd94f234 242 }
cc579963 243 }
244 // largest contribution was from photon and is not from shower or electron mother
245 if (isPhoton && (!isShower || !isPhotonWithElecMother )){
246 if (dummyPartMotherLabel > -1 && particleMotherLabel > -1){ // test whether first particle has a mother
fd94f234 247 if (dummyPartMotherLabel == particleMotherLabel) isMerged = kTRUE; // test whether current and first particle have the same mother => i.e. other gamma from decay or dalitz electron
248 if (dummyPartGrandMotherLabel > -1){ // test whether first particle has a grandmother
cc579963 249 // check whether particle is an electron from a conversion of a photon from the original mother
250 if (abs(dummyPart->GetPdgCode()) == 11 && dummyPartGrandMotherLabel == particleMotherLabel ) isMergedPartConv = kTRUE;
251 // check whether particle is an electron from a dalitz decay from the original mother
fd94f234 252 if (abs(dummyPart->GetPdgCode()) == 11 && dummyPartMotherLabel == particleMotherLabel ) isDalitzMerged = kTRUE;
fd94f234 253 }
254 }
cc579963 255 }
256
257 // largest contribution was from electron & not a from a shower
258 if (isElectron && !isShower){
259 if (dummyPartMotherLabel > -1 && particleMotherLabel > -1){ // test whether first particle has a mother
260 if (isConversion && dummyPartMotherLabel == particleMotherLabel) isConversionFullyContained = kTRUE; // test whether conversion is fully contained in cluster
fd94f234 261
cc579963 262 if (dummyPartGrandMotherLabel > -1 && particleGrandMotherLabel > -1){ // test whether first particle has a grandmother
fd94f234 263 if (abs(dummyPart->GetPdgCode()) == 22){ // test whether this particle is a photon
cc579963 264 // check whether orginal electron and this photon stem from the same particle and electron stems from conversion
fd94f234 265 if( dummyPartMotherLabel == particleGrandMotherLabel && (abs(dummyPartMotherPDG) != 11 || abs(dummyPartMotherPDG) != 22 ) ) isMergedPartConv = kTRUE;
cc579963 266 // check whether orginal electron and this photon stem from the same particle and electron originated in dalitz
fd94f234 267 if( dummyPartMotherLabel == particleMotherLabel && (abs(dummyPartMotherPDG) != 11 || abs(dummyPartMotherPDG) != 22 ) ) isDalitzMerged = kTRUE;
268 }
269 if (abs(dummyPart->GetPdgCode()) == 11) {
cc579963 270 // check whether orginal electron and this electron stem from the same particle and electron stems from conversion
fd94f234 271 if( dummyPartGrandMotherLabel == particleGrandMotherLabel && (abs(dummyPartGrandMotherPDG) != 11 || abs(dummyPartGrandMotherPDG) != 22 ) ) isMergedPartConv = kTRUE;
cc579963 272 // check whether orginal electron and this electron stem from the same particle and electron originated in dalitz decay
fd94f234 273 if( dummyPartMotherLabel == particleMotherLabel && abs(particleMotherPDG) != 22 && (abs(dummyPartGrandMotherPDG) != 11 || abs(dummyPartGrandMotherPDG) != 22 ) ) isDalitzMerged = kTRUE;
274 }
cc579963 275
276 }
277 }
278 }
279
280 if (dummyPartMotherLabel > -1){ // test whether particle has a mother
281 if (abs(dummyPart->GetPdgCode()) == 22){ // test whether particle is a photon
282 //check if photon directly comes from a pion/eta/eta_prime decay
283 if ( abs(dummyPartMotherPDG) == 111 || abs(dummyPartMotherPDG) == 221 || abs(dummyPartMotherPDG) == 331){
284 fCaloPhotonMotherMCLabels[i] = dummyPartMotherLabel;
285 Bool_t helpN=true;
286 for(Int_t j=0; j<i; j++){
287 if (fCaloPhotonMotherMCLabels[j] == dummyPartMotherLabel){ //check if mother is already contained in fCaloPhotonMotherMCLabels
288 helpN=false;
289 }
290 }
291 if (helpN) fNCaloPhotonMotherMCLabels++; //only if particle label is not yet contained in array, count up fNCaloPhotonMotherMCLabels
292 if (!isPhoton && !isElectron) isSubLeadingEM = kTRUE;
293 }
294 }
295
296 if (abs(dummyPart->GetPdgCode()) == 11){ //test whether particle is an electron
297 //check if electron comes from a pion decay
298 if ( abs(dummyPartMotherPDG) == 111){
299 fCaloPhotonMotherMCLabels[i] = dummyPartMotherLabel;
300 Bool_t helpN=true;
301 for(Int_t j=0; j<i; j++){
302 if (fCaloPhotonMotherMCLabels[j] == dummyPartMotherLabel){ //check if mother is already contained in fCaloPhotonMotherMCLabels
303 helpN=false;
304 }
305 }
306 if (helpN) fNCaloPhotonMotherMCLabels++; //only if particle label is not yet contained in array, count up fNCaloPhotonMotherMCLabels
307 if (!isPhoton && !isElectron) isSubLeadingEM = kTRUE;
308 }
309 else if (dummyPartGrandMotherLabel > -1){ //if it is not a dalitz decay, test whether particle has a grandmother
310 //check if it is a conversion electron that has pion/eta/eta_prime as grandmother
311 if ( abs(dummyPartMotherPDG) == 22 && (abs(dummyPartGrandMotherPDG) == 111 || abs(dummyPartGrandMotherPDG) == 221 || abs(dummyPartGrandMotherPDG) == 331)){
312 fCaloPhotonMotherMCLabels[i] = dummyPartGrandMotherLabel;
313 Bool_t helpN=true;
314 for(Int_t j=0; j<i; j++){
315 if (fCaloPhotonMotherMCLabels[j] == dummyPartGrandMotherLabel){ //check if grandmother is already contained in fCaloPhotonMotherMCLabels
316 helpN=false;
317 }
318 }
319 if (helpN) fNCaloPhotonMotherMCLabels++; //only if particle label is not yet contained in array, count up fNCaloPhotonMotherMCLabels
320 if (!isPhoton && !isElectron) isSubLeadingEM = kTRUE;
321 }
322 }
323 }
324
325 }
326
fd94f234 327 }
cc579963 328 }
329 fCaloPhotonMCFlags = isPhoton *1 + isElectron *2 + isConversion*4+ isConversionFullyContained *8 + isMerged *16 + isMergedPartConv*32 + isDalitz *64 + isDalitzMerged *128 + isPhotonWithElecMother *256 + isShower * 512 + isSubLeadingEM * 1024;
fd94f234 330}
331
332void AliAODConversionPhoton::SetCaloPhotonMCFlagsAOD(AliVEvent* event){
333
334 TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
335 if (!AODMCTrackArray) return;
336
fd94f234 337 Bool_t isPhoton = kFALSE; // largest contribution to cluster is photon
338 Bool_t isElectron = kFALSE; // largest contribution to cluster is electron
339 Bool_t isConversion = kFALSE; // largest contribution to cluster is converted electron
340 Bool_t isConversionFullyContained = kFALSE; // largest contribution to cluster is converted electron, second electron has been found in same cluster
341 Bool_t isMerged = kFALSE; // largest contribution to cluster is photon, second photon or electron from dalitz has been found in same cluster
342 Bool_t isMergedPartConv = kFALSE; // cluster contains more than one particle from the same decay and at least one of the particles came from a conversion
343 Bool_t isDalitz = kFALSE; // this cluster was created by a particle stemming from a dality decay
344 Bool_t isDalitzMerged = kFALSE; // this cluster was created by a particle stemming from a dality decay and more than one particle of the dalitz decay is contained in the cluster
345 Bool_t isPhotonWithElecMother = kFALSE; // this cluster is from a photon with an electron as mother
346 Bool_t isShower = kFALSE; // this cluster contains as a largest contribution a particle from a shower or radiative process
cc579963 347 Bool_t isSubLeadingEM = kFALSE; // cluster contains at least one electron or photon from a pi0 or eta in subleading contribution
fd94f234 348
349 AliAODMCParticle* Photon;
cc579963 350 AliAODMCParticle* PhotonMother;
351 AliAODMCParticle* PhotonGrandMother;
352
fd94f234 353 if (fNCaloPhotonMCLabels==0) return;
354 Photon = (AliAODMCParticle*) AODMCTrackArray->At(GetCaloPhotonMCLabel(0));
355
356 if(Photon == NULL){
357 return;
358 }
359
fd94f234 360 Int_t particleMotherLabel = Photon->GetMother();
361 Int_t particleGrandMotherLabel = -1;
362 Int_t particleMotherPDG = -1;
363 Int_t particleGrandMotherPDG = -1;
364 Int_t particleMotherNDaugthers = 0;
365 Int_t particleGrandMotherNDaugthers = 0;
366 if (particleMotherLabel > -1){
367 PhotonMother = (AliAODMCParticle*) AODMCTrackArray->At(Photon->GetMother());
368 particleMotherNDaugthers = PhotonMother->GetNDaughters();
369 particleGrandMotherLabel = PhotonMother->GetMother();
370 particleMotherPDG = PhotonMother->GetPdgCode();
371 if (particleGrandMotherLabel > -1){
372 PhotonGrandMother = (AliAODMCParticle*) AODMCTrackArray->At(PhotonMother->GetMother());
373 particleGrandMotherPDG = PhotonGrandMother->GetPdgCode();
374 particleGrandMotherNDaugthers = PhotonGrandMother->GetNDaughters();
375 }
376 }
cc579963 377
378 //determine mother/grandmother of leading particle and if it is pion/eta/eta_prime: fill array fCaloPhotonMotherMCLabels at position 0
379 if (particleMotherLabel > -1){
380 if( abs(particleMotherPDG) == 111 || abs(particleMotherPDG) == 221 || abs(particleMotherPDG) == 331 ){
381 fCaloPhotonMotherMCLabels[0] = particleMotherLabel;
382 fNCaloPhotonMotherMCLabels++;
383 }
384 else if (particleGrandMotherLabel > -1){
385 if ( abs(particleMotherPDG) == 22 && (abs(particleGrandMotherPDG) == 111 || abs(particleGrandMotherPDG) == 221 || abs(particleGrandMotherPDG) == 331) ){
386 fCaloPhotonMotherMCLabels[0] = particleGrandMotherLabel;
387 fNCaloPhotonMotherMCLabels++;
388 }
389 }
390 }
fd94f234 391
cc579963 392 // Check whether the first contribution was photon
fd94f234 393 if(abs(Photon->GetPdgCode()) == 22){
394 isPhoton=kTRUE;
395 // did it decay via the dalitz channel
396 if (particleMotherLabel > -1 && particleMotherNDaugthers == 3) isDalitz = kTRUE;
cc579963 397 // Test whether particle stems from a shower or radiation
fd94f234 398 if (abs(particleMotherPDG) == 11){ // check whether photon stems from electron
399 isPhotonWithElecMother = kTRUE;
400 if (particleGrandMotherLabel > -1){ // test whether first particle has a grandmother
401 if (abs(particleGrandMotherPDG) == 22 ) isShower = kTRUE; // check whether grandmother is a photon (meaning this is most likely a shower)
402 }
403 }
404 }
cc579963 405 // Check whether the first contribution was electron
fd94f234 406 if(abs(Photon->GetPdgCode()) == 11 ){
407 isElectron=kTRUE;
408 if (particleMotherLabel > -1) {
409 // was it a conversion
410 if (abs(particleMotherPDG) == 22) isConversion = kTRUE;
411 // did it decay via the dalitz channel
412 if (particleGrandMotherLabel > -1 && particleGrandMotherNDaugthers == 3 ) isDalitz = kTRUE;
413 }
414 if (particleGrandMotherLabel > -1){ // check whether electron has a grandmother
cc579963 415 if (abs(particleGrandMotherPDG) == 11 || abs(particleGrandMotherPDG) == 22){ // test whether electron has photon or electron as grandmother (meaning will most likely be a shower)
fd94f234 416 isShower = kTRUE;
417 }
418 }
419 }
420
cc579963 421
422 // check whether there were other contributions to the cluster
fd94f234 423 if (fNCaloPhotonMCLabels>1){
cc579963 424 AliAODMCParticle* dummyPart =NULL;
425 AliAODMCParticle* dummyPartMother = NULL;
426 AliAODMCParticle* dummyPartGrandMother = NULL;
427 for (Int_t i = 1; i< fNCaloPhotonMCLabels; i++){
428 if (i > 19) continue; // abort if more than 20 entries to the cluster have been checked (more are not stored in these objects)
429 dummyPart = (AliAODMCParticle*) AODMCTrackArray->At(GetCaloPhotonMCLabel(i));
430 Int_t dummyPartMotherLabel = dummyPart->GetMother();
431 Int_t dummyPartGrandMotherLabel = -1;
432 Int_t dummyPartMotherPDG = -1;
433 Int_t dummyPartGrandMotherPDG = -1;
434
435 // check whether this particle has a mother & obtain the pdg code
436 if (dummyPartMotherLabel > -1){
437 dummyPartMother = (AliAODMCParticle*) AODMCTrackArray->At(dummyPart->GetMother());
438 dummyPartGrandMotherLabel = dummyPartMother->GetMother();
439 dummyPartMotherPDG = dummyPartMother->GetPdgCode();
440 // check whether this particle has a grandmother & obtain its pdg code
441 if (dummyPartGrandMotherLabel > -1){
442 dummyPartGrandMother = (AliAODMCParticle*) AODMCTrackArray->At(dummyPartMother->GetMother());
443 dummyPartGrandMotherPDG = dummyPartGrandMother->GetPdgCode();
fd94f234 444 }
cc579963 445 }
446
447 // largest contribution was from photon and is not from shower or electron mother
448 if (isPhoton && (!isShower || !isPhotonWithElecMother )){
449 if (dummyPartMotherLabel > -1 && particleMotherLabel > -1){ // test whether first particle has a mother
fd94f234 450 if (dummyPartMotherLabel == particleMotherLabel) isMerged = kTRUE; // test whether current and first particle have the same mother => i.e. other gamma from decay or dalitz electron
451 if (dummyPartGrandMotherLabel > -1){ // test whether first particle has a grandmother
cc579963 452 // check whether particle is an electron from a conversion of a photon from the original mother
453 if (abs(dummyPart->GetPdgCode()) == 11 && dummyPartGrandMotherLabel == particleMotherLabel ) isMergedPartConv = kTRUE;
454 // check whether particle is an electron from a dalitz decay from the original mother
fd94f234 455 if (abs(dummyPart->GetPdgCode()) == 11 && dummyPartMotherLabel == particleMotherLabel ) isDalitzMerged = kTRUE;
fd94f234 456 }
457 }
cc579963 458 }
459
460 // largest contribution was from electron & not a from a shower
461 if (isElectron && !isShower){
462 if (dummyPartMotherLabel > -1 && particleMotherLabel > -1){ // test whether first particle has a mother
463 if (isConversion && dummyPartMotherLabel == particleMotherLabel) isConversionFullyContained = kTRUE; // test whether conversion is fully contained in cluster
fd94f234 464
cc579963 465 if (dummyPartGrandMotherLabel > -1 && particleGrandMotherLabel > -1){ // test whether first particle has a grandmother
fd94f234 466 if (abs(dummyPart->GetPdgCode()) == 22){ // test whether this particle is a photon
cc579963 467 // check whether orginal electron and this photon stem from the same particle and electron stems from conversion
fd94f234 468 if( dummyPartMotherLabel == particleGrandMotherLabel && (abs(dummyPartMotherPDG) != 11 || abs(dummyPartMotherPDG) != 22 ) ) isMergedPartConv = kTRUE;
cc579963 469 // check whether orginal electron and this photon stem from the same particle and electron originated in dalitz
fd94f234 470 if( dummyPartMotherLabel == particleMotherLabel && (abs(dummyPartMotherPDG) != 11 || abs(dummyPartMotherPDG) != 22 ) ) isDalitzMerged = kTRUE;
471 }
472 if (abs(dummyPart->GetPdgCode()) == 11) {
cc579963 473 // check whether orginal electron and this electron stem from the same particle and electron stems from conversion
fd94f234 474 if( dummyPartGrandMotherLabel == particleGrandMotherLabel && (abs(dummyPartGrandMotherPDG) != 11 || abs(dummyPartGrandMotherPDG) != 22 ) ) isMergedPartConv = kTRUE;
cc579963 475 // check whether orginal electron and this electron stem from the same particle and electron originated in dalitz decay
fd94f234 476 if( dummyPartMotherLabel == particleMotherLabel && abs(particleMotherPDG) != 22 && (abs(dummyPartGrandMotherPDG) != 11 || abs(dummyPartGrandMotherPDG) != 22 ) ) isDalitzMerged = kTRUE;
477 }
cb287740 478
cc579963 479 }
480 }
481 }
482
483 if (dummyPartMotherLabel > -1){ // test whether particle has a mother
484 if (abs(dummyPart->GetPdgCode()) == 22){ // test whether particle is a photon
485 //check if photon directly comes from a pion/eta/eta_prime decay
486 if ( abs(dummyPartMotherPDG) == 111 || abs(dummyPartMotherPDG) == 221 || abs(dummyPartMotherPDG) == 331){
487 fCaloPhotonMotherMCLabels[i] = dummyPartMotherLabel;
488 Bool_t helpN=true;
489 for(Int_t j=0; j<i; j++){
490 if (fCaloPhotonMotherMCLabels[j] == dummyPartMotherLabel){ //check if mother is already contained in fCaloPhotonMotherMCLabels
491 helpN=false;
492 }
493 }
494 if (helpN) fNCaloPhotonMotherMCLabels++; //only if particle label is not yet contained in array, count up fNCaloPhotonMotherMCLabels
495 if (!isPhoton && !isElectron) isSubLeadingEM = kTRUE;
496 }
497 }
498
499 if (abs(dummyPart->GetPdgCode()) == 11){ //test whether particle is an electron
500 //check if electron comes from a pion decay
501 if ( abs(dummyPartMotherPDG) == 111){
502 fCaloPhotonMotherMCLabels[i] = dummyPartMotherLabel;
503 Bool_t helpN=true;
504 for(Int_t j=0; j<i; j++){
505 if (fCaloPhotonMotherMCLabels[j] == dummyPartMotherLabel){ //check if mother is already contained in fCaloPhotonMotherMCLabels
506 helpN=false;
507 }
508 }
509 if (helpN) fNCaloPhotonMotherMCLabels++; //only if particle label is not yet contained in array, count up fNCaloPhotonMotherMCLabels
510 if (!isPhoton && !isElectron) isSubLeadingEM = kTRUE;
511 }
512 else if (dummyPartGrandMotherLabel > -1){ //if it is not a dalitz decay, test whether particle has a grandmother
513 //check if it is a conversion electron that has pion/eta/eta_prime as grandmother
514 if ( abs(dummyPartMotherPDG) == 22 && (abs(dummyPartGrandMotherPDG) == 111 || abs(dummyPartGrandMotherPDG) == 221 || abs(dummyPartGrandMotherPDG) == 331)){
515 fCaloPhotonMotherMCLabels[i] = dummyPartGrandMotherLabel;
516 Bool_t helpN=true;
517 for(Int_t j=0; j<i; j++){
518 if (fCaloPhotonMotherMCLabels[j] == dummyPartGrandMotherLabel){ //check if grandmother is already contained in fCaloPhotonMotherMCLabels
519 helpN=false;
520 }
521 }
522 if (helpN) fNCaloPhotonMotherMCLabels++; //only if particle label is not yet contained in array, count up fNCaloPhotonMotherMCLabels
523 if (!isPhoton && !isElectron) isSubLeadingEM = kTRUE;
524 }
525 }
526 }
527
528 }
529
530 }
531 }
532 fCaloPhotonMCFlags = isPhoton *1 + isElectron *2 + isConversion*4+ isConversionFullyContained *8 + isMerged *16 + isMergedPartConv*32 + isDalitz *64 + isDalitzMerged *128 + isPhotonWithElecMother *256 + isShower * 512 + isSubLeadingEM * 1024;
533}