<commit_before>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit (ITK)
  Module:
  Language:  C++
  Date:
  Version:

Copyright (c) 2000 National Library of Medicine
All rights reserved.

See COPYRIGHT.txt for copyright details.

=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif

#include <iostream>
// This file has been generated by BuildHeaderTest.tcl
// Test to include each header file for Insight

#include "itkAcosImageAdaptor.h"
#include "itkAddImageAdaptor.h"
#include "itkAddPixelAccessor.h"
#include "itkAffineTransform.txx"
#include "itkArray.txx"
#include "itkArray2D.txx"
#include "itkAsinImageAdaptor.h"
#include "itkAtanImageAdaptor.h"
#include "itkAutoPointer.h"
#include "itkAzimuthElevationToCartesianTransform.txx"
#include "itkBSplineDeformableTransform.txx"
#include "itkBSplineDerivativeKernelFunction.h"
#include "itkBSplineInterpolationWeightFunction.txx"
#include "itkBSplineKernelFunction.h"
#include "itkBackwardDifferenceOperator.txx"
#include "itkBinaryBallStructuringElement.txx"
#include "itkBinaryThresholdImageFunction.txx"
#include "itkBloxBoundaryPointImage.txx"
#include "itkBloxBoundaryPointItem.txx"
#include "itkBloxBoundaryPointPixel.txx"
#include "itkBloxBoundaryProfileImage.txx"
#include "itkBloxBoundaryProfileItem.txx"
#include "itkBloxBoundaryProfilePixel.txx"
#include "itkBloxCoreAtomImage.txx"
#include "itkBloxCoreAtomItem.txx"
#include "itkBloxCoreAtomPixel.txx"
#include "itkBloxImage.txx"
#include "itkBloxItem.h"
#include "itkBloxPixel.txx"
#include "itkBluePixelAccessor.h"
#include "itkBoundingBox.txx"
#include "itkByteSwapper.txx"
#include "itkCellBoundary.txx"
#include "itkCellInterface.txx"
#include "itkCellInterfaceVisitor.h"
#include "itkCenteredRigid2DTransform.txx"
#include "itkCenteredTransformInitializer.txx"
#include "itkCentralDifferenceImageFunction.txx"
#include "itkColorTable.txx"
#include "itkCommand.h"
#include "itkConceptChecking.h"
#include "itkConditionalConstIterator.txx"
#include "itkConditionalIterator.txx"
#include "itkConicShellInteriorExteriorSpatialFunction.txx"
#include "itkConstNeighborhoodIterator.txx"
#include "itkConstRandomAccessNeighborhoodIterator.txx"
#include "itkConstShapedNeighborhoodIterator.txx"
#include "itkConstSliceIterator.h"
#include "itkConstSmartNeighborhoodIterator.txx"
#include "itkConstantBoundaryCondition.h"
#include "itkContinuousIndex.h"
#include "itkCosImageAdaptor.h"
#include "itkCovariantVector.txx"
#include "itkCreateObjectFunction.h"
#include "itkDataObject.h"
#include "itkDecisionRuleBase.h"
#include "itkDefaultDynamicMeshTraits.h"
#include "itkDefaultImageTraits.h"
#include "itkDefaultPixelAccessor.h"
#include "itkDefaultStaticMeshTraits.h"
#include "itkDenseFiniteDifferenceImageFilter.txx"
#include "itkDerivativeOperator.txx"
#include "itkDifferenceImageFilter.txx"
#include "itkDirectory.h"
#include "itkDynamicLoader.h"
#include "itkElasticBodyReciprocalSplineKernelTransform.txx"
#include "itkElasticBodySplineKernelTransform.txx"
#include "itkEllipsoidInteriorExteriorSpatialFunction.txx"
#include "itkEntropyPreservingGradientMagnitudeImageFunction.txx"
#include "itkEuler2DTransform.txx"
#include "itkEventObject.h"
#include "itkExceptionObject.h"
#include "itkExpImageAdaptor.h"
#include "itkExpNegativeImageAdaptor.h"
#include "itkFastMutexLock.h"
#include "itkFileOutputWindow.h"
#include "itkFiniteDifferenceFunction.txx"
#include "itkFiniteDifferenceImageFilter.txx"
#include "itkFixedArray.txx"
#include "itkFloodFilledFunctionConditionalConstIterator.txx"
#include "itkFloodFilledFunctionConditionalIterator.txx"
#include "itkFloodFilledImageFunctionConditionalConstIterator.txx"
#include "itkFloodFilledImageFunctionConditionalIterator.txx"
#include "itkFloodFilledSpatialFunctionConditionalConstIterator.txx"
#include "itkFloodFilledSpatialFunctionConditionalIterator.txx"
#include "itkForwardDifferenceOperator.txx"
#include "itkFrustumSpatialFunction.txx"
#include "itkFunctionBase.h"
#include "itkGaussianKernelFunction.h"
#include "itkGaussianOperator.txx"
#include "itkGaussianSpatialFunction.txx"
#include "itkGreenPixelAccessor.h"
#include "itkHexahedronCell.txx"
#include "itkHexahedronCellTopology.h"
#include "itkIdentityTransform.h"
#include "itkImage.txx"
#include "itkImageAdaptor.txx"
#include "itkImageBase.txx"
#include "itkImageBoundaryCondition.h"
#include "itkImageConstIterator.txx"
#include "itkImageConstIteratorWithIndex.txx"
#include "itkImageContainerInterface.h"
#include "itkImageFunction.txx"
#include "itkImageIO.h"
#include "itkImageIOCommon.h"
#include "itkImageIterator.txx"
#include "itkImageIteratorWithIndex.txx"
#include "itkImageLinearConstIteratorWithIndex.txx"
#include "itkImageLinearIteratorWithIndex.txx"
#include "itkImageRandomConstIteratorWithIndex.txx"
#include "itkImageRandomIteratorWithIndex.txx"
#include "itkImageRegion.txx"
#include "itkImageRegionConstIterator.txx"
#include "itkImageRegionConstIteratorWithIndex.txx"
#include "itkImageRegionExclusionConstIteratorWithIndex.txx"
#include "itkImageRegionExclusionIteratorWithIndex.txx"
#include "itkImageRegionIterator.txx"
#include "itkImageRegionIteratorWithIndex.txx"
#include "itkImageRegionMultidimensionalSplitter.txx"
#include "itkImageRegionReverseConstIterator.txx"
#include "itkImageRegionReverseIterator.txx"
#include "itkImageRegionSplitter.txx"
#include "itkImageReverseConstIterator.txx"
#include "itkImageReverseIterator.txx"
#include "itkImageSliceConstIteratorWithIndex.txx"
#include "itkImageSliceIteratorWithIndex.txx"
#include "itkImageSource.txx"
#include "itkImageToImageFilter.txx"
#include "itkImageToImageFilterDetail.h"
#include "itkImportImageContainer.txx"
#include "itkIndent.h"
#include "itkIndex.h"
#include "itkIndexedContainerInterface.h"
#include "itkIntTypes.h"
#include "itkInteriorExteriorSpatialFunction.txx"
#include "itkInterpolateImageFunction.h"
#include "itkIterationReporter.h"
#include "itkKLMSegmentationBorder.h"
#include "itkKLMSegmentationRegion.h"
#include "itkKernelFunction.h"
#include "itkKernelTransform.txx"
#include "itkLaplacianOperator.txx"
#include "itkLevelSet.h"
#include "itkLevelSetCurvatureFunction.txx"
#include "itkLevelSetFunction.txx"
#include "itkLevelSetFunctionBase.txx"
#include "itkLightObject.h"
#include "itkLightProcessObject.h"
#include "itkLineCell.txx"
#include "itkLinearInterpolateImageFunction.txx"
#include "itkLog10ImageAdaptor.h"
#include "itkLogImageAdaptor.h"
#include "itkMacro.h"
#include "itkMapContainer.txx"
#include "itkMatrix.txx"
#include "itkMaximumDecisionRule.h"
#include "itkMeanImageFunction.txx"
#include "itkMedianImageFunction.txx"
#include "itkMesh.txx"
#include "itkMeshRegion.h"
#include "itkMeshSource.txx"
#include "itkMeshToMeshFilter.txx"
#include "itkMinimumDecisionRule.h"
#include "itkMultiThreader.h"
#include "itkMutexLock.h"
#include "itkMutexLockHolder.h"
#include "itkNearestNeighborInterpolateImageFunction.h"
#include "itkNeighborhood.txx"
#include "itkNeighborhoodAlgorithm.txx"
#include "itkNeighborhoodAllocator.h"
#include "itkNeighborhoodBinaryThresholdImageFunction.txx"
#include "itkNeighborhoodInnerProduct.txx"
#include "itkNeighborhoodIterator.txx"
#include "itkNeighborhoodOperator.txx"
#include "itkNthElementImageAdaptor.h"
#include "itkNthElementPixelAccessor.h"
#include "itkNumericTraits.h"
#include "itkObject.h"
#include "itkObjectFactory.h"
#include "itkObjectFactoryBase.h"
#include "itkObjectStore.txx"
#include "itkOffset.h"
#include "itkOutputWindow.h"
#include "itkPixelAccessor.h"
#include "itkPixelTraits.h"
#include "itkPoint.txx"
#include "itkPointLocator.txx"
#include "itkPointSet.txx"
#include "itkPolygonCell.txx"
#include "itkProcessObject.h"
#include "itkProgressReporter.h"
#include "itkQuadraticEdgeCell.txx"
#include "itkQuadraticTriangleCell.txx"
#include "itkQuadraticTriangleCellTopology.h"
#include "itkQuadrilateralCell.txx"
#include "itkQuadrilateralCellTopology.h"
#include "itkQuaternionRigidTransform.txx"
#include "itkRGBAPixel.txx"
#include "itkRGBPixel.txx"
#include "itkRGBToVectorImageAdaptor.h"
#include "itkRGBToVectorPixelAccessor.h"
#include "itkRandomAccessNeighborhoodIterator.txx"
#include "itkRedPixelAccessor.h"
#include "itkRegion.h"
#include "itkRigid2DTransform.txx"
#include "itkRigid3DPerspectiveTransform.txx"
#include "itkRigid3DTransform.txx"
#include "itkSTLConstContainerAdaptor.h"
#include "itkSTLContainerAdaptor.h"
#include "itkScalarVector.h"
#include "itkScaleTransform.txx"
#include "itkSegmentationBorder.h"
#include "itkSegmentationLevelSetFunction.txx"
#include "itkSegmentationRegion.h"
#include "itkShapedNeighborhoodIterator.txx"
#include "itkSimilarity2DTransform.txx"
#include "itkSimpleFastMutexLock.h"
#include "itkSinImageAdaptor.h"
#include "itkSize.h"
#include "itkSliceIterator.h"
#include "itkSmartNeighborhoodIterator.txx"
#include "itkSmartPointer.h"
#include "itkSmartPointerForwardReference.txx"
#include "itkSobelOperator.txx"
#include "itkSpatialFunction.txx"
#include "itkSphereSpatialFunction.txx"
#include "itkSqrtImageAdaptor.h"
#include "itkSymmetricEllipsoidInteriorExteriorSpatialFunction.txx"
#include "itkTanImageAdaptor.h"
#include "itkTetrahedronCell.txx"
#include "itkTetrahedronCellTopology.h"
#include "itkTextOutput.h"
#include "itkThinPlateR2LogRSplineKernelTransform.txx"
#include "itkThinPlateSplineKernelTransform.txx"
#include "itkTimeProbe.h"
#include "itkTimeProbesCollectorBase.h"
#include "itkTimeStamp.h"
#include "itkTorusInteriorExteriorSpatialFunction.txx"
#include "itkTransform.txx"
#include "itkTranslationTransform.txx"
#include "itkTriangleCell.txx"
#include "itkTriangleCellTopology.h"
#include "itkUpwindDerivativeImageFunction.txx"
#include "itkValarrayImageContainer.h"
#include "itkVarianceImageFunction.txx"
#include "itkVector.txx"
#include "itkVectorContainer.txx"
#include "itkVectorInterpolateImageFunction.h"
#include "itkVectorLinearInterpolateImageFunction.txx"
#include "itkVectorNeighborhoodInnerProduct.txx"
#include "itkVectorToRGBImageAdaptor.h"
#include "itkVectorToRGBPixelAccessor.h"
#include "itkVersion.h"
#include "itkVersor.txx"
#include "itkVersorRigid3DTransform.txx"
#include "itkVersorTransform.txx"
#include "itkVertexCell.txx"
#include "itkVolumeSplineKernelTransform.txx"
#include "itkWeakPointer.h"
#include "itkXMLFileOutputWindow.h"
#include "itkZeroFluxNeumannBoundaryCondition.txx"
#include "itk_alloc.h"
#include "itk_hash_map.h"
#include "itk_hash_set.h"
#include "itk_hashtable.h"
#include "vcl_alloc.h"

