]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALReconstructor.cxx
Modified init of AliMuonForwardTrack
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALReconstructor.cxx
index b2a6da7c0700a692ac293b35805f46acbe14fc3c..c191ec92c2223c1a90b50b73b5e826be170661cf 100644 (file)
@@ -135,8 +135,8 @@ AliEMCALReconstructor::AliEMCALReconstructor()
   //Init temporary list of digits
   fgDigitsArr     = new TClonesArray("AliEMCALDigit",1000);
   fgClustersArr   = new TObjArray(1000);
-  fgTriggerDigits = new TClonesArray("AliEMCALTriggerRawDigit",1000);  
-
+  fgTriggerDigits = new TClonesArray("AliEMCALTriggerRawDigit", 32 * 96);      
+       
   //Track matching
   fMatches = new TList();
   fMatches->SetOwner(kTRUE);
@@ -362,7 +362,7 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
       AliWarning("No V0 ESD! Run trigger processor w/ null V0 charges");
     }
   
-  if (fgTriggerDigits) fgTriggerDigits->Clear();
+  if (fgTriggerDigits && fgTriggerDigits->GetEntriesFast()) fgTriggerDigits->Delete();
   
   TBranch *branchtrg = digitsTree->GetBranch("EMTRG");
   
@@ -388,7 +388,8 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
       for (Int_t i = 0; i < fgTriggerDigits->GetEntriesFast(); i++)
        {         
          AliEMCALTriggerRawDigit* rdig = (AliEMCALTriggerRawDigit*)fgTriggerDigits->At(i);
-         
+         if (AliDebugLevel() > 999) rdig->Print("");
+               
          Int_t px, py;
          if (fGeom->GetPositionInEMCALFromAbsFastORIndex(rdig->GetId(), px, py))
            {
@@ -396,14 +397,15 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
              
              rdig->GetMaximum(a, t);
              rdig->GetL0Times(times);
-             
+                       
              trgESD->Add(px, py, a, t, times, rdig->GetNL0Times(), rdig->GetL1TimeSum(), rdig->GetTriggerBits());
            }
        }
       
-      trgESD->SetL1Threshold(0, fTriggerData->GetL1GammaThreshold());
-      
-      trgESD->SetL1Threshold(1, fTriggerData->GetL1JetThreshold()  );
+               for (int i = 0; i < 2; i++) {
+                       trgESD->SetL1Threshold(2 * i    , fTriggerData->GetL1JetThreshold(  i));
+                       trgESD->SetL1Threshold(2 * i + 1, fTriggerData->GetL1GammaThreshold(i));
+               }
       
       Int_t v0[2];
       fTriggerData->GetL1V0(v0);
@@ -413,7 +415,7 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
       
       if (!saveOnce && fTriggerData->GetL1DataDecoded()) 
        {
-         int type[8] = {0};
+         int type[15] = {0};
          fTriggerData->GetL1TriggerType(type);
          
          esd->SetCaloTriggerType(type);
@@ -434,23 +436,51 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
   
   Int_t nDigits = fgDigitsArr->GetEntries(), idignew = 0 ;
   AliDebug(1,Form("%d digits",nDigits));
+  
   AliESDCaloCells &emcCells = *(esd->GetEMCALCells());
   emcCells.CreateContainer(nDigits);
   emcCells.SetType(AliVCaloCells::kEMCALCell);
+  
   Float_t energy = 0;
   Float_t time   = 0;
-  for (Int_t idig = 0 ; idig < nDigits ; idig++) {
+  for (Int_t idig = 0 ; idig < nDigits ; idig++) 
+  {
     const AliEMCALDigit * dig = (const AliEMCALDigit*)fgDigitsArr->At(idig);
     time   = dig->GetTime();      // Time already calibrated in clusterizer
     energy = dig->GetAmplitude(); // energy calibrated in clusterizer
-    if(energy > 0 ){
+    
+    if(energy > 0 )
+    {
       fgClusterizer->Calibrate(energy,time,dig->GetId()); //Digits already calibrated in clusterizers
-      if(energy > 0){ //Digits tagged as bad (dead, hot, not alive) are set to 0 in calibrate, remove them
-        emcCells.SetCell(idignew,dig->GetId(),energy, time);   
+      
+      if(energy > 0) //Digits tagged as bad (dead, hot, not alive) are set to 0 in calibrate, remove them
+      { 
+        // Only for MC
+        // Get the label of the primary particle that generated the cell
+        // Assign the particle that deposited more energy
+        Int_t   nprimaries = dig->GetNprimary() ;
+        Int_t   digLabel   =-1 ;
+        Float_t edep       =-1.;
+        if ( nprimaries > 0 )
+        {
+          Int_t jndex ;
+          for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
+            if(edep < dig->GetDEParent(jndex+1))
+            {
+              digLabel = dig->GetIparent (jndex+1);
+              edep     = dig->GetDEParent(jndex+1);
+            }
+                   
+          } // all primaries in digit      
+        } // select primary label
+        
+        emcCells.SetCell(idignew,dig->GetId(),energy, time,digLabel);   
         idignew++;
       }
     }
   }
+  
   emcCells.SetNumberOfCells(idignew);
   emcCells.Sort();
   
@@ -709,7 +739,7 @@ Bool_t AliEMCALReconstructor::CalculateResidual(AliESDtrack *track, AliESDCaloCl
   if(!trkParam) return kFALSE;
 
   AliExternalTrackParam trkParamTmp (*trkParam);
-  if(!AliEMCALRecoUtils::ExtrapolateTrackToCluster(&trkParamTmp, cluster, track->GetMass(), GetRecParam()->GetExtrapolateStep(), dEta, dPhi)) return kFALSE;
+  if(!AliEMCALRecoUtils::ExtrapolateTrackToCluster(&trkParamTmp, cluster, track->GetMass(kTRUE), GetRecParam()->GetExtrapolateStep(), dEta, dPhi)) return kFALSE;
 
   return kTRUE;
 }