]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/MUONCheckMisAligner.C
Add a protection to avoid array boundary error in IntSpecGeant
[u/mrichter/AliRoot.git] / MUON / MUONCheckMisAligner.C
index 99301f39c9327dc0063aa0d990c13753b4396e95..efc2664614acb3290a1c8f2053461e11c0070ff1 100644 (file)
 
 */
 
+#if !defined(__CINT__) || defined(__MAKECINT__)
+
+#include "AliMUONGeometryTransformer.h"
+#include "AliMUONGeometryMisAligner.h"
+
+#include "AliGeomManager.h"
+#include "AliCDBManager.h"
+#include "AliCDBMetaData.h"
+#include "AliCDBId.h"
+
+#include <TGeoManager.h>
+#include <TClonesArray.h>
+
+#endif
+
 void MUONCheckMisAligner(Double_t xcartmisaligm = 0.0, Double_t xcartmisaligw = 0.004, 
                         Double_t ycartmisaligm = 0.0, Double_t ycartmisaligw = 0.003, 
                         Double_t angmisaligm = 0.0, Double_t angmisaligw = 0.0023,
-                        TString nameCDB = "ResMisAlignCDB")
+                        TString nameCDB = "ResMisAlignCDB", 
+                         const TString& geomFileName = "geometry.root")
 {
   
-  AliMUONGeometryTransformer *transform = new AliMUONGeometryTransformer(true);
-  transform->ReadGeometryData("volpath.dat", "transform.dat");
-  if (gSystem->AccessPathName("geometry.root",kFileExists))
-    gGeoManager->Export("geometry.root");
+  AliMUONGeometryTransformer *transform = new AliMUONGeometryTransformer();
+  transform->LoadGeometryData(geomFileName.Data());
+
   AliMUONGeometryMisAligner misAligner(xcartmisaligm,xcartmisaligw,
                                        ycartmisaligm,ycartmisaligw,
                                       angmisaligm,angmisaligw);
 
   // Generate mis alignment data
+
   // Uncomment lines below if you would like to generate module misalignments
-//  misAligner.SetModuleCartMisAlig(0.0,0.1,0.0,0.1,0.0,0.1); // Full
-//   misAligner.SetModuleAngMisAlig(0.0,0.02,0.0,0.04,0.0,0.02); // Full
-//   misAligner.SetModuleCartMisAlig(0.0,0.003,0.0,0.003,0.0,0.003); // Res
-//   misAligner.SetModuleAngMisAlig(0.0,0.0006,0.0,0.001,0.0,0.0005); // Res
+  // misAligner.SetModuleCartMisAlig(0.0,0.1,0.0,0.1,0.0,0.1); // Full
+  // misAligner.SetModuleAngMisAlig(0.0,0.02,0.0,0.04,0.0,0.02); // Full
+  // misAligner.SetModuleCartMisAlig(0.0,0.003,0.0,0.003,0.0,0.003); // Res
+  // misAligner.SetModuleAngMisAlig(0.0,0.0006,0.0,0.001,0.0,0.0005); // Res
+
   AliMUONGeometryTransformer *newTransform = misAligner.MisAlign(transform,true); 
   newTransform->WriteTransformations("transform2.dat");
   newTransform->WriteMisAlignmentData("misalign.root");
 
   // Apply misAlignment via AliRoot framework
-  TGeoManager::Import("geometry.root");
-  AliSimulation::ApplyAlignObjsToGeom(
-     const_cast<TClonesArray*>(newTransform->GetMisAlignmentData()));
+  AliGeomManager::ApplyAlignObjsToGeom(
+     *const_cast<TClonesArray*>(newTransform->GetMisAlignmentData()));
   // Save new geometry file
   gGeoManager->Export("geometry2.root");
   
   // Extract new transformations
-  AliMUONGeometryTransformer* transform3 = new AliMUONGeometryTransformer(true);
-  transform3->ReadGeometryData("volpath.dat", "geometry2.root");
+  AliMUONGeometryTransformer* transform3 = new AliMUONGeometryTransformer();
+  transform3->LoadGeometryData("geometry2.root");
   transform3->WriteTransformations("transform3.dat");
                // Check that transform3.dat is equal to transform2.dat
 
   // Generate misaligned data in local cdb
-  TClonesArray* array = newTransform->GetMisAlignmentData();
+  const TClonesArray* array = newTransform->GetMisAlignmentData();
    
   TString sLocCDB("local://");
   sLocCDB += nameCDB;
@@ -103,7 +119,7 @@ void MUONCheckMisAligner(Double_t xcartmisaligm = 0.0, Double_t xcartmisaligw =
   cdbData->SetResponsible("Dimuon Offline project");
   cdbData->SetComment("MUON alignment objects with residual misalignment");
   AliCDBId id("MUON/Align/Data", 0, 0); 
-  cdbManager->Put(array, id, cdbData);
+  cdbManager->Put(const_cast<TClonesArray*>(array), id, cdbData);
 
   // To run simulation with misaligned geometry, you have to set
   // the Align option in Config.C: