]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG4/PartCorrBase/AliCaloTrackReader.cxx
Move the rejection of events with large z vertex from the analysis code to the reader...
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliCaloTrackReader.cxx
index 11cb868996d69db1862c8da13ddc7764feea0795..8363f07a285a36bdf967c822f1c418128c94c8b4 100755 (executable)
@@ -68,7 +68,8 @@ ClassImp(AliCaloTrackReader)
     fDeltaAODFileName("deltaAODPartCorr.root"),fFiredTriggerClassName(""),
     fAnaLED(kFALSE),fTaskName(""),fCaloUtils(0x0), 
     fMixedEvent(NULL), fNMixedEvent(1), fVertex(NULL), 
-    fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE),fCaloFilterPatch(kFALSE)
+    fWriteOutputDeltaAOD(kFALSE),fOldAOD(kFALSE),fCaloFilterPatch(kFALSE),
+    fEMCALClustersListName(""),fZvtxCut(0.)
 {
   //Ctor
   
@@ -325,6 +326,8 @@ void AliCaloTrackReader::InitParameters()
   fV0ADC[0] = 0;   fV0ADC[1] = 0; 
   fV0Mul[0] = 0;   fV0Mul[1] = 0; 
 
+  fZvtxCut   = 10.;
+  
 }
 
 //________________________________________________________________
@@ -432,6 +435,8 @@ Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry, const char * curre
   //Fill Vertex array
   
   FillVertexArray();
+  //Reject events with Z vertex too large, only for SE analysis, if not, cut on the analysis code
+  if(!GetMixedEvent() && TMath::Abs(fVertex[0][2]) > fZvtxCut) return kFALSE;  
   
   //Fill the arrays with cluster/tracks/cells data
    if(fFillEMCALCells) 
@@ -668,82 +673,102 @@ void AliCaloTrackReader::FillInputCTS() {
     // 
 }
 
