]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALv1.cxx
switch on special cuts process
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALv1.cxx
CommitLineData
b13bbe81 1/**************************************************************************
173558f2 2
b13bbe81 3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
173558f2 4
b13bbe81 5 * *
173558f2 6
b13bbe81 7 * Author: The ALICE Off-line Project. *
173558f2 8
b13bbe81 9 * Contributors are mentioned in the code where appropriate. *
173558f2 10
b13bbe81 11 * *
173558f2 12
b13bbe81 13 * Permission to use, copy, modify and distribute this software and its *
173558f2 14
b13bbe81 15 * documentation strictly for non-commercial purposes is hereby granted *
173558f2 16
b13bbe81 17 * without fee, provided that the above copyright notice appears in all *
173558f2 18
b13bbe81 19 * copies and that both the copyright notice and this permission notice *
173558f2 20
b13bbe81 21 * appear in the supporting documentation. The authors make no claims *
173558f2 22
b13bbe81 23 * about the suitability of this software for any purpose. It is *
173558f2 24
b13bbe81 25 * provided "as is" without express or implied warranty. *
173558f2 26
b13bbe81 27 **************************************************************************/
28
173558f2 29
30
b13bbe81 31/* $Id$ */
32
173558f2 33
34
b13bbe81 35//_________________________________________________________________________
173558f2 36
b13bbe81 37// Implementation version v1 of EMCAL Manager class
173558f2 38
b13bbe81 39// An object of this class does not produce digits
173558f2 40
b13bbe81 41// It is the one to use if you do want to produce outputs in TREEH
173558f2 42
b13bbe81 43//
173558f2 44
b13bbe81 45//*-- Author: Sahal Yacoob (LBL /UCT)
173558f2 46
b13bbe81 47//*-- : Jennifer Klay (LBL)
48
173558f2 49
50
fceb09ed 51// This Class not stores information on all particles prior to EMCAL entry - in order to facilitate analysis.
173558f2 52
fceb09ed 53// This is done by setting fIShunt =2, and flagging all parents of particles entering the EMCAL.
54
173558f2 55
56
1f4d29d2 57// 15/02/2002 .... Yves Schutz
173558f2 58
1f4d29d2 59// 1. fSamplingFraction and fLayerToPreshowerRatio have been removed
173558f2 60
1f4d29d2 61// 2. Timing signal is collected and added to hit
b13bbe81 62
173558f2 63
64
b13bbe81 65// --- ROOT system ---
173558f2 66
b13bbe81 67#include "TPGON.h"
173558f2 68
b13bbe81 69#include "TTUBS.h"
173558f2 70
b13bbe81 71#include "TNode.h"
173558f2 72
b13bbe81 73#include "TRandom.h"
173558f2 74
b13bbe81 75#include "TTree.h"
173558f2 76
b13bbe81 77#include "TGeometry.h"
173558f2 78
fceb09ed 79#include "TParticle.h"
b13bbe81 80
173558f2 81
82
b13bbe81 83// --- Standard library ---
84
173558f2 85
86
b13bbe81 87#include <stdio.h>
173558f2 88
b13bbe81 89#include <string.h>
173558f2 90
b13bbe81 91#include <stdlib.h>
173558f2 92
70479d0e 93#include <Rstrstream.h>
173558f2 94
70479d0e 95#include <Riostream.h>
173558f2 96
b13bbe81 97#include <math.h>
173558f2 98
b13bbe81 99// --- AliRoot header files ---
100
173558f2 101
102
b13bbe81 103#include "AliEMCALv1.h"
173558f2 104
b13bbe81 105#include "AliEMCALHit.h"
173558f2 106
b13bbe81 107#include "AliEMCALGeometry.h"
173558f2 108
b13bbe81 109#include "AliConst.h"
173558f2 110
b13bbe81 111#include "AliRun.h"
173558f2 112
b13bbe81 113#include "AliMC.h"
114
173558f2 115
116
b13bbe81 117ClassImp(AliEMCALv1)
118
119
173558f2 120
121
122
b13bbe81 123//______________________________________________________________________
173558f2 124
b13bbe81 125AliEMCALv1::AliEMCALv1():AliEMCALv0(){
173558f2 126
b13bbe81 127 // ctor
173558f2 128
dfce7eb2 129 fLightYieldMean = 0 ;
173558f2 130
dfce7eb2 131 fIntrinsicAPDEfficiency = fLightFactor = fLightYieldAttenuation = fAPDFactor = fAPDGain = fRecalibrationFactor = fAPDFactor = 0. ;
173558f2 132
b13bbe81 133}
1f4d29d2 134
173558f2 135
136
b13bbe81 137//______________________________________________________________________
173558f2 138
b13bbe81 139AliEMCALv1::AliEMCALv1(const char *name, const char *title):
173558f2 140
b13bbe81 141 AliEMCALv0(name,title){
173558f2 142
b13bbe81 143 // Standard Creator.
144
173558f2 145
146
b13bbe81 147 fHits= new TClonesArray("AliEMCALHit",1000);
173558f2 148
b13bbe81 149 gAlice->AddHitList(fHits);
150
173558f2 151
152
b13bbe81 153 fNhits = 0;
173558f2 154
fceb09ed 155 fIshunt = 2; // All hits are associated with particles entering the calorimeter
dfce7eb2 156
173558f2 157
158
dfce7eb2 159 //Photoelectron statistics:
173558f2 160
dfce7eb2 161 // The light yield is a poissonian distribution of the number of
173558f2 162
dfce7eb2 163 // photons created in a plastic layer, calculated using following formula
173558f2 164
dfce7eb2 165 // NumberOfPhotons = EnergyLost * LightYieldMean* APDEfficiency *
173558f2 166
dfce7eb2 167 // exp (-LightYieldAttenuation * DistanceToPINdiodeFromTheHit)
173558f2 168
dfce7eb2 169 // LightYieldMean is parameter calculated to be over 100000 photons per GeV (a guess)
173558f2 170
dfce7eb2 171 // APDEfficiency is 0.02655
173558f2 172
dfce7eb2 173 // fLightYieldAttenuation is 0.0045 a guess
173558f2 174
dfce7eb2 175 // TO BE FIXED
173558f2 176
dfce7eb2 177 //***** Need a method in geometry to retrieve the fiber length corresponding to each layer
173558f2 178
dfce7eb2 179 //***** See the step manager for the light attenuation calculation
173558f2 180
dfce7eb2 181 // The number of electrons created in the APD is
173558f2 182
dfce7eb2 183 // NumberOfElectrons = APDGain * LightYield
173558f2 184
dfce7eb2 185 // The APD Gain is 300
173558f2 186
dfce7eb2 187
173558f2 188
dfce7eb2 189 fLightYieldMean = 10000000.; // This is a guess
173558f2 190
dfce7eb2 191 fIntrinsicAPDEfficiency = 0.02655 ;
173558f2 192
dfce7eb2 193 fLightFactor = fLightYieldMean * fIntrinsicAPDEfficiency ;
173558f2 194
dfce7eb2 195 fLightYieldAttenuation = 0.0045 ; // an other guess
173558f2 196
dfce7eb2 197 fAPDGain = 300. ;
173558f2 198
dfce7eb2 199 fRecalibrationFactor = 13.418/ fLightYieldMean ;
173558f2 200
dfce7eb2 201 fAPDFactor = (fRecalibrationFactor/100.) * fAPDGain ;
202
173558f2 203
204
b13bbe81 205}
1f4d29d2 206
173558f2 207
208
b13bbe81 209//______________________________________________________________________
173558f2 210
b13bbe81 211AliEMCALv1::~AliEMCALv1(){
173558f2 212
b13bbe81 213 // dtor
214
173558f2 215
216
b13bbe81 217 if ( fHits) {
173558f2 218
b13bbe81 219 fHits->Delete();
173558f2 220
b13bbe81 221 delete fHits;
173558f2 222
b13bbe81 223 fHits = 0;
173558f2 224
b13bbe81 225 }
173558f2 226
b13bbe81 227}
173558f2 228
b13bbe81 229//______________________________________________________________________
173558f2 230
61e0abb5 231void AliEMCALv1::AddHit(Int_t shunt, Int_t primary, Int_t tracknumber, Int_t iparent, Float_t ienergy,
173558f2 232
61e0abb5 233 Int_t id, Float_t * hits,Float_t * p){
173558f2 234
b13bbe81 235 // Add a hit to the hit list.
173558f2 236
ffa6d63b 237 // An EMCAL hit is the sum of all hits in a single segment
173558f2 238
ffa6d63b 239 // originating from the same enterring particle
173558f2 240
b13bbe81 241 Int_t hitCounter;
173558f2 242
b13bbe81 243
173558f2 244
b13bbe81 245 AliEMCALHit *newHit;
173558f2 246
b13bbe81 247 AliEMCALHit *curHit;
173558f2 248
b13bbe81 249 Bool_t deja = kFALSE;
250
173558f2 251
252
61e0abb5 253 newHit = new AliEMCALHit(shunt, primary, tracknumber, iparent, ienergy, id, hits, p);
173558f2 254
b13bbe81 255 for ( hitCounter = fNhits-1; hitCounter >= 0 && !deja; hitCounter-- ) {
173558f2 256
b13bbe81 257 curHit = (AliEMCALHit*) (*fHits)[hitCounter];
173558f2 258
61e0abb5 259 // We add hits with the same tracknumber, while GEANT treats
173558f2 260
b13bbe81 261 // primaries succesively
173558f2 262
b13bbe81 263 if(curHit->GetPrimary() != primary) break;
173558f2 264
b13bbe81 265 if( *curHit == *newHit ) {
173558f2 266
b13bbe81 267 *curHit = *curHit + *newHit;
173558f2 268
b13bbe81 269 deja = kTRUE;
173558f2 270
b13bbe81 271 } // end if
173558f2 272
b13bbe81 273 } // end for hitCounter
274
173558f2 275
276
b13bbe81 277 if ( !deja ) {
173558f2 278
b13bbe81 279 new((*fHits)[fNhits]) AliEMCALHit(*newHit);
173558f2 280
b13bbe81 281 fNhits++;
173558f2 282
b13bbe81 283 } // end if
284
173558f2 285
286
b13bbe81 287 delete newHit;
173558f2 288
b13bbe81 289}
173558f2 290
b13bbe81 291//______________________________________________________________________
173558f2 292
b13bbe81 293void AliEMCALv1::StepManager(void){
173558f2 294
1f4d29d2 295 // Accumulates hits as long as the track stays in a single
173558f2 296
1f4d29d2 297 // crystal or PPSD gas Cell
298
173558f2 299
300
1f4d29d2 301 Int_t id[2]; // (layer, phi, Eta) indices
173558f2 302
1f4d29d2 303 Int_t absid;
173558f2 304
1f4d29d2 305 // position wrt MRS and energy deposited
173558f2 306
1f4d29d2 307 Float_t xyzte[5]={0.,0.,0.,0.,0.};// position wrt MRS, time and energy deposited
173558f2 308
1f4d29d2 309 Float_t pmom[4]={0.,0.,0.,0.};
173558f2 310
1f4d29d2 311 TLorentzVector pos; // Lorentz vector of the track current position.
173558f2 312
1f4d29d2 313 TLorentzVector mom; // Lorentz vector of the track current momentum.
173558f2 314
1f4d29d2 315 Int_t tracknumber = gAlice->CurrentTrack();
173558f2 316
1f4d29d2 317 Int_t primary = 0;
173558f2 318
1f4d29d2 319 static Int_t iparent = 0;
173558f2 320
1f4d29d2 321 static Float_t ienergy = 0;
173558f2 322
1f4d29d2 323 Int_t copy = 0;
173558f2 324
1f4d29d2 325
173558f2 326
05a92d59 327 AliEMCALGeometry * geom = GetGeometry() ;
328
173558f2 329
330
1f4d29d2 331 if(gMC->IsTrackEntering() && (strcmp(gMC->CurrentVolName(),"XALU") == 0)){ // This Particle in enterring the Calorimeter
173558f2 332
1f4d29d2 333 gMC->TrackPosition(pos) ;
173558f2 334
1f4d29d2 335 xyzte[0] = pos[0] ;
173558f2 336
1f4d29d2 337 xyzte[1] = pos[1] ;
173558f2 338
1f4d29d2 339 xyzte[2] = pos[2] ;
173558f2 340
1f4d29d2 341 if ( (xyzte[0]*xyzte[0] + xyzte[1]*xyzte[1])
173558f2 342
05a92d59 343 < (geom->GetEnvelop(0)+geom->GetGap2Active()+1.5 )*(geom->GetEnvelop(0)+geom->GetGap2Active()+1.5 ) ) {
173558f2 344
1f4d29d2 345 iparent = tracknumber;
173558f2 346
1f4d29d2 347 gMC->TrackMomentum(mom);
173558f2 348
1f4d29d2 349 ienergy = mom[3];
173558f2 350
1f4d29d2 351 TParticle * part = 0 ;
173558f2 352
1f4d29d2 353 Int_t parent = iparent ;
173558f2 354
1f4d29d2 355 while ( parent != -1 ) { // <------------- flags this particle to be kept and
173558f2 356
1f4d29d2 357 //all the ancestors of this particle
173558f2 358
1f4d29d2 359 part = gAlice->Particle(parent) ;
173558f2 360
1f4d29d2 361 part->SetBit(kKeepBit);
173558f2 362
1f4d29d2 363 parent = part->GetFirstMother() ;
173558f2 364
fceb09ed 365 }
173558f2 366
1f4d29d2 367 }
173558f2 368
1f4d29d2 369 }
173558f2 370
1f4d29d2 371 if(gMC->CurrentVolID(copy) == gMC->VolId("XPHI") ) { // We are in a Scintillator Layer
173558f2 372
1f4d29d2 373
173558f2 374
dfce7eb2 375 Float_t depositedEnergy ;
173558f2 376
61e0abb5 377
173558f2 378
dfce7eb2 379 if( (depositedEnergy = gMC->Edep()) > 0.){// Track is inside a scintillator and deposits some energy
173558f2 380
dfce7eb2 381
173558f2 382
dfce7eb2 383 gMC->TrackPosition(pos);
173558f2 384
dfce7eb2 385 xyzte[0] = pos[0];
173558f2 386
dfce7eb2 387 xyzte[1] = pos[1];
173558f2 388
dfce7eb2 389 xyzte[2] = pos[2];
173558f2 390
dfce7eb2 391 xyzte[3] = gMC->TrackTime() ;
173558f2 392
dfce7eb2 393
173558f2 394
dfce7eb2 395 gMC->TrackMomentum(mom);
173558f2 396
dfce7eb2 397 pmom[0] = mom[0];
173558f2 398
dfce7eb2 399 pmom[1] = mom[1];
173558f2 400
dfce7eb2 401 pmom[2] = mom[2];
173558f2 402
dfce7eb2 403 pmom[3] = mom[3];
173558f2 404
dfce7eb2 405
173558f2 406
dfce7eb2 407 gMC->CurrentVolOffID(1, id[0]); // get the POLY copy number;
173558f2 408
dfce7eb2 409 gMC->CurrentVolID(id[1]); // get the phi number inside the layer
173558f2 410
05a92d59 411 absid = (id[0]-1)*(geom->GetNPhi()) + id[1];
173558f2 412
dfce7eb2 413
173558f2 414
dfce7eb2 415 //Calculates the light yield, the number of photons produced in the
173558f2 416
dfce7eb2 417 //plastic layer
173558f2 418
dfce7eb2 419 // Here we need to know the fiber lebgth to calculate the attenuation
173558f2 420
dfce7eb2 421
173558f2 422
dfce7eb2 423 Float_t lengthOfFiber = 0. ;// should be retrieved from the geometry
424
173558f2 425
426
dfce7eb2 427 Float_t lightYield = gRandom->Poisson(fLightFactor * depositedEnergy *
173558f2 428
dfce7eb2 429 exp(-fLightYieldAttenuation * lengthOfFiber)) ;
173558f2 430
dfce7eb2 431 xyzte[4] = fAPDFactor * lightYield ;
173558f2 432
dfce7eb2 433
173558f2 434
dfce7eb2 435 primary = gAlice->GetPrimary(tracknumber);
173558f2 436
1f4d29d2 437 AddHit(fIshunt, primary,tracknumber, iparent, ienergy, absid, xyzte, pmom);
173558f2 438
b13bbe81 439 } // there is deposited energy
173558f2 440
1f4d29d2 441 }
173558f2 442
b13bbe81 443}
173558f2 444