int main ( int , char*  )
{

  return 0;
}

<commit_msg>ENH: Updated to latest headers<commit_after>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit (ITK)
  Module:
  Language:  C++
  Date:
  Version:

Copyright (c) 2000 National Library of Medicine
All rights reserved.

See COPYRIGHT.txt for copyright details.

=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif

#include <iostream>
// This file has been generated by BuildHeaderTest.tcl
// Test to include each header file for Insight

#include "itkAcosImageAdaptor.h"
#include "itkAddImageAdaptor.h"
#include "itkAddPixelAccessor.h"
#include "itkAffineTransform.txx"
#include "itkArray.txx"
#include "itkArray2D.txx"
#include "itkAsinImageAdaptor.h"
#include "itkAtanImageAdaptor.h"
#include "itkAutoPointer.h"
#include "itkAzimuthElevationToCartesianTransform.txx"
#include "itkBSplineDeformableTransform.txx"
#include "itkBSplineDerivativeKernelFunction.h"
#include "itkBSplineInterpolationWeightFunction.txx"
#include "itkBSplineKernelFunction.h"
#include "itkBackwardDifferenceOperator.txx"
#include "itkBinaryBallStructuringElement.txx"
#include "itkBinaryThresholdImageFunction.txx"
#include "itkBloxBoundaryPointImage.txx"
#include "itkBloxBoundaryPointItem.txx"
#include "itkBloxBoundaryPointPixel.txx"
#include "itkBloxBoundaryProfileImage.txx"
#include "itkBloxBoundaryProfileItem.txx"
#include "itkBloxBoundaryProfilePixel.txx"
#include "itkBloxCoreAtomImage.txx"
#include "itkBloxCoreAtomItem.txx"
#include "itkBloxCoreAtomPixel.txx"
#include "itkBloxImage.txx"
#include "itkBloxItem.h"
#include "itkBloxPixel.txx"
#include "itkBluePixelAccessor.h"
#include "itkBoundingBox.txx"
#include "itkByteSwapper.txx"
#include "itkCellBoundary.txx"
#include "itkCellInterface.txx"
#include "itkCellInterfaceVisitor.h"
#include "itkCenteredRigid2DTransform.txx"
#include "itkCenteredTransformInitializer.txx"
#include "itkCentralDifferenceImageFunction.txx"
#include "itkColorTable.txx"
#include "itkCommand.h"
#include "itkConceptChecking.h"
#include "itkConditionalConstIterator.txx"
#include "itkConditionalIterator.txx"
#include "itkConicShellInteriorExteriorSpatialFunction.txx"
#include "itkConstNeighborhoodIterator.txx"
#include "itkConstRandomAccessNeighborhoodIterator.txx"
#include "itkConstShapedNeighborhoodIterator.txx"
#include "itkConstSliceIterator.h"
#include "itkConstSmartNeighborhoodIterator.txx"
#include "itkConstantBoundaryCondition.h"
#include "itkContinuousIndex.h"
#include "itkCosImageAdaptor.h"
#include "itkCovariantVector.txx"
#include "itkCreateObjectFunction.h"
#include "itkDataObject.h"
#include "itkDecisionRuleBase.h"
#include "itkDefaultDynamicMeshTraits.h"
#include "itkDefaultImageTraits.h"
#include "itkDefaultPixelAccessor.h"
#include "itkDefaultStaticMeshTraits.h"
#include "itkDenseFiniteDifferenceImageFilter.txx"
#include "itkDerivativeOperator.txx"
#include "itkDifferenceImageFilter.txx"
#include "itkDirectory.h"
#include "itkDynamicLoader.h"
#include "itkElasticBodyReciprocalSplineKernelTransform.txx"
#include "itkElasticBodySplineKernelTransform.txx"
#include "itkEllipsoidInteriorExteriorSpatialFunction.txx"
#include "itkEntropyPreservingGradientMagnitudeImageFunction.txx"
#include "itkEuler2DTransform.txx"
#include "itkEventObject.h"
#include "itkExceptionObject.h"
#include "itkExpImageAdaptor.h"
#include "itkExpNegativeImageAdaptor.h"
#include "itkFastMutexLock.h"
#include "itkFileOutputWindow.h"
#include "itkFiniteDifferenceFunction.txx"
#include "itkFiniteDifferenceImageFilter.txx"
#include "itkFixedArray.txx"
#include "itkFloodFilledFunctionConditionalConstIterator.txx"
#include "itkFloodFilledFunctionConditionalIterator.txx"
#include "itkFloodFilledImageFunctionConditionalConstIterator.txx"
#include "itkFloodFilledImageFunctionConditionalIterator.txx"
#include "itkFloodFilledSpatialFunctionConditionalConstIterator.txx"
#include "itkFloodFilledSpatialFunctionConditionalIterator.txx"
#include "itkForwardDifferenceOperator.txx"
#include "itkFrustumSpatialFunction.txx"
#include "itkFunctionBase.h"
#include "itkGaussianKernelFunction.h"
#include "itkGaussianOperator.txx"
#include "itkGaussianSpatialFunction.txx"
#include "itkGreenPixelAccessor.h"
#include "itkHexahedronCell.txx"
#include "itkHexahedronCellTopology.h"
#include "itkIdentityTransform.h"
#include "itkImage.txx"
#include "itkImageAdaptor.txx"
#include "itkImageBase.txx"
#include "itkImageBoundaryCondition.h"
#include "itkImageConstIterator.txx"
#include "itkImageConstIteratorWithIndex.txx"
#include "itkImageContainerInterface.h"
#include "itkImageFunction.txx"
#include "itkImageIO.h"
#include "itkImageIOCommon.h"
#include "itkImageIterator.txx"
#include "itkImageIteratorWithIndex.txx"
#include "itkImageLinearConstIteratorWithIndex.txx"
#include "itkImageLinearIteratorWithIndex.txx"
#include "itkImageRandomConstIteratorWithIndex.txx"
#include "itkImageRandomIteratorWithIndex.txx"
#include "itkImageRegion.txx"
#include "itkImageRegionConstIterator.txx"
#include "itkImageRegionConstIteratorWithIndex.txx"
#include "itkImageRegionExclusionConstIteratorWithIndex.txx"
#include "itkImageRegionExclusionIteratorWithIndex.txx"
#include "itkImageRegionIterator.txx"
#include "itkImageRegionIteratorWithIndex.txx"
#include "itkImageRegionMultidimensionalSplitter.txx"
#include "itkImageRegionReverseConstIterator.txx"
#include "itkImageRegionReverseIterator.txx"
#include "itkImageRegionSplitter.txx"
#include "itkImageReverseConstIterator.txx"
#include "itkImageReverseIterator.txx"
#include "itkImageSliceConstIteratorWithIndex.txx"
#include "itkImageSliceIteratorWithIndex.txx"
#include "itkImageSource.txx"
#include "itkImageToImageFilter.txx"
#include "itkImageToImageFilterDetail.h"
#include "itkImportImageContainer.txx"
#include "itkIndent.h"
#include "itkIndex.h"
#include "itkIndexedContainerInterface.h"
#include "itkIntTypes.h"
#include "itkInteriorExteriorSpatialFunction.txx"
#include "itkInterpolateImageFunction.h"
#include "itkIterationReporter.h"
#include "itkKLMSegmentationBorder.h"
#include "itkKLMSegmentationRegion.h"
#include "itkKernelFunction.h"
#include "itkKernelTransform.txx"
#include "itkLaplacianOperator.txx"
#include "itkLevelSet.h"
#include "itkLevelSetCurvatureFunction.txx"
#include "itkLevelSetFunction.txx"
#include "itkLevelSetFunctionBase.txx"
#include "itkLightObject.h"
#include "itkLightProcessObject.h"
#include "itkLineCell.txx"
#include "itkLinearInterpolateImageFunction.txx"
#include "itkLog10ImageAdaptor.h"
#include "itkLogImageAdaptor.h"
#include "itkMacro.h"
#include "itkMapContainer.txx"
#include "itkMatrix.txx"
#include "itkMaximumDecisionRule.h"
#include "itkMeanImageFunction.txx"
#include "itkMedianImageFunction.txx"
#include "itkMesh.txx"
#include "itkMeshRegion.h"
#include "itkMeshSource.txx"
#include "itkMeshToMeshFilter.txx"
#include "itkMinimumDecisionRule.h"
#include "itkMultiThreader.h"
#include "itkMutexLock.h"
#include "itkMutexLockHolder.h"
#include "itkNearestNeighborInterpolateImageFunction.h"
#include "itkNeighborhood.txx"
#include "itkNeighborhoodAlgorithm.txx"
#include "itkNeighborhoodAllocator.h"
#include "itkNeighborhoodBinaryThresholdImageFunction.txx"
#include "itkNeighborhoodInnerProduct.txx"
#include "itkNeighborhoodIterator.txx"
#include "itkNeighborhoodOperator.txx"
#include "itkNthElementImageAdaptor.h"
#include "itkNthElementPixelAccessor.h"
#include "itkNumericTraits.h"
#include "itkObject.h"
#include "itkObjectFactory.h"
#include "itkObjectFactoryBase.h"
#include "itkObjectStore.txx"
#include "itkOffset.h"
#include "itkOutputWindow.h"
#include "itkPixelAccessor.h"
#include "itkPixelTraits.h"
#include "itkPoint.txx"
#include "itkPointLocator.txx"
#include "itkPointSet.txx"
#include "itkPolygonCell.txx"
#include "itkProcessObject.h"
#include "itkProgressReporter.h"
#include "itkQuadraticEdgeCell.txx"
#include "itkQuadraticTriangleCell.txx"
#include "itkQuadraticTriangleCellTopology.h"
#include "itkQuadrilateralCell.txx"
#include "itkQuadrilateralCellTopology.h"
#include "itkQuaternionRigidTransform.txx"
#include "itkRGBAPixel.txx"
#include "itkRGBPixel.txx"
#include "itkRGBToVectorImageAdaptor.h"
#include "itkRGBToVectorPixelAccessor.h"
#include "itkRandomAccessNeighborhoodIterator.txx"
#include "itkRedPixelAccessor.h"
#include "itkRegion.h"
#include "itkRigid2DTransform.txx"
#include "itkRigid3DPerspectiveTransform.txx"
#include "itkRigid3DTransform.txx"
#include "itkSTLConstContainerAdaptor.h"
#include "itkSTLContainerAdaptor.h"
#include "itkScalarToRGBPixelFunctor.txx"
#include "itkScalarVector.h"
#include "itkScaleTransform.txx"
#include "itkSegmentationBorder.h"
#include "itkSegmentationLevelSetFunction.txx"
#include "itkSegmentationRegion.h"
#include "itkShapedNeighborhoodIterator.txx"
#include "itkSimilarity2DTransform.txx"
#include "itkSimpleFastMutexLock.h"
#include "itkSinImageAdaptor.h"
#include "itkSize.h"
#include "itkSliceIterator.h"
#include "itkSmartNeighborhoodIterator.txx"
#include "itkSmartPointer.h"
#include "itkSmartPointerForwardReference.txx"
#include "itkSobelOperator.txx"
#include "itkSpatialFunction.txx"
#include "itkSphereSpatialFunction.txx"
#include "itkSqrtImageAdaptor.h"
#include "itkSymmetricEllipsoidInteriorExteriorSpatialFunction.txx"
#include "itkTanImageAdaptor.h"
#include "itkTetrahedronCell.txx"
#include "itkTetrahedronCellTopology.h"
#include "itkTextOutput.h"
#include "itkThinPlateR2LogRSplineKernelTransform.txx"
#include "itkThinPlateSplineKernelTransform.txx"
#include "itkTimeProbe.h"
#include "itkTimeProbesCollectorBase.h"
#include "itkTimeStamp.h"
#include "itkTorusInteriorExteriorSpatialFunction.txx"
#include "itkTransform.txx"
#include "itkTranslationTransform.txx"
#include "itkTriangleCell.txx"
#include "itkTriangleCellTopology.h"
#include "itkUpwindDerivativeImageFunction.txx"
#include "itkValarrayImageContainer.h"
#include "itkVarianceImageFunction.txx"
#include "itkVector.txx"
#include "itkVectorContainer.txx"
#include "itkVectorInterpolateImageFunction.h"
#include "itkVectorLinearInterpolateImageFunction.txx"
#include "itkVectorNeighborhoodInnerProduct.txx"
#include "itkVectorToRGBImageAdaptor.h"
#include "itkVectorToRGBPixelAccessor.h"
#include "itkVersion.h"
#include "itkVersor.txx"
#include "itkVersorRigid3DTransform.txx"
#include "itkVersorTransform.txx"
#include "itkVertexCell.txx"
#include "itkVolumeSplineKernelTransform.txx"
#include "itkWeakPointer.h"
#include "itkXMLFileOutputWindow.h"
#include "itkZeroFluxNeumannBoundaryCondition.txx"
#include "itk_alloc.h"
#include "itk_hash_map.h"
#include "itk_hash_set.h"
#include "itk_hashtable.h"
#include "vcl_alloc.h"

int main ( int , char*  )
{

  return 0;
}

<|endoftext|>


<commit_before>/*
* This source file is part of ArkGameFrame
* For the latest info, see https://github.com/ArkGame
*
* Copyright (c) 2013-2017 ArkGame authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include "AFCGUIDModule.h"

namespace GUIDModule
{
//https://github.com/nebula-im/snowflake4cxx
/**
* Twitter_Snowflake
* SnowFlakeĽṹ(ÿ-ֿ):
* 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000
* 1λʶlongJavaǴŵģλǷλ01idһλ0
* 41λʱ(뼶)ע⣬41λʱزǴ洢ǰʱʱأǴ洢ʱصĲֵǰʱ - ʼʱ)
* õֵĵĿʼʱأһǵidʼʹõʱ䣬ǳָģIdWorkerstartTimeԣ41λʱأʹ69꣬T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69
* 10λݻλԲ1024ڵ㣬5λdatacenterId5λworkerId
* 12λУڵļ12λļ˳֧ÿڵÿ(ͬһͬһʱ)4096ID
* պ64λ
* SnowFlakeŵǣϰʱ򣬲ֲʽϵͳڲIDײ(IDͻID)Чʽϸߡ
*/

#ifndef _MSC_VER
# include <sys/time.h>
#else
# include <windows.h>
# include <winsock2.h>
# include <time.h>
#endif

#ifdef _MSC_VER
int gettimeofday(struct timeval* tp, void *tzp)
{
    time_t clock;
    struct tm tm;
    SYSTEMTIME wtm;
    GetLocalTime(&wtm);
    tm.tm_year = wtm.wYear - 1900;
    tm.tm_mon = wtm.wMonth - 1;
    tm.tm_mday = wtm.wDay;
    tm.tm_hour = wtm.wHour;
    tm.tm_min = wtm.wMinute;
    tm.tm_sec = wtm.wSecond;
    tm.tm_isdst = -1;
    clock = mktime(&tm);
    tp->tv_sec = clock;
    tp->tv_usec = wtm.wMilliseconds * 1000;
    return (0);
}
#endif

uint64_t GetNowInMsec()
{
    struct timeval tv;
    int  nRet = gettimeofday(&tv, 0);
    return uint64_t(tv.tv_sec) * 1000 + tv.tv_usec / 1000;
}

uint64_t WaitUntilNextMillis(uint64_t last_timestamp)
{
    uint64_t timestamp = GetNowInMsec();
    while(timestamp <= last_timestamp)
    {
        timestamp = GetNowInMsec();
    }
    return timestamp;
}

class IdWorkerUnThreadSafe
{
public:
    IdWorkerUnThreadSafe(uint16_t worker_id, uint16_t data_center_id)
        : worker_id_(worker_id)
        , data_center_id_(data_center_id)
    {}

    uint64_t GetNextID()
    {
        uint64_t timestamp = GetNowInMsec();

        // 在当前秒?
        if(last_timestamp_ == timestamp)
        {
            sequence_ = (sequence_ + 1) & 0xFFF;
            if(sequence_ == 0)
            {
                timestamp = WaitUntilNextMillis(last_timestamp_);
            }
        }
        else
        {
            sequence_ = 0;
        }

        last_timestamp_ = timestamp;
        return ((timestamp & 0x1FFFFFF) << 22 |
                (data_center_id_ & 0x1F) << 17 |
                (worker_id_ & 0x1F) << 12 |
                (sequence_ & 0xFFF));
    }

protected:
    uint16_t worker_id_{ 0 };
    uint16_t data_center_id_{ 0 };
    uint64_t last_timestamp_{ 0 };
    uint32_t sequence_{ 0 };
};

class IdWorkerThreadSafe
{
public:
    IdWorkerThreadSafe(uint16_t worker_id, uint16_t data_center_id)
        : id_worker_(worker_id, data_center_id)
    {}

    uint64_t GetNextID()
    {
        std::lock_guard<std::mutex> g(lock_);
        return id_worker_.GetNextID();
    }

protected:
    IdWorkerUnThreadSafe id_worker_;
    std::mutex lock_;
};
}

//////////////////////////////////////////////////////////////////////////

AFCGUIDModule::AFCGUIDModule(AFIPluginManager* p)
{
    pPluginManager = p;
}

bool AFCGUIDModule::Init()
{
    return true;
}

bool AFCGUIDModule::AfterInit()
{
    return true;
}

bool AFCGUIDModule::Execute()
{
    return true;
}

bool AFCGUIDModule::BeforeShut()
{
    if(NULL != m_pIDWoker)
    {
        delete m_pIDWoker;
        m_pIDWoker = NULL;
    }

    return true;
}

bool AFCGUIDModule::Shut()
{
    return true;
}

void AFCGUIDModule::SetWorkerAndDatacenter(uint16_t worker_id, uint16_t data_center_id)
{
#ifdef AF_THREAD_SAFE
    m_pIDWoker = ARK_NEW GUIDModule::IdWorkerThreadSafe(worker_id, data_center_id);
#else
    m_pIDWoker = ARK_NEW GUIDModule::IdWorkerUnThreadSafe(worker_id, data_center_id);
#endif
}

uint64_t AFCGUIDModule::CreateGUID()
{
    assert(NULL != m_pIDWoker);

    return m_pIDWoker->GetNextID();
}
<commit_msg>add time epoch for GUID<commit_after>/*
* This source file is part of ArkGameFrame
* For the latest info, see https://github.com/ArkGame
*
* Copyright (c) 2013-2017 ArkGame authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include "AFCGUIDModule.h"

namespace GUIDModule
{
//https://github.com/nebula-im/snowflake4cxx
/**
* Twitter_Snowflake
* SnowFlakeĽṹ(ÿ-ֿ):
* 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000
* 1λʶlongJavaǴŵģλǷλ01idһλ0
* 41λʱ(뼶)ע⣬41λʱزǴ洢ǰʱʱأǴ洢ʱصĲֵǰʱ - ʼʱ)
* õֵĵĿʼʱأһǵidʼʹõʱ䣬ǳָģIdWorkerstartTimeԣ41λʱأʹ69꣬T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69
* 10λݻλԲ1024ڵ㣬5λdatacenterId5λworkerId
* 12λУڵļ12λļ˳֧ÿڵÿ(ͬһͬһʱ)4096ID
* պ64λ
* SnowFlakeŵǣϰʱ򣬲ֲʽϵͳڲIDײ(IDͻID)Чʽϸߡ
*/

#ifndef _MSC_VER
# include <sys/time.h>
#else
# include <windows.h>
# include <winsock2.h>
# include <time.h>
#endif

#define ARK_EPOCH 1288834974657L

#ifdef _MSC_VER
int gettimeofday(struct timeval* tp, void *tzp)
{
    time_t clock;
    struct tm tm;
    SYSTEMTIME wtm;
    GetLocalTime(&wtm);
    tm.tm_year = wtm.wYear - 1900;
    tm.tm_mon = wtm.wMonth - 1;
    tm.tm_mday = wtm.wDay;
    tm.tm_hour = wtm.wHour;
    tm.tm_min = wtm.wMinute;
    tm.tm_sec = wtm.wSecond;
    tm.tm_isdst = -1;
    clock = mktime(&tm);
    tp->tv_sec = clock;
    tp->tv_usec = wtm.wMilliseconds * 1000;
    return (0);
}
#endif

uint64_t GetNowInMsec()
{
    struct timeval tv;
    int  nRet = gettimeofday(&tv, 0);
    return uint64_t(tv.tv_sec) * 1000 + tv.tv_usec / 1000;
}

uint64_t WaitUntilNextMillis(uint64_t last_timestamp)
{
    uint64_t timestamp = GetNowInMsec();
    while(timestamp <= last_timestamp)
    {
        timestamp = GetNowInMsec();
    }
    return timestamp;
}

class IdWorkerUnThreadSafe
{
public:
    IdWorkerUnThreadSafe(uint16_t worker_id, uint16_t data_center_id)
        : worker_id_(worker_id)
        , data_center_id_(data_center_id)
    {}

    uint64_t GetNextID()
    {
        uint64_t timestamp = GetNowInMsec();

        //in current microsecond
        if(last_timestamp_ == timestamp)
        {
            sequence_ = (sequence_ + 1) & 0xFFF;
            if(sequence_ == 0)
            {
                timestamp = WaitUntilNextMillis(last_timestamp_);
            }
        }
        else
        {
            sequence_ = 0;
        }

        last_timestamp_ = timestamp;
        return (
            (timestamp - ARK_EPOCH) << 22
            | data_center_id_ << 17
            | worker_id_ << 12
            | sequence_);
    }

protected:
    uint16_t worker_id_{ 0 };
    uint16_t data_center_id_{ 0 };
    uint64_t last_timestamp_{ 0 };
    uint32_t sequence_{ 0 };
};

class IdWorkerThreadSafe
{
public:
    IdWorkerThreadSafe(uint16_t worker_id, uint16_t data_center_id)
        : id_worker_(worker_id, data_center_id)
    {}

    uint64_t GetNextID()
    {
        std::lock_guard<std::mutex> g(lock_);
        return id_worker_.GetNextID();
    }

protected:
    IdWorkerUnThreadSafe id_worker_;
    std::mutex lock_;
};
}

//////////////////////////////////////////////////////////////////////////

AFCGUIDModule::AFCGUIDModule(AFIPluginManager* p)
{
    pPluginManager = p;
}

bool AFCGUIDModule::Init()
{
    return true;
}

bool AFCGUIDModule::AfterInit()
{
    return true;
}

bool AFCGUIDModule::Execute()
{
    return true;
}

bool AFCGUIDModule::BeforeShut()
{
    if(NULL != m_pIDWoker)
    {
        delete m_pIDWoker;
        m_pIDWoker = NULL;
    }

    return true;
}

bool AFCGUIDModule::Shut()
{
    return true;
}

void AFCGUIDModule::SetWorkerAndDatacenter(uint16_t worker_id, uint16_t data_center_id)
{
#ifdef AF_THREAD_SAFE
    m_pIDWoker = ARK_NEW GUIDModule::IdWorkerThreadSafe(worker_id, data_center_id);
#else
    m_pIDWoker = ARK_NEW GUIDModule::IdWorkerUnThreadSafe(worker_id, data_center_id);
#endif
}

uint64_t AFCGUIDModule::CreateGUID()
{
    assert(NULL != m_pIDWoker);

    return m_pIDWoker->GetNextID();
}
<|endoftext|>


<commit_before>/**
 *  For conditions of distribution and use, see copyright notice in license.txt
 *
 *  @file   EC_Hydrax.cpp
 *  @brief  A photorealistic water plane component using Hydrax, http://www.ogre3d.org/tikiwiki/Hydrax
 */

#define OGRE_INTEROP

#include "DebugOperatorNew.h"

#include "EC_Hydrax.h"

#include "Scene.h"
#include "Framework.h"
#include "FrameAPI.h"
#include "AssetAPI.h"
#include "IAssetTransfer.h"
#include "IAsset.h"

#include "OgreWorld.h"
#include "Renderer.h"
#include "EC_Camera.h"
#include "Entity.h"
#include "OgreConversionUtils.h"
#include "Profiler.h"

#include "AttributeMetadata.h"
#ifdef SKYX_ENABLED
#include "EC_SkyX.h"
#endif

#include <Hydrax.h>
#include <Noise/Perlin/Perlin.h>
#include <Noise/FFT/FFT.h>
#include <Modules/ProjectedGrid/ProjectedGrid.h>
#include <Modules/RadialGrid/RadialGrid.h>
#include <Modules/SimpleGrid/SimpleGrid.h>

#include "LoggingFunctions.h"
#include "MemoryLeakCheck.h"

struct EC_HydraxImpl
{
    EC_HydraxImpl() : hydrax(0), module(0) {}
    ~EC_HydraxImpl()
    {
        if (hydrax)
            hydrax->remove();
        SAFE_DELETE(hydrax);
        //SAFE_DELETE(module); ///< @todo Possible mem leak?
    }

    Hydrax::Hydrax *hydrax;
    Hydrax::Module::Module *module;
#ifdef SKYX_ENABLED
    boost::weak_ptr<EC_SkyX> skyX;
#endif
};

EC_Hydrax::EC_Hydrax(Scene* scene) :
    IComponent(scene),
    configRef(this, "Config ref", AssetReference("HydraxDefault.hdx")),
    visible(this, "Visible", true),
    position(this, "Position"),
//    noiseModule(this, "Noise module", 0),
//    noiseType(this, "Noise type", 0),
//    normalMode(this, "Normal mode", 0),
    impl(0)
{
/*
    static AttributeMetadata noiseTypeMetadata;
    static AttributeMetadata normalModeMetadata;
    static bool metadataInitialized = false;
    if (!metadataInitialized)
    {
        noiseTypeMetadata.enums[Perlin] = "Perlin";
        noiseTypeMetadata.enums[FFT] = "FFT";

        normalModeMetadata.enums[Texture] = "Texture";
        normalModeMetadata.enums[Vertex] = "Vertex";
        normalModeMetadata.enums[RTT] = "RTT";

        metadataInitialized = true;
    }

    noiseType.SetMetadata(&noiseTypeMetadata);
    normalMode.SetMetadata(&normalModeMetadata);
*/
    OgreWorldPtr w = scene->GetWorld<OgreWorld>();
    if (!w)
    {
        LogError("EC_Hydrax: no OgreWorld available. Cannot be created.");
        return;
    }

    connect(w->GetRenderer(), SIGNAL(MainCameraChanged(Entity *)), SLOT(OnActiveCameraChanged(Entity *)));
    connect(this, SIGNAL(ParentEntitySet()), SLOT(Create()));
}

EC_Hydrax::~EC_Hydrax()
{
    SAFE_DELETE(impl);
}

void EC_Hydrax::Create()
{
    SAFE_DELETE(impl);

    try
    {
        if (!ParentScene())
        {
            LogError("EC_Hydrax: no parent scene. Cannot be created.");
            return;
        }

        OgreWorldPtr w = ParentScene()->GetWorld<OgreWorld>();
        assert(w);

        Entity *mainCamera = w->GetRenderer()->MainCamera();
        if (!mainCamera)
        {
            LogError("Cannot create EC_Hydrax: No main camera set!");
            return; // Can't create Hydrax just yet, no main camera set.
        }

        Ogre::Camera *cam = mainCamera->GetComponent<EC_Camera>()->GetCamera();
        impl = new EC_HydraxImpl();
        impl->hydrax = new Hydrax::Hydrax(w->GetSceneManager(), cam, w->GetRenderer()->MainViewport());

        // Using projected grid module by default
        Hydrax::Module::ProjectedGrid *module = new Hydrax::Module::ProjectedGrid(impl->hydrax, new Hydrax::Noise::Perlin(),
            Ogre::Plane(Ogre::Vector3::UNIT_Y, Ogre::Vector3::ZERO), Hydrax::MaterialManager::NM_VERTEX);
        impl->hydrax->setModule(module);
        impl->module = module;

        // Load all parameters from config file
        impl->hydrax->loadCfg(configRef.Get().ref.toStdString());

//        position.Set(impl->hydrax->getPosition(), AttributeChange::Disconnected);

        impl->hydrax->create();

        connect(framework->Frame(), SIGNAL(PostFrameUpdate(float)), SLOT(Update(float)), Qt::UniqueConnection);
        connect(this, SIGNAL(AttributeChanged(IAttribute*, AttributeChange::Type)), SLOT(UpdateAttribute(IAttribute*)), Qt::UniqueConnection);
    }
    catch(Ogre::Exception &e)
    {
        // Currently if we try to create more than one Hydrax component we end up here due to Ogre internal name collision.
        LogError("Could not create EC_Hydrax: " + std::string(e.what()));
    }
}

void EC_Hydrax::OnActiveCameraChanged(Entity *newActiveCamera)
{
    if (!newActiveCamera)
    {
        SAFE_DELETE(impl);
        return;
    }
    // If we haven't yet initialized, do a full init.
    if (!impl)
        Create();
    else // Otherwise, update the camera to an existing initialized Hydrax instance.
        if (impl && impl->hydrax)
            impl->hydrax->setCamera(newActiveCamera->GetComponent<EC_Camera>()->GetCamera());
}

void EC_Hydrax::UpdateAttribute(IAttribute *attr)
{
    if (attr == &configRef)
    {
        if (!configRef.Get().ref.isEmpty())
        {
            AssetTransferPtr transfer = framework->Asset()->RequestAsset(configRef.Get().ref, "Binary");
            if (transfer.get())
                connect(transfer.get(), SIGNAL(Succeeded(AssetPtr)), SLOT(ConfigLoadSucceeded(AssetPtr)), Qt::UniqueConnection);
        }
        else
            LoadDefaultConfig();
    }

    if (!impl->hydrax)
        return;
    if (attr == &configRef)
    {
        impl->hydrax->loadCfg(configRef.Get().ref.toStdString());
        // The position attribute is always authoritative for the position value.
        impl->hydrax->setPosition(position.Get());
    }
    else if (attr == &visible)
        impl->hydrax->setVisible(visible.Get());
    else if (attr == &position)
        impl->hydrax->setPosition(position.Get());
/*
    else if (attr == &noiseModule || attr == &normalMode || &noiseType)
        UpdateNoiseModule();
*/
}
/*
void EC_Hydrax::UpdateNoiseModule()
{
    Hydrax::Noise::Noise *noise = 0;
    switch(noiseType.Get())
    {
    case Perlin:
        noise = new Hydrax::Noise::Perlin();
        break;
    case FFT:
        noise = new Hydrax::Noise::FFT();
        break;
    default:
        LogError("Invalid Hydrax noise module type.");
        return;
    }

    Hydrax::Module::Module *module = 0;
    switch(noiseModule.Get())
    {
    case ProjectedGrid:
        module = new Hydrax::Module::ProjectedGrid(impl->hydrax, noise, Ogre::Plane(Ogre::Vector3::UNIT_Y, Ogre::Vector3::ZERO),
            (Hydrax::MaterialManager::NormalMode)normalMode.Get());
        break;
    case RadialGrid:
        module = new Hydrax::Module::RadialGrid(impl->hydrax, noise, (Hydrax::MaterialManager::NormalMode)normalMode.Get());
        break;
    case SimpleGrid:
        module = new Hydrax::Module::SimpleGrid(impl->hydrax, noise, (Hydrax::MaterialManager::NormalMode)normalMode.Get());
        break;
    default:
        SAFE_DELETE(noise);
        LogError("Invalid Hydrax noise module type.");
        return;
    }
    //if (impl->module && noise)
    //    impl->module->setNoise(noise);

    impl->hydrax->setModule(module);
    impl->module = module;
    //impl->hydrax->loadCfg("HydraxDemo.hdx");
    impl->hydrax->create();
}
*/
void EC_Hydrax::Update(float frameTime)
{
    if (impl->hydrax)
    {
        PROFILE(EC_Hydrax_Update);
#ifdef SKYX_ENABLED
        // Find out if we have SkyX in the scene. If yes, use its sun position.
        if (impl->skyX.expired())
        {
            EntityList entities = ParentEntity()->ParentScene()->GetEntitiesWithComponent(EC_SkyX::TypeNameStatic());
            if (!entities.empty())
                impl->skyX = (*entities.begin())->GetComponent<EC_SkyX>();
        }
        if (!impl->skyX.expired())
            impl->hydrax->setSunPosition(impl->skyX.lock()->SunPosition());
#endif
        impl->hydrax->update(frameTime);
    }
}

void EC_Hydrax::ConfigLoadSucceeded(AssetPtr asset)
{
    if (!impl || !impl->hydrax || !impl->module)
    {
        LogError("EC_Hydrax: Could not apply loaded config, hydrax not initialized.");
        return;
    }

    std::vector<u8> rawData;
    asset->SerializeTo(rawData);
    QString configData = QString::fromAscii((const char*)&rawData[0], rawData.size());

    if (configData.isEmpty())
    {
        LogInfo("EC_Hydrax: Downloaded config is empty!");
        return;
    }

    try
    {
        // Update the noise module
        if (configData.contains("noise=fft", Qt::CaseInsensitive))
        {
            /// \note Using the FFT noise plugin seems to crash somewhere after we leave this function.
            /// FFT looks better so would be nice to investigate further!
            if (impl->module->getNoise()->getName() != "FFT")
                impl->module->setNoise(new Hydrax::Noise::FFT());
        }
        else if (configData.contains("noise=perlin", Qt::CaseInsensitive))
        {
            if (impl->module->getNoise()->getName() != "Perlin")
                impl->module->setNoise(new Hydrax::Noise::Perlin());
        }
        else
        {
            LogError("EC_Hydrax: Unknown noise param in loaded config, acceptable = FFT/Perlin.");
            return;
        }

        // Load config from the asset data string.
        impl->hydrax->loadCfgString(configData.toStdString());
    }
    catch (Ogre::Exception &e)
    {
        LogError(std::string("EC_Hydrax: Ogre threw exception while loading new config: ") + e.what());
    }
}

void EC_Hydrax::LoadDefaultConfig()
{
    if (!impl || !impl->hydrax || !impl->module)
    {
        LogError("EC_Hydrax: Could not apply default config, hydrax not initialized.");
        return;
    }

    if (impl->module->getNoise()->getName() != "Perlin")
        impl->module->setNoise(new Hydrax::Noise::Perlin());

    // Load all parameters from the default config file we ship in /media/hydrax
    /// \todo Inspect if we can change the current ShaderMode to HLSL or GLSL on the fly here, depending on the platform!
    impl->hydrax->loadCfg("HydraxDefault.hdx");
}
<commit_msg>Position attribute of EC_Hydrax is always authoritative for the water's position. Fixes #125, https://github.com/realXtend/naali/issues/125<commit_after>/**
 *  For conditions of distribution and use, see copyright notice in license.txt
 *
 *  @file   EC_Hydrax.cpp
 *  @brief  A photorealistic water plane component using Hydrax, http://www.ogre3d.org/tikiwiki/Hydrax
 */

#define OGRE_INTEROP

#include "DebugOperatorNew.h"

#include "EC_Hydrax.h"

#include "Scene.h"
#include "Framework.h"
#include "FrameAPI.h"
#include "AssetAPI.h"
#include "IAssetTransfer.h"
#include "IAsset.h"

#include "OgreWorld.h"
#include "Renderer.h"
#include "EC_Camera.h"
#include "Entity.h"
#include "OgreConversionUtils.h"
#include "Profiler.h"

#include "AttributeMetadata.h"
#ifdef SKYX_ENABLED
#include "EC_SkyX.h"
#endif

#include <Hydrax.h>
#include <Noise/Perlin/Perlin.h>
#include <Noise/FFT/FFT.h>
#include <Modules/ProjectedGrid/ProjectedGrid.h>
#include <Modules/RadialGrid/RadialGrid.h>
#include <Modules/SimpleGrid/SimpleGrid.h>

#include "LoggingFunctions.h"
#include "MemoryLeakCheck.h"

struct EC_HydraxImpl
{
    EC_HydraxImpl() : hydrax(0), module(0) {}
    ~EC_HydraxImpl()
    {
        if (hydrax)
            hydrax->remove();
        SAFE_DELETE(hydrax);
        //SAFE_DELETE(module); ///< @todo Possible mem leak?
    }

    Hydrax::Hydrax *hydrax;
    Hydrax::Module::Module *module;
#ifdef SKYX_ENABLED
    boost::weak_ptr<EC_SkyX> skyX;
#endif
};

EC_Hydrax::EC_Hydrax(Scene* scene) :
    IComponent(scene),
    configRef(this, "Config ref", AssetReference("HydraxDefault.hdx")),
    visible(this, "Visible", true),
    position(this, "Position"),
//    noiseModule(this, "Noise module", 0),
//    noiseType(this, "Noise type", 0),
//    normalMode(this, "Normal mode", 0),
    impl(0)
{
/*
    static AttributeMetadata noiseTypeMetadata;
    static AttributeMetadata normalModeMetadata;
    static bool metadataInitialized = false;
    if (!metadataInitialized)
    {
        noiseTypeMetadata.enums[Perlin] = "Perlin";
        noiseTypeMetadata.enums[FFT] = "FFT";

        normalModeMetadata.enums[Texture] = "Texture";
        normalModeMetadata.enums[Vertex] = "Vertex";
        normalModeMetadata.enums[RTT] = "RTT";

        metadataInitialized = true;
    }

    noiseType.SetMetadata(&noiseTypeMetadata);
    normalMode.SetMetadata(&normalModeMetadata);
*/
    OgreWorldPtr w = scene->GetWorld<OgreWorld>();
    if (!w)
    {
        LogError("EC_Hydrax: no OgreWorld available. Cannot be created.");
        return;
    }

    connect(w->GetRenderer(), SIGNAL(MainCameraChanged(Entity *)), SLOT(OnActiveCameraChanged(Entity *)));
    connect(this, SIGNAL(ParentEntitySet()), SLOT(Create()));
}

EC_Hydrax::~EC_Hydrax()
{
    SAFE_DELETE(impl);
}

void EC_Hydrax::Create()
{
    SAFE_DELETE(impl);

    try
    {
        if (!ParentScene())
        {
            LogError("EC_Hydrax: no parent scene. Cannot be created.");
            return;
        }

        OgreWorldPtr w = ParentScene()->GetWorld<OgreWorld>();
        assert(w);

        Entity *mainCamera = w->GetRenderer()->MainCamera();
        if (!mainCamera)
        {
            LogError("Cannot create EC_Hydrax: No main camera set!");
            return; // Can't create Hydrax just yet, no main camera set.
        }

        Ogre::Camera *cam = mainCamera->GetComponent<EC_Camera>()->GetCamera();
        impl = new EC_HydraxImpl();
        impl->hydrax = new Hydrax::Hydrax(w->GetSceneManager(), cam, w->GetRenderer()->MainViewport());

        // Using projected grid module by default
        Hydrax::Module::ProjectedGrid *module = new Hydrax::Module::ProjectedGrid(impl->hydrax, new Hydrax::Noise::Perlin(),
            Ogre::Plane(Ogre::Vector3::UNIT_Y, Ogre::Vector3::ZERO), Hydrax::MaterialManager::NM_VERTEX);
        impl->hydrax->setModule(module);
        impl->module = module;

        // Load all parameters from config file, but position attribute is always authoritative for the position.
        impl->hydrax->loadCfg(configRef.Get().ref.toStdString());
        impl->hydrax->setPosition(position.Get());
        impl->hydrax->create();

        connect(framework->Frame(), SIGNAL(PostFrameUpdate(float)), SLOT(Update(float)), Qt::UniqueConnection);
        connect(this, SIGNAL(AttributeChanged(IAttribute*, AttributeChange::Type)), SLOT(UpdateAttribute(IAttribute*)), Qt::UniqueConnection);
    }
    catch(Ogre::Exception &e)
    {
        // Currently if we try to create more than one Hydrax component we end up here due to Ogre internal name collision.
        LogError("Could not create EC_Hydrax: " + std::string(e.what()));
    }
}

void EC_Hydrax::OnActiveCameraChanged(Entity *newActiveCamera)
{
    if (!newActiveCamera)
    {
        SAFE_DELETE(impl);
        return;
    }
    // If we haven't yet initialized, do a full init.
    if (!impl)
        Create();
    else // Otherwise, update the camera to an existing initialized Hydrax instance.
        if (impl && impl->hydrax)
            impl->hydrax->setCamera(newActiveCamera->GetComponent<EC_Camera>()->GetCamera());
}

void EC_Hydrax::UpdateAttribute(IAttribute *attr)
{
    if (attr == &configRef)
    {
        if (!configRef.Get().ref.isEmpty())
        {
            AssetTransferPtr transfer = framework->Asset()->RequestAsset(configRef.Get().ref, "Binary");
            if (transfer.get())
                connect(transfer.get(), SIGNAL(Succeeded(AssetPtr)), SLOT(ConfigLoadSucceeded(AssetPtr)), Qt::UniqueConnection);
        }
        else
            LoadDefaultConfig();
    }

    if (!impl->hydrax)
        return;
    if (attr == &configRef)
    {
        impl->hydrax->loadCfg(configRef.Get().ref.toStdString());
        impl->hydrax->setPosition(position.Get()); // The position attribute is always authoritative for the position value.
    }
    else if (attr == &visible)
        impl->hydrax->setVisible(visible.Get());
    else if (attr == &position)
        impl->hydrax->setPosition(position.Get());
/*
    else if (attr == &noiseModule || attr == &normalMode || &noiseType)
        UpdateNoiseModule();
*/
}
/*
void EC_Hydrax::UpdateNoiseModule()
{
    Hydrax::Noise::Noise *noise = 0;
    switch(noiseType.Get())
    {
    case Perlin:
        noise = new Hydrax::Noise::Perlin();
        break;
    case FFT:
        noise = new Hydrax::Noise::FFT();
        break;
    default:
        LogError("Invalid Hydrax noise module type.");
        return;
    }

    Hydrax::Module::Module *module = 0;
    switch(noiseModule.Get())
    {
    case ProjectedGrid:
        module = new Hydrax::Module::ProjectedGrid(impl->hydrax, noise, Ogre::Plane(Ogre::Vector3::UNIT_Y, Ogre::Vector3::ZERO),
            (Hydrax::MaterialManager::NormalMode)normalMode.Get());
        break;
    case RadialGrid:
        module = new Hydrax::Module::RadialGrid(impl->hydrax, noise, (Hydrax::MaterialManager::NormalMode)normalMode.Get());
        break;
    case SimpleGrid:
        module = new Hydrax::Module::SimpleGrid(impl->hydrax, noise, (Hydrax::MaterialManager::NormalMode)normalMode.Get());
        break;
    default:
        SAFE_DELETE(noise);
        LogError("Invalid Hydrax noise module type.");
        return;
    }
    //if (impl->module && noise)
    //    impl->module->setNoise(noise);

    impl->hydrax->setModule(module);
    impl->module = module;
    //impl->hydrax->loadCfg("HydraxDemo.hdx");
    impl->hydrax->create();
}
*/
void EC_Hydrax::Update(float frameTime)
{
    if (impl->hydrax)
    {
        PROFILE(EC_Hydrax_Update);
#ifdef SKYX_ENABLED
        // Find out if we have SkyX in the scene. If yes, use its sun position.
        if (impl->skyX.expired())
        {
            EntityList entities = ParentEntity()->ParentScene()->GetEntitiesWithComponent(EC_SkyX::TypeNameStatic());
            if (!entities.empty())
                impl->skyX = (*entities.begin())->GetComponent<EC_SkyX>();
        }
        if (!impl->skyX.expired())
            impl->hydrax->setSunPosition(impl->skyX.lock()->SunPosition());
#endif
        impl->hydrax->update(frameTime);
    }
}

void EC_Hydrax::ConfigLoadSucceeded(AssetPtr asset)
{
    if (!impl || !impl->hydrax || !impl->module)
    {
        LogError("EC_Hydrax: Could not apply loaded config, hydrax not initialized.");
        return;
    }

    std::vector<u8> rawData;
    asset->SerializeTo(rawData);
    QString configData = QString::fromAscii((const char*)&rawData[0], rawData.size());

    if (configData.isEmpty())
    {
        LogInfo("EC_Hydrax: Downloaded config is empty!");
        return;
    }

    try
    {
        // Update the noise module
        if (configData.contains("noise=fft", Qt::CaseInsensitive))
        {
            /// \note Using the FFT noise plugin seems to crash somewhere after we leave this function.
            /// FFT looks better so would be nice to investigate further!
            if (impl->module->getNoise()->getName() != "FFT")
                impl->module->setNoise(new Hydrax::Noise::FFT());
        }
        else if (configData.contains("noise=perlin", Qt::CaseInsensitive))
        {
            if (impl->module->getNoise()->getName() != "Perlin")
                impl->module->setNoise(new Hydrax::Noise::Perlin());
        }
        else
        {
            LogError("EC_Hydrax: Unknown noise param in loaded config, acceptable = FFT/Perlin.");
            return;
        }

        // Load config from the asset data string.
        impl->hydrax->loadCfgString(configData.toStdString());
        impl->hydrax->setPosition(position.Get());  // The position attribute is always authoritative for the position value.
    }
    catch (Ogre::Exception &e)
    {
        LogError(std::string("EC_Hydrax: Ogre threw exception while loading new config: ") + e.what());
    }
}

void EC_Hydrax::LoadDefaultConfig()
{
    if (!impl || !impl->hydrax || !impl->module)
    {
        LogError("EC_Hydrax: Could not apply default config, Hydrax not initialized.");
        return;
    }

    if (impl->module->getNoise()->getName() != "Perlin")
        impl->module->setNoise(new Hydrax::Noise::Perlin());

    // Load all parameters from the default config file in /media/Hydrax
    /// \todo Inspect if we can change the current ShaderMode to HLSL or GLSL on the fly here, depending on the platform!
    impl->hydrax->loadCfg("HydraxDefault.hdx");
    impl->hydrax->setPosition(position.Get());  // The position attribute is always authoritative for the position value.
}
<|endoftext|>


<commit_before>// Entry point to the program.

#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>

#include "AbsProgramGenerator.h"
#include "CGOptions.h"
#include "CLSmith/CLOptions.h"
#include "CLSmith/CLOutputMgr.h"
#include "CLSmith/CLProgramGenerator.h"
#include "platform.h"

// Generator seed.
static unsigned long g_Seed = 0;

bool CheckArgExists(int idx, int argc) {
  if (idx >= argc) std::cout << "Expected another argument" << std::endl;
  return idx < argc;
}

bool ParseIntArg(const char *arg, unsigned long *value) {
  bool res = sscanf(arg, "%lu", value);
  if (!res) std::cout << "Expected integer arg for " << arg << std::endl;
  return res;
}

int main(int argc, char **argv) {
  g_Seed = platform_gen_seed();
  CGOptions::set_default_settings();
  CLSmith::CLOptions::set_default_settings();
  std::string output_filename = "";

  // Parse command line arguments.
  for (int idx = 1; idx < argc; ++idx) {
    if (!strcmp(argv[idx], "--seed") ||
        !strcmp(argv[idx], "-s")) {
      ++idx;
      if (!CheckArgExists(idx, argc)) return -1;
      if (!ParseIntArg(argv[idx], &g_Seed)) return -1;
      continue;
    }

    if (!strcmp(argv[idx], "--output_file") ||
        !strcmp(argv[idx], "-o")) {
      ++idx;
      if (!CheckArgExists(idx, argc)) return -1;
      CLSmith::CLOptions::output(argv[idx]);
      continue;
    }

    if (!strcmp(argv[idx], "--atomics")) {
      CLSmith::CLOptions::atomics(true);
      continue;
    }

    if (!strcmp(argv[idx], "--barriers")) {
      CLSmith::CLOptions::barriers(true);
      continue;
    }

    if (!strcmp(argv[idx], "--divergence")) {
      CLSmith::CLOptions::divergence(true);
      continue;
    }

    if (!strcmp(argv[idx], "--EMI")) {
      CLSmith::CLOptions::EMI(true);
      continue;
    }

    if (!strcmp(argv[idx], "--EMI_p_compound")) {
      ++idx;
      if (!CheckArgExists(idx, argc)) return -1;
      unsigned long value;
      if (!ParseIntArg(argv[idx], &value)) return -1;
      CLSmith::CLOptions::EMI_p_compound(value);
      continue;
    }

    if (!strcmp(argv[idx], "--EMI_p_leaf")) {
      ++idx;
      if (!CheckArgExists(idx, argc)) return -1;
      unsigned long value;
      if (!ParseIntArg(argv[idx], &value)) return -1;
      CLSmith::CLOptions::EMI_p_leaf(value);
      continue;
    }

    if (!strcmp(argv[idx], "--EMI_p_lift")) {
      ++idx;
      if (!CheckArgExists(idx, argc)) return -1;
      unsigned long value;
      if (!ParseIntArg(argv[idx], &value)) return -1;
      CLSmith::CLOptions::EMI_p_lift(value);
      continue;
    }

    if (!strcmp(argv[idx], "--fake_divergence")) {
      CLSmith::CLOptions::fake_divergence(true);
      continue;
    }

    if (!strcmp(argv[idx], "--group_divergence")) {
      CLSmith::CLOptions::group_divergence(true);
      continue;
    }

    if (!strcmp(argv[idx], "--inter_thread_comm")) {
      CLSmith::CLOptions::inter_thread_comm(true);
      continue;
    }

    if (!strcmp(argv[idx], "--small")) {
      CLSmith::CLOptions::small(true);
      continue;
    }

    if (!strcmp(argv[idx], "--track_divergence")) {
      CLSmith::CLOptions::track_divergence(true);
      continue;
    }

    if (!strcmp(argv[idx], "--vectors")) {
      CLSmith::CLOptions::vectors(true);
      continue;
    }

    std::cout << "Invalid option \"" << argv[idx] << '"' << std::endl;
    return -1;
  }
  // End parsing.

  // Resolve any options in CGOptions that must change as a result of options
  // that the user has set.
  CLSmith::CLOptions::ResolveCGOptions();
  // Check for conflicting options
  if (CLSmith::CLOptions::Conflict()) return -1;

  // AbsProgramGenerator does other initialisation stuff, besides itself. So we
  // call it, disregarding the returned object. Still need to delete it.
  AbsProgramGenerator *generator =
      AbsProgramGenerator::CreateInstance(argc, argv, g_Seed);
  if (!generator) {
    cout << "error: can't create AbsProgramGenerator. csmith init failed!"
         << std::endl;
    return -1;
  }

  // Now create our program generator for OpenCL.
  CLSmith::CLProgramGenerator cl_generator(g_Seed);
  cl_generator.goGenerator();

  // Calls Finalization::doFinalization(), which deletes everything, so must be
  // called after program generation.
  delete generator;

  return 0;
}
<commit_msg>Forgot to add this modified file in previous commit.<commit_after>// Entry point to the program.

#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>

#include "AbsProgramGenerator.h"
#include "CGOptions.h"
#include "CLSmith/CLOptions.h"
#include "CLSmith/CLOutputMgr.h"
#include "CLSmith/CLProgramGenerator.h"
#include "platform.h"

// Generator seed.
static unsigned long g_Seed = 0;

bool CheckArgExists(int idx, int argc) {
  if (idx >= argc) std::cout << "Expected another argument" << std::endl;
  return idx < argc;
}

bool ParseIntArg(const char *arg, unsigned long *value) {
  bool res = sscanf(arg, "%lu", value);
  if (!res) std::cout << "Expected integer arg for " << arg << std::endl;
  return res;
}

int main(int argc, char **argv) {
  g_Seed = platform_gen_seed();
  CGOptions::set_default_settings();
  CLSmith::CLOptions::set_default_settings();
  std::string output_filename = "";

  // Parse command line arguments.
  for (int idx = 1; idx < argc; ++idx) {
    if (!strcmp(argv[idx], "--seed") ||
        !strcmp(argv[idx], "-s")) {
      ++idx;
      if (!CheckArgExists(idx, argc)) return -1;
      if (!ParseIntArg(argv[idx], &g_Seed)) return -1;
      continue;
    }

    if (!strcmp(argv[idx], "--output_file") ||
        !strcmp(argv[idx], "-o")) {
      ++idx;
      if (!CheckArgExists(idx, argc)) return -1;
      CLSmith::CLOptions::output(argv[idx]);
      continue;
    }

    if (!strcmp(argv[idx], "--atomics")) {
      CLSmith::CLOptions::atomics(true);
      continue;
    }

    if (!strcmp(argv[idx], "--barriers")) {
      CLSmith::CLOptions::barriers(true);
      continue;
    }

    if (!strcmp(argv[idx], "--divergence")) {
      CLSmith::CLOptions::divergence(true);
      continue;
    }

    if (!strcmp(argv[idx], "--EMI")) {
      CLSmith::CLOptions::EMI(true);
      continue;
    }

    if (!strcmp(argv[idx], "--atomic_reductions")) {
      CLSmith::CLOptions::atomic_reductions(true);
      continue;
    }

    if (!strcmp(argv[idx], "--EMI_p_compound")) {
      ++idx;
      if (!CheckArgExists(idx, argc)) return -1;
      unsigned long value;
      if (!ParseIntArg(argv[idx], &value)) return -1;
      CLSmith::CLOptions::EMI_p_compound(value);
      continue;
    }

    if (!strcmp(argv[idx], "--EMI_p_leaf")) {
      ++idx;
      if (!CheckArgExists(idx, argc)) return -1;
      unsigned long value;
      if (!ParseIntArg(argv[idx], &value)) return -1;
      CLSmith::CLOptions::EMI_p_leaf(value);
      continue;
    }

    if (!strcmp(argv[idx], "--EMI_p_lift")) {
      ++idx;
      if (!CheckArgExists(idx, argc)) return -1;
      unsigned long value;
      if (!ParseIntArg(argv[idx], &value)) return -1;
      CLSmith::CLOptions::EMI_p_lift(value);
      continue;
    }

    if (!strcmp(argv[idx], "--fake_divergence")) {
      CLSmith::CLOptions::fake_divergence(true);
      continue;
    }

    if (!strcmp(argv[idx], "--group_divergence")) {
      CLSmith::CLOptions::group_divergence(true);
      continue;
    }

    if (!strcmp(argv[idx], "--inter_thread_comm")) {
      CLSmith::CLOptions::inter_thread_comm(true);
      continue;
    }

    if (!strcmp(argv[idx], "--small")) {
      CLSmith::CLOptions::small(true);
      continue;
    }

    if (!strcmp(argv[idx], "--track_divergence")) {
      CLSmith::CLOptions::track_divergence(true);
      continue;
    }

    if (!strcmp(argv[idx], "--vectors")) {
      CLSmith::CLOptions::vectors(true);
      continue;
    }

    std::cout << "Invalid option \"" << argv[idx] << '"' << std::endl;
    return -1;
  }
  // End parsing.

  // Resolve any options in CGOptions that must change as a result of options
  // that the user has set.
  CLSmith::CLOptions::ResolveCGOptions();
  // Check for conflicting options
  if (CLSmith::CLOptions::Conflict()) return -1;

  // AbsProgramGenerator does other initialisation stuff, besides itself. So we
  // call it, disregarding the returned object. Still need to delete it.
  AbsProgramGenerator *generator =
      AbsProgramGenerator::CreateInstance(argc, argv, g_Seed);
  if (!generator) {
    cout << "error: can't create AbsProgramGenerator. csmith init failed!"
         << std::endl;
    return -1;
  }

  // Now create our program generator for OpenCL.
  CLSmith::CLProgramGenerator cl_generator(g_Seed);
  cl_generator.goGenerator();

  // Calls Finalization::doFinalization(), which deletes everything, so must be
  // called after program generation.
  delete generator;

  return 0;
}
<|endoftext|>


<commit_before>//===- llvm/ADT/SmallVector.cpp - 'Normally small' vectors ----------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License.
// ==============================================================================
// LLVM Release License
// ==============================================================================
// University of Illinois/NCSA
// Open Source License
//
// Copyright (c) 2003-2010 University of Illinois at Urbana-Champaign.
// All rights reserved.
//
// Developed by:
//
// LLVM Team
//
// University of Illinois at Urbana-Champaign
//
// http://llvm.org
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal with
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimers.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimers in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the names of the LLVM Team, University of Illinois at
// Urbana-Champaign, nor the names of its contributors may be used to
// endorse or promote products derived from this Software without specific
// prior written permission.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
// CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
// SOFTWARE.
//
//===----------------------------------------------------------------------===//
//
// This file implements the SmallVector class.
//
//===----------------------------------------------------------------------===//

#include "OgreSmallVector.h"

namespace Ogre {

/// grow_pod - This is an implementation of the grow() method which only works
/// on POD-like datatypes and is out of line to reduce code duplication.
void SmallVectorBase::grow_pod(size_t MinSizeInBytes, size_t TSize) {
	size_t CurSizeBytes = size_in_bytes();
  size_t NewCapacityInBytes = 2 * capacity_in_bytes() + TSize; // Always grow.
	if (NewCapacityInBytes < MinSizeInBytes)
		NewCapacityInBytes = MinSizeInBytes;

  void *NewElts;
  if (this->isSmall()) {
    NewElts = malloc(NewCapacityInBytes);

	// Copy the elements over.  No need to run dtors on PODs.
	memcpy(NewElts, this->BeginX, CurSizeBytes);
  } else {
    // If this wasn't grown from the inline copy, grow the allocated space.
    NewElts = realloc(this->BeginX, NewCapacityInBytes);
  }

	this->EndX = (char*)NewElts+CurSizeBytes;
	this->BeginX = NewElts;
	this->CapacityX = (char*)this->BeginX + NewCapacityInBytes;
}

}<commit_msg>Added missing #include "OgreStableHeaders.h" to OgreSmallVector.cpp.<commit_after>//===- llvm/ADT/SmallVector.cpp - 'Normally small' vectors ----------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License.
// ==============================================================================
// LLVM Release License
// ==============================================================================
// University of Illinois/NCSA
// Open Source License
//
// Copyright (c) 2003-2010 University of Illinois at Urbana-Champaign.
// All rights reserved.
//
// Developed by:
//
// LLVM Team
//
// University of Illinois at Urbana-Champaign
//
// http://llvm.org
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal with
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimers.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimers in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the names of the LLVM Team, University of Illinois at
// Urbana-Champaign, nor the names of its contributors may be used to
// endorse or promote products derived from this Software without specific
// prior written permission.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
// CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
// SOFTWARE.
//
//===----------------------------------------------------------------------===//
//
// This file implements the SmallVector class.
//
//===----------------------------------------------------------------------===//

#include "OgreStableHeaders.h"

#include "OgreSmallVector.h"

namespace Ogre {

/// grow_pod - This is an implementation of the grow() method which only works
/// on POD-like datatypes and is out of line to reduce code duplication.
void SmallVectorBase::grow_pod(size_t MinSizeInBytes, size_t TSize) {
	size_t CurSizeBytes = size_in_bytes();
  size_t NewCapacityInBytes = 2 * capacity_in_bytes() + TSize; // Always grow.
	if (NewCapacityInBytes < MinSizeInBytes)
		NewCapacityInBytes = MinSizeInBytes;

  void *NewElts;
  if (this->isSmall()) {
    NewElts = malloc(NewCapacityInBytes);

	// Copy the elements over.  No need to run dtors on PODs.
	memcpy(NewElts, this->BeginX, CurSizeBytes);
  } else {
    // If this wasn't grown from the inline copy, grow the allocated space.
    NewElts = realloc(this->BeginX, NewCapacityInBytes);
  }

	this->EndX = (char*)NewElts+CurSizeBytes;
	this->BeginX = NewElts;
	this->CapacityX = (char*)this->BeginX + NewCapacityInBytes;
}

}<|endoftext|>


<commit_before>#include "Catalogue.h"
#include "catalogue.lex.h"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/tokenizer.hpp>
#include <boost/format.hpp>
#include <iostream>

#include <cctype>

#include "openc2e.h"

using boost::str;

namespace fs = boost::filesystem;

struct quote_subst {
	char escape;
	char subst;
};

static struct quote_subst subst_table[] = {
	{ 'n', '\n' },
	{ '\\', '\\' },
	{ '\"', '\"' },
	{ 't', '\t' },
	{ 0, 0 }
};

char catalogue_descape(char c) {
	struct quote_subst *qs = subst_table;
	while (qs->escape) {
		if (qs->escape == c)
			return qs->subst;
		qs++;
	}
	std::cerr << "Unmatched substitution: \\" << c << std::endl;
	return c;
}

static const char *tok_str[] = { "EOF", "word", "string", "integer" };

std::string cat_str;
int cat_int = -1;

catalogueFlexLexer *catalexer = NULL;
Catalogue *parsing_cat = NULL;

void Catalogue::addVals(std::string &title, bool override, int count,
		const std::list<std::string> &vals)
{
	if (data.find(title) != data.end() && !override)
		return; // XXX: ?
	data[title].clear();
//	copy(vals.begin(), vals.end(), data[title].begin());
	std::list<std::string>::const_iterator i = vals.begin();
	while(i != vals.end()) {
		data[title].push_back(*i++);
	}
}

extern int cataparse();

void cataerror(const char *err) {
	// XXX: we may leak here - memory pools?
	throw catalogueException(err);
}
void catalogueParseError(int lineno) {
	std::ostringstream oss;
	oss << "Catalogue parse error at line " << lineno << std::endl;

	throw catalogueException(oss.str());
}

std::istream &operator >> (std::istream &s, Catalogue &c) {
	catalogueFlexLexer lex(&s);
	catalexer = &lex;
	parsing_cat = &c;

	cataparse();

	catalexer = NULL;
	parsing_cat = NULL;

	return s;
}

void Catalogue::reset() {
	data.clear();
}

void Catalogue::initFrom(fs::path path) {
	assert(fs::exists(path));
	assert(fs::is_directory(path));

	std::cout << "Catalogue is reading " << path.native_directory_string() << std::endl;

	fs::directory_iterator end;
	std::string file;
	for (fs::directory_iterator i(path); i != end; ++i) {
		try {
			if ((!fs::is_directory(*i)) && (fs::extension(*i) == ".catalogue")) {
				file = (*i).string();
				std::string x = fs::basename(*i);
				// TODO: '-en-GB' exists too, this doesn't work for that
				if ((x.size() > 3) && (x[x.size() - 3] == '-')) {
					// TODO: this is NOT how we should do it
					continue; // skip all localised files
				}
				std::cout << "Catalogue file '" << x << "' being read" << std::endl;
				fs::ifstream f(*i);
				f >> *this;
			}
		}
		catch (const catalogueException &ex) {
			std::cerr << "Error reading catalogue file " << file << ":" << std::endl << '\t' << ex.what() << std::endl;
		}
		catch (const std::exception &ex) {
			std::cerr << "directory_iterator died on '" << i->leaf() << "' with " << ex.what() << std::endl;
		}
	}
}

std::string stringFromInt(int i) {
	// TODO: hacky? also, put somewhere more appropriate

	char buffer[20]; // more than enough
	snprintf(buffer, 20, "%i", i);

	return std::string(buffer);
}

const std::string Catalogue::getAgentName(unsigned char family, unsigned char genus, unsigned short species) const {
	std::string buf;
	buf = str(boost::format("Agent Help %d %d %d") % (int)family % (int)genus % species);
	std::cerr << "cat " << buf << std::endl;
	if (hasTag(buf)) {
		return getTag(buf)[0];
	} else {
		return "";
	}
}

std::string Catalogue::calculateWildcardTag(std::string tag, unsigned char family, unsigned char genus, unsigned short species) const {
	std::string searchstring = tag + " " + stringFromInt(family) + " " + stringFromInt(genus) + " " + stringFromInt(species);
	if (hasTag(searchstring)) return searchstring;
	searchstring = tag + " " + stringFromInt(family) + " " + stringFromInt(genus) + " 0";
	if (hasTag(searchstring)) return searchstring;
	searchstring = tag + " " + stringFromInt(family) + " 0 0";
	if (hasTag(searchstring)) return searchstring;
	searchstring = tag + "0 0 0";
	if (hasTag(searchstring)) return searchstring;
	return "";
}

/* vim: set noet: */
<commit_msg>Kill a bit of leftover debug<commit_after>#include "Catalogue.h"
#include "catalogue.lex.h"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/convenience.hpp>
#include <boost/tokenizer.hpp>
#include <boost/format.hpp>
#include <iostream>

#include <cctype>

#include "openc2e.h"

using boost::str;

namespace fs = boost::filesystem;

struct quote_subst {
	char escape;
	char subst;
};

static struct quote_subst subst_table[] = {
	{ 'n', '\n' },
	{ '\\', '\\' },
	{ '\"', '\"' },
	{ 't', '\t' },
	{ 0, 0 }
};

char catalogue_descape(char c) {
	struct quote_subst *qs = subst_table;
	while (qs->escape) {
		if (qs->escape == c)
			return qs->subst;
		qs++;
	}
	std::cerr << "Unmatched substitution: \\" << c << std::endl;
	return c;
}

static const char *tok_str[] = { "EOF", "word", "string", "integer" };

std::string cat_str;
int cat_int = -1;

catalogueFlexLexer *catalexer = NULL;
Catalogue *parsing_cat = NULL;

void Catalogue::addVals(std::string &title, bool override, int count,
		const std::list<std::string> &vals)
{
	if (data.find(title) != data.end() && !override)
		return; // XXX: ?
	data[title].clear();
//	copy(vals.begin(), vals.end(), data[title].begin());
	std::list<std::string>::const_iterator i = vals.begin();
	while(i != vals.end()) {
		data[title].push_back(*i++);
	}
}

extern int cataparse();

void cataerror(const char *err) {
	// XXX: we may leak here - memory pools?
	throw catalogueException(err);
}
void catalogueParseError(int lineno) {
	std::ostringstream oss;
	oss << "Catalogue parse error at line " << lineno << std::endl;

	throw catalogueException(oss.str());
}

std::istream &operator >> (std::istream &s, Catalogue &c) {
	catalogueFlexLexer lex(&s);
	catalexer = &lex;
	parsing_cat = &c;

	cataparse();

	catalexer = NULL;
	parsing_cat = NULL;

	return s;
}

void Catalogue::reset() {
	data.clear();
}

void Catalogue::initFrom(fs::path path) {
	assert(fs::exists(path));
	assert(fs::is_directory(path));

	std::cout << "Catalogue is reading " << path.native_directory_string() << std::endl;

	fs::directory_iterator end;
	std::string file;
	for (fs::directory_iterator i(path); i != end; ++i) {
		try {
			if ((!fs::is_directory(*i)) && (fs::extension(*i) == ".catalogue")) {
				file = (*i).string();
				std::string x = fs::basename(*i);
				// TODO: '-en-GB' exists too, this doesn't work for that
				if ((x.size() > 3) && (x[x.size() - 3] == '-')) {
					// TODO: this is NOT how we should do it
					continue; // skip all localised files
				}
				std::cout << "Catalogue file '" << x << "' being read" << std::endl;
				fs::ifstream f(*i);
				f >> *this;
			}
		}
		catch (const catalogueException &ex) {
			std::cerr << "Error reading catalogue file " << file << ":" << std::endl << '\t' << ex.what() << std::endl;
		}
		catch (const std::exception &ex) {
			std::cerr << "directory_iterator died on '" << i->leaf() << "' with " << ex.what() << std::endl;
		}
	}
}

std::string stringFromInt(int i) {
	// TODO: hacky? also, put somewhere more appropriate

	char buffer[20]; // more than enough
	snprintf(buffer, 20, "%i", i);

	return std::string(buffer);
}

const std::string Catalogue::getAgentName(unsigned char family, unsigned char genus, unsigned short species) const {
	std::string buf;
	buf = str(boost::format("Agent Help %d %d %d") % (int)family % (int)genus % species);
	if (hasTag(buf)) {
		return getTag(buf)[0];
	} else {
		return "";
	}
}

std::string Catalogue::calculateWildcardTag(std::string tag, unsigned char family, unsigned char genus, unsigned short species) const {
	std::string searchstring = tag + " " + stringFromInt(family) + " " + stringFromInt(genus) + " " + stringFromInt(species);
	if (hasTag(searchstring)) return searchstring;
	searchstring = tag + " " + stringFromInt(family) + " " + stringFromInt(genus) + " 0";
	if (hasTag(searchstring)) return searchstring;
	searchstring = tag + " " + stringFromInt(family) + " 0 0";
	if (hasTag(searchstring)) return searchstring;
	searchstring = tag + "0 0 0";
	if (hasTag(searchstring)) return searchstring;
	return "";
}

/* vim: set noet: */
<|endoftext|>