-  //____________________________________________________________________________
+//____________________________________________________________________________
+void AliCaloTrackReader::FillInputEMCALAlgorithm(AliVCluster * clus, const Int_t iclus) {
+  //Fill the EMCAL data in the array, do it
+  
+  Int_t vindex = 0 ;  
+  if (fMixedEvent) 
+    vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
+  
+  //Check if the cluster contains any bad channel and if close to calorimeter borders
+  if(GetCaloUtils()->ClusterContainsBadChannel("EMCAL",clus->GetCellsAbsId(), clus->GetNCells())) 
+    return;
+  if(!GetCaloUtils()->CheckCellFiducialRegion(clus, (AliVCaloCells*)fInputEvent->GetEMCALCells(), fInputEvent, vindex)) 
+    return;
+  
+  TLorentzVector momentum ;
+  
+  clus->GetMomentum(momentum, fVertex[vindex]);      
+  
+  if(fEMCALPtMin < momentum.Pt()){
+    
+    if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) 
+      return;
+    
+    if(fDebug > 2 && momentum.E() > 0.1) 
+      printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
+             momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
+    
+    //Float_t pos[3];
+    //clus->GetPosition(pos);
+    //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
+    
+    //Recalibrate the cluster energy 
+    if(GetCaloUtils()->IsRecalibrationOn()) {
+      Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
+      clus->SetE(energy);
+      //printf("Recalibrated Energy %f\n",clus->E());  
+      GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
+      GetCaloUtils()->RecalculateClusterPID(clus);
+      
+    }
+    
+    //Recalculate distance to bad channels, if new list of bad channels provided
+    GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
+    
+    //Recalculate cluster position
+    if(GetCaloUtils()->IsRecalculationOfClusterPositionOn()){
+      GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus); 
+      //clus->GetPosition(pos);
+      //printf("After  Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
+    }
+    
+    //Correct non linearity
+    if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn()){
+      GetCaloUtils()->CorrectClusterEnergy(clus) ;
+      //printf("Linearity Corrected Energy %f\n",clus->E());  
+    }          
+    
+    if (fMixedEvent) 
+      clus->SetID(iclus) ; 
+    
+    fAODEMCAL->Add(clus);      
+  }
+}
+
+//____________________________________________________________________________
 void AliCaloTrackReader::FillInputEMCAL() {
   //Return array with EMCAL clusters in aod format
   
   if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputEMCAL()\n");
   
   //Loop to select clusters in fiducial cut and fill container with aodClusters
-  Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
-  for (Int_t iclus =  0; iclus <  nclusters; iclus++) {
-    AliVCluster * clus = 0;
-    if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
-      if (IsEMCALCluster(clus)){
-        
-        //Check if the cluster contains any bad channel and if close to calorimeter borders
-        Int_t vindex = 0 ;  
-        if (fMixedEvent) 
-          vindex = fMixedEvent->EventIndexForCaloCluster(iclus);
-        
-        if(GetCaloUtils()->ClusterContainsBadChannel("EMCAL",clus->GetCellsAbsId(), clus->GetNCells())) 
-          continue;
-        if(!GetCaloUtils()->CheckCellFiducialRegion(clus, (AliVCaloCells*)fInputEvent->GetEMCALCells(), fInputEvent, vindex)) 
-          continue;
-        
-        TLorentzVector momentum ;
-        
-        clus->GetMomentum(momentum, fVertex[vindex]);      
-        
-        if(fEMCALPtMin < momentum.Pt()){
-          
-          if(fCheckFidCut && !fFiducialCut->IsInFiducialCut(momentum,"EMCAL")) 
-            continue;
-          
-          if(fDebug > 2 && momentum.E() > 0.1) 
-            printf("AliCaloTrackReader::FillInputEMCAL() - Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
-                   momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
-          
-          //Float_t pos[3];
-          //clus->GetPosition(pos);
-          //printf("Before Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
-          
-          //Recalibrate the cluster energy 
-          if(GetCaloUtils()->IsRecalibrationOn()) {
-            Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, GetEMCALCells());
-            clus->SetE(energy);
-            //printf("Recalibrated Energy %f\n",clus->E());  
-            GetCaloUtils()->RecalculateClusterShowerShapeParameters(GetEMCALCells(),clus);
-            GetCaloUtils()->RecalculateClusterPID(clus);
-
-          }
-
-          //Recalculate distance to bad channels, if new list of bad channels provided
-          GetCaloUtils()->RecalculateClusterDistanceToBadChannel(GetEMCALCells(),clus);
-                    
-          //Recalculate cluster position
-          if(GetCaloUtils()->IsRecalculationOfClusterPositionOn()){
-            GetCaloUtils()->RecalculateClusterPosition(GetEMCALCells(),clus); 
-            //clus->GetPosition(pos);
-            //printf("After  Corrections: e %f, x %f, y %f, z %f\n",clus->E(),pos[0],pos[1],pos[2]);
-          }
-          
-          //Correct non linearity
-          if(GetCaloUtils()->IsCorrectionOfClusterEnergyOn()){
-            GetCaloUtils()->CorrectClusterEnergy(clus) ;
-            //printf("Linearity Corrected Energy %f\n",clus->E());  
-          }          
-          
-          if (fMixedEvent) {
-            clus->SetID(iclus) ; 
-          }
-            
-          fAODEMCAL->Add(clus);        
-          
-        }//Pt and Fiducial cut passed.
-      }//EMCAL cluster
-    }// cluster exists
-  }// cluster loop
+  if(fEMCALClustersListName==""){
+    Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
+    for (Int_t iclus =  0; iclus <  nclusters; iclus++) {
+      AliVCluster * clus = 0;
+      if ( (clus = fInputEvent->GetCaloCluster(iclus)) ) {
+        if (IsEMCALCluster(clus)){          
+          FillInputEMCALAlgorithm(clus, iclus);
+        }//EMCAL cluster
+      }// cluster exists
+    }// cluster loop
+  }//Get the clusters from the input event
+  else {
+    TClonesArray * clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
+    if(!clusterList){
+      printf("AliCaloTrackReader::FillInputEMCAL() - Wrong name of list with clusters? <%s>\n",fEMCALClustersListName.Data());
+      return;
+    }
+    Int_t nclusters = clusterList->GetEntriesFast();
+    for (Int_t iclus =  0; iclus <  nclusters; iclus++) {
+      AliVCluster * clus = dynamic_cast<AliVCluster*> (clusterList->At(iclus));
+      //printf("E %f\n",clus->E());
+      if (clus) FillInputEMCALAlgorithm(clus, iclus);
+      else printf("AliCaloTrackReader::FillInputEMCAL() - Null cluster in list!\n");
+    }// cluster loop
+  }
   
   //Recalculate track matching
   GetCaloUtils()->RecalculateClusterTrackMatching(fInputEvent);