]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONReAlignTask.cxx
CID 22679: Out-of-bounds write (OVERRUN_STATIC)
[u/mrichter/AliRoot.git] / MUON / AliMUONReAlignTask.cxx
index fb13dfd74d2986a9f09c8aa29bdcd0732355b6d0..0e930f736761888b20e02930e785b93fcddc6510 100644 (file)
@@ -1,3 +1,20 @@
+/**************************************************************************
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+// $Id$
+
 //-----------------------------------------------------------------------------
 /// \class AliMUONReAlignTask
 /// AliAnalysisTask to realign the MUON spectrometer.
@@ -28,6 +45,7 @@
 #include "AliESDMuonTrack.h"
 #include "AliMagF.h"
 #include "AliCDBManager.h"
+#include "AliGRPManager.h"
 #include "AliGeomManager.h"
 
 #include "AliMpConstants.h"
@@ -54,6 +72,8 @@
 
 #include "AliMUONReAlignTask.h"
 
+using std::cout;
+using std::endl;
 ///\cond CLASSIMP   
 ClassImp(AliMUONReAlignTask)
 ///\endcond
@@ -131,6 +151,7 @@ AliMUONReAlignTask::AliMUONReAlignTask(const AliMUONReAlignTask& obj)
 AliMUONReAlignTask& AliMUONReAlignTask::operator=(const AliMUONReAlignTask& other)
 {
   /// Assignment
+  if(&other == this) return *this;
   AliAnalysisTask::operator=(other);
   fESD = other.fESD;
   fClusterInfoTree = other.fClusterInfoTree;
@@ -291,14 +312,6 @@ void AliMUONReAlignTask::Exec(Option_t *)
     // Find the corresponding re-fitted MUON track
     AliMUONTrack* newTrack = (AliMUONTrack*) newTrackStore->FindObject(esdTrack->GetUniqueID());
     
-//     // replace the content of the current ESD track or remove it if the refitting has failed
-//     if (newTrack) {
-//       Double_t vertex[3] = {esdTrack->GetNonBendingCoor(), esdTrack->GetBendingCoor(), esdTrack->GetZ()};
-//       AliMUONESDInterface::MUONToESD(*newTrack, *esdTrack, vertex, esdInterface.GetDigits());
-//       } else {
-//       esdTracks->Remove(esdTrack);
-//       }
-      
     // print initial and re-fitted track parameters at first cluster if any
     if (fPrintLevel>0) {
       cout<<"            ----------------track #"<<iTrack+1<<"----------------"<<endl;
@@ -373,10 +386,17 @@ void AliMUONReAlignTask::Exec(Option_t *)
        padInfo.SetPadADC(digit->ADC());
        padInfo.SetSaturated(digit->IsSaturated());
        padInfo.SetCalibrated(digit->IsCalibrated());
-       padInfo.SetPedestal(ped->ValueAsFloatFast(manuChannel,0), ped->ValueAsFloatFast(manuChannel,1));
-       padInfo.SetGain(gain->ValueAsFloatFast(manuChannel,0), gain->ValueAsFloatFast(manuChannel,1),
-                       gain->ValueAsFloatFast(manuChannel,2), gain->ValueAsFloatFast(manuChannel,3));
-       
+       if (ped) {
+         padInfo.SetPedestal(ped->ValueAsFloatFast(manuChannel,0), ped->ValueAsFloatFast(manuChannel,1));
+       } else {
+         padInfo.SetPedestal(-250.,-5.);
+       }
+       if (gain) {
+         padInfo.SetGain(gain->ValueAsFloatFast(manuChannel,0), gain->ValueAsFloatFast(manuChannel,1),
+                         gain->ValueAsIntFast(manuChannel,2), gain->ValueAsIntFast(manuChannel,3));
+       } else {
+         padInfo.SetGain(-1.,-0.1,-4095,-1);
+       }       
        fClusterInfo->AddPad(padInfo);
       }
          
@@ -413,13 +433,7 @@ void AliMUONReAlignTask::Prepare(const char* geoFilename, const char* defaultOCD
       return;
     }
   }
-  
-  // set mag field
-  printf("Loading field map...\n");
-  AliMagF* field = new AliMagF("Maps","Maps",2,0.,0., 10.,AliMagF::k5kG);
-  TGeoGlobalMagField::Instance()->SetField(field);
-  TGeoGlobalMagField::Instance()->Lock();
-  
+    
   // Load mapping
   AliCDBManager* man = AliCDBManager::Instance();
   man->SetDefaultStorage(defaultOCDB);
@@ -430,6 +444,17 @@ void AliMUONReAlignTask::Prepare(const char* geoFilename, const char* defaultOCD
     Error("MUONRefit","Could not access mapping from OCDB !");
     exit(-1);
   }
+
+  // set mag field
+  if (!TGeoGlobalMagField::Instance()->GetField()) {
+    printf("Loading field map...\n");
+    AliGRPManager *grpMan = new AliGRPManager();
+    grpMan->ReadGRPEntry();
+    grpMan->SetMagField();
+    delete grpMan;
+  }
+  // set the magnetic field for track extrapolations
+  AliMUONTrackExtrap::SetField();
   
   // Load initial reconstruction parameters from OCDB
   // reconstruction parameters