- branchH->GetEntry(iTrack);
- Int_t nHit = fHits->GetEntriesFast();
- for(iHit = 0; iHit< nHit;iHit++){
-
- AliEMCALHit * hit = dynamic_cast<AliEMCALHit*>(fHits->At(iHit)) ;
- AliEMCALDigit * curSDigit = 0 ;
- AliEMCALDigit * sdigit = 0 ;
- Bool_t newsdigit = kTRUE;
-
- // hit->GetId() - Absolute Id number EMCAL segment
- if(geom->CheckAbsCellId(hit->GetId())) { // was IsInECA(hit->GetId())
- energy = hit->GetEnergy() * fSampling; // 23-nov-04
- if(energy > fECPrimThreshold )
- // Assign primary number only if deposited energy is significant
- curSDigit = new AliEMCALDigit(hit->GetPrimary(),
- hit->GetIparent(), hit->GetId(),
- Digitize(energy), hit->GetTime(),kFALSE,
- -1, 0,0,energy ) ;
- else
- curSDigit = new AliEMCALDigit(-1,
- -1,
- hit->GetId(),
- Digitize(energy), hit->GetTime(),kFALSE,
- -1, 0,0,energy ) ;
- } else {
- Warning("Exec"," abs id %i is bad \n", hit->GetId());
- newsdigit = kFALSE;
- curSDigit = 0;
- }
-
- if(curSDigit != 0){
- for(Int_t check= 0; check < nSdigits ; check++) {
- sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(check)) ;
-
- if( sdigit->GetId() == curSDigit->GetId()) { // Are we in the same ECAL tower ?
- *sdigit = *sdigit + *curSDigit;
- newsdigit = kFALSE;
- }
- }
- }
- if (newsdigit) {
- new((*sdigits)[nSdigits]) AliEMCALDigit(*curSDigit);
- nSdigits++ ;
- }
- delete curSDigit ;
- } // loop over all hits (hit = deposited energy/entering particle)
+ branchH->GetEntry(iTrack);
+
+ if(fHits){
+
+ Int_t nHit = fHits->GetEntriesFast();
+ for(iHit = 0; iHit< nHit;iHit++){
+
+ AliEMCALHit * hit = dynamic_cast<AliEMCALHit*>(fHits->At(iHit)) ;
+ AliEMCALDigit * curSDigit = 0 ;
+ AliEMCALDigit * sdigit = 0 ;
+ Bool_t newsdigit = kTRUE;
+
+ // hit->GetId() - Absolute Id number EMCAL segment
+ if(hit){
+ if(geom->CheckAbsCellId(hit->GetId())) { // was IsInECA(hit->GetId())
+ energy = hit->GetEnergy() * fSampling; // 23-nov-04
+ if(energy > fECPrimThreshold )
+ // Assign primary number only if deposited energy is significant
+ curSDigit = new AliEMCALDigit(hit->GetPrimary(),
+ hit->GetIparent(), hit->GetId(),
+ Digitize(energy), hit->GetTime(),kFALSE,
+ -1, 0,0,energy ) ;
+ else
+ curSDigit = new AliEMCALDigit(-1,
+ -1,
+ hit->GetId(),
+ Digitize(energy), hit->GetTime(),kFALSE,
+ -1, 0,0,energy ) ;
+ } else {
+ Warning("Exec"," abs id %i is bad \n", hit->GetId());
+ newsdigit = kFALSE;
+ curSDigit = 0;
+ }
+
+ if(curSDigit != 0){
+ for(Int_t check= 0; check < nSdigits ; check++) {
+ sdigit = dynamic_cast<AliEMCALDigit *>(sdigits->At(check)) ;
+ if(sdigit){
+ if( sdigit->GetId() == curSDigit->GetId()) { // Are we in the same ECAL tower ?
+ *sdigit = *sdigit + *curSDigit;
+ newsdigit = kFALSE;
+ }
+ }// sdigit exists
+ else {
+ AliWarning("Sdigit do not exist");
+ newsdigit = kFALSE;
+ }// sdigit does not exist
+ }//sdigit loop
+ }// currsdigit exists
+
+ if (newsdigit) {
+ new((*sdigits)[nSdigits]) AliEMCALDigit(*curSDigit);
+ nSdigits++ ;
+ }
+ delete curSDigit ;
+
+ }// hit exists
+ else AliFatal("Hit is NULL!");
+
+ } // loop over all hits (hit = deposited energy/entering particle)
+
+ }//fHits is not NULL
+ else AliFatal("fHit is NULL!");
+