<commit_before>AliAnalysisTask *AddTaskHFECal()
{
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    Error("AddTaskHFEECal", "No analysis manager found.");
    return NULL;
  }

  if (!mgr->GetInputEventHandler()) {
    ::Error("AddTaskHFECal", "This task requires an input event handler");
    return NULL;
  }
  TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
  if (type=="AOD"){
    ::Error("AddTaskHFECal", "The tasks exits because AODs are in input");
    return NULL;
  }
  Bool_t MCthere=kFALSE;
  AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler*>(mgr->GetMCtruthEventHandler());
  if(!mcH){
    MCthere=kFALSE;
  }else{
    MCthere=kTRUE;
  }

  //analysis task
  gROOT->LoadMacro("$ALICE_ROOT/PWGHF/hfe/macros/configs/PbPb/ConfigHFECal.C");

  AliAnalysisTaskHFECal *hfetaskCent = ConfigHFECal(MCthere);
  AliAnalysisTaskHFECal *hfetaskTrig= ConfigHFECal(MCthere);
  AliAnalysisTaskHFECal *hfetaskTrig2= ConfigHFECal(MCthere);

  mgr->AddTask(hfetaskCent);
  mgr->AddTask(hfetaskTrig);
  mgr->AddTask(hfetaskTrig2);

  // central trigger
  hfetaskCent->SelectCollisionCandidates(AliVEvent::kCentral);

  TString containerName = mgr->GetCommonFileName();
  containerName += ":PWGHF_hfeCalCentral";

  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("HFE_Results_EMCalCentral", TList::Class(),AliAnalysisManager::kOutputContainer, containerName.Data());
  mgr->ConnectInput(hfetaskCent, 0, cinput);
  mgr->ConnectOutput(hfetaskCent, 1, coutput1);

  //L1 gamma trigger
  hfetaskTrig->SelectCollisionCandidates(AliVEvent::kEMCEGA);

  TString containerName2 = mgr->GetCommonFileName();
  containerName2 += ":PWGHF_hfeCalTrigEGA";

  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("HFE_Results_EMCalTrigEGA", TList::Class(),AliAnalysisManager::kOutputContainer, containerName2.Data());
  mgr->ConnectInput(hfetaskTrig, 0, cinput);
  mgr->ConnectOutput(hfetaskTrig, 1, coutput1);

  //Jet trigger
  hfetaskTrig2->SelectCollisionCandidates(AliVEvent::kEMCEJE);

  TString containerName3 = mgr->GetCommonFileName();
  containerName3 += ":PWGHF_hfeCalTrigEJE";

  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("HFE_Results_EMCalTrigEJE", TList::Class(),AliAnalysisManager::kOutputContainer, containerName3.Data());
  mgr->ConnectInput(hfetaskTrig2, 0, cinput);
  mgr->ConnectOutput(hfetaskTrig2, 1, coutput1);

  //if(MCthere)
    //{
    //MB trigger
    AliAnalysisTaskHFECal *hfetaskMB = ConfigHFECal(MCthere);
    mgr->AddTask(hfetaskMB);
    hfetaskMB->SelectCollisionCandidates(AliVEvent::kMB);

    TString containerName3 = mgr->GetCommonFileName();
    containerName3 += ":PWGHF_hfeCalkMB";

     AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
     AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("HFE_Results_EMCalMB", TList::Class(),AliAnalysisManager::kOutputContainer, containerName3.Data());
     mgr->ConnectInput(hfetaskMB, 0, cinput);
     mgr->ConnectOutput(hfetaskMB, 1, coutput1);
     //}

  return NULL;
}
<commit_msg>upadted<commit_after>AliAnalysisTask *AddTaskHFECal()
{
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    Error("AddTaskHFEECal", "No analysis manager found.");
    return NULL;
  }

  if (!mgr->GetInputEventHandler()) {
    ::Error("AddTaskHFECal", "This task requires an input event handler");
    return NULL;
  }
  TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
  if (type=="AOD"){
    ::Error("AddTaskHFECal", "The tasks exits because AODs are in input");
    return NULL;
  }
  Bool_t MCthere=kFALSE;
  AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler*>(mgr->GetMCtruthEventHandler());
  if(!mcH){
    MCthere=kFALSE;
  }else{
    MCthere=kTRUE;
  }

  //analysis task
  gROOT->LoadMacro("$ALICE_ROOT/PWGHF/hfe/macros/configs/PbPb/ConfigHFECal.C");

  AliAnalysisTaskHFECal *hfetaskCent = ConfigHFECal(MCthere);
  AliAnalysisTaskHFECal *hfetaskTrig= ConfigHFECal(MCthere);
  AliAnalysisTaskHFECal *hfetaskTrig2= ConfigHFECal(MCthere);

  mgr->AddTask(hfetaskCent);
  mgr->AddTask(hfetaskTrig);
  mgr->AddTask(hfetaskTrig2);

  // central trigger
  hfetaskCent->SelectCollisionCandidates(AliVEvent::kCentral);

  TString containerName = mgr->GetCommonFileName();
  containerName += ":PWGHF_hfeCalCentral";

  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("HFE_Results_EMCalCentral", TList::Class(),AliAnalysisManager::kOutputContainer, containerName.Data());
  mgr->ConnectInput(hfetaskCent, 0, cinput);
  mgr->ConnectOutput(hfetaskCent, 1, coutput1);

  //L1 gamma trigger
  hfetaskTrig->SelectCollisionCandidates(AliVEvent::kEMCEGA);

  TString containerName2 = mgr->GetCommonFileName();
  containerName2 += ":PWGHF_hfeCalTrigEGA";

  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("HFE_Results_EMCalTrigEGA", TList::Class(),AliAnalysisManager::kOutputContainer, containerName2.Data());
  mgr->ConnectInput(hfetaskTrig, 0, cinput);
  mgr->ConnectOutput(hfetaskTrig, 1, coutput1);

  //Jet trigger
  // semi-central
  hfetaskTrig2->SelectCollisionCandidates(AliVEvent::kSemiCentral);

  TString containerName3 = mgr->GetCommonFileName();
  containerName3 += ":PWGHF_hfeCalSemiCentral";

  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("HFE_Results_SemiCentral", TList::Class(),AliAnalysisManager::kOutputContainer, containerName3.Data());
  mgr->ConnectInput(hfetaskTrig2, 0, cinput);
  mgr->ConnectOutput(hfetaskTrig2, 1, coutput1);

  //if(MCthere)
    //{
    //MB trigger
    AliAnalysisTaskHFECal *hfetaskMB = ConfigHFECal(MCthere);
    mgr->AddTask(hfetaskMB);
    hfetaskMB->SelectCollisionCandidates(AliVEvent::kMB);

    TString containerName3 = mgr->GetCommonFileName();
    containerName3 += ":PWGHF_hfeCalkMB";

     AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
     AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("HFE_Results_EMCalMB", TList::Class(),AliAnalysisManager::kOutputContainer, containerName3.Data());
     mgr->ConnectInput(hfetaskMB, 0, cinput);
     mgr->ConnectOutput(hfetaskMB, 1, coutput1);
     //}

  return NULL;
}
<|endoftext|>


<commit_before>void makeCentralityFit(const char * run="188362",const char * system="TKL", int Rebin=1,int Nevt=1e6)
{
 //load libraries
  gSystem->SetBuildDir("/tmp/");
  gSystem->Load("libCore.so");
  gSystem->Load("libTree.so");
  gSystem->Load("libGeom.so");
  gSystem->Load("libVMC.so");
  gSystem->Load("libPhysics.so");
  gSystem->Load("libSTEERBase.so");
  gROOT->ProcessLine(".include $ALICE_ROOT/include");
  gROOT->LoadMacro("AliCentralityGlauberFit.cxx+");

  const char *finnameGlau ="/home/atoia/GlauberNtuplePA/GlauberMC_pPb_ntuple_sigma71_mind4_r662_a546.root";
  TString finname = Form("/home/atoia/analysis/data2012/multRef/EventStat_temp_%s.root",run);
  TString foutname = Form("/home/atoia/analysis/data2012/fit/%s_fit_%s.root",system,run);
  TString foutnameGlau = Form("/home/atoia/analysis/data2012/fit/%s_ntuple_%s.root",system,run);
  const char *histname=Form("fHOutMult%s",system);

  AliCentralityGlauberFit *mPM = new AliCentralityGlauberFit(finnameGlau);
  mPM->SetInputFile(finname);
  mPM->SetInputNtuple(finnameGlau);
  mPM->SetOutputFile(foutname);
  mPM->SetOutputNtuple(foutnameGlau);
  mPM->AddHisto(histname);

  mPM->SetRebin(Rebin);
  mPM->SetNevents(Nevt);
  mPM->SetAncestorMode(1); // 1: Npart**alpha, 2: alpha*Npart + (1-alpha)*Ncoll
  mPM->SetFastFitMode(0);  // 1:NBD, 2:Gauss
  mPM->UseChi2(kTRUE);     // If TRUE minimize Chi2
  mPM->UseAverage(kFALSE); // If TRUE use Average
  mPM->SetNtrials(1);

  // ----------range to fit--------------
  if (strncmp (system,"V0A",1) == 0) {
    mPM->SetRangeToFit(15., 600.);   // range to fit
    mPM->SetRangeToScale(15.); // range to scale
    mPM->SetGlauberParam(1,12.8,13, 20,0.5,2.5, 1,1,1); // fit parameters
  }
  else if (strncmp (system,"TKL",1) == 0) {
    mPM->SetRangeToFit(15., 200.);   // range to fit
    mPM->SetRangeToScale(15.); // range to scale
    mPM->SetGlauberParam(1,4.9,5.5, 1,0.61,0.62, 1,1,1); // fit parameters
  }
  else if (strncmp (system,"CL1",1) == 0) {
    mPM->SetRangeToFit(40., 400.);
    mPM->SetRangeToScale(40.);
    mPM->SetGlauberParam(1,7.9,8, 1,0.43,0.46, 1,1,1);
  }
  else if (strncmp (system,"TRK",1) == 0) {
    mPM->SetRangeToFit(10., 2600.);
    mPM->SetRangeToScale(10.);
    mPM->SetGlauberParam(1,3.9,4.2, 1,1.3,2.5, 1,0.801,0.81);
  }

  mPM->MakeFits();

  // ----------for Minuit--------------
  //mPM->MakeFitsMinuitNBD(1,8,0.5);          // initial parameters

  TFile * f = new TFile (foutname);
  TH1 * hd = (TH1*) gDirectory->Get(Form("fHOutMult%s",system));
  TH1 * hg = (TH1*) gDirectory->Get(Form("fHOutMult%s_GLAU",system));
  hg->SetLineColor(kRed);
  hd->Draw("e");
  hg->Draw("same");

}

<commit_msg>update glauber ntuple<commit_after>void makeCentralityFit(const char * run="188362",const char * system="TKL", int Rebin=1,int Nevt=1e6)
{
 //load libraries
  gSystem->SetBuildDir("/tmp/");
  gSystem->Load("libCore.so");
  gSystem->Load("libTree.so");
  gSystem->Load("libGeom.so");
  gSystem->Load("libVMC.so");
  gSystem->Load("libPhysics.so");
  gSystem->Load("libSTEERBase.so");
  gROOT->ProcessLine(".include $ALICE_ROOT/include");
  gROOT->LoadMacro("AliCentralityGlauberFit.cxx+");

  const char *finnameGlau ="/home/atoia/GlauberNtuplePA/GlauberMC_pPb_ntuple_sigma70_mind4_r662_a546_Rpro4.root";
  TString finname = Form("/home/atoia/analysis/data2012/multRef/EventStat_temp_%s.root",run);
  TString foutname = Form("/home/atoia/analysis/data2012/fit/%s_fit_%s.root",system,run);
  TString foutnameGlau = Form("/home/atoia/analysis/data2012/fit/%s_ntuple_%s.root",system,run);
  const char *histname=Form("fHOutMult%s",system);

  AliCentralityGlauberFit *mPM = new AliCentralityGlauberFit(finnameGlau);
  mPM->SetInputFile(finname);
  mPM->SetInputNtuple(finnameGlau);
  mPM->SetOutputFile(foutname);
  mPM->SetOutputNtuple(foutnameGlau);
  mPM->AddHisto(histname);

  mPM->SetRebin(Rebin);
  mPM->SetNevents(Nevt);
  mPM->SetAncestorMode(1); // 1: Npart**alpha, 2: alpha*Npart + (1-alpha)*Ncoll
  mPM->SetFastFitMode(0);  // 1:NBD, 2:Gauss
  mPM->UseChi2(kTRUE);     // If TRUE minimize Chi2
  mPM->UseAverage(kFALSE); // If TRUE use Average
  mPM->SetNtrials(1);

  // ----------range to fit--------------
  if (strncmp (system,"V0A",1) == 0) {
    mPM->SetRangeToFit(15., 600.);   // range to fit
    mPM->SetRangeToScale(15.); // range to scale
    mPM->SetGlauberParam(1,12.8,13, 20,0.5,2.5, 1,1,1); // fit parameters
  }
  else if (strncmp (system,"TKL",1) == 0) {
    mPM->SetRangeToFit(15., 200.);   // range to fit
    mPM->SetRangeToScale(15.); // range to scale
    mPM->SetGlauberParam(1,4.9,5.5, 1,0.61,0.62, 1,1,1); // fit parameters
  }
  else if (strncmp (system,"CL1",1) == 0) {
    mPM->SetRangeToFit(40., 400.);
    mPM->SetRangeToScale(40.);
    mPM->SetGlauberParam(1,7.9,8, 1,0.43,0.46, 1,1,1);
  }
  else if (strncmp (system,"TRK",1) == 0) {
    mPM->SetRangeToFit(10., 2600.);
    mPM->SetRangeToScale(10.);
    mPM->SetGlauberParam(1,3.9,4.2, 1,1.3,2.5, 1,0.801,0.81);
  }

  mPM->MakeFits();

  // ----------for Minuit--------------
  //mPM->MakeFitsMinuitNBD(1,8,0.5);          // initial parameters

  TFile * f = new TFile (foutname);
  TH1 * hd = (TH1*) gDirectory->Get(Form("fHOutMult%s",system));
  TH1 * hg = (TH1*) gDirectory->Get(Form("fHOutMult%s_GLAU",system));
  hg->SetLineColor(kRed);
  hd->Draw("e");
  hg->Draw("same");

}

<|endoftext|>